3 * @brief External header for wimlib.
5 * This file contains extensive comments for generating documentation with
6 * Doxygen. The built HTML documentation can be viewed at
7 * http://wimlib.sourceforge.net. Make sure to see the <a
8 * href="modules.html">Modules page</a> to make more sense of the declarations
13 * Copyright (C) 2012, 2013, 2014 Eric Biggers
15 * This file is part of wimlib, a library for working with WIM files.
17 * wimlib is free software; you can redistribute it and/or modify it under the
18 * terms of the GNU General Public License as published by the Free
19 * Software Foundation; either version 3 of the License, or (at your option)
22 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
23 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
24 * A PARTICULAR PURPOSE. See the GNU General Public License for more
27 * You should have received a copy of the GNU General Public License
28 * along with wimlib; if not, see http://www.gnu.org/licenses/.
34 * @section sec_intro Introduction
36 * This is the documentation for the library interface of wimlib 1.7.0, a C
37 * library for creating, modifying, extracting, and mounting files in the
38 * Windows Imaging Format. This documentation is intended for developers only.
39 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
40 * program, please see the README file or manual pages.
42 * @section sec_installing_and_compiling Installing and Compiling
44 * wimlib uses the GNU autotools, so, on UNIX-like systems, it should be easy to
45 * install with <code>configure && make && sudo make install</code>; however,
46 * please see the README for more information about installing it.
48 * To use wimlib in your program after installing it, include wimlib.h and link
49 * your program with @c -lwim.
51 * As of wimlib 1.5.0, wimlib.h is also compatible with C++.
53 * Note: before calling any other function declared in wimlib.h,
54 * wimlib_global_init() can (and in some cases, must) be called. See its
55 * documentation for more details.
57 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
59 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
60 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
61 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
62 * which creates a new ::WIMStruct that initially contains no images and does
63 * not yet have a backing on-disk file. See @ref G_creating_and_opening_wims
66 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
67 * Images can be extracted (or "applied") using wimlib_extract_image(), added
68 * (or "captured" or "appended") using wimlib_add_image(), deleted using
69 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
70 * modified using wimlib_update_image(). However, changes made to a WIM
71 * represented by a ::WIMStruct have no persistent effect until the WIM is
72 * actually written to an on-disk file. This can be done using wimlib_write(),
73 * but if the WIM was originally opened using wimlib_open_wim(), then
74 * wimlib_overwrite() can be used instead. See @ref G_extracting_wims, @ref
75 * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
77 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
78 * files is a multi-step process. For example, to add, or "append" an image to
79 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
80 * append</b>, you must call the following functions:
82 * 1. wimlib_open_wim()
83 * 2. wimlib_add_image()
84 * 3. wimlib_overwrite()
86 * This design is very much on purpose as it makes the library more useful in
87 * general by allowing functions to be composed in different ways. For example,
88 * you can make multiple changes to a WIM and commit them all to the underlying
89 * file in only one overwrite operation, which is more efficient.
91 * @section sec_cleaning_up Cleaning up
93 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
94 * all resources associated with it. Also, when you are completely done with
95 * using wimlib in your program, you can call wimlib_global_cleanup() to free
96 * any other resources allocated by the library.
98 * @section sec_error_handling Error Handling
100 * Most functions in wimlib return 0 on success and a positive error code on
101 * failure. Use wimlib_get_error_string() to get a string that describes an
102 * error code. wimlib also can print error messages to standard error itself
103 * when an error happens, and these may be more informative than the error code;
104 * to enable this, call wimlib_set_print_errors(). Please note that this is for
105 * convenience only, and some errors can occur without a message being printed.
106 * Currently, error messages and strings (as well as all documentation, for that
107 * matter) are only available in English.
109 * @section sec_encodings Locales and character encodings
111 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
112 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
115 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
116 * and the encoding is UTF-16LE.
118 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
119 * and the encoding is the locale-dependent multibyte encoding. I recommend you
120 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
121 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
122 * call wimlib_global_init() after having set your desired locale.
124 * @section sec_advanced Additional information and features
127 * @subsection subsec_mounting_wim_images Mounting WIM images
129 * See @ref G_mounting_wim_images.
131 * @subsection subsec_progress_functions Progress Messages
133 * See @ref G_progress.
135 * @subsection subsec_non_standalone_wims Non-standalone WIMs
137 * See @ref G_nonstandalone_wims.
139 * @subsection subsec_pipable_wims Pipable WIMs
141 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
142 * compatible with Microsoft's software. To create a pipable WIM, call
143 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
144 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
145 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
146 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
147 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
148 * s using a seekable file descriptor using the regular function calls (e.g.
149 * wimlib_open_wim(), wimlib_extract_image()).
151 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
152 * capture</b> for more information about pipable WIMs.
154 * @subsection subsec_thread_safety Thread Safety
156 * wimlib is thread-safe, with the following exceptions:
157 * - Different threads cannot operate on the same ::WIMStruct at the same time;
158 * they must use different ::WIMStruct's.
159 * - You must call wimlib_global_init() in one thread before calling any other
161 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
162 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
163 * concurrently in the same process, will daemonize the entire process when it
164 * does so for the first time. This includes changing the working directory
165 * to the root directory.
167 * @subsection subsec_limitations Limitations
169 * This section documents some technical limitations of wimlib not already
170 * documented in the man page for @b wimlib-imagex.
172 * - The old WIM format from Vista pre-releases is not supported.
173 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
174 * functionality other than that already present in @b ImageX, that allows you
175 * to make certain Windows-specific modifications to a Windows PE image, such
176 * as adding a driver or Windows component. Such a tool could be implemented
179 * @subsection more_info More information
181 * You are advised to read the README as well as the manual pages for
182 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
183 * the API documentation.
186 /** @defgroup G_general General
188 * @brief Declarations and structures shared across the library.
191 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
193 * @brief Create new WIMs and open existing WIMs.
196 /** @defgroup G_wim_information Retrieving WIM information and directory listings
198 * @brief Retrieve information about a WIM or WIM image.
201 /** @defgroup G_modifying_wims Modifying WIMs
203 * @brief Make changes to a WIM.
205 * @section sec_adding_images Capturing and adding WIM images
207 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
208 * appending an image to an existing WIM is a multi-step process, but at its
209 * core is wimlib_add_image() or an equivalent function. Normally,
210 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
211 * ::WIMStruct as a new image. However, when supported by the build of the
212 * library, there is also a special NTFS volume capture mode (entered when
213 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
214 * from an unmounted NTFS volume.
216 * Another function, wimlib_add_image_multisource() is also provided. It
217 * generalizes wimlib_add_image() to allow combining multiple files or directory
218 * trees into a single WIM image in a configurable way.
220 * For maximum customization of WIM image creation, it is also possible to add a
221 * completely empty WIM image with wimlib_add_empty_image(), then update it with
222 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
223 * wimlib_add_image_multisource() do internally.)
225 * Note that some details of how image addition/capture works are documented
226 * more fully in the manual page for <b>wimlib-imagex capture</b>.
228 * @section sec_deleting_images Deleting WIM images
230 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
231 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
232 * be made persistent in an on-disk WIM file.
234 * @section sec_exporting_images Exporting WIM images
236 * wimlib_export_image() can copy, or "export", an image from one WIM to
239 * @section sec_other_modifications Other modifications
241 * wimlib_update_image() can add, delete, and rename files in a WIM image.
243 * wimlib_set_image_name(), wimlib_set_image_descripton(), and
244 * wimlib_set_image_flags() can change other image metadata.
246 * wimlib_set_wim_info() can change information about the WIM file itself, such
250 /** @defgroup G_extracting_wims Extracting WIMs
252 * @brief Extract files, directories, and images from a WIM.
254 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
255 * represented by a ::WIMStruct. This normally extracts the image to a
256 * directory, but when supported by the build of the library there is also a
257 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
258 * is specified) that allows extracting a WIM image directly to an unmounted
259 * NTFS volume. Various other flags allow further customization of image
262 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
263 * of (possibly wildcard) paths from a WIM image.
265 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
266 * over a pipe; see @ref subsec_pipable_wims.
268 * Some details of how WIM extraction works are documented more fully in the
269 * manual pages for <b>wimlib-imagex apply</b> and <b>wimlib-imagex extract</b>.
272 /** @defgroup G_mounting_wim_images Mounting WIM images
274 * @brief Mount and unmount WIM images.
276 * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
277 * mounting images from WIM files either read-only or read-write. To mount an
278 * image, call wimlib_mount_image(). To unmount an image, call
279 * wimlib_unmount_image(). Mounting can be done without root privileges because
280 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
281 * compiled with the <code>--without-fuse</code> flag, these functions will be
282 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED. Note that mounting an
283 * image read-write is an alternative to calling wimlib_update_image().
287 * @defgroup G_progress Progress Messages
289 * @brief Track the progress of long WIM operations.
291 * Library users can provide a progress function which will be called
292 * periodically during operations such as extracting a WIM image or writing a
293 * WIM image. A ::WIMStruct can have a progress function of type
294 * ::wimlib_progress_func_t associated with it by calling
295 * wimlib_register_progress_function() or by opening the ::WIMStruct using
296 * wimlib_open_wim_with_progress(). Once this is done, the progress function
297 * will be called automatically during many operations, such as
298 * wimlib_extract_image() and wimlib_write().
300 * Some functions that do not operate directly on a user-provided ::WIMStruct,
301 * such as wimlib_join(), also take the progress function directly using an
302 * extended version of the function, such as wimlib_join_with_progress().
304 * In wimlib v1.7.0 and later, progress functions are no longer just
305 * unidirectional. You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause
306 * the current operation to be aborted. wimlib v1.7.0 also added the third
307 * argument to ::wimlib_progress_func_t, which is a user-supplied context.
310 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
312 * @brief Write and overwrite on-disk WIM files.
314 * As described in @ref sec_basic_wim_handling_concepts, these functions are
315 * fundamental to the design of the library as they allow new or modified
316 * ::WIMStruct's to actually be written to on-disk files. Call wimlib_write()
317 * to write a new WIM file, or wimlib_overwrite() to persistently update an
321 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
323 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
325 * Normally, a ::WIMStruct represents a WIM file, but there's a bit more to it
326 * than that. Normally, WIM files are "standalone". However, WIM files can
327 * also be arranged in non-standalone ways, such as a set of on-disk files that
328 * together form a single "split WIM" or "delta WIM". Such arrangements are
329 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
330 * created from one of these on-disk files initially only partially represents
331 * the full WIM and needs to, in effect, be logically combined with other
332 * ::WIMStruct's before performing certain operations, such as extracting files
333 * with wimlib_extract_image() or wimlib_extract_paths(). This is done by
334 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
336 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
337 * specialized function (wimlib_split()) is needed to create a split WIM.
346 #include <inttypes.h>
350 # define _wimlib_deprecated __attribute__((deprecated))
352 # define _wimlib_deprecated
355 /** @addtogroup G_general
358 /** Major version of the library (for example, the 1 in 1.2.5). */
359 #define WIMLIB_MAJOR_VERSION 1
361 /** Minor version of the library (for example, the 2 in 1.2.5). */
362 #define WIMLIB_MINOR_VERSION 7
364 /** Patch version of the library (for example, the 5 in 1.2.5). */
365 #define WIMLIB_PATCH_VERSION 0
372 * Opaque structure that represents a WIM file. This is an in-memory structure
373 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
374 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
375 * continuing to exist so that data can be read from it as needed.
377 * Most functions in this library will work the same way regardless of whether a
378 * given ::WIMStruct was obtained through wimlib_open_wim() or
379 * wimlib_create_new_wim(). Exceptions are documented.
381 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
382 * file from a ::WIMStruct.
384 * See @ref sec_basic_wim_handling_concepts for more information.
386 #ifndef WIMLIB_WIMSTRUCT_DECLARED
387 typedef struct WIMStruct WIMStruct;
388 #define WIMLIB_WIMSTRUCT_DECLARED
392 typedef wchar_t wimlib_tchar;
394 /** See @ref sec_encodings */
395 typedef char wimlib_tchar;
399 /** Path separator for WIM paths passed back to progress callbacks.
400 * This is forward slash on UNIX and backslash on Windows. */
401 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
402 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
404 /** Path separator for WIM paths passed back to progress callbacks.
405 * This is forward slash on UNIX and backslash on Windows. */
406 # define WIMLIB_WIM_PATH_SEPARATOR '/'
407 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
410 /** Use this to specify the root directory of the WIM image. */
411 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
413 /** Use this to test if the specified path refers to the root directory of the
415 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
416 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
419 /** Length of a Globally Unique Identifier (GUID) */
420 #define WIMLIB_GUID_LEN 16
423 * Specifies a compression format. Pass one of these values to
424 * wimlib_create_new_wim(), wimlib_create_compressor(), or
425 * wimlib_create_decompressor().
427 * A WIM file has one default compression type and chunk size. Normally, each
428 * resource is compressed with this compression type. However, resources may be
429 * stored as uncompressed. In addition, a WIM with the new version number of
430 * 3584, or "ESD file", might contain solid blocks with different compression
433 enum wimlib_compression_type {
434 /** No compression. */
435 WIMLIB_COMPRESSION_TYPE_NONE = 0,
437 /** The XPRESS compression format. This format combines Lempel-Ziv
438 * factorization with Huffman encoding. Compression and decompression
439 * are both fast. This format supports chunk sizes that are powers of 2
440 * between <c>2^12</c> and <c>2^26</c>, inclusively. */
441 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
443 /** The LZX compression format. This format combines Lempel-Ziv
444 * factorization with Huffman encoding, but with more features and
445 * complexity than XPRESS. Compression is slow to somewhat fast,
446 * depending on the settings. Decompression is fast but slower than
447 * XPRESS. This format supports chunk sizes that are powers of 2
448 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
449 * other than <c>2^15</c> are not compatible with the Microsoft
451 WIMLIB_COMPRESSION_TYPE_LZX = 2,
453 /** The LZMS compression format. This format combines Lempel-Ziv
454 * factorization with adaptive Huffman encoding and range coding.
455 * Compression and decompression are both fairly slow. This format
456 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
457 * <c>2^30</c>, inclusively. This format is best used for large chunk
458 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
459 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
460 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
461 * with the Microsoft implementation. */
462 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
466 /** @addtogroup G_progress
469 /** Possible values of the first parameter to the user-supplied
470 * ::wimlib_progress_func_t progress function */
471 enum wimlib_progress_msg {
473 /** A WIM image is about to be extracted. @p info will point to
474 * ::wimlib_progress_info.extract. This message is received once per
475 * image for calls to wimlib_extract_image() and
476 * wimlib_extract_image_from_pipe(). */
477 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
479 /** One or more file or directory trees within a WIM image is about to
480 * be extracted. @p info will point to ::wimlib_progress_info.extract.
481 * This message is received only once per wimlib_extract_paths() and
482 * wimlib_extract_pathlist(), since wimlib combines all paths into a
483 * single extraction operation for optimization purposes. */
484 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
486 /** File data is currently being extracted. @p info will point to
487 * ::wimlib_progress_info.extract. This is the main message to track
488 * the progress of an extraction operation. */
489 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
491 /** Starting to read a new part of a split pipable WIM over the pipe.
492 * @p info will point to ::wimlib_progress_info.extract. */
493 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
495 /** Confirms that the image has been successfully extracted. @p info
496 * will point to ::wimlib_progress_info.extract. This is paired with
497 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
498 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
500 /** Confirms that the files or directory trees have been successfully
501 * extracted. @p info will point to ::wimlib_progress_info.extract.
502 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
503 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
505 /** The directory or NTFS volume is about to be scanned for metadata.
506 * @p info will point to ::wimlib_progress_info.scan. This message is
507 * received once per call to wimlib_add_image(), or once per capture
508 * source passed to wimlib_add_image_multisource(), or once per add
509 * command passed to wimlib_update_image(). */
510 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
512 /** A directory or file has been scanned. @p info will point to
513 * ::wimlib_progress_info.scan, and its @p cur_path member will be
514 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
516 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
518 /** Confirms that the directory or NTFS volume has been successfully
519 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
520 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
521 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
523 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
525 /** File resources ("streams") are currently being written to the WIM.
526 * @p info will point to ::wimlib_progress_info.write_streams. This
527 * message may be received many times while the WIM file is being
528 * written or appended to with wimlib_write(), wimlib_overwrite(), or
529 * wimlib_write_to_fd(). */
530 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
532 /** Per-image metadata is about to be written to the WIM file. @p info
533 * will not be valid. */
534 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
536 /** Confirms that per-image metadata has been successfully been written
537 * to the WIM file. @p info will not be valid. This message is paired
538 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
540 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
542 /** wimlib_overwrite() has successfully renamed the temporary file to
543 * the original WIM file, thereby committing the update. @p info will
544 * point to ::wimlib_progress_info.rename. Note: this message is not
545 * received if wimlib_overwrite() chose to append to the WIM file
547 WIMLIB_PROGRESS_MSG_RENAME = 15,
549 /** The contents of the WIM file are being checked against the integrity
550 * table. @p info will point to ::wimlib_progress_info.integrity. This
551 * message is only received (and may be received many times) when
552 * wimlib_open_wim_with_progress() is called with the
553 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
554 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
556 /** An integrity table is being calculated for the WIM being written.
557 * @p info will point to ::wimlib_progress_info.integrity. This message
558 * is only received (and may be received many times) when a WIM file is
559 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
560 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
562 /** A wimlib_split() operation is in progress, and a new split part is
563 * about to be started. @p info will point to
564 * ::wimlib_progress_info.split. */
565 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
567 /** A wimlib_split() operation is in progress, and a split part has been
568 * finished. @p info will point to ::wimlib_progress_info.split. */
569 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
571 /** A WIM update command is just about to be executed. @p info will
572 * point to ::wimlib_progress_info.update. This message is received
573 * once per update command when wimlib_update_image() is called with the
574 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
575 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
577 /** A WIM update command has just been executed. @p info will point to
578 * ::wimlib_progress_info.update. This message is received once per
579 * update command when wimlib_update_image() is called with the flag
580 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
581 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
583 /** A file in the WIM image is being replaced as a result of a
584 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
585 * @p info will point to ::wimlib_progress_info.replace. This is only
586 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
588 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
590 /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
591 * a file is being extracted normally (not as a WIMBoot "pointer file")
592 * due to it matching a pattern in the [PrepopulateList] section of the
593 * configuration file @c \\Windows\\System32\\WimBootCompress.ini in the
594 * WIM image. @p info will point to
595 * ::wimlib_progress_info.wimboot_exclude.
597 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
599 /** Starting to unmount a WIM image. @p info will point to
600 * ::wimlib_progress_info.unmount. */
601 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
604 /** Valid return values from user-provided progress functions
605 * (::wimlib_progress_func_t).
607 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
610 enum wimlib_progress_status {
612 /** The operation should be continued. This is the normal return value.
614 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
616 /** The operation should be aborted. This will cause the current
617 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
618 WIMLIB_PROGRESS_STATUS_ABORT = 1,
622 * A pointer to this union is passed to the user-supplied
623 * ::wimlib_progress_func_t progress function. One (or none) of the structures
624 * contained in this union will be applicable for the operation
625 * (::wimlib_progress_msg) indicated in the first argument to the progress
627 union wimlib_progress_info {
629 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
630 * document them if they aren't given a name... */
632 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
633 * the primary message for tracking the progress of writing a WIM file.
635 struct wimlib_progress_info_write_streams {
636 /** Total number of uncompressed bytes of stream data being
637 * written. This can be thought of as the total uncompressed
638 * size of the files being archived, with some caveats. WIM
639 * files use single-instance streams, so the size provided here
640 * only counts distinct streams, except for the following
641 * exception: the size provided here may include the sizes of
642 * all newly added (e.g. with wimlib_add_image() streams,
643 * pending automatic de-duplication during the write operation
644 * itself. When each such stream de-duplication occurs, this
645 * number will be decreased by the size of the duplicate stream
646 * that need not be written.
648 * In the case of a wimlib_overwrite() that the library opted to
649 * perform in-place, both @p total_streams and @p total_bytes
650 * will only count the streams actually being written and not
651 * pre-existing streams in the WIM file. */
652 uint64_t total_bytes;
654 /** Total number of streams being written. This can be thought
655 * of as the total number of files being archived, with some
656 * caveats. In general, a single file or directory may contain
657 * multiple data streams, each of which will be represented
658 * separately in this number. Furthermore, WIM files use
659 * single-instance streams, so the stream count provided here
660 * only counts distinct streams, except for the following
661 * exception: the stream count provided here may include newly
662 * added (e.g. with wimlib_add_image() streams, pending
663 * automatic de-duplication during the write operation itself.
664 * When each such stream de-duplication occurs, this number will
665 * be decreased by 1 to account for the duplicate stream that
666 * need not be written. */
667 uint64_t total_streams;
669 /** Number of uncompressed bytes of stream data that have been
670 * written so far. This number be 0 initially, and will be
671 * equal to @p total_bytes at the end of the write operation.
672 * Note that @p total_bytes (but not @p completed_bytes) may
673 * decrease throughout the write operation due to the discovery
674 * of stream duplications. */
675 uint64_t completed_bytes;
677 /** Number of streams that have been written so far. This
678 * number will be 0 initially, and will be equal to @p
679 * total_streams at the end of the write operation. Note that
680 * @p total_streams (but not @p completed_streams) may decrease
681 * throughout the write operation due to the discovery of stream
684 * For applications that wish to calculate a simple "percent
685 * complete" for the write operation, it will likely be more
686 * accurate to calculate the percentage from @p completed_bytes
687 * and @p total_bytes rather than @p completed_streams and
688 * @p total_streams because the time for the operation to
689 * complete is mainly determined by the number of bytes that
690 * need to be read, compressed, and written, not just the number
691 * of files being archived. */
692 uint64_t completed_streams;
694 /** Number of threads that are being used to compress streams,
695 * or 1 if streams are being written uncompressed. */
696 uint32_t num_threads;
698 /** The compression type being used to write the streams, as one
699 * of the ::wimlib_compression_type constants. */
700 int32_t compression_type;
702 /** Number of split WIM parts from which streams are being
703 * written (may be 0 if irrelevant). */
704 uint32_t total_parts;
706 /** This is currently broken and will always be 0. */
707 uint32_t completed_parts;
710 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
711 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
712 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
713 struct wimlib_progress_info_scan {
714 /** Top-level directory being scanned; or, when capturing an NTFS
715 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
716 * to the file or block device that contains the NTFS volume
718 const wimlib_tchar *source;
720 /** Path to the file (or directory) that has been scanned, valid
721 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
722 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
723 * relative to the root of the NTFS volume. */
724 const wimlib_tchar *cur_path;
726 /** Dentry scan status, valid on
727 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
729 /** The file looks okay and will be captured. */
730 WIMLIB_SCAN_DENTRY_OK = 0,
732 /** File is being excluded from capture due to the
733 * capture configuration. */
734 WIMLIB_SCAN_DENTRY_EXCLUDED,
736 /** File is being excluded from capture due to being
737 * unsupported (e.g. an encrypted or device file). */
738 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
740 /** The file is an absolute symbolic link or junction
741 * that points into the capture directory, and
742 * reparse-point fixups are enabled, so its target is
743 * being adjusted. (Reparse point fixups can be
744 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
746 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
748 /** Reparse-point fixups are enabled, but the file is an
749 * absolute symbolic link or junction that does
750 * <b>not</b> point into the capture directory, so its
751 * target is <b>not</b> being adjusted. */
752 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK,
756 /** Target path in the WIM image. Only valid on
757 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
758 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
759 const wimlib_tchar *wim_target_path;
761 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
762 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
763 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
764 * target of the absolute symbolic link or junction. */
765 const wimlib_tchar *symlink_target;
768 /** Number of directories scanned so far, including the root
769 * directory but excluding any unsupported/excluded directories.
771 * Details: On Windows and in NTFS capture mode, a reparse point
772 * counts as a directory if and only if it has
773 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
774 * counts as a directory if and only if when fully dereferenced
775 * it points to an accessible directory. If a file has multiple
776 * names (hard links), it is only counted one time. */
777 uint64_t num_dirs_scanned;
779 /** Number of non-directories scanned so far, excluding any
780 * unsupported/excluded files.
782 * Details: On Windows and in NTFS capture mode, a reparse point
783 * counts as a non-directory if and only if it does not have
784 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
785 * counts as a non-directory if and only if when fully
786 * dereferenced it points to a non-directory or its target is
787 * inaccessible. If a file has multiple names (hard links), it
788 * is only counted one time. */
789 uint64_t num_nondirs_scanned;
791 /** Number of bytes of file data that have been detected so far.
793 * Details: This data may not actually have been read yet, and
794 * it will not actually be written to the WIM file until
795 * wimlib_write() or wimlib_overwrite() has been called. Data
796 * from excluded files is not counted. This number includes
797 * default file contents as well as named data streams and
798 * reparse point data. The size of reparse point data is
799 * tallied after any reparse-point fixups, and in the case of
800 * capturing a symbolic link on a UNIX-like system, the creation
801 * of the reparse point data itself. If a file has multiple
802 * names (hard links), its size(s) are only counted one time.
803 * On Windows, encrypted files have their encrypted size
804 * counted, not their unencrypted size; however, compressed
805 * files have their uncompressed size counted. */
806 uint64_t num_bytes_scanned;
809 /** Valid on messages
810 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
811 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
812 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
813 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
814 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
815 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
817 * Note: most of the time of an extraction operation will be spent
818 * extracting streams, and the application will receive
819 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
820 * completed_bytes and @p total_bytes, the application can calculate a
821 * percentage complete. However, note that this message does not, in
822 * general, actually provide information about which "file" is currently
823 * being extracted. This is because wimlib, by default, extracts the
824 * individual data streams in whichever order it determines to be the
827 struct wimlib_progress_info_extract {
828 /** Number of the image from which files are being extracted
832 /** Extraction flags being used. */
833 uint32_t extract_flags;
835 /** Full path to the WIM file from which files are being
836 * extracted, or @c NULL if the WIMStruct has no associated
838 const wimlib_tchar *wimfile_name;
840 /** Name of the image from which files are being extracted, or
841 * the empty string if the image is unnamed. */
842 const wimlib_tchar *image_name;
844 /** Path to the directory or NTFS volume to which the files are
845 * being extracted. */
846 const wimlib_tchar *target;
849 const wimlib_tchar *reserved;
851 /** Number of bytes of uncompressed data that will be extracted.
852 * If a file has multiple names (hard links), its size (or
853 * sizes, in the case of named data streams) is only counted one
854 * time. For "reparse points" and symbolic links, the size to
855 * be extracted is the size of the reparse data buffer.
857 * This number will stay constant throughout the extraction. */
858 uint64_t total_bytes;
860 /** Number of bytes of uncompressed data that have been
861 * extracted so far. This initially be 0 and will equal to @p
862 * total_bytes at the end of the extraction. */
863 uint64_t completed_bytes;
865 /** Number of (not necessarily unique) streams that will be
866 * extracted. This may be more or less than the number of
867 * "files" to be extracted due to hard links as well as
868 * potentially multiple streams per file (named data streams).
869 * A "stream" may be the default contents of a file, a named
870 * data stream, or a reparse data buffer. */
871 uint64_t num_streams;
874 const wimlib_tchar *reserved_2;
876 /** Currently only used for
877 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
878 uint32_t part_number;
880 /** Currently only used for
881 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
882 uint32_t total_parts;
884 /** Currently only used for
885 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
886 uint8_t guid[WIMLIB_GUID_LEN];
889 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
890 struct wimlib_progress_info_rename {
891 /** Name of the temporary file that the WIM was written to. */
892 const wimlib_tchar *from;
894 /** Name of the original WIM file to which the temporary file is
896 const wimlib_tchar *to;
899 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
900 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
901 struct wimlib_progress_info_update {
902 /** Pointer to the update command that will be executed or has
903 * just been executed. */
904 const struct wimlib_update_command *command;
906 /** Number of update commands that have been completed so far.
908 size_t completed_commands;
910 /** Number of update commands that are being executed as part of
911 * this call to wimlib_update_image(). */
912 size_t total_commands;
915 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
916 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
917 struct wimlib_progress_info_integrity {
918 /** Number of bytes from the end of the WIM header to the end of
919 * the lookup table (the area that is covered by the SHA1
920 * integrity checks.) */
921 uint64_t total_bytes;
923 /** Number of bytes that have been SHA1-summed so far. Will be
924 * 0 initially, and equal @p total_bytes at the end. */
925 uint64_t completed_bytes;
927 /** Number of chunks that the checksummed region is divided
929 uint32_t total_chunks;
931 /** Number of chunks that have been SHA1-summed so far. Will
932 * be 0 initially, and equal to @p total_chunks at the end. */
933 uint32_t completed_chunks;
935 /** Size of the chunks used for the integrity calculation. */
938 /** Filename of the WIM (only valid if the message is
939 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
940 const wimlib_tchar *filename;
943 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
944 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
945 struct wimlib_progress_info_split {
946 /** Total size of the original WIM's file and metadata resources
948 uint64_t total_bytes;
950 /** Number of bytes of file and metadata resources that have
951 * been copied out of the original WIM so far. Will be 0
952 * initially, and equal to @p total_bytes at the end. */
953 uint64_t completed_bytes;
955 /** Number of the split WIM part that is about to be started
956 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
957 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
958 unsigned cur_part_number;
960 /** Total number of split WIM parts that are being written. */
961 unsigned total_parts;
963 /** Name of the split WIM part that is about to be started
964 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
965 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
966 * As of wimlib v1.7.0, the library user may change this when
967 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
968 * cause the next split WIM part to be written to a different
970 wimlib_tchar *part_name;
973 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
974 struct wimlib_progress_info_replace {
975 /** Path to the file in the WIM image that is being replaced */
976 const wimlib_tchar *path_in_wim;
979 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
980 struct wimlib_progress_info_wimboot_exclude {
981 /** Path to the file in the WIM image */
982 const wimlib_tchar *path_in_wim;
984 /** Path to which the file is being extracted */
985 const wimlib_tchar *extraction_path;
988 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
989 struct wimlib_progress_info_unmount {
990 /** Path to directory being unmounted */
991 const wimlib_tchar *mountpoint;
993 /** Path to WIM file being unmounted */
994 const wimlib_tchar *mounted_wim;
996 /** 1-based index of image being unmounted. */
997 uint32_t mounted_image;
999 /** Flags that were passed to wimlib_mount_image() when the
1000 * mountpoint was set up. */
1001 uint32_t mount_flags;
1003 /** Flags passed to wimlib_unmount_image(). */
1004 uint32_t unmount_flags;
1009 * A user-supplied function that will be called periodically during certain WIM
1012 * The first argument will be the type of operation that is being performed or
1013 * is about to be started or has been completed.
1015 * The second argument will be a pointer to one of a number of structures
1016 * depending on the first argument. It may be @c NULL for some message types.
1017 * Note that although this argument is not @c const, users should not modify it
1018 * except in explicitly documented cases.
1020 * The third argument will be a user-supplied value that was provided when
1021 * registering or specifying the progress function.
1023 * This function must return one of the ::wimlib_progress_status values. By
1024 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1026 typedef enum wimlib_progress_status
1027 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1028 union wimlib_progress_info *info,
1032 /** @addtogroup G_modifying_wims
1035 /** An array of these structures is passed to wimlib_add_image_multisource() to
1036 * specify the sources from which to create a WIM image. */
1037 struct wimlib_capture_source {
1038 /** Absolute or relative path to a file or directory on the external
1039 * filesystem to be included in the WIM image. */
1040 wimlib_tchar *fs_source_path;
1042 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1043 * specify the root directory of the WIM image. */
1044 wimlib_tchar *wim_target_path;
1046 /** Reserved; set to 0. */
1050 /** Set or unset the WIM header flag that marks it read-only
1051 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
1052 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
1053 * is distinct from basic file permissions; this flag can be set on a WIM file
1054 * that is physically writable. If this flag is set, all further operations to
1055 * modify the WIM will fail, except calling wimlib_overwrite() with
1056 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
1057 * allows you to set this flag persistently on the underlying WIM file.
1059 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1061 /** Set the GUID (globally unique identifier) of the WIM file to the value
1062 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1063 #define WIMLIB_CHANGE_GUID 0x00000002
1065 /** Change the bootable image of the WIM to the value specified in
1066 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1067 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1069 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1070 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
1071 * indicates whether an image in the WIM has been captured with reparse-point
1072 * fixups enabled. wimlib also treats this flag as specifying whether to do
1073 * reparse-point fixups by default when capturing or applying WIM images. */
1074 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1078 /** @addtogroup G_wim_information
1083 /** General information about a WIM file. */
1084 struct wimlib_wim_info {
1086 /** Globally unique identifier for the WIM file. Note: all parts of a
1087 * split WIM should have an identical value in this field. */
1088 uint8_t guid[WIMLIB_GUID_LEN];
1090 /** Number of images in the WIM. */
1091 uint32_t image_count;
1093 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1095 uint32_t boot_index;
1097 /** Version of the WIM file. */
1098 uint32_t wim_version;
1100 /** Chunk size used for compression. */
1101 uint32_t chunk_size;
1103 /** For split WIMs, the 1-based index of this part within the split WIM;
1105 uint16_t part_number;
1107 /** For split WIMs, the total number of parts in the split WIM;
1109 uint16_t total_parts;
1111 /** One of the ::wimlib_compression_type values that specifies the
1112 * method used to compress resources in the WIM. */
1113 int32_t compression_type;
1115 /** Size of the WIM file in bytes, excluding the XML data and integrity
1117 uint64_t total_bytes;
1119 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1120 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1121 * this will always be 0, even if the ::WIMStruct was written to
1122 * somewhere by calling wimlib_write() with the
1123 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1124 uint32_t has_integrity_table : 1;
1126 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1127 * wimlib_create_new_wim(). */
1128 uint32_t opened_from_file : 1;
1130 /** 1 if the WIM is considered readonly for any reason. */
1131 uint32_t is_readonly : 1;
1133 /** 1 if reparse-point fixups are supposedly enabled for one or more
1134 * images in the WIM. */
1135 uint32_t has_rpfix : 1;
1137 /** 1 if the WIM is marked as read-only. */
1138 uint32_t is_marked_readonly : 1;
1140 /** 1 if the WIM is part of a spanned set. */
1141 uint32_t spanned : 1;
1143 uint32_t write_in_progress : 1;
1144 uint32_t metadata_only : 1;
1145 uint32_t resource_only : 1;
1147 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1148 uint32_t pipable : 1;
1149 uint32_t reserved_flags : 22;
1150 uint32_t reserved[9];
1153 /** Information about a unique stream in the WIM file. (A stream is the same
1154 * thing as a "resource", except in the case of packed resources.) */
1155 struct wimlib_resource_entry {
1156 /** Uncompressed size of the stream in bytes. */
1157 uint64_t uncompressed_size;
1159 /** Compressed size of the stream in bytes. This will be the same as @p
1160 * uncompressed_size if the stream is uncompressed. Or, if @p
1161 * is_packed_streams is 1, this will be 0. */
1162 uint64_t compressed_size;
1164 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1165 * if @p packed is 1, then this is actually the offset at which this
1166 * stream begins in the uncompressed contents of the packed resource.
1170 /** SHA1 message digest of the stream's uncompressed contents. */
1171 uint8_t sha1_hash[20];
1173 /** Which part number of the split WIM this stream is in. This should
1174 * be the same as the part number provided by wimlib_get_wim_info(). */
1175 uint32_t part_number;
1177 /** Number of times this stream is referenced over all WIM images. */
1178 uint32_t reference_count;
1180 /** 1 if this stream is compressed. */
1181 uint32_t is_compressed : 1;
1183 /** 1 if this stream is a metadata resource rather than a file resource.
1185 uint32_t is_metadata : 1;
1187 uint32_t is_free : 1;
1188 uint32_t is_spanned : 1;
1190 /** 1 if this stream was not found in the lookup table of the
1191 * ::WIMStruct. This normally implies a missing call to
1192 * wimlib_reference_resource_files() or wimlib_reference_resources().
1194 uint32_t is_missing : 1;
1196 /** 1 if this stream is located in a packed resource which may contain
1197 * other streams (all compressed together) as well. */
1198 uint32_t packed : 1;
1200 uint32_t reserved_flags : 26;
1202 /** If @p packed is 1, then this will specify the offset of the packed
1203 * resource in the WIM. */
1204 uint64_t raw_resource_offset_in_wim;
1206 /** If @p is_packed_streams is 1, then this will specify the compressed
1207 * size of the packed resource in the WIM. */
1208 uint64_t raw_resource_compressed_size;
1210 uint64_t reserved[2];
1213 /** Information about a stream of a particular file in the WIM. */
1214 struct wimlib_stream_entry {
1215 /** Name of the stream, or NULL if the stream is unnamed. */
1216 const wimlib_tchar *stream_name;
1217 /** Location, size, etc. of the stream within the WIM file. */
1218 struct wimlib_resource_entry resource;
1219 uint64_t reserved[4];
1222 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1223 * Roughly, the information about a "file" in the WIM--- but really a directory
1224 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1225 * field can be used to distinguish actual file inodes. */
1226 struct wimlib_dir_entry {
1227 /** Name of the file, or NULL if this file is unnamed (only possible for
1228 * the root directory) */
1229 const wimlib_tchar *filename;
1231 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1233 const wimlib_tchar *dos_name;
1235 /** Full path to this file within the WIM image. */
1236 const wimlib_tchar *full_path;
1238 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1239 * children, ..., etc. */
1242 /** Pointer to the security descriptor for this file, in Windows
1243 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1244 * security descriptor. */
1245 const char *security_descriptor;
1247 /** Length of the above security descriptor. */
1248 size_t security_descriptor_size;
1250 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1251 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1252 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1253 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1254 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1255 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1256 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1257 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1258 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1259 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1260 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1261 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1262 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1263 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1264 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1265 /** File attributes, such as whether the file is a directory or not.
1266 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1267 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1268 * on other platforms. */
1269 uint32_t attributes;
1271 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1272 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1273 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1274 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1275 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1276 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1277 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1278 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1279 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1280 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1281 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1282 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1283 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1284 * attributes), this will give the reparse tag. This tells you whether
1285 * the reparse point is a symbolic link, junction point, or some other,
1286 * more unusual kind of reparse point. */
1287 uint32_t reparse_tag;
1289 /* Number of (hard) links to this file. */
1292 /** Number of named data streams that this file has. Normally 0. */
1293 uint32_t num_named_streams;
1295 /** Roughly, the inode number of this file. However, it may be 0 if
1296 * @p num_links == 1. */
1297 uint64_t hard_link_group_id;
1299 /** Time this file was created. */
1300 struct timespec creation_time;
1302 /** Time this file was last written to. */
1303 struct timespec last_write_time;
1305 /** Time this file was last accessed. */
1306 struct timespec last_access_time;
1308 /* UNIX data (wimlib extension), only valid if unix_mode != 0 */
1314 uint64_t reserved[14];
1316 /** Array of streams that make up this file. The first entry will
1317 * always exist and will correspond to the unnamed data stream (default
1318 * file contents), so it will have @p stream_name == @c NULL. There
1319 * will then be @p num_named_streams additional entries that specify the
1320 * named data streams, if any, each of which will have @p stream_name !=
1322 struct wimlib_stream_entry streams[];
1326 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1329 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1333 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1336 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1339 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1340 * just on the specified path. */
1341 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1343 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1344 * itself; only its children (in the case of a non-empty directory) */
1345 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1347 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1348 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1349 * table of the ::WIMStruct. The default behavior without this flag is to fill
1350 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1351 * wimlib_resource_entry::is_missing "is_missing" flag. */
1352 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1356 /** @addtogroup G_modifying_wims
1359 /** Directly capture an NTFS volume rather than a generic directory. This flag
1360 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1361 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1362 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1364 /** Follow symlinks; archive and dump the files they point to. Currently only
1365 * supported on UNIX-like systems. */
1366 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1368 /** Call the progress function with the message
1369 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1371 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1373 /** Mark the image being added as the bootable image of the WIM. Not valid for
1374 * wimlib_update_image(). */
1375 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1377 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1378 * (major and minor number) of each file. See the documentation for the
1379 * <b>--unix-data</b> option to <b>wimlib-imagex capture</b> for more
1381 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1383 /** Do not capture security descriptors. Only has an effect in NTFS capture
1384 * mode, or in Windows native builds. */
1385 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1387 /** Fail immediately if the full security descriptor of any file or directory
1388 * cannot be accessed. Only has an effect in Windows native builds. The
1389 * default behavior without this flag is to first try omitting the SACL from the
1390 * security descriptor, then to try omitting the security descriptor entirely.
1392 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1394 /** Call the progress function with the message
1395 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1396 * capture. This is a subset of the messages provided by
1397 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1398 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1400 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1401 * in the case of Windows) that point inside the directory being captured to
1402 * instead be absolute relative to the directory being captured, rather than the
1405 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1406 * the WIM header or if this is the first image being added.
1407 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1408 * reparse point fixups enabled and currently cannot be unset. */
1409 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1411 /** Don't do reparse point fixups. The default behavior is described in the
1412 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1413 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1415 /** Do not automatically exclude unsupported files or directories from capture;
1416 * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1417 * UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1418 * such a file is encountered. */
1419 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1422 * Automatically select a capture configuration appropriate for capturing
1423 * filesystems containing Windows operating systems. For example,
1424 * "pagefile.sys" and "System Volume Information" will be excluded.
1426 * When this flag is specified, the corresponding @p config parameter or member
1429 * Note that the default behavior--- that is, when this flag is not specified
1430 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1431 * no files are excluded from capture.
1433 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1436 * Capture image as WIMBoot compatible. In addition, if no capture
1437 * configuration file is explicitly specified use the capture configuration file
1438 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1439 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1440 * configuration file is explicitly specified, use it and also place it at
1441 * /Windows/System32/WimBootCompress.ini in the WIM image.
1443 * Note: this will not by itself change the compression type. Before writing
1444 * the WIM file, it's recommended to also do:
1447 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1448 * wimlib_set_output_chunk_size(wim, 4096);
1451 * since that makes access to the data faster (at the cost of a worse
1452 * compression ratio compared to the 32768-byte LZX chunks usually used).
1454 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1457 * If the add command involves adding a non-directory file to a location at
1458 * which there already exists a nondirectory file in the WIM image, issue
1459 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This only has an
1460 * effect when updating an existing image with wimlib_update_image().
1461 * This was the default behavior in wimlib v1.6.2 and earlier.
1463 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1465 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1466 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1467 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1468 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1469 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1470 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1471 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1472 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1473 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1474 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1475 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1476 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1477 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1478 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT WIMLIB_ADD_FLAG_WIMBOOT
1482 /** @addtogroup G_modifying_wims
1485 /** Do not issue an error if the path to delete does not exist. */
1486 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1488 /** Delete the file or directory tree recursively; if not specified, an error is
1489 * issued if the path to delete is a directory. */
1490 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1493 /** @addtogroup G_modifying_wims
1497 * If a single image is being exported, mark it bootable in the destination WIM.
1498 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1499 * the image in the source WIM (if any) that is marked as bootable is also
1500 * marked as bootable in the destination WIM.
1502 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1504 /** Give the exported image(s) no names. Avoids problems with image name
1507 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1509 /** Give the exported image(s) no descriptions. */
1510 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1512 /** This advises the library that the program is finished with the source
1513 * WIMStruct and will not attempt to access it after the call to
1514 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1515 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1518 * Mark each exported image as WIMBoot-compatible.
1520 * Note: by itself, this does change the destination WIM's compression type, nor
1521 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1522 * image. Before writing the destination WIM, it's recommended to do something
1526 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1527 * wimlib_set_output_chunk_size(wim, 4096);
1528 * wimlib_add_tree(wim, image, L"myconfig.ini",
1529 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1532 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1535 /** @addtogroup G_extracting_wims
1538 /** Extract the image directly to an NTFS volume rather than a generic directory.
1539 * This mode is only available if wimlib was compiled with libntfs-3g support;
1540 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1541 * extraction target will be interpreted as the path to an NTFS volume image (as
1542 * a regular file or block device) rather than a directory. It will be opened
1543 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1544 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1545 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1546 * wimlib_extract_paths() when passed multiple paths. */
1547 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1549 /** UNIX-like systems only: Extract special UNIX data captured with
1550 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1551 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1552 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1554 /** Do not extract security descriptors. This flag cannot be combined with
1555 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1556 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1558 /** Fail immediately if the full security descriptor of any file or directory
1559 * cannot be set exactly as specified in the WIM file. On Windows, the default
1560 * behavior without this flag when wimlib does not have permission to set the
1561 * correct security descriptor is to fall back to setting the security
1562 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1563 * owner omitted, then not at all. This flag cannot be combined with
1564 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1565 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1567 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1568 * reparse-point fixups on, so absolute symbolic links or junction points will
1569 * be fixed to be absolute relative to the actual extraction root. Reparse-
1570 * point fixups are done by default for wimlib_extract_image() and
1571 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1572 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1573 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1575 /** Force reparse-point fixups on extraction off, regardless of the state of the
1576 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1577 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1578 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1580 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1581 * paths, each of which must name a regular file, to standard output. */
1582 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1584 /** Instead of ignoring files and directories with names that cannot be
1585 * represented on the current platform (note: Windows has more restrictions on
1586 * filenames than POSIX-compliant systems), try to replace characters or append
1587 * junk to the names so that they can be extracted in some form. */
1588 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1590 /** On Windows, when there exist two or more files with the same case
1591 * insensitive name but different case sensitive names, try to extract them all
1592 * by appending junk to the end of them, rather than arbitrarily extracting only
1594 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1596 /** Do not ignore failure to set timestamps on extracted files. */
1597 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1599 /** Do not ignore failure to set short names on extracted files. */
1600 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1602 /** On Windows, do not ignore failure to extract symbolic links and junctions
1603 * due to permissions problems. By default, such failures are ignored since the
1604 * default configuration of Windows only allows the Administrator to create
1605 * symbolic links. */
1606 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1608 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1609 * behavior is currently less than satisfactory. Do not use (yet). */
1610 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1612 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1613 * paths to extract as wildcard patterns ("globs") which may contain the
1614 * wildcard characters @c ? and @c *. The @c ? character matches any
1615 * non-path-separator character, whereas the @c * character matches zero or more
1616 * non-path-separator characters. Consequently, each glob may match zero or
1617 * more actual paths in the WIM image. By default, if a glob does not match any
1618 * files, a warning but not an error will be issued, even if the glob did not
1619 * actually contain wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
1620 * to get an error instead. */
1621 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1623 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1624 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1625 * one of the provided globs did not match a file. */
1626 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1628 /** Do not extract Windows file attributes such as readonly, hidden, etc. */
1629 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1631 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1632 * preserve the directory structure of the archive when extracting --- that is,
1633 * place each extracted file or directory tree directly in the target directory.
1635 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1637 /** Windows only: Extract files as "pointers" back to the WIM archive. See the
1638 * documentation for the <b>--wimboot</b> option of <b>wimlib-imagex apply</b>
1639 * for more information. */
1640 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1643 /** @addtogroup G_mounting_wim_images
1646 /** Mount the WIM image read-write rather than the default of read-only. */
1647 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1649 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1650 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1652 /** Do not allow accessing named data streams in the mounted WIM image. */
1653 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1655 /** Access named data streams in the mounted WIM image through extended file
1656 * attributes named "user.X", where X is the name of a data stream. This is the
1658 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1660 /** Access named data streams in the mounted WIM image by specifying the file
1661 * name, a colon, then the name of the data stream. */
1662 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1664 /** Use UNIX metadata if available in the WIM image. See
1665 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1666 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1668 /** Allow other users to see the mounted filesystem. This passes the @c
1669 * allow_other option to the FUSE mount. */
1670 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1673 /** @addtogroup G_creating_and_opening_wims
1676 /** Verify the WIM contents against the WIM's integrity table, if present. This
1677 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1678 * checksummed and checked against the SHA1 message digests specified in the
1679 * integrity table. If there are any mismatches, ::WIMLIB_ERR_INTEGRITY is
1680 * issued. If the WIM file does not contain an integrity table, this flag has
1682 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1684 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
1685 * WIM. Software can provide this flag for convenience if it explicitly does
1686 * not want to support split WIMs. */
1687 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1689 /** Check if the WIM is writable and issue an error
1690 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
1691 * only if it is writable at the filesystem level, does not have the
1692 * WIM_HDR_FLAG_READONLY flag set in its header, and is not part of a spanned
1693 * set. It is not required to provide this flag before attempting to make
1694 * changes to the WIM, but with this flag you get an error sooner rather than
1696 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1699 /** @addtogroup G_mounting_wim_images
1702 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
1703 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1704 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1706 /** Commit changes to the read-write mounted WIM image.
1707 * If this flag is not specified, changes will be discarded. */
1708 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1710 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
1711 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1712 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1714 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
1715 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1716 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1719 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
1720 * image, forces all file descriptors to the open WIM image to be closed before
1723 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
1724 * this flag has no effect.
1726 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
1728 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1729 * WIM image, causes the modified image to be committed to the WIM file as a
1730 * new, unnamed image appended to the archive. The original image in the WIM
1731 * file will be unmodified. */
1732 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
1735 /** @addtogroup G_modifying_wims
1738 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1739 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1740 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1743 /** @addtogroup G_writing_and_overwriting_wims
1747 * Include an integrity table in the resulting WIM file.
1749 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1750 * include an integrity table if and only if one was present before. For
1751 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1752 * to not include an integrity table.
1754 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1757 * Do not include an integrity table in the resulting WIM file. This is the
1758 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
1761 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1764 * Write the WIM as "pipable". After writing a WIM with this flag specified,
1765 * images from it can be applied directly from a pipe using
1766 * wimlib_extract_image_from_pipe(). See the documentation for the
1767 * <b>--pipable</b> option of <b>wimlib-imagex capture</b> for more information.
1768 * Beware: WIMs written with this flag will not be compatible with Microsoft's
1771 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1772 * write the WIM as pipable if and only if it was pipable before. For
1773 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1774 * to write the WIM as non-pipable.
1776 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1779 * Do not write the WIM as "pipable". This is the default behavior, unless the
1780 * ::WIMStruct was created by opening a pipable WIM.
1782 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1785 * When writing streams to the WIM file, recompress them, even if their data is
1786 * already available in the desired compressed form (for example, in a WIM file
1787 * from which an image has been exported using wimlib_export_image()).
1789 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
1790 * compression ratio for the same compression type and chunk size. wimlib's LZX
1791 * compressor currently can be given different parameters in order to achieve
1792 * different balances between compression ratio and time. In its default mode
1793 * as of v1.7.0, it usually compresses slightly better than the competing
1794 * Microsoft implementation and is almost as fast.
1796 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can also be used in combination with
1797 * ::WIMLIB_WRITE_FLAG_PACK_STREAMS to prevent any solid blocks from being
1798 * re-used. (Otherwise, solid blocks are re-used somewhat more liberally than
1799 * normal compressed blocks.)
1801 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
1802 * that would not otherwise be written. For example, a call to
1803 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
1804 * cause already-existing streams in the WIM file to be recompressed. To force
1805 * the WIM file to be fully rebuilt and recompressed, combine
1806 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
1808 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1811 * Immediately before closing the WIM file, sync its data to disk.
1813 * wimlib_overwrite() will set this flag automatically if it decides to
1814 * overwrite the WIM file via a temporary file instead of in-place.
1816 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1819 * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
1820 * could be updated merely by appending to it.
1822 * When rebuilding the WIM file, stream reference counts will be recomputed, and
1823 * any streams with 0 reference count (e.g. from deleted files or images) will
1824 * not be included in the resulting WIM file.
1826 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
1827 * data to be recompressed. Otherwise, compressed data is re-used if possible.
1829 * wimlib_write() ignores this flag.
1831 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1834 * For wimlib_overwrite(), override the default behavior after one or more calls
1835 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
1836 * flag, only minimal changes to correctly remove the image from the WIM file
1837 * will be taken. In particular, all streams will be retained, even if they are
1838 * no longer referenced. This may not be what you want, because no space will
1839 * be saved by deleting an image in this way.
1841 * wimlib_write() ignores this flag.
1843 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1846 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
1847 * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header. This can be used
1848 * following a call to wimlib_set_wim_info() with the
1849 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
1852 * wimlib_write() ignores this flag.
1854 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1857 * Do not include streams already present in other WIMs. This flag can be used
1858 * to write a "delta" WIM after resources from the WIM on which the delta is to
1859 * be based were referenced with wimlib_reference_resource_files() or
1860 * wimlib_reference_resources().
1862 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1865 * Advises the library that for writes of all WIM images, all streams needed for
1866 * the WIM are already present (not in external resource WIMs) and their
1867 * reference counts are correct, so the code does not need to recalculate which
1868 * streams are referenced. This is for optimization purposes only, since with
1869 * this flag specified, the metadata resources may not need to be decompressed
1872 * wimlib_overwrite() will set this flag automatically.
1874 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1877 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
1879 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
1882 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
1885 * When writing streams in the resulting WIM file, pack multiple streams into a
1886 * single compressed resource instead of compressing them independently. This
1887 * is also known as creating a "solid archive". This tends to produce a better
1888 * compression ratio at the cost of much slower random access.
1890 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
1891 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
1892 * created with this flag use a different version number in their header (3584
1893 * instead of 68864) and are also called "ESD files".
1895 * If this flag is passed to wimlib_overwrite(), any new data streams will be
1896 * written in solid mode. Use both ::WIMLIB_WRITE_FLAG_REBUILD and
1897 * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
1898 * all streams recompressed in solid mode.
1900 * Currently, new solid blocks will, by default, be written using LZMS
1901 * compression with 64 MiB (67108864 byte) chunks. Use
1902 * wimlib_set_output_pack_compression_type() and/or
1903 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
1904 * the WIM's main compression type and chunk size; you can have a WIM that
1905 * nominally uses LZX compression and 32768 byte chunks but actually contains
1906 * LZMS-compressed solid blocks, for example. However, if including solid
1907 * blocks, I suggest that you set the WIM's main compression type to LZMS as
1908 * well, either by creating the WIM with
1909 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
1910 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
1912 * This flag will be set by default when writing or overwriting a WIM file that
1913 * either already contains packed streams, or has had packed streams exported
1914 * into it and the WIM's main compression type is LZMS.
1916 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
1919 /** @addtogroup G_general
1922 /** Assume that strings are represented in UTF-8, even if this is not the
1923 * locale's character encoding. This flag is ignored on Windows, where wimlib
1924 * always uses UTF-16LE. */
1925 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1927 /** Windows-only: do not attempt to acquire additional privileges (currently
1928 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1929 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1930 * for the case where the calling program manages these privileges itself.
1931 * Note: no error is issued if privileges cannot be acquired, although related
1932 * errors may be reported later, depending on if the operations performed
1933 * actually require additional privileges or not. */
1934 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1936 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1937 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1938 * to read all possible data and metadata for a capture operation could not be
1939 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1941 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1943 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1944 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1945 * to restore all possible data and metadata for an apply operation could not be
1946 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1948 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1950 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1952 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
1954 /** Default to interpreting WIM paths case insensitively (default on Windows).
1955 * This does not apply to mounted images. */
1956 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
1959 /** @addtogroup G_nonstandalone_wims
1962 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
1963 * Ignored by wimlib_reference_resources(). */
1964 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1966 /** For wimlib_reference_resource_files(), issue an error
1967 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1968 * default behavior without this flag is to issue no error at that point, but
1969 * then attempt to open the glob as a literal path, which of course will fail
1970 * anyway if no file exists at that path. No effect if
1971 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
1972 * wimlib_reference_resources(). */
1973 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1976 /** @addtogroup G_modifying_wims
1979 /** The specific type of update to perform. */
1980 enum wimlib_update_op {
1981 /** Add a new file or directory tree to the WIM image in a
1982 * certain location. */
1983 WIMLIB_UPDATE_OP_ADD = 0,
1985 /** Delete a file or directory tree from the WIM image. */
1986 WIMLIB_UPDATE_OP_DELETE,
1988 /** Rename a file or directory tree in the WIM image. */
1989 WIMLIB_UPDATE_OP_RENAME,
1992 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1993 struct wimlib_add_command {
1994 /** Filesystem path to the file or directory tree to add. */
1995 wimlib_tchar *fs_source_path;
1997 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1998 * specify the root directory of the WIM image. */
1999 wimlib_tchar *wim_target_path;
2001 /** Path to capture configuration file to use, or @c NULL for default.
2003 wimlib_tchar *config_file;
2005 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2009 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2010 struct wimlib_delete_command {
2012 /** Path, specified from the root of the WIM image, for the file or
2013 * directory tree within the WIM image to be deleted. */
2014 wimlib_tchar *wim_path;
2016 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2020 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2021 struct wimlib_rename_command {
2023 /** Path, specified from the root of the WIM image, for the source file
2024 * or directory tree within the WIM image. */
2025 wimlib_tchar *wim_source_path;
2027 /** Path, specified from the root of the WIM image, for the destination
2028 * file or directory tree within the WIM image. */
2029 wimlib_tchar *wim_target_path;
2031 /** Reserved; set to 0. */
2035 /** Specification of an update to perform on a WIM image. */
2036 struct wimlib_update_command {
2038 enum wimlib_update_op op;
2041 struct wimlib_add_command add;
2042 struct wimlib_delete_command delete_; /* Underscore is for C++
2044 struct wimlib_rename_command rename;
2049 /** @addtogroup G_general
2053 * Possible values of the error code returned by many functions in wimlib.
2055 * See the documentation for each wimlib function to see specifically what error
2056 * codes can be returned by a given function, and what they mean.
2058 enum wimlib_error_code {
2059 WIMLIB_ERR_SUCCESS = 0,
2060 WIMLIB_ERR_ALREADY_LOCKED = 1,
2061 WIMLIB_ERR_DECOMPRESSION = 2,
2062 WIMLIB_ERR_FUSE = 6,
2063 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2064 WIMLIB_ERR_ICONV_NOT_AVAILABLE = 9,
2065 WIMLIB_ERR_IMAGE_COUNT = 10,
2066 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2067 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2068 WIMLIB_ERR_INTEGRITY = 13,
2069 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2070 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2071 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2072 WIMLIB_ERR_INVALID_HEADER = 17,
2073 WIMLIB_ERR_INVALID_IMAGE = 18,
2074 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2075 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2076 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2077 WIMLIB_ERR_INVALID_MULTIBYTE_STRING = 22,
2078 WIMLIB_ERR_INVALID_OVERLAY = 23,
2079 WIMLIB_ERR_INVALID_PARAM = 24,
2080 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2081 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2082 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2083 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2084 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2085 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2086 WIMLIB_ERR_IS_DIRECTORY = 32,
2087 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2088 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE = 34,
2089 WIMLIB_ERR_LINK = 35,
2090 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2091 WIMLIB_ERR_MKDIR = 37,
2092 WIMLIB_ERR_MQUEUE = 38,
2093 WIMLIB_ERR_NOMEM = 39,
2094 WIMLIB_ERR_NOTDIR = 40,
2095 WIMLIB_ERR_NOTEMPTY = 41,
2096 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2097 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2098 WIMLIB_ERR_NOT_PIPABLE = 44,
2099 WIMLIB_ERR_NO_FILENAME = 45,
2100 WIMLIB_ERR_NTFS_3G = 46,
2101 WIMLIB_ERR_OPEN = 47,
2102 WIMLIB_ERR_OPENDIR = 48,
2103 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2104 WIMLIB_ERR_READ = 50,
2105 WIMLIB_ERR_READLINK = 51,
2106 WIMLIB_ERR_RENAME = 52,
2107 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2108 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2109 WIMLIB_ERR_RESOURCE_ORDER = 56,
2110 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2111 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2112 WIMLIB_ERR_SET_SECURITY = 59,
2113 WIMLIB_ERR_SET_SHORT_NAME = 60,
2114 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2115 WIMLIB_ERR_SPLIT_INVALID = 62,
2116 WIMLIB_ERR_STAT = 63,
2117 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2118 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2119 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2120 WIMLIB_ERR_UNSUPPORTED = 68,
2121 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2122 WIMLIB_ERR_WIM_IS_READONLY = 71,
2123 WIMLIB_ERR_WRITE = 72,
2124 WIMLIB_ERR_XML = 73,
2125 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2126 WIMLIB_ERR_WIMBOOT = 75,
2127 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2128 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2129 WIMLIB_ERR_MKNOD = 78,
2130 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2131 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2132 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2136 /** Used to indicate no WIM image or an invalid WIM image. */
2137 #define WIMLIB_NO_IMAGE 0
2139 /** Used to specify all images in the WIM. */
2140 #define WIMLIB_ALL_IMAGES (-1)
2145 * @ingroup G_modifying_wims
2147 * Appends an empty image to a WIM file. This empty image will initially
2148 * contain no files or directories, although if written without further
2149 * modifications, a root directory will be created automatically for it. After
2150 * calling this function, you can use wimlib_update_image() to add files to the
2151 * new WIM image. This gives you slightly more control over making the new
2152 * image compared to calling wimlib_add_image() or
2153 * wimlib_add_image_multisource() directly.
2156 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2159 * Name to give the new image. If @c NULL or empty, the new image is given
2160 * no name. If nonempty, it must specify a name that does not already
2162 * @param new_idx_ret
2163 * If non-<code>NULL</code>, the index of the newly added image is returned
2166 * @return 0 on success; nonzero on failure. The possible error codes are:
2168 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2169 * There is already an image in @p wim named @p name.
2170 * @retval ::WIMLIB_ERR_NOMEM
2171 * Failed to allocate the memory needed to add the new image.
2172 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2173 * The WIM file is considered read-only because of any of the reasons
2174 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2178 wimlib_add_empty_image(WIMStruct *wim,
2179 const wimlib_tchar *name,
2183 * @ingroup G_modifying_wims
2185 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2187 * The directory tree or NTFS volume is scanned immediately to load the dentry
2188 * tree into memory, and file attributes and symbolic links are read. However,
2189 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2192 * See the manual page for the @b wimlib-imagex program for more information
2193 * about the "normal" capture mode versus the NTFS capture mode (entered by
2194 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2196 * Note that @b no changes are committed to the underlying WIM file (if
2197 * any) until wimlib_write() or wimlib_overwrite() is called.
2200 * Pointer to the ::WIMStruct to which to add the image.
2202 * A path to a directory or unmounted NTFS volume that will be captured as
2205 * Name to give the new image. If @c NULL or empty, the new image is given
2206 * no name. If nonempty, it must specify a name that does not already
2208 * @param config_file
2209 * Path to capture configuration file, or @c NULL. This file may specify,
2210 * among other things, which files to exclude from capture. See the man
2211 * page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2212 * details of the file format. If @c NULL, the default capture
2213 * configuration shall be used. Ordinarily, the default capture
2214 * configuration will result in no files being excluded from capture purely
2215 * based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2216 * ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2218 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2220 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2221 * discarded so that it appears to be in the same state as when this function
2224 * This function is implemented by calling wimlib_add_empty_image(), then
2225 * calling wimlib_update_image() with a single "add" command, so any error code
2226 * returned by wimlib_add_empty_image() may be returned, as well as any error
2227 * codes returned by wimlib_update_image() other than ones documented as only
2228 * being returned specifically by an update involving delete or rename commands.
2230 * If a progress function is registered with @p wim, it will receive the
2231 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2232 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2233 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2236 wimlib_add_image(WIMStruct *wim,
2237 const wimlib_tchar *source,
2238 const wimlib_tchar *name,
2239 const wimlib_tchar *config_file,
2243 * @ingroup G_modifying_wims
2245 * This function is equivalent to wimlib_add_image() except it allows for
2246 * multiple sources to be combined into a single WIM image. This is done by
2247 * specifying the @p sources and @p num_sources parameters instead of the @p
2248 * source parameter of wimlib_add_image(). The rest of the parameters are the
2249 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2250 * capture</b> for full details on how this mode works.
2252 * In addition to the error codes that wimlib_add_image() can return,
2253 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2254 * when trying to overlay a non-directory on a directory or when otherwise
2255 * trying to overlay multiple conflicting files to the same location in the WIM
2256 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2257 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2258 * was not exactly one capture source with the target being the root directory.
2259 * (In this respect, there is no advantage to using
2260 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2263 wimlib_add_image_multisource(WIMStruct *wim,
2264 const struct wimlib_capture_source *sources,
2266 const wimlib_tchar *name,
2267 const wimlib_tchar *config_file,
2271 * @ingroup G_modifying_wims
2273 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2274 * location @p wim_target_path within the specified @p image of the @p wim.
2276 * This just builds an appropriate ::wimlib_add_command and passes it to
2277 * wimlib_update_image().
2280 wimlib_add_tree(WIMStruct *wim, int image,
2281 const wimlib_tchar *fs_source_path,
2282 const wimlib_tchar *wim_target_path, int add_flags);
2285 * @ingroup G_creating_and_opening_wims
2287 * Creates a ::WIMStruct for a new WIM file.
2289 * This only creates an in-memory structure for a WIM that initially contains no
2290 * images. No on-disk file is created until wimlib_write() is called.
2293 * The type of compression to be used in the new WIM file, as one of the
2294 * ::wimlib_compression_type constants.
2296 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2297 * written to the memory location pointed to by this parameter. The
2298 * ::WIMStruct must be freed using using wimlib_free() when finished with
2300 * @return 0 on success; nonzero on error.
2301 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2302 * @p ctype was not a supported compression type.
2303 * @retval ::WIMLIB_ERR_NOMEM
2304 * Failed to allocate needed memory.
2307 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2310 * @ingroup G_modifying_wims
2312 * Deletes an image, or all images, from a WIM file.
2314 * All streams referenced by the image(s) being deleted are removed from the
2315 * lookup table of the WIM if they are not referenced by any other images in the
2318 * Please note that @b no changes are committed to the underlying WIM file (if
2319 * any) until wimlib_write() or wimlib_overwrite() is called.
2322 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2325 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2327 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2328 * to be left unmodified only if @p image specified a single image. If instead
2329 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2330 * possible for some but not all of the images to have been deleted when a
2331 * failure status is returned.
2333 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2334 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2335 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2336 * The WIM file is considered read-only because of any of the reasons
2337 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2340 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2341 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2342 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2343 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2344 * different reasons) to read the metadata resource for an image that needed to
2348 wimlib_delete_image(WIMStruct *wim, int image);
2351 * @ingroup G_modifying_wims
2353 * Delete the @p path from the specified @p image of the @p wim.
2355 * This just builds an appropriate ::wimlib_delete_command and passes it to
2356 * wimlib_update_image().
2359 wimlib_delete_path(WIMStruct *wim, int image,
2360 const wimlib_tchar *path, int delete_flags);
2363 * @ingroup G_modifying_wims
2365 * Exports an image, or all the images, from a WIM file, into another WIM file.
2367 * The destination image is made to share the same dentry tree and security data
2368 * structure as the source image. This places some restrictions on additional
2369 * functions that may be called. For example, you may not call wimlib_free() on
2370 * @p src_wim before calling wimlib_write() or wimlib_overwrite() on @p dest_wim
2371 * because @p dest_wim will have references back to @p src_wim.
2373 * If this function fails, all changes to @p dest_wim are rolled back.
2375 * Please note that no changes are committed to the underlying WIM file of @p
2376 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2379 * The WIM from which to export the images, specified as a pointer to the
2380 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2381 * split WIM. In the case of a WIM file that is not standalone, this
2382 * ::WIMStruct must have had any needed external resources previously
2383 * referenced using wimlib_reference_resources() or
2384 * wimlib_reference_resource_files().
2386 * The image to export from @p src_wim, as either a 1-based image index to
2387 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2389 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2392 * For single-image exports, the name to give the exported image in @p
2393 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2394 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2395 * that case, the names are all taken from @p src_wim. This parameter is
2396 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2397 * @param dest_description
2398 * For single-image exports, the description to give the exported image in
2399 * the new WIM file. If left @c NULL, the description from @p src_wim is
2400 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2401 * NULL; in that case, the description are all taken from @p src_wim. This
2402 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2403 * @param export_flags
2404 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2406 * @return 0 on success; nonzero on error.
2407 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2408 * One or more of the names being given to an exported image was already in
2409 * use in the destination WIM.
2410 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2411 * @p src_image does not exist in @p src_wim and was not
2412 * ::WIMLIB_ALL_IMAGES.
2413 * @retval ::WIMLIB_ERR_INVALID_PARAM
2414 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2415 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2417 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2418 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2419 * example, one of them was a non-first part of a split WIM.
2420 * @retval ::WIMLIB_ERR_NOMEM
2421 * Failed to allocate needed memory.
2422 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2423 * A resource that needed to be exported could not be found in either the
2424 * source or destination WIMs. This error can occur if, for example, @p
2425 * src_wim is part of a split WIM but needed resources from the other split
2426 * WIM parts were not referenced with wimlib_reference_resources() or
2427 * wimlib_reference_resource_files() before the call to
2428 * wimlib_export_image().
2429 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2430 * @p dest_wim is considered read-only because of any of the reasons
2431 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2434 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2435 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2436 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2437 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2438 * different reasons) to read the metadata resource for an image in @p src_wim
2439 * that needed to be exported.
2442 wimlib_export_image(WIMStruct *src_wim, int src_image,
2443 WIMStruct *dest_wim,
2444 const wimlib_tchar *dest_name,
2445 const wimlib_tchar *dest_description,
2449 * @ingroup G_extracting_wims
2451 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2454 * The exact behavior of how wimlib extracts files from a WIM image is
2455 * controllable by the @p extract_flags parameter, but there also are
2456 * differences depending on the platform (UNIX-like vs Windows). See the manual
2457 * page for <b>wimlib-imagex apply</b> for more information, including about the
2458 * special "NTFS volume extraction mode" entered by providing
2459 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2462 * The WIM from which to extract the image(s), specified as a pointer to
2463 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2464 * of a split WIM. In the case of a WIM file that is not standalone, this
2465 * ::WIMStruct must have had any needed external resources previously
2466 * referenced using wimlib_reference_resources() or
2467 * wimlib_reference_resource_files().
2469 * The image to extract, specified as either the 1-based index of a single
2470 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2471 * to be extracted. ::WIMLIB_ALL_IMAGES cannot be used if
2472 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2474 * Directory to extract the WIM image(s) to; or, with
2475 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2476 * the unmounted NTFS volume to which to extract the image.
2477 * @param extract_flags
2478 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2480 * @return 0 on success; nonzero on error.
2481 * @retval ::WIMLIB_ERR_DECOMPRESSION
2482 * Failed to decompress data contained in the WIM.
2483 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2484 * The metadata for one of the images to extract was invalid.
2485 * @retval ::WIMLIB_ERR_INVALID_PARAM
2486 * The extraction flags were invalid; more details may be found in the
2487 * documentation for the specific extraction flags that were specified. Or
2488 * @p target was @c NULL or the empty string, or @p wim was @c NULL.
2489 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2490 * The SHA1 message digest of an extracted stream did not match the SHA1
2491 * message digest given in the WIM.
2492 * @retval ::WIMLIB_ERR_LINK
2493 * Failed to create a symbolic link or a hard link.
2494 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2495 * The metadata resource for one of the images to extract was not found.
2496 * This can happen if @p wim represents a non-first part of a split WIM.
2497 * @retval ::WIMLIB_ERR_MKDIR
2498 * Failed create a directory.
2499 * @retval ::WIMLIB_ERR_NOMEM
2500 * Failed to allocate needed memory.
2501 * @retval ::WIMLIB_ERR_OPEN
2502 * Could not create a file, or failed to open an already-extracted file.
2503 * @retval ::WIMLIB_ERR_READ
2504 * Failed to read data from the WIM.
2505 * @retval ::WIMLIB_ERR_READLINK
2506 * Failed to determine the target of a symbolic link in the WIM.
2507 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2508 * Failed to fix the target of an absolute symbolic link (e.g. if the
2509 * target would have exceeded the maximum allowed length). (Only if
2510 * reparse data was supported by the extraction mode and
2511 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2513 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2514 * One of the files or directories that needed to be extracted referenced a
2515 * stream not present in the WIM's lookup table (or in any of the lookup
2516 * tables of the split WIM parts).
2517 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2518 * Failed to set attributes on a file.
2519 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2520 * Failed to set reparse data on a file (only if reparse data was supported
2521 * by the extraction mode).
2522 * @retval ::WIMLIB_ERR_SET_SECURITY
2523 * Failed to set security descriptor on a file
2524 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2526 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2527 * Failed to set the short name of a file (only if
2528 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2529 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2530 * Failed to set timestamps on a file (only if
2531 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2532 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2533 * Unexpected end-of-file occurred when reading data from the WIM.
2534 * @retval ::WIMLIB_ERR_UNSUPPORTED
2535 * A requested extraction flag, or the data or metadata that must be
2536 * extracted to support it, is unsupported in the build and configuration
2537 * of wimlib, or on the current platform or extraction mode or target
2538 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2539 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2540 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2541 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2542 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2543 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2544 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2545 * image contains one or more files with short names, but extracting short
2546 * names is not supported --- on Windows, this occurs if the target volume
2547 * does not support short names, while on non-Windows, this occurs if
2548 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2549 * @retval ::WIMLIB_ERR_WIMBOOT
2550 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2551 * there was a problem creating WIMBoot pointer files.
2552 * @retval ::WIMLIB_ERR_WRITE
2553 * Failed to write data to a file being extracted.
2555 * If a progress function is registered with @p wim, then as each image is
2556 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2557 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then
2558 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2561 wimlib_extract_image(WIMStruct *wim, int image,
2562 const wimlib_tchar *target, int extract_flags);
2565 * @ingroup G_extracting_wims
2567 * Since wimlib v1.5.0: Extract one image from a pipe on which a pipable WIM is
2570 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2571 * about pipable WIMs.
2573 * This function operates in a special way to read the WIM fully sequentially.
2574 * As a result, there is no ::WIMStruct is made visible to library users, and
2575 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2576 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2577 * seekable file, not a pipe.)
2580 * File descriptor, which may be a pipe, opened for reading and positioned
2581 * at the start of the pipable WIM.
2582 * @param image_num_or_name
2583 * String that specifies the 1-based index or name of the image to extract.
2584 * It is translated to an image index using the same rules that
2585 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2586 * only a single image (not all images) can be specified. Alternatively,
2587 * specify @p NULL here to use the first image in the WIM if it contains
2588 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2590 * Same as the corresponding parameter to wimlib_extract_image().
2591 * @param extract_flags
2592 * Same as the corresponding parameter to wimlib_extract_image().
2594 * @return 0 on success; nonzero on error. The possible error codes include
2595 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2598 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2599 * Data read from the pipable WIM was invalid.
2600 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2601 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2604 wimlib_extract_image_from_pipe(int pipe_fd,
2605 const wimlib_tchar *image_num_or_name,
2606 const wimlib_tchar *target, int extract_flags);
2609 * @ingroup G_extracting_wims
2611 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2612 * function. The progress function will be used while extracting the WIM image
2613 * and will receive the normal extraction progress messages, such as
2614 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2615 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2618 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2619 const wimlib_tchar *image_num_or_name,
2620 const wimlib_tchar *target,
2622 wimlib_progress_func_t progfunc,
2626 * @ingroup G_extracting_wims
2628 * Since wimlib v1.6.0: Similar to wimlib_extract_paths(), but the paths to
2629 * extract from the WIM image are specified in the ASCII, UTF-8, or UTF-16LE
2630 * text file named by @p path_list_file which itself contains the list of paths
2631 * to use, one per line. Leading and trailing whitespace, and otherwise empty
2632 * lines and lines beginning with the ';' character are ignored. No quotes are
2633 * needed as paths are otherwise delimited by the newline character.
2635 * The error codes are the same as those returned by wimlib_extract_paths(),
2636 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2637 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2638 * ::WIMLIB_ERR_READ).
2641 wimlib_extract_pathlist(WIMStruct *wim, int image,
2642 const wimlib_tchar *target,
2643 const wimlib_tchar *path_list_file,
2647 * @ingroup G_extracting_wims
2649 * Since wimlib v1.6.0: Extract zero or more paths (files or directory trees)
2650 * from the specified WIM image.
2652 * By default, each path will be extracted to a corresponding subdirectory of
2653 * the target based on its location in the WIM image. For example, if one of
2654 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2655 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
2656 * can be changed by providing the flag
2657 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2658 * or directory tree to be placed directly in the target directory --- so the
2659 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2661 * Symbolic links will not be dereferenced when paths in the WIM image are
2665 * WIM from which to extract the paths, specified as a pointer to the
2666 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2667 * split WIM. In the case of a WIM file that is not standalone, this
2668 * ::WIMStruct must have had any needed external resources previously
2669 * referenced using wimlib_reference_resources() or
2670 * wimlib_reference_resource_files().
2672 * 1-based index of the WIM image from which to extract the paths.
2674 * Array of paths to extract. Each element must be the absolute path to a
2675 * file or directory within the WIM image. Separators may be either
2676 * forwards or backwards slashes, and leading path separators are optional.
2677 * The paths will be interpreted either case-sensitively (UNIX default) or
2678 * case-insensitively (Windows default); this can be changed by
2679 * wimlib_global_init().
2681 * By default, the characters @c * and @c ? are interpreted literally.
2682 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2685 * By default, if any paths to extract do not exist, the error code
2686 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
2687 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2689 * Number of paths specified in @p paths.
2691 * Directory to which to extract the paths; or with
2692 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2693 * unmounted NTFS volume to which to extract the paths. Unlike the @p
2694 * paths being extracted, the @p target must be native path. On UNIX-like
2695 * systems it may not contain backslashes, for example.
2696 * @param extract_flags
2697 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2699 * @return 0 on success; nonzero on error. Most of the error codes are the same
2700 * as those returned by wimlib_extract_image(). Below, some of the error codes
2701 * returned in situations specific to path-mode extraction are documented:
2703 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2704 * @p image was ::WIMLIB_ALL_IMAGES or was otherwise not a valid single
2706 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2707 * One of the paths to extract did not exist in the WIM image. This error
2708 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2709 * specified in @p extract_flags, or if both
2710 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2711 * were specified in @p extract_flags.
2712 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2713 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2714 * one of the paths to extract did not name a regular file.
2716 * If a progress function is registered with @p wim, it will receive
2717 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. Note that because the extraction code
2718 * is stream-based and not file-based, there is no way to get information about
2719 * which path is currently being extracted, but based on byte count you can
2720 * still calculate an approximate percentage complete for the extraction overall
2721 * which may be all you really need anyway.
2724 wimlib_extract_paths(WIMStruct *wim,
2726 const wimlib_tchar *target,
2727 const wimlib_tchar * const *paths,
2732 * @ingroup G_wim_information
2734 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2735 * includes a string of XML that describes the images contained in the WIM.
2737 * See wimlib_get_xml_data() to read the XML data into memory instead.
2740 * Pointer to the ::WIMStruct to query. This need not represent a
2741 * standalone WIM (e.g. it could represent part of a split WIM).
2743 * @c stdout, or a FILE* opened for writing, to extract the data to.
2745 * @return 0 on success; nonzero on error.
2746 * @retval ::WIMLIB_ERR_INVALID_PARAM
2747 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2748 * @retval ::WIMLIB_ERR_NOMEM
2749 * Failed to allocate needed memory.
2750 * @retval ::WIMLIB_ERR_READ
2751 * Error reading the XML data from the WIM file.
2752 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2753 * Error reading the XML data from the WIM file.
2754 * @retval ::WIMLIB_ERR_WRITE
2755 * Failed to completely write the XML data to @p fp.
2758 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2761 * @ingroup G_general
2763 * Frees all memory allocated for a WIMStruct and closes all files associated
2767 * Pointer to the ::WIMStruct to free.
2769 * @return This function has no return value.
2772 wimlib_free(WIMStruct *wim);
2775 * @ingroup G_general
2777 * Converts a ::wimlib_compression_type value into a string.
2780 * The ::wimlib_compression_type value to convert.
2783 * A statically allocated string naming the compression algorithm,
2784 * such as "None", "LZX", "XPRESS", or "Invalid".
2786 extern const wimlib_tchar *
2787 wimlib_get_compression_type_string(int ctype);
2790 * @ingroup G_general
2792 * Converts an error code into a string describing it.
2795 * The error code returned by one of wimlib's functions.
2798 * Pointer to a statically allocated string describing the error code,
2799 * or @c NULL if the error code is not valid.
2801 extern const wimlib_tchar *
2802 wimlib_get_error_string(enum wimlib_error_code code);
2805 * @ingroup G_wim_information
2807 * Returns the description of the specified image.
2810 * Pointer to the ::WIMStruct to query. This need not represent a
2811 * standalone WIM (e.g. it could represent part of a split WIM).
2813 * The number of the image, numbered starting at 1.
2816 * The description of the image, or @c NULL if there is no such image, or
2817 * @c NULL if the specified image has no description. The description
2818 * string is in library-internal memory and may not be modified or freed;
2819 * in addition, the string will become invalid if the description of the
2820 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2822 extern const wimlib_tchar *
2823 wimlib_get_image_description(const WIMStruct *wim, int image);
2826 * @ingroup G_wim_information
2828 * Returns the name of the specified image.
2831 * Pointer to the ::WIMStruct to query. This need not represent a
2832 * standalone WIM (e.g. it could represent part of a split WIM).
2834 * The number of the image, numbered starting at 1.
2837 * The name of the image, or @c NULL if there is no such image, or an empty
2838 * string if the image is unnamed. The name string is in
2839 * library-internal memory and may not be modified or freed; in addition,
2840 * the string will become invalid if the name of the image is changed, the
2841 * image is deleted, or the ::WIMStruct is destroyed.
2843 extern const wimlib_tchar *
2844 wimlib_get_image_name(const WIMStruct *wim, int image);
2847 * @ingroup G_general
2849 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
2850 * the major version, the next 10 bits contain the minor version, and the low 10
2851 * bits contain the patch version.
2853 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
2854 * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
2855 * corresponding header file.
2858 wimlib_get_version(void);
2861 * @ingroup G_wim_information
2863 * Get basic information about a WIM file.
2866 * Pointer to the ::WIMStruct to query. This need not represent a
2867 * standalone WIM (e.g. it could represent part of a split WIM).
2869 * A ::wimlib_wim_info structure that will be filled in with information
2870 * about the WIM file.
2875 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2878 * @ingroup G_wim_information
2880 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
2881 * includes a string of XML that describes the images contained in the WIM.
2883 * See wimlib_extract_xml_data() to extract the XML data to a file stream
2887 * Pointer to the ::WIMStruct to query. This need not represent a
2888 * standalone WIM (e.g. it could represent part of a split WIM).
2890 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
2891 * XML data is written to this location.
2892 * @param bufsize_ret
2893 * The size of the XML data in bytes is written to this location.
2895 * @return 0 on success; nonzero on error.
2896 * @retval ::WIMLIB_ERR_INVALID_PARAM
2897 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2898 * @p buf_ret or @p bufsize_ret was @c NULL.
2899 * @retval ::WIMLIB_ERR_NOMEM
2900 * @retval ::WIMLIB_ERR_READ
2901 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2902 * Failed to read the XML data from the WIM.
2905 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2908 * @ingroup G_general
2910 * Initialization function for wimlib. Call before using any other wimlib
2911 * function except wimlib_set_print_errors(). If not done manually, this
2912 * function will be called automatically with @p init_flags set to
2913 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
2914 * after it has already successfully run.
2917 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2919 * @return 0 on success; nonzero on failure. Currently, only the following
2920 * error code is defined:
2922 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2923 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2924 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2925 * init_flags, but the corresponding privileges could not be acquired.
2928 wimlib_global_init(int init_flags);
2931 * @ingroup G_general
2933 * Cleanup function for wimlib. You are not required to call this function, but
2934 * it will release any global resources allocated by the library.
2937 wimlib_global_cleanup(void);
2940 * @ingroup G_wim_information
2942 * Determines if an image name is already used by some image in the WIM.
2945 * Pointer to the ::WIMStruct to query. This need not represent a
2946 * standalone WIM (e.g. it could represent part of a split WIM).
2948 * The name to check.
2951 * @c true if there is already an image in @p wim named @p name; @c false
2952 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2953 * the empty string, @c false is returned.
2956 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2959 * @ingroup G_wim_information
2961 * Iterate through a file or directory tree in the WIM image. By specifying
2962 * appropriate flags and a callback function, you can get the attributes of a
2963 * file in the WIM, get a directory listing, or even get a listing of the entire
2967 * The WIM containing the image(s) over which to iterate, specified as a
2968 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2969 * or part 1 of a split WIM. In the case of a WIM file that is not
2970 * standalone, this ::WIMStruct should have had any needed external
2971 * resources previously referenced using wimlib_reference_resources() or
2972 * wimlib_reference_resource_files(). If not, see
2973 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2974 * the behavior when resources are missing.
2977 * The 1-based number of the image in @p wim that contains the files or
2978 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2979 * iteration on all images in the WIM.
2982 * Path in the WIM image at which to do the iteration.
2985 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2988 * A callback function that will receive each directory entry.
2991 * An extra parameter that will always be passed to the callback function
2994 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2995 * first nonzero value that was returned from @p cb. However, additional error
2996 * codes may be returned, including the following:
2998 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2999 * @p path did not exist in the WIM image.
3000 * @retval ::WIMLIB_ERR_NOMEM
3001 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
3003 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3004 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3005 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3006 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3007 * different reasons) to read the metadata resource for an image over which
3008 * iteration needed to be done.
3011 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3013 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3016 * @ingroup G_wim_information
3018 * Iterate through the lookup table of a WIM file. This can be used to directly
3019 * get a listing of the unique resources contained in a WIM file over all
3020 * images. Both file resources and metadata resources are included. However,
3021 * only resources actually included in the file represented by @a wim, plus
3022 * explicitly referenced external resources (via wimlib_reference_resources() or
3023 * wimlib_reference_resource_files()) are included in the iteration. For
3024 * example, if @p wim represents just one part of a split WIM, then only
3025 * resources in that part will be included, unless other resources were
3026 * explicitly referenced.
3029 * Pointer to the ::WIMStruct to query. This need not represent a
3030 * standalone WIM (e.g. it could represent part of a split WIM).
3033 * Reserved; set to 0.
3036 * A callback function that will receive each resource.
3039 * An extra parameter that will always be passed to the callback function
3042 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3043 * that was returned from @p cb.
3046 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3047 wimlib_iterate_lookup_table_callback_t cb,
3051 * @ingroup G_nonstandalone_wims
3053 * Joins a split WIM into a stand-alone one-part WIM.
3056 * An array of strings that gives the filenames of all parts of the split
3057 * WIM. No specific order is required, but all parts must be included with
3060 * Number of filenames in @p swms.
3061 * @param swm_open_flags
3062 * Open flags for the split WIM parts (e.g.
3063 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3064 * @param wim_write_flags
3065 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3066 * be used to write the joined WIM.
3067 * @param output_path
3068 * The path to write the joined WIM file to.
3070 * @return 0 on success; nonzero on error. This function may return most error
3071 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
3072 * as the following error code:
3074 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3075 * The split WIMs do not form a valid WIM because they do not include all
3076 * the parts of the original WIM, there are duplicate parts, or not all the
3077 * parts have the same GUID and compression type.
3079 * Note: wimlib is generalized enough that this function is not actually needed
3080 * to join a split WIM; instead, you could open the first part of the split WIM,
3081 * then reference the other parts with wimlib_reference_resource_files(), then
3082 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3083 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3087 wimlib_join(const wimlib_tchar * const *swms,
3089 const wimlib_tchar *output_path,
3091 int wim_write_flags);
3094 * @ingroup G_nonstandalone_wims
3096 * Same as wimlib_join(), but allows specifying a progress function. The
3097 * progress function will receive the write progress messages, such as
3098 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3099 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3100 * swm_open_flags, the progress function will receive a series of
3101 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3105 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3107 const wimlib_tchar *output_path,
3109 int wim_write_flags,
3110 wimlib_progress_func_t progfunc,
3115 * @ingroup G_mounting_wim_images
3117 * Mounts an image from a WIM file on a directory read-only or read-write.
3120 * Pointer to the ::WIMStruct containing the image to be mounted.
3122 * The 1-based index of the image to mount.
3124 * The path to an existing empty directory on which to mount the WIM image.
3125 * @param mount_flags
3126 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3127 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3129 * @param staging_dir
3130 * If non-NULL, the name of a directory in which a temporary directory for
3131 * storing modified or added files will be created. Ignored if
3132 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3133 * left @c NULL, the staging directory is created in the same directory as
3134 * the WIM file that @p wim was originally read from. The staging
3135 * directory is deleted when the image is unmounted.
3137 * @return 0 on success; nonzero on error. The possible error codes include:
3139 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3140 * An image from the WIM file is already mounted read-write, or another
3141 * process is currently appending data to the WIM file.
3142 * @retval ::WIMLIB_ERR_FUSE
3143 * A non-zero status code was returned by @c fuse_main().
3144 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3145 * @p image does not specify an existing, single image in @p wim.
3146 * @retval ::WIMLIB_ERR_INVALID_PARAM
3147 * @p wim was @c NULL; or @p dir was NULL or the empty string; or an
3148 * unrecognized flag was specified in @p mount_flags; or the WIM image has
3149 * already been modified in memory (e.g. by wimlib_update_image()).
3150 * @retval ::WIMLIB_ERR_MKDIR
3151 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3152 * staging directory could not be created.
3153 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3154 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3155 * WIM file is considered read-only because of any of the reasons mentioned
3156 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3157 * @retval ::WIMLIB_ERR_UNSUPPORTED
3158 * Mounting is not supported, either because the platform is Windows, or
3159 * because the platform is UNIX-like and wimlib was compiled using
3160 * <code>--without-fuse</code>.
3162 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3163 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3164 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3165 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3166 * different reasons) to read the metadata resource for the image to mount.
3168 * The ability to mount WIM image is implemented using FUSE (Filesystem in
3169 * UserSpacE). Depending on how FUSE is set up on your system, this function
3170 * may work as normal users in addition to the root user.
3172 * Mounting WIM images is not supported if wimlib was configured
3173 * <code>--without-fuse</code>. This includes Windows builds of wimlib;
3174 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3176 * Calling this function daemonizes the process, unless
3177 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3179 * It is safe to mount multiple images from the same underlying WIM file
3180 * read-only at the same time, but only if different ::WIMStruct's are used. It
3181 * is @b not safe to mount multiple images from the same WIM file read-write at
3184 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3185 * different process.
3188 wimlib_mount_image(WIMStruct *wim,
3190 const wimlib_tchar *dir,
3192 const wimlib_tchar *staging_dir);
3195 * @ingroup G_creating_and_opening_wims
3197 * Opens a WIM file and creates a ::WIMStruct for it.
3200 * The path to the WIM file to open.
3203 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3206 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3207 * is written to the memory location pointed to by this parameter. The
3208 * ::WIMStruct must be freed using using wimlib_free() when finished with
3211 * @return 0 on success; nonzero on error.
3212 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3213 * The number of metadata resources found in the WIM did not match the
3214 * image count specified in the WIM header, or the number of <IMAGE>
3215 * elements in the XML data of the WIM did not match the image count
3216 * specified in the WIM header.
3217 * @retval ::WIMLIB_ERR_INTEGRITY
3218 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3219 * the WIM contained an integrity table, but the SHA1 message digest for a
3220 * chunk of the WIM did not match the corresponding value in the integrity
3222 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3223 * The library did not recognize the compression chunk size of the WIM as
3224 * valid for its compression type.
3225 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3226 * The library did not recognize the compression type of the WIM.
3227 * @retval ::WIMLIB_ERR_INVALID_HEADER
3228 * The header of the WIM was otherwise invalid.
3229 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3230 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3231 * the WIM contained an integrity table, but the integrity table was
3233 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3234 * The lookup table of the WIM was invalid.
3235 * @retval ::WIMLIB_ERR_INVALID_PARAM
3236 * @p wim_ret was @c NULL.
3237 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3238 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3239 * specified in @p open_flags.
3240 * @retval ::WIMLIB_ERR_NOMEM
3241 * Failed to allocated needed memory.
3242 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3243 * The file did not begin with the magic characters that identify a WIM
3245 * @retval ::WIMLIB_ERR_OPEN
3246 * Failed to open the file for reading.
3247 * @retval ::WIMLIB_ERR_READ
3248 * Failed to read data from the file.
3249 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3250 * Unexpected end-of-file while reading data from the file.
3251 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3252 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3253 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3254 * The WIM cannot be opened because it contains encrypted segments. (It
3255 * may be a Windows 8 "ESD" file.)
3256 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3257 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3258 * considered read-only because of any of the reasons mentioned in the
3259 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3260 * @retval ::WIMLIB_ERR_XML
3261 * The XML data of the WIM was invalid.
3264 wimlib_open_wim(const wimlib_tchar *wim_file,
3266 WIMStruct **wim_ret);
3269 * @ingroup G_creating_and_opening_wims
3271 * Same as wimlib_open_wim(), but allows specifying a progress function and
3272 * progress context. If successful, the progress function will be registered in
3273 * the newly open ::WIMStruct, as if by an automatic call to
3274 * wimlib_register_progress_function(). In addition, if
3275 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, the
3276 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3277 * messages while checking the WIM's integrity.
3280 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3282 WIMStruct **wim_ret,
3283 wimlib_progress_func_t progfunc,
3287 * @ingroup G_writing_and_overwriting_wims
3289 * Overwrites the file that the WIM was originally read from, with changes made.
3290 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3291 * rather than wimlib_create_new_wim().
3293 * There are two ways that a WIM may be overwritten. The first is to do a full
3294 * rebuild. In this mode, the new WIM is written to a temporary file and then
3295 * renamed to the original file after it is has been completely written. The
3296 * temporary file is made in the same directory as the original WIM file. A
3297 * full rebuild may take a while, but it will save space by producing a WIM with
3300 * The second way to overwrite a WIM is by appending to the end of it and
3301 * overwriting the header. This can be much faster than a full rebuild, but the
3302 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3303 * begins with writing any new file resources *after* everything in the old WIM,
3304 * even though this will leave a hole where the old lookup table, XML data, and
3305 * integrity were. This is done so that the WIM remains valid even if the
3306 * operation is aborted mid-write. The WIM header is only overwritten at the
3307 * very last moment, and up until that point the WIM will be seen as the old
3310 * By default, wimlib_overwrite() does the append-style overwrite described
3311 * above, unless resources in the WIM are arranged in an unusual way or if
3312 * images have been deleted from the WIM. Use the flag
3313 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3314 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3315 * images have been deleted from the WIM.
3317 * If this function completes successfully, no more functions should be called
3318 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
3319 * the WIM file anew.
3322 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3323 * been in-memory changes made to it, which are then reflected in the
3325 * @param write_flags
3326 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3327 * @param num_threads
3328 * Number of threads to use for compression (see wimlib_write()).
3330 * @return 0 on success; nonzero on error. This function may return most error
3331 * codes returned by wimlib_write() as well as the following error codes:
3333 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3334 * The WIM was going to be modified in-place (with no temporary file), but
3335 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3336 * because another thread or process has mounted an image from the WIM
3337 * read-write or is currently modifying the WIM in-place.
3338 * @retval ::WIMLIB_ERR_NO_FILENAME
3339 * @p wim corresponds to a ::WIMStruct created with wimlib_create_new_wim()
3340 * rather than a WIM read with wimlib_open_wim().
3341 * @retval ::WIMLIB_ERR_RENAME
3342 * The temporary file that the WIM was written to could not be renamed to
3343 * the original filename of @p wim.
3344 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3345 * The WIM file is considered read-only because of any of the reasons
3346 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3349 * If a progress function is registered with @p wim, it will receive the
3350 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3351 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3352 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3355 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3358 * @ingroup G_wim_information
3360 * Prints information about one image, or all images, contained in a WIM.
3363 * Pointer to the ::WIMStruct to query. This need not represent a
3364 * standalone WIM (e.g. it could represent part of a split WIM).
3366 * The image about which to print information. Can be the number of an
3367 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3370 * @return This function has no return value. No error checking is done when
3371 * printing the information. If @p image is invalid, an error message is
3375 wimlib_print_available_images(const WIMStruct *wim, int image);
3378 * @ingroup G_wim_information
3380 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3381 * in a way that can be accessed programatically.
3384 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3387 * @ingroup G_nonstandalone_wims
3389 * Reference resources from other WIM files or split WIM parts. This function
3390 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3391 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3392 * from other files, before calling a function such as wimlib_extract_image()
3393 * that requires the resources to be present.
3396 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3397 * necessarily "standalone". In the case of split WIMs, this should be the
3398 * first part, since only the first part contains the metadata resources.
3399 * In the case of delta WIMs, this should be the delta WIM rather than the
3400 * WIM on which it is based.
3401 * @param resource_wimfiles_or_globs
3402 * Array of paths to WIM files and/or split WIM parts to reference.
3403 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3404 * ref_flags, these are treated as globs rather than literal paths. That
3405 * is, using this function you can specify zero or more globs, each of
3406 * which expands to one or more literal paths.
3408 * Number of entries in @p resource_wimfiles_or_globs.
3410 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3411 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3413 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3414 * pass to internal calls to wimlib_open_wim() on the reference files.
3416 * @return 0 on success; nonzero on error.
3418 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3419 * One of the specified globs did not match any paths (only with both
3420 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3421 * specified in @p ref_flags).
3422 * @retval ::WIMLIB_ERR_NOMEM
3423 * Failed to allocate memory.
3424 * @retval ::WIMLIB_ERR_READ
3425 * I/O or permissions error while processing a file glob.
3427 * This function can additionally return most values that can be returned by
3428 * wimlib_open_wim().
3431 wimlib_reference_resource_files(WIMStruct *wim,
3432 const wimlib_tchar * const *resource_wimfiles_or_globs,
3438 * @ingroup G_nonstandalone_wims
3440 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3441 * where the caller must open the ::WIMStruct for each referenced file itself.
3444 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3445 * necessarily "standalone". In the case of split WIMs, this should be the
3446 * first part, since only the first part contains the metadata resources.
3447 * @param resource_wims
3448 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3449 * split WIM parts to reference.
3450 * @param num_resource_wims
3451 * Number of entries in @p resource_wims.
3453 * Currently ignored (set to 0).
3455 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3456 * @p resource_wims are referenced internally by @p wim and must not be freed
3457 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3458 * been freed with wimlib_free(), or immediately before freeing @p wim with
3461 * @retval ::WIMLIB_ERR_INVALID_PARAM
3462 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3463 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3464 * @retval ::WIMLIB_ERR_NOMEM
3465 * Failed to allocate memory.
3468 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3469 unsigned num_resource_wims, int ref_flags);
3472 * @ingroup G_modifying_wims
3474 * Declares that a newly added image is mostly the same as a prior image, but
3475 * captured at a later point in time, possibly with some modifications in the
3476 * intervening time. This is designed to be used in incremental backups of the
3477 * same filesystem or directory tree.
3479 * This function compares the metadata of the directory tree of the newly added
3480 * image against that of the old image. Any files that are present in both the
3481 * newly added image and the old image and have timestamps that indicate they
3482 * haven't been modified are deemed not to have been modified and have their
3483 * SHA1 message digest copied from the old image. Because of this and because
3484 * WIM uses single-instance streams, such files need not be read from the
3485 * filesystem when the WIM is being written or overwritten. Note that these
3486 * unchanged files will still be "archived" and will be logically present in the
3487 * new image; the optimization is that they don't need to actually be read from
3488 * the filesystem because the WIM already contains them.
3490 * This function is provided to optimize incremental backups. The resulting WIM
3491 * file will still be the same regardless of whether this function is called.
3492 * (This is, however, assuming that timestamps have not been manipulated or
3493 * unmaintained as to trick this function into thinking a file has not been
3494 * modified when really it has. To partly guard against such cases, other
3495 * metadata such as file sizes will be checked as well.)
3497 * This function must be called after adding the new image (e.g. with
3498 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3499 * wimlib_overwrite()).
3502 * Pointer to the ::WIMStruct for a WIM.
3504 * 1-based index in the WIM of the newly added image. This image can have
3505 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3506 * wimlib_add_empty_image() followed by wimlib_update_image().
3507 * @param template_wim
3508 * The ::WIMStruct for the WIM containing the template image. This can be
3509 * the same as @p wim, or it can be a different ::WIMStruct.
3510 * @param template_image
3511 * 1-based index in the WIM of a template image that reflects a prior state
3512 * of the directory tree being captured.
3514 * Reserved; must be 0.
3516 * @return 0 on success; nonzero on error.
3518 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3519 * @p new_image and/or @p template_image were not a valid image indices in
3521 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3522 * The specified ::WIMStruct did not actually contain the metadata resource
3523 * for the new or template image; for example, it was a non-first part of a
3525 * @retval ::WIMLIB_ERR_NOMEM
3526 * Failed to allocate needed memory.
3527 * @retval ::WIMLIB_ERR_INVALID_PARAM
3528 * @p new_image was equal to @p template_image, or @p new_image specified
3529 * an image that had not been modified since opening the WIM.
3531 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3532 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3533 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3534 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3535 * different reasons) to read the metadata resource for the template image.
3538 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3539 WIMStruct *template_wim, int template_image,
3543 * @ingroup G_general
3545 * Registers a progress function with a ::WIMStruct.
3548 * The ::WIMStruct for which to register the progress function.
3550 * Pointer to the progress function to register. If the WIM already has a
3551 * progress function registered, it will be replaced with this one. If @p
3552 * NULL, the current progress function (if any) will be unregistered.
3554 * The value which will be passed as the third argument to calls to @p
3558 wimlib_register_progress_function(WIMStruct *wim,
3559 wimlib_progress_func_t progfunc,
3563 * @ingroup G_modifying_wims
3565 * Rename the @p source_path to the @p dest_path in the specified @p image of
3568 * This just builds an appropriate ::wimlib_rename_command and passes it to
3569 * wimlib_update_image().
3572 wimlib_rename_path(WIMStruct *wim, int image,
3573 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3576 * @ingroup G_wim_information
3578 * Translates a string specifying the name or number of an image in the WIM into
3579 * the number of the image. The images are numbered starting at 1.
3582 * Pointer to the ::WIMStruct for a WIM.
3583 * @param image_name_or_num
3584 * A string specifying the name or number of an image in the WIM. If it
3585 * parses to a positive integer, this integer is taken to specify the
3586 * number of the image, indexed starting at 1. Otherwise, it is taken to
3587 * be the name of an image, as given in the XML data for the WIM file. It
3588 * also may be the keyword "all" or the string "*", both of which will
3589 * resolve to ::WIMLIB_ALL_IMAGES.
3591 * There is no way to search for an image actually named "all", "*", or an
3592 * integer number, or an image that has no name. However, you can use
3593 * wimlib_get_image_name() to get the name of any image.
3596 * If the string resolved to a single existing image, the number of that
3597 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3598 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3599 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3600 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3601 * images in @p wim has no name.
3604 wimlib_resolve_image(WIMStruct *wim,
3605 const wimlib_tchar *image_name_or_num);
3608 * @ingroup G_modifying_wims
3610 * Changes the description of an image in the WIM.
3613 * Pointer to the ::WIMStruct for a WIM.
3615 * The number of the image for which to change the description.
3616 * @param description
3617 * The new description to give the image. It may be @c NULL, which
3618 * indicates that the image is to be given no description.
3620 * @return 0 on success; nonzero on error.
3621 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3622 * @p image does not specify a single existing image in @p wim.
3623 * @retval ::WIMLIB_ERR_NOMEM
3624 * Failed to allocate the memory needed to duplicate the @p description
3626 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3627 * @p wim is considered read-only because of any of the reasons mentioned
3628 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3631 wimlib_set_image_descripton(WIMStruct *wim, int image,
3632 const wimlib_tchar *description);
3635 * @ingroup G_writing_and_overwriting_wims
3637 * Set the compression chunk size of a WIM to use in subsequent calls to
3638 * wimlib_write() or wimlib_overwrite().
3640 * A larger compression chunk size will likely result in a better compression
3641 * ratio, but the speed of random access to the WIM will be reduced.
3642 * Furthermore, the effect of a larger compression chunk size is limited by the
3643 * size of each stream ("file") being compressed.
3646 * ::WIMStruct for a WIM.
3648 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3649 * on the compression format. See the documentation for each
3650 * ::wimlib_compression_type constant for more information. As a special
3651 * case, if @p chunk_size is specified as 0, the chunk size is set to the
3652 * default for the currently selected output compression type.
3654 * @return 0 on success; nonzero on error.
3656 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3657 * @p chunk_size is not a supported chunk size for the currently selected
3658 * output compression type.
3661 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3664 * @ingroup G_writing_and_overwriting_wims
3666 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3667 * packed streams (solid blocks).
3670 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3673 * @ingroup G_writing_and_overwriting_wims
3675 * Set the compression type of a WIM to use in subsequent calls to
3676 * wimlib_write() or wimlib_overwrite().
3679 * ::WIMStruct for a WIM.
3681 * The compression type to set (one of ::wimlib_compression_type). If this
3682 * compression type is incompatible with the current output chunk size
3683 * (either the default or as set with wimlib_set_output_chunk_size()), the
3684 * output chunk size is reset to the default for that compression type.
3686 * @return 0 on success; nonzero on error.
3688 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3689 * @p ctype did not specify a valid compression type.
3692 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3695 * @ingroup G_writing_and_overwriting_wims
3697 * Similar to wimlib_set_output_compression_type(), but set the compression type
3698 * for writing packed streams (solid blocks).
3701 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3704 * @ingroup G_modifying_wims
3706 * Set basic information about a WIM.
3709 * Pointer to the ::WIMStruct for a WIM.
3711 * A struct ::wimlib_wim_info that contains the information to set. Only
3712 * the information explicitly specified in the @p which flags need be
3715 * Flags that specify which information to set. This is a bitwise OR of
3716 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3717 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3719 * @return 0 on success; nonzero on failure.
3720 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3721 * The WIM file is considered read-only because of any of the reasons
3722 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3723 * flag. However, as a special case, if you are using
3724 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3725 * function will not fail due to the readonly flag being previously set.
3726 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3727 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3728 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3732 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3736 * @ingroup G_modifying_wims
3738 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3739 * (something like "Core" or "Ultimate")
3742 * Pointer to the ::WIMStruct for a WIM.
3744 * The number of the image for which to change the description.
3746 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3747 * indicates that the image is to be given no \<FLAGS\> element.
3749 * @return 0 on success; nonzero on error.
3750 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3751 * @p image does not specify a single existing image in @p wim.
3752 * @retval ::WIMLIB_ERR_NOMEM
3753 * Failed to allocate the memory needed to duplicate the @p flags string.
3754 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3755 * @p wim is considered read-only because of any of the reasons mentioned
3756 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3759 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3762 * @ingroup G_modifying_wims
3764 * Changes the name of an image in the WIM.
3767 * Pointer to the ::WIMStruct for a WIM.
3769 * The number of the image for which to change the name.
3771 * New name to give the new image. If @c NULL or empty, the new image is
3772 * given no name. If nonempty, it must specify a name that does not
3773 * already exist in @p wim.
3775 * @return 0 on success; nonzero on error.
3776 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3777 * There is already an image named @p name in @p wim.
3778 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3779 * @p image does not specify a single existing image in @p wim.
3780 * @retval ::WIMLIB_ERR_NOMEM
3781 * Failed to allocate the memory needed to duplicate the @p name string.
3782 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3783 * @p wim is considered read-only because of any of the reasons mentioned
3784 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3787 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3790 * @ingroup G_general
3792 * Set the functions that wimlib uses to allocate and free memory.
3794 * These settings are global and not per-WIM.
3796 * The default is to use the default @c malloc() and @c free() from the C
3799 * Please note that some external functions, such as those in @c libntfs-3g, may
3800 * use the standard memory allocation functions regardless of this setting.
3802 * @param malloc_func
3803 * A function equivalent to @c malloc() that wimlib will use to allocate
3804 * memory. If @c NULL, the allocator function is set back to the default
3805 * @c malloc() from the C library.
3807 * A function equivalent to @c free() that wimlib will use to free memory.
3808 * If @c NULL, the free function is set back to the default @c free() from
3810 * @param realloc_func
3811 * A function equivalent to @c realloc() that wimlib will use to reallocate
3812 * memory. If @c NULL, the free function is set back to the default @c
3813 * realloc() from the C library.
3817 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3818 void (*free_func)(void *),
3819 void *(*realloc_func)(void *, size_t));
3822 * @ingroup G_general
3824 * Sets whether wimlib is to print error messages to @c stderr when a function
3825 * fails. These error messages may provide information that cannot be
3826 * determined only from the error code that is returned. Not every error will
3827 * result in an error message being printed.
3829 * This setting is global and not per-WIM.
3831 * By default, error messages are not printed.
3833 * This can be called before wimlib_global_init().
3835 * @param show_messages
3836 * @c true if error messages are to be printed; @c false if error messages
3837 * are not to be printed.
3839 * @return 0 on success; nonzero on error.
3840 * @retval ::WIMLIB_ERR_UNSUPPORTED
3841 * @p show_messages was @c true, but wimlib was compiled with the @c
3842 * --without-error-messages option. Therefore, error messages cannot be
3846 wimlib_set_print_errors(bool show_messages);
3849 * @ingroup G_nonstandalone_wims
3851 * Splits a WIM into multiple parts.
3854 * The ::WIMStruct for the WIM to split.
3856 * Name of the SWM file to create. This will be the name of the first
3857 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3858 * appended before the suffix.
3860 * The maximum size per part, in bytes. Unfortunately, it is not
3861 * guaranteed that this will really be the maximum size per part, because
3862 * some file resources in the WIM may be larger than this size, and the WIM
3863 * file format provides no way to split up file resources among multiple
3865 * @param write_flags
3866 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3867 * flags will be used to write each split WIM part. Specify 0 here to get
3868 * the default behavior.
3870 * @return 0 on success; nonzero on error. This function may return most error
3871 * codes that can be returned by wimlib_write() as well as the following error
3874 * @retval ::WIMLIB_ERR_INVALID_PARAM
3875 * @p swm_name was not a nonempty string, or @p part_size was 0.
3877 * If a progress function is registered with @p wim, for each split WIM part
3878 * that is written it will receive the messages
3879 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3880 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
3883 wimlib_split(WIMStruct *wim,
3884 const wimlib_tchar *swm_name,
3889 * @ingroup G_mounting_wim_images
3891 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3893 * When unmounting a read-write mounted image, the default behavior is to
3894 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
3895 * WIM image to be committed.
3898 * The directory the WIM image was mounted on.
3899 * @param unmount_flags
3900 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
3902 * @return 0 on success; nonzero on error. The possible error codes include:
3904 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
3905 * There is no WIM image mounted on the specified directory.
3906 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
3907 * The read-write mounted WIM image cannot be committed because there are
3908 * file descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
3910 * @retval ::WIMLIB_ERR_MQUEUE
3911 * Could not create a POSIX message queue.
3912 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
3913 * The WIM image was mounted by a different user.
3914 * @retval ::WIMLIB_ERR_UNSUPPORTED
3915 * Mounting is not supported, either because the platform is Windows, or
3916 * because the platform is UNIX-like and wimlib was compiled using @c
3919 * Note: you can also unmount the image by using the @c umount() system call, or
3920 * by using the @c umount or @c fusermount programs. However, you need to call
3921 * this function if you want changes to be committed.
3924 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
3927 * @ingroup G_mounting_wim_images
3929 * Same as wimlib_unmount_image(), but allows specifying a progress function.
3930 * If changes are committed from a read-write mount, the progress function will
3931 * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
3934 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
3936 wimlib_progress_func_t progfunc,
3940 * @ingroup G_modifying_wims
3942 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3945 * Pointer to the ::WIMStruct for the WIM file to update.
3947 * The 1-based index of the image in the WIM to update. It cannot be
3948 * ::WIMLIB_ALL_IMAGES.
3950 * An array of ::wimlib_update_command's that specify the update operations
3953 * Number of commands in @p cmds.
3954 * @param update_flags
3955 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3957 * @return 0 on success; nonzero on error. On failure, all update commands will
3958 * be rolled back, and no visible changes shall have been made to @p wim.
3959 * Possible error codes include:
3961 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3962 * The capture configuration structure specified for an add command was
3964 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3965 * @p image did not specify a single, existing image in @p wim.
3966 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3967 * Attempted to perform an add command that conflicted with previously
3968 * existing files in the WIM when an overlay was attempted.
3969 * @retval ::WIMLIB_ERR_INVALID_PARAM
3970 * An unknown operation type was specified in the update commands; or,
3971 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3972 * in the @p add_flags, but the same image had previously already been
3973 * added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3974 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3975 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3976 * specified in the @p add_flags for an add command in which @p
3977 * wim_target_path was not the root directory of the WIM image.
3978 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3979 * (Windows only): While executing an add command, tried to capture a
3980 * reparse point with invalid data.
3981 * @retval ::WIMLIB_ERR_IS_DIRECTORY
3982 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3983 * for a WIM path that corresponded to a directory; or, a rename command
3984 * attempted to rename a directory to a non-directory.
3985 * @retval ::WIMLIB_ERR_NOMEM
3986 * Failed to allocate needed memory.
3987 * @retval ::WIMLIB_ERR_NOTDIR
3988 * A rename command attempted to rename a directory to a non-directory; or,
3989 * an add command was executed that attempted to set the root of the WIM
3990 * image as a non-directory; or, a path component used as a directory in a
3991 * rename command was not, in fact, a directory.
3992 * @retval ::WIMLIB_ERR_NOTEMPTY
3993 * A rename command attempted to rename a directory to a non-empty
3995 * @retval ::WIMLIB_ERR_NTFS_3G
3996 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3997 * error occurred while reading data from the NTFS volume using libntfs-3g.
3998 * @retval ::WIMLIB_ERR_OPEN
3999 * Failed to open a file to be captured while executing an add command.
4000 * @retval ::WIMLIB_ERR_OPENDIR
4001 * Failed to open a directory to be captured while executing an add command.
4002 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4003 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4004 * WIM path that did not exist; or, a rename command attempted to rename a
4005 * file that does not exist.
4006 * @retval ::WIMLIB_ERR_READ
4007 * While executing an add command, failed to read data from a file or
4008 * directory to be captured.
4009 * @retval ::WIMLIB_ERR_READLINK
4010 * While executing an add command, failed to read the target of a symbolic
4011 * link or junction point.
4012 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
4013 * (Windows only) Failed to perform a reparse point fixup because of
4014 * problems with the data of a reparse point.
4015 * @retval ::WIMLIB_ERR_STAT
4016 * While executing an add command, failed to get attributes for a file or
4018 * @retval ::WIMLIB_ERR_UNSUPPORTED
4019 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
4020 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
4021 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
4022 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
4023 * add_flags for an update command.
4024 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4025 * While executing an add command, attempted to capture a file that was not
4026 * a supported file type (e.g. a device file). Only if
4027 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
4028 * for an update command.
4029 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4030 * The WIM file is considered read-only because of any of the reasons
4031 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
4034 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4035 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4036 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4037 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4038 * different reasons) to read the metadata resource for an image that needed to
4042 wimlib_update_image(WIMStruct *wim,
4044 const struct wimlib_update_command *cmds,
4049 * @ingroup G_writing_and_overwriting_wims
4051 * Writes a WIM to a file.
4053 * This brings in resources from any external locations, such as directory trees
4054 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4055 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
4057 * By default, the new WIM file is written as stand-alone. Using the
4058 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4059 * instead. However, this function cannot directly write a "split" WIM; use
4060 * wimlib_split() for that.
4063 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
4064 * changes made to it, which are then reflected in the output file.
4066 * The path to the file to write the WIM to.
4068 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4069 * images are to be included in the new on-disk WIM file. If for some
4070 * reason you only want to include a single image, specify the index of
4071 * that image instead.
4072 * @param write_flags
4073 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
4074 * @param num_threads
4075 * Number of threads to use for compressing data. If 0, the number of
4076 * threads is taken to be the number of online processors. Note: if no
4077 * data compression needs to be done, no additional threads will be created
4078 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
4079 * exporting an image from a compressed WIM to another WIM of the same
4080 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
4083 * @return 0 on success; nonzero on error.
4085 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4086 * @p image does not specify a single existing image in @p wim, and is not
4087 * ::WIMLIB_ALL_IMAGES.
4088 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4089 * A file that had previously been scanned for inclusion in the WIM by
4090 * wimlib_add_image() was concurrently modified, so it failed the SHA1
4091 * message digest check.
4092 * @retval ::WIMLIB_ERR_INVALID_PARAM
4093 * @p path was @c NULL.
4094 * @retval ::WIMLIB_ERR_NOMEM
4095 * Failed to allocate needed memory.
4096 * @retval ::WIMLIB_ERR_OPEN
4097 * Failed to open @p path for writing, or some file resources in @p wim
4098 * refer to files in the outside filesystem, and one of these files could
4099 * not be opened for reading.
4100 * @retval ::WIMLIB_ERR_READ
4101 * An error occurred when trying to read data from the WIM file associated
4102 * with @p wim, or some file resources in @p wim refer to files in the
4103 * outside filesystem, and a read error occurred when reading one of these
4105 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4106 * A stream that needed to be written could not be found in the stream
4107 * lookup table of @p wim. This error can occur if, for example, @p wim is
4108 * part of a split WIM but needed resources from the other split WIM parts
4109 * were not referenced with wimlib_reference_resources() or
4110 * wimlib_reference_resource_files() before the call to wimlib_write().
4111 * @retval ::WIMLIB_ERR_WRITE
4112 * An error occurred when trying to write data to the new WIM file.
4114 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4115 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4116 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4117 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4118 * different reasons) to read the metadata resource for an image that needed to
4121 * If a progress function is registered with @p wim, it will receive the
4122 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4123 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4124 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4127 wimlib_write(WIMStruct *wim,
4128 const wimlib_tchar *path,
4131 unsigned num_threads);
4134 * @ingroup G_writing_and_overwriting_wims
4136 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
4137 * file descriptor, which need not be seekable if the write is done in a special
4138 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
4139 * write_flags. This can, for example, allow capturing a WIM image and
4140 * streaming it over the network. See the documentation for
4141 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
4143 * The file descriptor @p fd will @b not be closed when the write is complete;
4144 * the calling code is responsible for this.
4146 * Returns 0 on success; nonzero on failure. The possible error codes include
4147 * those that can be returned by wimlib_write() as well as the following:
4149 * @retval ::WIMLIB_ERR_INVALID_PARAM
4150 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4151 * specified in @p write_flags.
4154 wimlib_write_to_fd(WIMStruct *wim,
4158 unsigned num_threads);
4161 * @defgroup G_compression Compression and decompression functions
4163 * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
4164 * exported for convenience only, as they are already used by wimlib internally
4167 * These functions can be used for general-purpose lossless data compression,
4168 * but some limitations apply; for example, none of the compressors or
4169 * decompressors currently support sliding windows, and there also exist
4170 * slightly different variants of these formats that are not supported
4176 /** Header for compression parameters to pass to wimlib_create_compressor() or
4177 * wimlib_set_default_compressor_params(). */
4178 struct wimlib_compressor_params_header {
4179 /** Size of the parameters, in bytes. */
4183 /** Header for decompression parameters to pass to wimlib_create_decompressor()
4184 * or wimlib_set_default_decompressor_params() */
4185 struct wimlib_decompressor_params_header {
4186 /** Size of the parameters, in bytes. */
4190 /** LZX compression parameters that can optionally be passed to
4191 * wimlib_create_compressor() with the compression type
4192 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
4193 struct wimlib_lzx_compressor_params {
4194 /** hdr.size Must be set to the size of this structure, in bytes. */
4195 struct wimlib_compressor_params_header hdr;
4197 /** Relatively fast LZX compression algorithm with a decent compression
4199 #define WIMLIB_LZX_ALGORITHM_FAST 0
4201 /** Slower LZX compression algorithm that provides a better compression
4202 * ratio. This is the default. */
4203 #define WIMLIB_LZX_ALGORITHM_SLOW 1
4205 /** Algorithm to use to perform the compression: either
4206 * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW. The
4207 * format is still LZX; this refers to the method the code will use to
4208 * perform LZX-compatible compression. */
4209 uint32_t algorithm : 3;
4211 /** If set to 1, the default parameters for the specified algorithm are
4212 * used rather than the ones specified in the following union. */
4213 uint32_t use_defaults : 1;
4216 /** Parameters for the fast algorithm. */
4217 struct wimlib_lzx_fast_params {
4218 uint32_t fast_reserved1[10];
4221 /** Parameters for the "slow" algorithm. */
4222 struct wimlib_lzx_slow_params {
4223 /** If set to 1, the compressor can output length 2
4224 * matches. If set 0, the compressor can only output
4225 * matches of length 3 or greater. Suggested value: 1
4227 uint32_t use_len2_matches : 1;
4229 uint32_t slow_reserved1 : 31;
4231 /** Matches with length (in bytes) greater than or equal
4232 * to this value are immediately taken without spending
4233 * time on minimum-cost measurements. Suggested value:
4235 uint32_t nice_match_length;
4237 /** Number of passes to compute a match/literal sequence
4238 * for each LZX block. This is for an iterative
4239 * algorithm that attempts to minimize the cost of the
4240 * match/literal sequence by using a cost model provided
4241 * by the previous iteration. Must be at least 1.
4242 * Suggested value: 2. */
4243 uint32_t num_optim_passes;
4245 /** Reserved; set to 0. */
4246 uint32_t slow_reserved_blocksplit;
4248 /** Maximum depth to search for matches at each
4249 * position. Suggested value: 50. */
4250 uint32_t max_search_depth;
4252 /* Note: max_matches_per_pos has been removed and no
4253 * longer has any effect. */
4255 uint32_t slow_reserved2[3];
4257 /** Assumed cost of a main symbol with zero frequency.
4258 * Must be at least 1 and no more than 16. Suggested
4260 uint8_t main_nostat_cost;
4262 /** Assumed cost of a length symbol with zero frequency.
4263 * Must be at least 1 and no more than 16. Suggested
4265 uint8_t len_nostat_cost;
4267 /** Assumed cost of an aligned symbol with zero
4268 * frequency. Must be at least 1 and no more than 8.
4269 * Suggested value: 7. */
4270 uint8_t aligned_nostat_cost;
4272 uint8_t slow_reserved3[5];
4277 /** LZMS compression parameters that can optionally be passed to
4278 * wimlib_create_compressor() with the compression type
4279 * ::WIMLIB_COMPRESSION_TYPE_LZMS. */
4280 struct wimlib_lzms_compressor_params {
4281 /** hdr.size Must be set to the size of this structure, in bytes. */
4282 struct wimlib_compressor_params_header hdr;
4284 /** Minimum match length to output. This must be at least 2. Suggested
4286 uint32_t min_match_length;
4288 /** Maximum match length to output. This must be at least @p
4289 * min_match_length. Suggested value: @p UINT32_MAX. */
4290 uint32_t max_match_length;
4292 /** Matches with length (in bytes) greater than or equal to this value
4293 * are immediately taken without spending time on minimum-cost
4294 * measurements. The minimum of @p max_match_length and @p
4295 * nice_match_length may not exceed 65536. Suggested value: 32. */
4296 uint32_t nice_match_length;
4298 /** Maximum depth to search for matches at each position. Suggested
4300 uint32_t max_search_depth;
4302 /* Note: max_matches_per_pos has been removed and no longer has any
4307 /** Length of the array for the near-optimal LZ parsing algorithm. This
4308 * must be at least 1. Suggested value: 1024. */
4309 uint32_t optim_array_length;
4311 uint64_t reserved2[4];
4314 /** Opaque compressor handle. */
4315 struct wimlib_compressor;
4317 /** Opaque decompressor handle. */
4318 struct wimlib_decompressor;
4321 * Set the default compression parameters for the specified compression type.
4322 * This will affect both explicit and library-internal calls to
4323 * wimlib_create_compressor().
4326 * Compression type for which to set the default compression parameters.
4328 * Compression-type specific parameters. This may be @c NULL, in which
4329 * case the "default default" parameters are restored.
4331 * @return 0 on success; nonzero on error.
4333 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4334 * @p ctype was not a supported compression type.
4335 * @retval ::WIMLIB_ERR_INVALID_PARAM
4336 * @p params were invalid.
4337 * @retval ::WIMLIB_ERR_NOMEM
4338 * Not enough memory to duplicate the parameters (perhaps @c params->size
4342 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
4343 const struct wimlib_compressor_params_header *params);
4346 * Returns the approximate number of bytes needed to allocate a compressor with
4347 * wimlib_create_compressor() for the specified compression type, block size,
4348 * and parameters. @p params may be @c NULL, in which case the current default
4349 * parameters for @p ctype are used. Returns 0 if the compression type or
4350 * parameters are invalid.
4353 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4354 size_t max_block_size,
4355 const struct wimlib_compressor_params_header *params);
4358 * Allocate a compressor for the specified compression type using the specified
4359 * parameters. This function is part of wimlib's compression API; it is not
4360 * necessary to call this to process a WIM file.
4363 * Compression type for which to create the compressor.
4364 * @param max_block_size
4365 * Maximum block size to support. The exact meaning and allowed values for
4366 * this parameter depend on the compression type, but it at least specifies
4367 * the maximum allowed value for @p uncompressed_size to wimlib_compress().
4368 * @param extra_params
4369 * An optional pointer to extra compressor parameters for the specified
4370 * compression type. For LZX, a pointer to ::wimlib_lzx_compressor_params
4371 * may be specified here. For LZMS, a pointer to
4372 * ::wimlib_lzms_compressor_params may be specified here. If left @c NULL,
4373 * the default parameters are used.
4374 * @param compressor_ret
4375 * A location into which to return the pointer to the allocated compressor,
4376 * which can be used for any number of calls to wimlib_compress() before
4377 * being freed with wimlib_free_compressor().
4379 * @return 0 on success; nonzero on error.
4381 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4382 * @p ctype was not a supported compression type.
4383 * @retval ::WIMLIB_ERR_INVALID_PARAM
4384 * The compression parameters were invalid.
4385 * @retval ::WIMLIB_ERR_NOMEM
4386 * Insufficient memory to allocate the compressor.
4389 wimlib_create_compressor(enum wimlib_compression_type ctype,
4390 size_t max_block_size,
4391 const struct wimlib_compressor_params_header *extra_params,
4392 struct wimlib_compressor **compressor_ret);
4395 * Losslessly compress a block of data using a compressor previously created
4396 * with wimlib_create_compressor().
4398 * @param uncompressed_data
4399 * Buffer containing the data to compress.
4400 * @param uncompressed_size
4401 * Size, in bytes, of the data to compress.
4402 * @param compressed_data
4403 * Buffer into which to write the compressed data.
4404 * @param compressed_size_avail
4405 * Number of bytes available in @p compressed_data.
4407 * A compressor previously allocated with wimlib_create_compressor().
4410 * The size of the compressed data, in bytes, or 0 if the input data could
4411 * not be compressed to @p compressed_size_avail or fewer bytes.
4414 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4415 void *compressed_data, size_t compressed_size_avail,
4416 struct wimlib_compressor *compressor);
4419 * Free a compressor previously allocated with wimlib_create_compressor().
4422 * The compressor to free.
4425 wimlib_free_compressor(struct wimlib_compressor *compressor);
4428 * Set the default decompression parameters for the specified compression type.
4429 * This will affect both explicit and library-internal calls to
4430 * wimlib_create_decompressor().
4433 * Compression type for which to set the default decompression parameters.
4435 * Compression-type specific parameters. This may be @c NULL, in which
4436 * case the "default default" parameters are restored.
4438 * @return 0 on success; nonzero on error.
4440 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4441 * @p ctype was not a supported compression type.
4442 * @retval ::WIMLIB_ERR_NOMEM
4443 * Not enough memory to duplicate the parameters (perhaps @c params->size
4447 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4448 const struct wimlib_decompressor_params_header *params);
4451 * Allocate a decompressor for the specified compression type using the
4452 * specified parameters. This function is part of wimlib's compression API; it
4453 * is not necessary to call this to process a WIM file.
4456 * Compression type for which to create the decompressor.
4457 * @param max_block_size
4458 * Maximum block size to support. The exact meaning and allowed values for
4459 * this parameter depend on the compression type, but it at least specifies
4460 * the maximum allowed value for @p uncompressed_size to
4461 * wimlib_decompress().
4462 * @param extra_params
4463 * An optional pointer to extra decompressor parameters for the specified
4464 * compression type. If @c NULL, the default parameters are used.
4465 * @param decompressor_ret
4466 * A location into which to return the pointer to the allocated
4467 * decompressor, which can be used for any number of calls to
4468 * wimlib_decompress() before being freed with wimlib_free_decompressor().
4470 * @return 0 on success; nonzero on error.
4472 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4473 * @p ctype was not a supported compression type.
4474 * @retval ::WIMLIB_ERR_INVALID_PARAM
4475 * The decompression parameters were invalid.
4476 * @retval ::WIMLIB_ERR_NOMEM
4477 * Insufficient memory to allocate the decompressor.
4480 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4481 size_t max_block_size,
4482 const struct wimlib_decompressor_params_header *extra_params,
4483 struct wimlib_decompressor **decompressor_ret);
4486 * Decompress a block of data using a decompressor previously created with
4487 * wimlib_create_decompressor().
4489 * @param compressed_data
4490 * Buffer containing the data to decompress.
4491 * @param compressed_size
4492 * Size, in bytes, of the data to decompress.
4493 * @param uncompressed_data
4494 * Buffer into which to write the uncompressed data.
4495 * @param uncompressed_size
4496 * Size, in bytes, of the data when uncompressed.
4497 * @param decompressor
4498 * A decompressor previously allocated with wimlib_create_decompressor().
4500 * @return 0 on success; nonzero on error.
4503 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4504 void *uncompressed_data, size_t uncompressed_size,
4505 struct wimlib_decompressor *decompressor);
4508 * Free a decompressor previously allocated with wimlib_create_decompressor().
4510 * @param decompressor
4511 * The decompressor to free.
4514 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4526 #endif /* _WIMLIB_H */