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
15 * This is the documentation for the library interface of wimlib 1.8.0, a C
16 * library for creating, modifying, extracting, and mounting files in the
17 * Windows Imaging Format. This documentation is intended for developers only.
18 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
19 * program, please see the manual pages and also the <a
20 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/README">README
23 * @section sec_installing Installing
27 * Download the source code from <a
28 * href="http://sourceforge.net/projects/wimlib/files">http://sourceforge.net/projects/wimlib/files</a>.
29 * Install the library by running <c>configure && make && sudo make install</c>.
30 * See the README for information about configuration options. To use wimlib in
31 * your program after installing it, include wimlib.h and link your program with
36 * Download the Windows binary distribution with the appropriate architecture
37 * (i686 or x86_64 --- also called "x86" and "amd64" respectively) from <a
38 * href="http://sourceforge.net/projects/wimlib/files">http://sourceforge.net/projects/wimlib/files</a>.
39 * Link your program with the libwim-15.dll file. Make sure to also download
40 * the source code so you can get wimlib.h, as it is not included in the binary
41 * distribution. If you need to access the DLL from other programming
42 * languages, note that the calling convention is "cdecl".
44 * @section sec_examples Examples
46 * Several examples are located in the <a
47 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/examples">examples</a>
48 * directory of the source distribution.
50 * There is also the <a
51 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/programs/imagex.c">
52 * source code of <b>wimlib-imagex</b></a>, which is complicated but uses most
53 * capabilities of wimlib.
55 * @section backwards_compatibility Backwards Compatibility
57 * New releases of wimlib are intended to be API/ABI compatible with old
58 * releases, except when the libtool "age" is reset. This most recently
59 * occurred for the v1.4.0 (libwim7), v1.5.0 (libwim9), and v1.7.0 (libwim15)
60 * releases. However, the library is becoming increasingly stable, and the goal
61 * is to maintain the current API/ABI for as long as possible unless there is a
62 * strong reason not to. Even for the v1.7.0 release (libwim15), the changes
63 * were fairly limited.
65 * As with any other library, applications should not rely on internal
66 * implementation details that may be subject to change.
68 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
70 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
71 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
72 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
73 * which creates a new ::WIMStruct that initially contains no images and does
74 * not yet have a backing on-disk file. See @ref G_creating_and_opening_wims
77 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
78 * Images can be extracted (or "applied") using wimlib_extract_image(), added
79 * (or "captured" or "appended") using wimlib_add_image(), deleted using
80 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
81 * modified using wimlib_update_image(). However, changes made to a WIM
82 * represented by a ::WIMStruct have no persistent effect until the WIM is
83 * actually written to an on-disk file. This can be done using wimlib_write(),
84 * but if the WIM was originally opened using wimlib_open_wim(), then
85 * wimlib_overwrite() can be used instead. See @ref G_extracting_wims, @ref
86 * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
88 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
89 * files is a multi-step process. For example, to add, or "append" an image to
90 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
91 * append</b>, you must call the following functions:
93 * 1. wimlib_open_wim()
94 * 2. wimlib_add_image()
95 * 3. wimlib_overwrite()
97 * This design is very much on purpose as it makes the library more useful in
98 * general by allowing functions to be composed in different ways. For example,
99 * you can make multiple changes to a WIM and commit them all to the underlying
100 * file in only one overwrite operation, which is more efficient.
102 * Note: before calling any other function declared in wimlib.h,
103 * wimlib_global_init() can (and in some cases, must) be called. See its
104 * documentation for more details.
106 * @section sec_cleaning_up Cleaning up
108 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
109 * all resources associated with it. Also, when you are completely done with
110 * using wimlib in your program, you can call wimlib_global_cleanup() to free
111 * any other resources allocated by the library.
113 * @section sec_error_handling Error Handling
115 * Most functions in wimlib return 0 on success and a positive error code on
116 * failure. Use wimlib_get_error_string() to get a string that describes an
117 * error code. wimlib also can print error messages to standard error itself
118 * when an error happens, and these may be more informative than the error code;
119 * to enable this, call wimlib_set_print_errors(). Please note that this is for
120 * convenience only, and some errors can occur without a message being printed.
121 * Currently, error messages and strings (as well as all documentation, for that
122 * matter) are only available in English.
124 * @section sec_encodings Locales and character encodings
126 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
127 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
130 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
131 * and the encoding is UTF-16LE.
133 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
134 * and the encoding is the locale-dependent multibyte encoding. I recommend you
135 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
136 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
137 * call wimlib_global_init() after having set your desired locale.
139 * @section sec_advanced Additional information and features
142 * @subsection subsec_mounting_wim_images Mounting WIM images
144 * See @ref G_mounting_wim_images.
146 * @subsection subsec_progress_functions Progress Messages
148 * See @ref G_progress.
150 * @subsection subsec_non_standalone_wims Non-standalone WIMs
152 * See @ref G_nonstandalone_wims.
154 * @subsection subsec_pipable_wims Pipable WIMs
156 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
157 * compatible with Microsoft's software. To create a pipable WIM, call
158 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
159 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
160 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
161 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
162 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
163 * s using a seekable file descriptor using the regular function calls (e.g.
164 * wimlib_open_wim(), wimlib_extract_image()).
166 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
167 * capture</b> for more information about pipable WIMs.
169 * @subsection subsec_thread_safety Thread Safety
171 * wimlib is thread-safe, with the following exceptions:
172 * - Different threads cannot operate on the same ::WIMStruct at the same time;
173 * they must use different ::WIMStruct's.
174 * - You must call wimlib_global_init() in one thread before calling any other
176 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
177 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
178 * concurrently in the same process, will daemonize the entire process when it
179 * does so for the first time. This includes changing the working directory
180 * to the root directory.
182 * @subsection subsec_limitations Limitations
184 * This section documents some technical limitations of wimlib not already
185 * documented in the man page for @b wimlib-imagex.
187 * - The old WIM format from Vista pre-releases is not supported.
188 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
189 * functionality other than that already present in @b ImageX, that allows you
190 * to make certain Windows-specific modifications to a Windows PE image, such
191 * as adding a driver or Windows component. Such a tool could be implemented
194 * @subsection more_info More information
196 * You are advised to read the README as well as the manual pages for
197 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
198 * the API documentation.
201 /** @defgroup G_general General
203 * @brief Declarations and structures shared across the library.
206 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
208 * @brief Create new WIMs and open existing WIMs.
211 /** @defgroup G_wim_information Retrieving WIM information and directory listings
213 * @brief Retrieve information about a WIM or WIM image.
216 /** @defgroup G_modifying_wims Modifying WIMs
218 * @brief Make changes to a WIM.
220 * @section sec_adding_images Capturing and adding WIM images
222 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
223 * appending an image to an existing WIM is a multi-step process, but at its
224 * core is wimlib_add_image() or an equivalent function. Normally,
225 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
226 * ::WIMStruct as a new image. However, when supported by the build of the
227 * library, there is also a special NTFS volume capture mode (entered when
228 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
229 * from an unmounted NTFS volume.
231 * Another function, wimlib_add_image_multisource() is also provided. It
232 * generalizes wimlib_add_image() to allow combining multiple files or directory
233 * trees into a single WIM image in a configurable way.
235 * For maximum customization of WIM image creation, it is also possible to add a
236 * completely empty WIM image with wimlib_add_empty_image(), then update it with
237 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
238 * wimlib_add_image_multisource() do internally.)
240 * Note that some details of how image addition/capture works are documented
241 * more fully in the manual page for <b>wimlib-imagex capture</b>.
243 * @section sec_deleting_images Deleting WIM images
245 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
246 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
247 * be made persistent in an on-disk WIM file.
249 * @section sec_exporting_images Exporting WIM images
251 * wimlib_export_image() can copy, or "export", an image from one WIM to
254 * @section sec_other_modifications Other modifications
256 * wimlib_update_image() can add, delete, and rename files in a WIM image.
258 * wimlib_set_image_name(), wimlib_set_image_descripton(), and
259 * wimlib_set_image_flags() can change other image metadata.
261 * wimlib_set_wim_info() can change information about the WIM file itself, such
265 /** @defgroup G_extracting_wims Extracting WIMs
267 * @brief Extract files, directories, and images from a WIM.
269 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
270 * represented by a ::WIMStruct. This normally extracts the image to a
271 * directory, but when supported by the build of the library there is also a
272 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
273 * is specified) that allows extracting a WIM image directly to an unmounted
274 * NTFS volume. Various other flags allow further customization of image
277 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
278 * of (possibly wildcard) paths from a WIM image.
280 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
281 * over a pipe; see @ref subsec_pipable_wims.
283 * Some details of how WIM extraction works are documented more fully in the
284 * manual pages for <b>wimlib-imagex apply</b> and <b>wimlib-imagex extract</b>.
287 /** @defgroup G_mounting_wim_images Mounting WIM images
289 * @brief Mount and unmount WIM images.
291 * On Linux, wimlib supports mounting images from WIM files either read-only or
292 * read-write. To mount an image, call wimlib_mount_image(). To unmount an
293 * image, call wimlib_unmount_image(). Mounting can be done without root
294 * privileges because it is implemented using FUSE (Filesystem in Userspace).
296 * If wimlib is compiled using the <code>--without-fuse</code> flag, these
297 * functions will be available but will fail with ::WIMLIB_ERR_UNSUPPORTED.
299 * Note: if mounting is unsupported, wimlib still provides another way to modify
300 * a WIM image (wimlib_update_image()).
304 * @defgroup G_progress Progress Messages
306 * @brief Track the progress of long WIM operations.
308 * Library users can provide a progress function which will be called
309 * periodically during operations such as extracting a WIM image or writing a
310 * WIM image. A ::WIMStruct can have a progress function of type
311 * ::wimlib_progress_func_t associated with it by calling
312 * wimlib_register_progress_function() or by opening the ::WIMStruct using
313 * wimlib_open_wim_with_progress(). Once this is done, the progress function
314 * will be called automatically during many operations, such as
315 * wimlib_extract_image() and wimlib_write().
317 * Some functions that do not operate directly on a user-provided ::WIMStruct,
318 * such as wimlib_join(), also take the progress function directly using an
319 * extended version of the function, such as wimlib_join_with_progress().
321 * In wimlib v1.7.0 and later, progress functions are no longer just
322 * unidirectional. You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause
323 * the current operation to be aborted. wimlib v1.7.0 also added the third
324 * argument to ::wimlib_progress_func_t, which is a user-supplied context.
327 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
329 * @brief Write and overwrite on-disk WIM files.
331 * As described in @ref sec_basic_wim_handling_concepts, these functions are
332 * fundamental to the design of the library as they allow new or modified
333 * ::WIMStruct's to actually be written to on-disk files. Call wimlib_write()
334 * to write a new WIM file, or wimlib_overwrite() to persistently update an
338 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
340 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
342 * Normally, a ::WIMStruct represents a WIM file, but there's a bit more to it
343 * than that. Normally, WIM files are "standalone". However, WIM files can
344 * also be arranged in non-standalone ways, such as a set of on-disk files that
345 * together form a single "split WIM" or "delta WIM". Such arrangements are
346 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
347 * created from one of these on-disk files initially only partially represents
348 * the full WIM and needs to, in effect, be logically combined with other
349 * ::WIMStruct's before performing certain operations, such as extracting files
350 * with wimlib_extract_image() or wimlib_extract_paths(). This is done by
351 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
353 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
354 * specialized function (wimlib_split()) is needed to create a split WIM.
363 #include <inttypes.h>
367 # define _wimlib_deprecated __attribute__((deprecated))
369 # define _wimlib_deprecated
372 /** @addtogroup G_general
375 /** Major version of the library (for example, the 1 in 1.2.5). */
376 #define WIMLIB_MAJOR_VERSION 1
378 /** Minor version of the library (for example, the 2 in 1.2.5). */
379 #define WIMLIB_MINOR_VERSION 8
381 /** Patch version of the library (for example, the 5 in 1.2.5). */
382 #define WIMLIB_PATCH_VERSION 0
389 * Opaque structure that represents a WIM file. This is an in-memory structure
390 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
391 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
392 * continuing to exist so that data can be read from it as needed.
394 * Most functions in this library will work the same way regardless of whether a
395 * given ::WIMStruct was obtained through wimlib_open_wim() or
396 * wimlib_create_new_wim(). Exceptions are documented.
398 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
399 * file from a ::WIMStruct.
401 * See @ref sec_basic_wim_handling_concepts for more information.
403 #ifndef WIMLIB_WIMSTRUCT_DECLARED
404 typedef struct WIMStruct WIMStruct;
405 #define WIMLIB_WIMSTRUCT_DECLARED
409 typedef wchar_t wimlib_tchar;
411 /** See @ref sec_encodings */
412 typedef char wimlib_tchar;
416 /** Path separator for WIM paths passed back to progress callbacks.
417 * This is forward slash on UNIX and backslash on Windows. */
418 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
419 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
421 /** Path separator for WIM paths passed back to progress callbacks.
422 * This is forward slash on UNIX and backslash on Windows. */
423 # define WIMLIB_WIM_PATH_SEPARATOR '/'
424 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
427 /** Use this to specify the root directory of the WIM image. */
428 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
430 /** Use this to test if the specified path refers to the root directory of the
432 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
433 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
436 /** Length of a Globally Unique Identifier (GUID) */
437 #define WIMLIB_GUID_LEN 16
440 * Specifies a compression format. Pass one of these values to
441 * wimlib_create_new_wim(), wimlib_set_output_compression_type(),
442 * wimlib_create_compressor(), or wimlib_create_decompressor().
444 * A WIM file has one default compression type and chunk size. Normally, each
445 * resource in the WIM file is compressed with this compression type. However,
446 * resources may be stored as uncompressed; for example, wimlib will do so if a
447 * resource does not compress to less than its original size. In addition, a
448 * WIM with the new version number of 3584, or "ESD file", might contain solid
449 * blocks with different compression types.
451 enum wimlib_compression_type {
455 * This is a valid argument to wimlib_create_new_wim() and
456 * wimlib_set_output_compression_type(), but not to the functions in the
457 * compression API such as wimlib_create_compressor().
459 WIMLIB_COMPRESSION_TYPE_NONE = 0,
462 * The XPRESS compression format. This format combines Lempel-Ziv
463 * factorization with Huffman encoding. Compression and decompression
464 * are both fast. This format supports chunk sizes that are powers of 2
465 * between <c>2^12</c> and <c>2^16</c>, inclusively.
467 * wimlib's XPRESS compressor will, with the default settings, usually
468 * produce a better compression ratio, and work more quickly, than the
469 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
470 * Non-default compression levels are also supported. For example,
471 * level 80 will enable two-pass optimal parsing, which is significantly
472 * slower but usually improves compression by several percent over the
473 * default level of 50.
475 * If using wimlib_create_compressor() to create an XPRESS compressor
476 * directly, the @p max_block_size parameter may be any positive value
477 * up to and including <c>2^16</c>.
479 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
482 * The LZX compression format. This format combines Lempel-Ziv
483 * factorization with Huffman encoding, but with more features and
484 * complexity than XPRESS. Compression is slow to somewhat fast,
485 * depending on the settings. Decompression is fast but slower than
486 * XPRESS. This format supports chunk sizes that are powers of 2
487 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
488 * other than <c>2^15</c> are not compatible with the Microsoft
491 * wimlib's LZX compressor will, with the default settings, usually
492 * produce a better compression ratio, and work more quickly, than the
493 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
494 * Non-default compression levels are also supported. For example,
495 * level 20 will provide fast compression, almost as fast as XPRESS.
497 * If using wimlib_create_compressor() to create an LZX compressor
498 * directly, the @p max_block_size parameter may be any positive value
499 * up to and including <c>2^21</c>.
501 WIMLIB_COMPRESSION_TYPE_LZX = 2,
504 * The LZMS compression format. This format combines Lempel-Ziv
505 * factorization with adaptive Huffman encoding and range coding.
506 * Compression and decompression are both fairly slow. This format
507 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
508 * <c>2^30</c>, inclusively. This format is best used for large chunk
509 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
510 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
511 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
512 * with the Microsoft implementation.
514 * wimlib's LZMS compressor will, with the default settings, usually
515 * produce a better compression ratio, and work more quickly, than the
516 * implementation in Microsoft's WIMGAPI (as of Windows 8.1). There is
517 * limited support for non-default compression levels, but compression
518 * will be noticably faster if you choose a level < 35.
520 * If using wimlib_create_compressor() to create an LZMS compressor
521 * directly, the @p max_block_size parameter may be any positive value
522 * up to and including <c>2^30</c>.
524 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
528 /** @addtogroup G_progress
531 /** Possible values of the first parameter to the user-supplied
532 * ::wimlib_progress_func_t progress function */
533 enum wimlib_progress_msg {
535 /** A WIM image is about to be extracted. @p info will point to
536 * ::wimlib_progress_info.extract. This message is received once per
537 * image for calls to wimlib_extract_image() and
538 * wimlib_extract_image_from_pipe(). */
539 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
541 /** One or more file or directory trees within a WIM image is about to
542 * be extracted. @p info will point to ::wimlib_progress_info.extract.
543 * This message is received only once per wimlib_extract_paths() and
544 * wimlib_extract_pathlist(), since wimlib combines all paths into a
545 * single extraction operation for optimization purposes. */
546 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
548 /** This message may be sent periodically (not for every file) while
549 * files or directories are being created, prior to data stream
550 * extraction. @p info will point to ::wimlib_progress_info.extract.
551 * In particular, the @p current_file_count and @p end_file_count
552 * members may be used to track the progress of this phase of
554 WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE = 3,
556 /** File data is currently being extracted. @p info will point to
557 * ::wimlib_progress_info.extract. This is the main message to track
558 * the progress of an extraction operation. */
559 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
561 /** Starting to read a new part of a split pipable WIM over the pipe.
562 * @p info will point to ::wimlib_progress_info.extract. */
563 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
565 /** This message may be sent periodically (not for every file) while
566 * file and directory metadata is being applied, following data stream
567 * extraction. @p info will point to ::wimlib_progress_info.extract.
568 * In particular, the @p current_file_count and @p end_file_count
569 * members may be used to track the progress of this phase of
571 WIMLIB_PROGRESS_MSG_EXTRACT_METADATA = 6,
573 /** Confirms that the image has been successfully extracted. @p info
574 * will point to ::wimlib_progress_info.extract. This is paired with
575 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
576 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
578 /** Confirms that the files or directory trees have been successfully
579 * extracted. @p info will point to ::wimlib_progress_info.extract.
580 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
581 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
583 /** The directory or NTFS volume is about to be scanned for metadata.
584 * @p info will point to ::wimlib_progress_info.scan. This message is
585 * received once per call to wimlib_add_image(), or once per capture
586 * source passed to wimlib_add_image_multisource(), or once per add
587 * command passed to wimlib_update_image(). */
588 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
590 /** A directory or file has been scanned. @p info will point to
591 * ::wimlib_progress_info.scan, and its @p cur_path member will be
592 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
594 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
596 /** Confirms that the directory or NTFS volume has been successfully
597 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
598 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
599 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
601 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
603 /** File resources ("streams") are currently being written to the WIM.
604 * @p info will point to ::wimlib_progress_info.write_streams. This
605 * message may be received many times while the WIM file is being
606 * written or appended to with wimlib_write(), wimlib_overwrite(), or
607 * wimlib_write_to_fd(). */
608 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
610 /** Per-image metadata is about to be written to the WIM file. @p info
611 * will not be valid. */
612 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
614 /** Confirms that per-image metadata has been successfully been written
615 * to the WIM file. @p info will not be valid. This message is paired
616 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
618 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
620 /** wimlib_overwrite() has successfully renamed the temporary file to
621 * the original WIM file, thereby committing the update. @p info will
622 * point to ::wimlib_progress_info.rename. Note: this message is not
623 * received if wimlib_overwrite() chose to append to the WIM file
625 WIMLIB_PROGRESS_MSG_RENAME = 15,
627 /** The contents of the WIM file are being checked against the integrity
628 * table. @p info will point to ::wimlib_progress_info.integrity. This
629 * message is only received (and may be received many times) when
630 * wimlib_open_wim_with_progress() is called with the
631 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
632 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
634 /** An integrity table is being calculated for the WIM being written.
635 * @p info will point to ::wimlib_progress_info.integrity. This message
636 * is only received (and may be received many times) when a WIM file is
637 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
638 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
640 /** A wimlib_split() operation is in progress, and a new split part is
641 * about to be started. @p info will point to
642 * ::wimlib_progress_info.split. */
643 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
645 /** A wimlib_split() operation is in progress, and a split part has been
646 * finished. @p info will point to ::wimlib_progress_info.split. */
647 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
649 /** A WIM update command is just about to be executed. @p info will
650 * point to ::wimlib_progress_info.update. This message is received
651 * once per update command when wimlib_update_image() is called with the
652 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
653 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
655 /** A WIM update command has just been executed. @p info will point to
656 * ::wimlib_progress_info.update. This message is received once per
657 * update command when wimlib_update_image() is called with the flag
658 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
659 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
661 /** A file in the WIM image is being replaced as a result of a
662 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
663 * @p info will point to ::wimlib_progress_info.replace. This is only
664 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
666 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
668 /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
669 * a file is being extracted normally (not as a WIMBoot "pointer file")
670 * due to it matching a pattern in the [PrepopulateList] section of the
671 * configuration file @c \\Windows\\System32\\WimBootCompress.ini in the
672 * WIM image. @p info will point to
673 * ::wimlib_progress_info.wimboot_exclude.
675 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
677 /** Starting to unmount a WIM image. @p info will point to
678 * ::wimlib_progress_info.unmount. */
679 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
681 /** wimlib has used a file's data for the last time (including all data
682 * streams, if it has multiple). @p info will point to
683 * ::wimlib_progress_info.done_with_file. This message is only received
684 * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided. */
685 WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
687 /** wimlib_verify_wim() is starting to verify the metadata for an image.
688 * @p info will point to ::wimlib_progress_info.verify_image. */
689 WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
691 /** wimlib_verify_wim() has finished verifying the metadata for an
692 * image. @p info will point to ::wimlib_progress_info.verify_image.
694 WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
696 /** wimlib_verify_wim() is verifying stream integrity. @p info will
697 * point to ::wimlib_progress_info.verify_streams. */
698 WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
701 * The progress function is being asked whether a file should be
702 * excluded from capture or not. @p info will point to
703 * ::wimlib_progress_info.test_file_exclusion. This is a bidirectional
704 * message that allows the progress function to set a flag if the file
705 * should be excluded.
707 * This message is only received if the flag
708 * ::WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION is used. This method for file
709 * exclusions is independent of the "capture configuration file"
712 WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION = 30,
715 * An error has occurred and the progress function is being asked
716 * whether to ignore the error or not. @p info will point to
717 * ::wimlib_progress_info.handle_error. This is a bidirectional
720 * This message provides a limited capability for applications to
721 * recover from "unexpected" errors (i.e. those with no in-library
722 * handling policy) arising from the underlying operating system.
723 * Normally, any such error will cause the library to abort the current
724 * operation. By implementing a handler for this message, the
725 * application can instead choose to ignore a given error.
727 * Currently, only the following types of errors will result in this
728 * progress message being sent:
730 * - Directory tree scan errors, e.g. from wimlib_add_image()
731 * - Most extraction errors; currently restricted to the Windows
732 * build of the library only.
734 WIMLIB_PROGRESS_MSG_HANDLE_ERROR = 31,
737 /** Valid return values from user-provided progress functions
738 * (::wimlib_progress_func_t).
740 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
743 enum wimlib_progress_status {
745 /** The operation should be continued. This is the normal return value.
747 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
749 /** The operation should be aborted. This will cause the current
750 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
751 WIMLIB_PROGRESS_STATUS_ABORT = 1,
755 * A pointer to this union is passed to the user-supplied
756 * ::wimlib_progress_func_t progress function. One (or none) of the structures
757 * contained in this union will be applicable for the operation
758 * (::wimlib_progress_msg) indicated in the first argument to the progress
760 union wimlib_progress_info {
762 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
763 * document them if they aren't given a name... */
765 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
766 * the primary message for tracking the progress of writing a WIM file.
768 struct wimlib_progress_info_write_streams {
769 /** Total number of uncompressed bytes of stream data being
770 * written. This can be thought of as the total uncompressed
771 * size of the files being archived, with some caveats. WIM
772 * files use single-instance streams, so the size provided here
773 * only counts distinct streams, except for the following
774 * exception: the size provided here may include the sizes of
775 * all newly added (e.g. with wimlib_add_image() streams,
776 * pending automatic de-duplication during the write operation
777 * itself. When each such stream de-duplication occurs, this
778 * number will be decreased by the size of the duplicate stream
779 * that need not be written.
781 * In the case of a wimlib_overwrite() that the library opted to
782 * perform in-place, both @p total_streams and @p total_bytes
783 * will only count the streams actually being written and not
784 * pre-existing streams in the WIM file. */
785 uint64_t total_bytes;
787 /** Total number of streams being written. This can be thought
788 * of as the total number of files being archived, with some
789 * caveats. In general, a single file or directory may contain
790 * multiple data streams, each of which will be represented
791 * separately in this number. Furthermore, WIM files use
792 * single-instance streams, so the stream count provided here
793 * only counts distinct streams, except for the following
794 * exception: the stream count provided here may include newly
795 * added (e.g. with wimlib_add_image() streams, pending
796 * automatic de-duplication during the write operation itself.
797 * When each such stream de-duplication occurs, this number will
798 * be decreased by 1 to account for the duplicate stream that
799 * need not be written. */
800 uint64_t total_streams;
802 /** Number of uncompressed bytes of stream data that have been
803 * written so far. This number be 0 initially, and will be
804 * equal to @p total_bytes at the end of the write operation.
805 * Note that @p total_bytes (but not @p completed_bytes) may
806 * decrease throughout the write operation due to the discovery
807 * of stream duplications. */
808 uint64_t completed_bytes;
810 /** Number of streams that have been written so far. This
811 * number will be 0 initially, and will be equal to @p
812 * total_streams at the end of the write operation. Note that
813 * @p total_streams (but not @p completed_streams) may decrease
814 * throughout the write operation due to the discovery of stream
817 * For applications that wish to calculate a simple "percent
818 * complete" for the write operation, it will likely be more
819 * accurate to calculate the percentage from @p completed_bytes
820 * and @p total_bytes rather than @p completed_streams and
821 * @p total_streams because the time for the operation to
822 * complete is mainly determined by the number of bytes that
823 * need to be read, compressed, and written, not just the number
824 * of files being archived. */
825 uint64_t completed_streams;
827 /** Number of threads that are being used to compress streams,
828 * or 1 if streams are being written uncompressed. */
829 uint32_t num_threads;
831 /** The compression type being used to write the streams, as one
832 * of the ::wimlib_compression_type constants. */
833 int32_t compression_type;
835 /** Number of split WIM parts from which streams are being
836 * written (may be 0 if irrelevant). */
837 uint32_t total_parts;
839 /** This is currently broken and will always be 0. */
840 uint32_t completed_parts;
843 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
844 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
845 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
846 struct wimlib_progress_info_scan {
847 /** Top-level directory being scanned; or, when capturing an NTFS
848 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
849 * to the file or block device that contains the NTFS volume
851 const wimlib_tchar *source;
853 /** Path to the file (or directory) that has been scanned, valid
854 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
855 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
856 * relative to the root of the NTFS volume. */
857 const wimlib_tchar *cur_path;
859 /** Dentry scan status, valid on
860 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
862 /** The file looks okay and will be captured. */
863 WIMLIB_SCAN_DENTRY_OK = 0,
865 /** File is being excluded from capture due to the
866 * capture configuration. */
867 WIMLIB_SCAN_DENTRY_EXCLUDED,
869 /** File is being excluded from capture due to being
870 * unsupported (e.g. an encrypted or device file). */
871 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
873 /** The file is an absolute symbolic link or junction
874 * that points into the capture directory, and
875 * reparse-point fixups are enabled, so its target is
876 * being adjusted. (Reparse point fixups can be
877 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
879 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
881 /** Reparse-point fixups are enabled, but the file is an
882 * absolute symbolic link or junction that does
883 * <b>not</b> point into the capture directory, so its
884 * target is <b>not</b> being adjusted. */
885 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK,
889 /** Target path in the WIM image. Only valid on
890 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
891 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
892 const wimlib_tchar *wim_target_path;
894 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
895 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
896 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
897 * target of the absolute symbolic link or junction. */
898 const wimlib_tchar *symlink_target;
901 /** Number of directories scanned so far, including the root
902 * directory but excluding any unsupported/excluded directories.
904 * Details: On Windows and in NTFS capture mode, a reparse point
905 * counts as a directory if and only if it has
906 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
907 * counts as a directory if and only if when fully dereferenced
908 * it points to an accessible directory. If a file has multiple
909 * names (hard links), it is only counted one time. */
910 uint64_t num_dirs_scanned;
912 /** Number of non-directories scanned so far, excluding any
913 * unsupported/excluded files.
915 * Details: On Windows and in NTFS capture mode, a reparse point
916 * counts as a non-directory if and only if it does not have
917 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
918 * counts as a non-directory if and only if when fully
919 * dereferenced it points to a non-directory or its target is
920 * inaccessible. If a file has multiple names (hard links), it
921 * is only counted one time. */
922 uint64_t num_nondirs_scanned;
924 /** Number of bytes of file data that have been detected so far.
926 * Details: This data may not actually have been read yet, and
927 * it will not actually be written to the WIM file until
928 * wimlib_write() or wimlib_overwrite() has been called. Data
929 * from excluded files is not counted. This number includes
930 * default file contents as well as named data streams and
931 * reparse point data. The size of reparse point data is
932 * tallied after any reparse-point fixups, and in the case of
933 * capturing a symbolic link on a UNIX-like system, the creation
934 * of the reparse point data itself. If a file has multiple
935 * names (hard links), its size(s) are only counted one time.
936 * On Windows, encrypted files have their encrypted size
937 * counted, not their unencrypted size; however, compressed
938 * files have their uncompressed size counted. */
939 uint64_t num_bytes_scanned;
942 /** Valid on messages
943 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
944 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
945 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
946 * ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE,
947 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
948 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA,
949 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
950 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
952 * Note: most of the time of an extraction operation will be spent
953 * extracting streams, and the application will receive
954 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
955 * completed_bytes and @p total_bytes, the application can calculate a
956 * percentage complete. However, note that this message does not, in
957 * general, actually provide information about which "file" is currently
958 * being extracted. This is because wimlib, by default, extracts the
959 * individual data streams in whichever order it determines to be the
962 struct wimlib_progress_info_extract {
963 /** Number of the image from which files are being extracted
967 /** Extraction flags being used. */
968 uint32_t extract_flags;
970 /** Full path to the WIM file from which files are being
971 * extracted, or @c NULL if the WIMStruct has no associated
973 const wimlib_tchar *wimfile_name;
975 /** Name of the image from which files are being extracted, or
976 * the empty string if the image is unnamed. */
977 const wimlib_tchar *image_name;
979 /** Path to the directory or NTFS volume to which the files are
980 * being extracted. */
981 const wimlib_tchar *target;
984 const wimlib_tchar *reserved;
986 /** Number of bytes of uncompressed data that will be extracted.
987 * If a file has multiple names (hard links), its size (or
988 * sizes, in the case of named data streams) is only counted one
989 * time. For "reparse points" and symbolic links, the size to
990 * be extracted is the size of the reparse data buffer.
992 * This number will stay constant throughout the extraction. */
993 uint64_t total_bytes;
995 /** Number of bytes of uncompressed data that have been
996 * extracted so far. This initially be 0 and will equal to @p
997 * total_bytes at the end of the extraction. */
998 uint64_t completed_bytes;
1000 /** Number of (not necessarily unique) streams that will be
1001 * extracted. This may be more or less than the number of
1002 * "files" to be extracted due to hard links as well as
1003 * potentially multiple streams per file (named data streams).
1004 * A "stream" may be the default contents of a file, a named
1005 * data stream, or a reparse data buffer. */
1006 uint64_t total_streams;
1008 /** Number of (not necessarily unique) streams that have been
1009 * extracted so far. */
1010 uint64_t completed_streams;
1012 /** Currently only used for
1013 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
1014 uint32_t part_number;
1016 /** Currently only used for
1017 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
1018 uint32_t total_parts;
1020 /** Currently only used for
1021 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
1022 uint8_t guid[WIMLIB_GUID_LEN];
1024 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
1025 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is the
1026 * number of files that have been processed so far. Once the
1027 * corresponding phase of extraction is complete, this value
1028 * will be equal to @c end_file_count. */
1029 uint64_t current_file_count;
1031 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
1032 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is
1033 * total number of files that will be processed.
1035 * This number is provided for informational purposes only.
1036 * This number will not necessarily be equal to the number of
1037 * files actually being extracted. This is because extraction
1038 * backends are free to implement an extraction algorithm that
1039 * might be more efficient than processing every file in the
1040 * "extract file structure" and "extract metadata" phases. For
1041 * example, the current implementation of the UNIX extraction
1042 * backend will create files on-demand during the stream
1043 * extraction phase. Therefore, when using that particular
1044 * extraction backend, @p end_file_count will only include
1045 * directories and empty files. */
1046 uint64_t end_file_count;
1049 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
1050 struct wimlib_progress_info_rename {
1051 /** Name of the temporary file that the WIM was written to. */
1052 const wimlib_tchar *from;
1054 /** Name of the original WIM file to which the temporary file is
1056 const wimlib_tchar *to;
1059 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1060 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
1061 struct wimlib_progress_info_update {
1062 /** Pointer to the update command that will be executed or has
1063 * just been executed. */
1064 const struct wimlib_update_command *command;
1066 /** Number of update commands that have been completed so far.
1068 size_t completed_commands;
1070 /** Number of update commands that are being executed as part of
1071 * this call to wimlib_update_image(). */
1072 size_t total_commands;
1075 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
1076 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
1077 struct wimlib_progress_info_integrity {
1078 /** Number of bytes from the end of the WIM header to the end of
1079 * the lookup table (the area that is covered by the SHA1
1080 * integrity checks.) */
1081 uint64_t total_bytes;
1083 /** Number of bytes that have been SHA1-summed so far. Will be
1084 * 0 initially, and equal @p total_bytes at the end. */
1085 uint64_t completed_bytes;
1087 /** Number of chunks that the checksummed region is divided
1089 uint32_t total_chunks;
1091 /** Number of chunks that have been SHA1-summed so far. Will
1092 * be 0 initially, and equal to @p total_chunks at the end. */
1093 uint32_t completed_chunks;
1095 /** Size of the chunks used for the integrity calculation. */
1096 uint32_t chunk_size;
1098 /** Filename of the WIM (only valid if the message is
1099 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
1100 const wimlib_tchar *filename;
1103 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
1104 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
1105 struct wimlib_progress_info_split {
1106 /** Total size of the original WIM's file and metadata resources
1108 uint64_t total_bytes;
1110 /** Number of bytes of file and metadata resources that have
1111 * been copied out of the original WIM so far. Will be 0
1112 * initially, and equal to @p total_bytes at the end. */
1113 uint64_t completed_bytes;
1115 /** Number of the split WIM part that is about to be started
1116 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1117 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
1118 unsigned cur_part_number;
1120 /** Total number of split WIM parts that are being written. */
1121 unsigned total_parts;
1123 /** Name of the split WIM part that is about to be started
1124 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1125 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
1126 * As of wimlib v1.7.0, the library user may change this when
1127 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
1128 * cause the next split WIM part to be written to a different
1130 wimlib_tchar *part_name;
1133 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
1134 struct wimlib_progress_info_replace {
1135 /** Path to the file in the WIM image that is being replaced */
1136 const wimlib_tchar *path_in_wim;
1139 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1140 struct wimlib_progress_info_wimboot_exclude {
1141 /** Path to the file in the WIM image */
1142 const wimlib_tchar *path_in_wim;
1144 /** Path to which the file is being extracted */
1145 const wimlib_tchar *extraction_path;
1148 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1149 struct wimlib_progress_info_unmount {
1150 /** Path to directory being unmounted */
1151 const wimlib_tchar *mountpoint;
1153 /** Path to WIM file being unmounted */
1154 const wimlib_tchar *mounted_wim;
1156 /** 1-based index of image being unmounted. */
1157 uint32_t mounted_image;
1159 /** Flags that were passed to wimlib_mount_image() when the
1160 * mountpoint was set up. */
1161 uint32_t mount_flags;
1163 /** Flags passed to wimlib_unmount_image(). */
1164 uint32_t unmount_flags;
1167 /** Valid on messages ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE. */
1168 struct wimlib_progress_info_done_with_file {
1169 /* Path to the file whose data has been written to the WIM file,
1170 * or is currently being asynchronously compressed in memory,
1171 * and therefore is no longer needed by wimlib.
1173 * WARNING: The file data will not actually be accessible in the
1174 * WIM file until the WIM file has been completely written.
1175 * Ordinarily you should <b>not</b> treat this message as a
1176 * green light to go ahead and delete the specified file, since
1177 * that would result in data loss if the WIM file cannot be
1178 * successfully created for any reason.
1180 * If a file has multiple names (hard links),
1181 * ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE will only be received
1182 * for one name. Also, this message will not be received for
1183 * empty files or reparse points (or symbolic links), unless
1184 * they have nonempty named data streams.
1186 const wimlib_tchar *path_to_file;
1189 /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
1190 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE. */
1191 struct wimlib_progress_info_verify_image {
1192 const wimlib_tchar *wimfile;
1193 uint32_t total_images;
1194 uint32_t current_image;
1197 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS. */
1198 struct wimlib_progress_info_verify_streams {
1199 const wimlib_tchar *wimfile;
1200 uint64_t total_streams;
1201 uint64_t total_bytes;
1202 uint64_t completed_streams;
1203 uint64_t completed_bytes;
1206 /** Valid on messages ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION. */
1207 struct wimlib_progress_info_test_file_exclusion {
1210 * Path to the file for which exclusion is being tested.
1212 * UNIX capture mode: The path will be a standard relative or
1213 * absolute UNIX filesystem path.
1215 * NTFS-3g capture mode: The path will be given relative to the
1216 * root of the NTFS volume, with a leading slash.
1218 * Windows capture mode: The path will be a Win32 namespace
1221 const wimlib_tchar *path;
1224 * Indicates whether the file or directory will be excluded from
1225 * capture or not. This will be <tt>false</tt> by default. The
1226 * progress function can set this to <tt>true</tt> if it decides
1227 * that the file needs to be excluded.
1230 } test_file_exclusion;
1232 /** Valid on messages ::WIMLIB_PROGRESS_MSG_HANDLE_ERROR. */
1233 struct wimlib_progress_info_handle_error {
1235 /** Path to the file for which the error occurred, or NULL if
1237 const wimlib_tchar *path;
1239 /** The wimlib error code associated with the error. */
1243 * Indicates whether the error will be ignored or not. This
1244 * will be <tt>false</tt> by default; the progress function may
1245 * set it to <tt>true</tt>.
1252 * A user-supplied function that will be called periodically during certain WIM
1255 * The first argument will be the type of operation that is being performed or
1256 * is about to be started or has been completed.
1258 * The second argument will be a pointer to one of a number of structures
1259 * depending on the first argument. It may be @c NULL for some message types.
1260 * Note that although this argument is not @c const, users should not modify it
1261 * except in explicitly documented cases.
1263 * The third argument will be a user-supplied value that was provided when
1264 * registering or specifying the progress function.
1266 * This function must return one of the ::wimlib_progress_status values. By
1267 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1269 typedef enum wimlib_progress_status
1270 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1271 union wimlib_progress_info *info,
1275 /** @addtogroup G_modifying_wims
1278 /** An array of these structures is passed to wimlib_add_image_multisource() to
1279 * specify the sources from which to create a WIM image. */
1280 struct wimlib_capture_source {
1281 /** Absolute or relative path to a file or directory on the external
1282 * filesystem to be included in the WIM image. */
1283 wimlib_tchar *fs_source_path;
1285 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1286 * specify the root directory of the WIM image. */
1287 wimlib_tchar *wim_target_path;
1289 /** Reserved; set to 0. */
1293 /** Set or unset the "readonly" WIM header flag (WIM_HDR_FLAG_READONLY in
1294 * Microsoft's documentation), based on the ::wimlib_wim_info.is_marked_readonly
1295 * member of the @p info parameter. This is distinct from basic file
1296 * permissions; this flag can be set on a WIM file that is physically writable.
1298 * wimlib disallows modifying on-disk WIM files with the readonly flag set.
1299 * However, wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG
1300 * will override this --- and in fact, this is necessary to set the readonly
1301 * flag persistently on an existing WIM file.
1303 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1305 /** Set the GUID (globally unique identifier) of the WIM file to the value
1306 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1307 #define WIMLIB_CHANGE_GUID 0x00000002
1309 /** Change the bootable image of the WIM to the value specified in
1310 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1311 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1313 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1314 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
1315 * indicates whether an image in the WIM has been captured with reparse-point
1316 * fixups enabled. wimlib also treats this flag as specifying whether to do
1317 * reparse-point fixups by default when capturing or applying WIM images. */
1318 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1322 /** @addtogroup G_wim_information */
1326 /** General information about a WIM file. */
1327 struct wimlib_wim_info {
1329 /** Globally unique identifier for the WIM file. Note: all parts of a
1330 * split WIM should have an identical value in this field. */
1331 uint8_t guid[WIMLIB_GUID_LEN];
1333 /** Number of images in the WIM. */
1334 uint32_t image_count;
1336 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1338 uint32_t boot_index;
1340 /** Version of the WIM file. */
1341 uint32_t wim_version;
1343 /** Chunk size used for compression. */
1344 uint32_t chunk_size;
1346 /** For split WIMs, the 1-based index of this part within the split WIM;
1348 uint16_t part_number;
1350 /** For split WIMs, the total number of parts in the split WIM;
1352 uint16_t total_parts;
1354 /** One of the ::wimlib_compression_type values that specifies the
1355 * method used to compress resources in the WIM. */
1356 int32_t compression_type;
1358 /** Size of the WIM file in bytes, excluding the XML data and integrity
1360 uint64_t total_bytes;
1362 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1363 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1364 * this will always be 0, even if the ::WIMStruct was written to
1365 * somewhere by calling wimlib_write() with the
1366 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1367 uint32_t has_integrity_table : 1;
1369 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1370 * wimlib_create_new_wim(). */
1371 uint32_t opened_from_file : 1;
1373 /** 1 if the WIM is considered readonly for any reason. */
1374 uint32_t is_readonly : 1;
1376 /** 1 if reparse-point fixups are enabled for one or more images in the
1378 uint32_t has_rpfix : 1;
1380 /** 1 if the WIM is marked read-only. */
1381 uint32_t is_marked_readonly : 1;
1383 /** 1 if the WIM is part of a spanned set. */
1384 uint32_t spanned : 1;
1386 uint32_t write_in_progress : 1;
1387 uint32_t metadata_only : 1;
1388 uint32_t resource_only : 1;
1390 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1391 uint32_t pipable : 1;
1392 uint32_t reserved_flags : 22;
1393 uint32_t reserved[9];
1396 /** Information about a unique stream in the WIM file. (A stream is the same
1397 * thing as a "resource", except in the case of solid resources.) */
1398 struct wimlib_resource_entry {
1399 /** Uncompressed size of the stream in bytes. */
1400 uint64_t uncompressed_size;
1402 /** Compressed size of the stream in bytes. This will be the same as @p
1403 * uncompressed_size if the stream is uncompressed. Or, if @p packed is
1404 * 1, this will be 0. */
1405 uint64_t compressed_size;
1407 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1408 * if @p packed is 1, then this is actually the offset at which this
1409 * stream begins in the uncompressed contents of the solid resource.
1413 /** SHA1 message digest of the stream's uncompressed contents. */
1414 uint8_t sha1_hash[20];
1416 /** Which part of WIM this stream is in. */
1417 uint32_t part_number;
1419 /** Number of times this stream is referenced over all WIM images. */
1420 uint32_t reference_count;
1422 /** 1 if this stream is compressed. */
1423 uint32_t is_compressed : 1;
1425 /** 1 if this stream is a metadata resource rather than a file resource.
1427 uint32_t is_metadata : 1;
1429 uint32_t is_free : 1;
1430 uint32_t is_spanned : 1;
1432 /** 1 if this stream was not found in the lookup table of the
1433 * ::WIMStruct. This normally implies a missing call to
1434 * wimlib_reference_resource_files() or wimlib_reference_resources().
1436 uint32_t is_missing : 1;
1438 /** 1 if this stream is located in a solid resource which may contain
1439 * other streams (all compressed together) as well. */
1440 uint32_t packed : 1;
1442 uint32_t reserved_flags : 26;
1444 /** If @p packed is 1, then this will specify the offset of the solid
1445 * resource in the WIM. */
1446 uint64_t raw_resource_offset_in_wim;
1448 /** If @p packed is 1, then this will specify the compressed size of the
1449 * solid resource in the WIM. */
1450 uint64_t raw_resource_compressed_size;
1452 /** If @p packed is 1, then this will specify the uncompressed size of
1453 * the solid resource in the WIM. */
1454 uint64_t raw_resource_uncompressed_size;
1456 uint64_t reserved[1];
1460 * Information about a stream of a particular file in the WIM.
1462 * Normally, only WIM images captured from NTFS filesystems will have multiple
1463 * streams per file. In practice, this is a rarely used feature of the
1466 struct wimlib_stream_entry {
1467 /** Name of the stream, or NULL if the stream is unnamed. */
1468 const wimlib_tchar *stream_name;
1469 /** Location, size, and other information about the stream's data as
1470 * stored in the WIM file. */
1471 struct wimlib_resource_entry resource;
1472 uint64_t reserved[4];
1475 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1476 * Roughly, the information about a "file" in the WIM--- but really a directory
1477 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1478 * field can be used to distinguish actual file inodes. */
1479 struct wimlib_dir_entry {
1480 /** Name of the file, or NULL if this file is unnamed. Only the root
1481 * directory of an image will be unnamed. */
1482 const wimlib_tchar *filename;
1484 /** 8.3 name (or "DOS name", or "short name") of this file; or NULL if
1485 * this file has no such name. */
1486 const wimlib_tchar *dos_name;
1488 /** Full path to this file within the WIM image. Path separators will
1489 * be ::WIMLIB_WIM_PATH_SEPARATOR. */
1490 const wimlib_tchar *full_path;
1492 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1493 * children, ..., etc. */
1496 /** Pointer to the security descriptor for this file, in Windows
1497 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1498 * security descriptor. */
1499 const char *security_descriptor;
1501 /** Length of the above security descriptor. */
1502 size_t security_descriptor_size;
1504 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1505 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1506 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1507 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1508 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1509 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1510 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1511 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1512 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1513 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1514 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1515 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1516 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1517 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1518 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1519 /** File attributes, such as whether the file is a directory or not.
1520 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1521 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1522 * on other platforms. */
1523 uint32_t attributes;
1525 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1526 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1527 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1528 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1529 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1530 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1531 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1532 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1533 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1534 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1535 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1536 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1537 /** If the file is a reparse point (FILE_ATTRIBUTE_REPARSE_POINT set in
1538 * the attributes), this will give the reparse tag. This tells you
1539 * whether the reparse point is a symbolic link, junction point, or some
1540 * other, more unusual kind of reparse point. */
1541 uint32_t reparse_tag;
1543 /** Number of links to this file's inode (hard links).
1545 * Currently, this will always be 1 for directories. However, it can be
1546 * greater than 1 for nondirectory files. */
1549 /** Number of named data streams this file has. Normally 0. */
1550 uint32_t num_named_streams;
1552 /** A unique identifier for this file's inode. However, as a special
1553 * case, if the inode only has a single link (@p num_links == 1), this
1556 * Note: if a WIM image is captured from a filesystem, this value is not
1557 * guaranteed to be the same as the original number of the inode on the
1559 uint64_t hard_link_group_id;
1561 /** Time this file was created. */
1562 struct timespec creation_time;
1564 /** Time this file was last written to. */
1565 struct timespec last_write_time;
1567 /** Time this file was last accessed. */
1568 struct timespec last_access_time;
1570 /** The UNIX user ID of this file. This is a wimlib extension.
1572 * This field is only valid if @p unix_mode != 0. */
1575 /** The UNIX group ID of this file. This is a wimlib extension.
1577 * This field is only valid if @p unix_mode != 0. */
1580 /** The UNIX mode of this file. This is a wimlib extension.
1582 * If this field is 0, then @p unix_uid, @p unix_gid, @p unix_mode, and
1583 * @p unix_rdev are all unknown (fields are not present in the WIM
1587 /** The UNIX device ID (major and minor number) of this file. This is a
1590 * This field is only valid if @p unix_mode != 0. */
1593 uint64_t reserved[14];
1596 * Array of streams that make up this file.
1598 * The first entry will always exist and will correspond to the unnamed
1599 * data stream (default file contents), so it will have <c>stream_name
1600 * == NULL</c>. Alternatively, for reparse point files, the first entry
1601 * will corresponding to the reparse data stream.
1603 * Then, following the first entry, there be @p num_named_streams
1604 * additional entries that specify the named data streams, if any, each
1605 * of which will have <c>stream_name != NULL</c>.
1607 struct wimlib_stream_entry streams[];
1611 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1614 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1618 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1621 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1624 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1625 * just on the specified path. */
1626 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1628 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1629 * itself; only its children (in the case of a non-empty directory) */
1630 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1632 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1633 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1634 * table of the ::WIMStruct. The default behavior without this flag is to fill
1635 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1636 * wimlib_resource_entry::is_missing "is_missing" flag. */
1637 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1641 /** @addtogroup G_modifying_wims
1644 /** UNIX-like systems only: Directly capture an NTFS volume rather than a
1645 * generic directory. This requires that wimlib was compiled with support for
1648 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1649 * ::WIMLIB_ADD_FLAG_UNIX_DATA.
1651 * Do not use this flag on Windows, where wimlib already supports all
1652 * Windows-native filesystems, including NTFS, through the Windows APIs. */
1653 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1655 /** Follow symbolic links when scanning the directory tree. Currently only
1656 * supported on UNIX-like systems. */
1657 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1659 /** Call the progress function with the message
1660 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1662 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1664 /** Mark the image being added as the bootable image of the WIM. This flag is
1665 * valid only for wimlib_add_image() and wimlib_add_image_multisource().
1667 * Note that you can also change the bootable image of a WIM using
1668 * wimlib_set_wim_info().
1670 * Note: ::WIMLIB_ADD_FLAG_BOOT does something different from, and independent
1671 * from, ::WIMLIB_ADD_FLAG_WIMBOOT. */
1672 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1674 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1675 * (major and minor number) of each file. Also allows capturing special files
1676 * such as device nodes and FIFOs. See the documentation for the
1677 * <b>--unix-data</b> option to <b>wimlib-imagex capture</b> for more
1679 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1681 /** Do not capture security descriptors. Only has an effect in NTFS capture
1682 * mode, or in Windows native builds. */
1683 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1685 /** Fail immediately if the full security descriptor of any file or directory
1686 * cannot be accessed. Only has an effect in Windows native builds. The
1687 * default behavior without this flag is to first try omitting the SACL from the
1688 * security descriptor, then to try omitting the security descriptor entirely.
1690 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1692 /** Call the progress function with the message
1693 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1694 * capture. This is a subset of the messages provided by
1695 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1696 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1698 /** Reparse-point fixups: Modify absolute symbolic links (and junctions, in the
1699 * case of Windows) that point inside the directory being captured to instead be
1700 * absolute relative to the directory being captured.
1702 * Without this flag, the default is to do reparse-point fixups if
1703 * WIM_HDR_FLAG_RP_FIX is set in the WIM header or if this is the first image
1704 * being added. WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is
1705 * captured with reparse point fixups enabled and currently cannot be unset. */
1706 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1708 /** Don't do reparse point fixups. See ::WIMLIB_ADD_FLAG_RPFIX. */
1709 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1711 /** Do not automatically exclude unsupported files or directories from capture;
1712 * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1713 * UNIX-like systems when not also using ::WIMLIB_ADD_FLAG_UNIX_DATA. Instead,
1714 * fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when such a file is encountered. */
1715 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1718 * Automatically select a capture configuration appropriate for capturing
1719 * filesystems containing Windows operating systems. For example,
1720 * "/pagefile.sys" and "System Volume Information" will be excluded.
1722 * When this flag is specified, the corresponding @p config parameter (for
1723 * wimlib_add_image()) or member (for wimlib_update_image()) must be @c NULL.
1724 * Otherwise, ::WIMLIB_ERR_INVALID_PARAM will be returned.
1726 * Note that the default behavior--- that is, when neither
1727 * ::WIMLIB_ADD_FLAG_WINCONFIG nor ::WIMLIB_ADD_FLAG_WIMBOOT is specified and @p
1728 * config is @c NULL--- is to use no capture configuration, meaning that no
1729 * files are excluded from capture.
1731 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1734 * Capture image as WIMBoot compatible. In addition, if no capture
1735 * configuration file is explicitly specified use the capture configuration file
1736 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1737 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1738 * configuration file is explicitly specified, use it and also place it at
1739 * /Windows/System32/WimBootCompress.ini in the WIM image.
1741 * Note: this will not by itself change the compression type. Before writing
1742 * the WIM file, it's recommended to also do:
1745 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1746 * wimlib_set_output_chunk_size(wim, 4096);
1749 * since that makes access to the data faster (at the cost of a worse
1750 * compression ratio compared to the 32768-byte LZX chunks usually used).
1752 * Note: ::WIMLIB_ADD_FLAG_WIMBOOT does something different from, and
1753 * independent from, ::WIMLIB_ADD_FLAG_BOOT.
1755 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1758 * If the add command involves adding a non-directory file to a location at
1759 * which there already exists a nondirectory file in the WIM image, issue
1760 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This only has an
1761 * effect when updating an existing image with wimlib_update_image().
1762 * This was the default behavior in wimlib v1.6.2 and earlier.
1764 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1767 * Send ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION messages to the progress
1770 * Note: This method for file exclusions is independent from the capture
1771 * configuration file mechanism.
1773 #define WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION 0x00004000
1775 /* Note: the WIMLIB_ADD_IMAGE_FLAG names are retained for source compatibility.
1776 * Use the WIMLIB_ADD_FLAG names in new code. */
1777 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1778 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1779 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1780 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1781 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1782 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1783 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1784 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1785 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1786 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1787 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1788 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1789 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1790 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT WIMLIB_ADD_FLAG_WIMBOOT
1794 /** @addtogroup G_modifying_wims
1797 /** Do not issue an error if the path to delete does not exist. */
1798 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1800 /** Delete the file or directory tree recursively; if not specified, an error is
1801 * issued if the path to delete is a directory. */
1802 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1805 /** @addtogroup G_modifying_wims
1809 * If a single image is being exported, mark it bootable in the destination WIM.
1810 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1811 * the image in the source WIM (if any) that is marked as bootable is also
1812 * marked as bootable in the destination WIM.
1814 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1816 /** Give the exported image(s) no names. Avoids problems with image name
1819 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1821 /** Give the exported image(s) no descriptions. */
1822 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1824 /** This advises the library that the program is finished with the source
1825 * WIMStruct and will not attempt to access it after the call to
1826 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1827 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1830 * Mark each exported image as WIMBoot-compatible.
1832 * Note: by itself, this does change the destination WIM's compression type, nor
1833 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1834 * image. Before writing the destination WIM, it's recommended to do something
1838 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1839 * wimlib_set_output_chunk_size(wim, 4096);
1840 * wimlib_add_tree(wim, image, L"myconfig.ini",
1841 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1844 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1847 /** @addtogroup G_extracting_wims
1850 /** Extract the image directly to an NTFS volume rather than a generic directory.
1851 * This mode is only available if wimlib was compiled with libntfs-3g support;
1852 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1853 * extraction target will be interpreted as the path to an NTFS volume image (as
1854 * a regular file or block device) rather than a directory. It will be opened
1855 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1856 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1857 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1858 * wimlib_extract_paths() when passed multiple paths. */
1859 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1861 /** UNIX-like systems only: Extract special UNIX data captured with
1862 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1863 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1864 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1866 /** Do not extract security descriptors. This flag cannot be combined with
1867 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1868 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1870 /** Fail immediately if the full security descriptor of any file or directory
1871 * cannot be set exactly as specified in the WIM file. On Windows, the default
1872 * behavior without this flag when wimlib does not have permission to set the
1873 * correct security descriptor is to fall back to setting the security
1874 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1875 * owner omitted, then not at all. This flag cannot be combined with
1876 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1877 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1879 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1880 * reparse-point fixups on, so absolute symbolic links or junction points will
1881 * be fixed to be absolute relative to the actual extraction root. Reparse-
1882 * point fixups are done by default for wimlib_extract_image() and
1883 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1884 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1885 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1887 /** Force reparse-point fixups on extraction off, regardless of the state of the
1888 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1889 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1890 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1892 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1893 * paths, each of which must name a regular file, to standard output. */
1894 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1896 /** Instead of ignoring files and directories with names that cannot be
1897 * represented on the current platform (note: Windows has more restrictions on
1898 * filenames than POSIX-compliant systems), try to replace characters or append
1899 * junk to the names so that they can be extracted in some form.
1901 * Note: this flag is unlikely to have any effect when extracting a WIM image
1902 * that was captured on Windows.
1904 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1906 /** On Windows, when there exist two or more files with the same case
1907 * insensitive name but different case sensitive names, try to extract them all
1908 * by appending junk to the end of them, rather than arbitrarily extracting only
1911 * Note: this flag is unlikely to have any effect when extracting a WIM image
1912 * that was captured on Windows.
1914 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1916 /** Do not ignore failure to set timestamps on extracted files. This flag
1917 * currently only has an effect when extracting to a directory on UNIX-like
1919 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1921 /** Do not ignore failure to set short names on extracted files. This flag
1922 * currently only has an effect on Windows. */
1923 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1925 /** Do not ignore failure to extract symbolic links and junctions due to
1926 * permissions problems. This flag currently only has an effect on Windows. By
1927 * default, such failures are ignored since the default configuration of Windows
1928 * only allows the Administrator to create symbolic links. */
1929 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1931 /** Reserved for future use. */
1932 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1934 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1935 * paths to extract as wildcard patterns ("globs") which may contain the
1936 * wildcard characters @c ? and @c *. The @c ? character matches any
1937 * non-path-separator character, whereas the @c * character matches zero or more
1938 * non-path-separator characters. Consequently, each glob may match zero or
1939 * more actual paths in the WIM image.
1941 * By default, if a glob does not match any files, a warning but not an error
1942 * will be issued. This is the case even if the glob did not actually contain
1943 * wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error
1946 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1948 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1949 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1950 * one of the provided globs did not match a file. */
1951 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1953 /** Do not extract Windows file attributes such as readonly, hidden, etc.
1955 * This flag has an effect on Windows as well as in the NTFS-3g extraction mode.
1957 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1959 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1960 * preserve the directory structure of the archive when extracting --- that is,
1961 * place each extracted file or directory tree directly in the target directory.
1963 * The target directory will still be created if it does not already exist. */
1964 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1966 /** Windows only: Extract files as "pointers" back to the WIM archive.
1968 * The effects of this option are fairly complex. See the documentation for the
1969 * <b>--wimboot</b> option of <b>wimlib-imagex apply</b> for more information.
1971 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1974 /** @addtogroup G_mounting_wim_images
1977 /** Mount the WIM image read-write rather than the default of read-only. */
1978 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1980 /** Enable FUSE debugging by passing the @c -d option to @c fuse_main(). */
1981 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1983 /** Do not allow accessing named data streams in the mounted WIM image. */
1984 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1986 /** Access named data streams in the mounted WIM image through extended file
1987 * attributes named "user.X", where X is the name of a data stream. This is the
1989 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1991 /** Access named data streams in the mounted WIM image by specifying the file
1992 * name, a colon, then the name of the data stream. */
1993 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1995 /** Use UNIX metadata if available in the WIM image. See
1996 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1997 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1999 /** Allow other users to see the mounted filesystem. This passes the @c
2000 * allow_other option to fuse_main(). */
2001 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
2004 /** @addtogroup G_creating_and_opening_wims
2007 /** Verify the WIM contents against the WIM's integrity table, if present. This
2008 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
2009 * checksummed and checked against the SHA1 message digests specified in the
2010 * integrity table. If there are any mismatches, ::WIMLIB_ERR_INTEGRITY is
2011 * issued. If the WIM file does not contain an integrity table, this flag has
2013 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
2015 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
2016 * WIM. Software can provide this flag for convenience if it explicitly does
2017 * not want to support split WIMs. */
2018 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
2020 /** Check if the WIM is writable and issue an error
2021 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
2022 * only if it is writable at the filesystem level, does not have the
2023 * WIM_HDR_FLAG_READONLY flag set in its header, and is not part of a spanned
2024 * set. It is not required to provide this flag before attempting to make
2025 * changes to the WIM, but with this flag you get an error immediately rather
2026 * than potentially much later, when wimlib_overwrite() is finally called. */
2027 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
2030 /** @addtogroup G_mounting_wim_images
2033 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
2034 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2035 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
2037 /** Commit changes to the read-write mounted WIM image.
2038 * If this flag is not specified, changes will be discarded. */
2039 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
2041 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
2042 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2043 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
2045 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
2046 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2047 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
2050 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
2051 * image, forces all file descriptors to the open WIM image to be closed before
2054 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
2055 * this flag has no effect.
2057 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
2059 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
2060 * WIM image, causes the modified image to be committed to the WIM file as a
2061 * new, unnamed image appended to the archive. The original image in the WIM
2062 * file will be unmodified. */
2063 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
2066 /** @addtogroup G_modifying_wims
2069 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
2070 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
2071 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
2074 /** @addtogroup G_writing_and_overwriting_wims
2078 * Include an integrity table in the resulting WIM file.
2080 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2081 * include an integrity table if and only if one was present before. For
2082 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2083 * to not include an integrity table.
2085 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
2088 * Do not include an integrity table in the resulting WIM file. This is the
2089 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
2092 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
2095 * Write the WIM as "pipable". After writing a WIM with this flag specified,
2096 * images from it can be applied directly from a pipe using
2097 * wimlib_extract_image_from_pipe(). See the documentation for the
2098 * <b>--pipable</b> option of <b>wimlib-imagex capture</b> for more information.
2099 * Beware: WIMs written with this flag will not be compatible with Microsoft's
2102 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2103 * write the WIM as pipable if and only if it was pipable before. For
2104 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2105 * to write the WIM as non-pipable.
2107 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
2110 * Do not write the WIM as "pipable". This is the default behavior, unless the
2111 * ::WIMStruct was created by opening a pipable WIM.
2113 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
2116 * When writing streams to the WIM file, recompress them, even if their data is
2117 * already available in the desired compressed form (for example, in a WIM file
2118 * from which an image has been exported using wimlib_export_image()).
2120 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
2121 * compression ratio for the same compression type and chunk size. Simply using
2122 * the default compression settings may suffice for this, especially if the WIM
2123 * file was created using another program/library that may not use as
2124 * sophisticated compression algorithms. Or,
2125 * wimlib_set_default_compression_level() can be called beforehand to set an
2126 * even higher compression level than the default.
2128 * If the WIM contains solid resources, then ::WIMLIB_WRITE_FLAG_RECOMPRESS can
2129 * be used in combination with ::WIMLIB_WRITE_FLAG_SOLID to prevent any solid
2130 * resources from being re-used. Otherwise, solid resources are re-used
2131 * somewhat more liberally than normal compressed resources.
2133 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
2134 * that would not otherwise be written. For example, a call to
2135 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
2136 * cause already-existing streams in the WIM file to be recompressed. To force
2137 * the WIM file to be fully rebuilt and recompressed, combine
2138 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
2140 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
2143 * Immediately before closing the WIM file, sync its data to disk.
2145 * This flag forces the function to wait until the data is safely on disk before
2146 * returning success. Otherwise, modern operating systems tend to cache data
2147 * for some time (in some cases, 30+ seconds) before actually writing it to
2148 * disk, even after reporting to the application that the writes have succeeded.
2150 * wimlib_overwrite() will set this flag automatically if it decides to
2151 * overwrite the WIM file via a temporary file instead of in-place. This is
2152 * necessary on POSIX systems; it will, for example, avoid problems with delayed
2153 * allocation on ext4.
2155 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
2158 * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
2159 * could be updated in-place by appending to it.
2161 * When rebuilding the WIM file, stream reference counts will be recomputed, and
2162 * any streams with 0 reference count (e.g. from deleted files or images) will
2163 * not be included in the resulting WIM file. This can free up space that is
2164 * currently not being used.
2166 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
2167 * data to be recompressed. Otherwise, compressed data is re-used if possible.
2169 * wimlib_write() ignores this flag.
2171 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
2174 * For wimlib_overwrite(), override the default behavior after one or more calls
2175 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
2176 * flag, only minimal changes to correctly remove the image from the WIM file
2177 * will be taken. In particular, all streams will be retained, even if they are
2178 * no longer referenced. This may not be what you want, because no space will
2179 * be saved by deleting an image in this way.
2181 * wimlib_write() ignores this flag.
2183 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
2186 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
2187 * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header. This can be used
2188 * following a call to wimlib_set_wim_info() with the
2189 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
2192 * wimlib_write() ignores this flag.
2194 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
2197 * Do not include streams already present in other WIMs. This flag can be used
2198 * to write a "delta" WIM after resources from the WIM on which the delta is to
2199 * be based were referenced with wimlib_reference_resource_files() or
2200 * wimlib_reference_resources().
2202 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
2205 * Advises the library that for writes of all WIM images, all streams needed for
2206 * the WIM are already present (not in external resource WIMs) and their
2207 * reference counts are correct, so the code does not need to recalculate which
2208 * streams are referenced. This is for optimization purposes only, since with
2209 * this flag specified, the metadata resources may not need to be decompressed
2212 * wimlib_overwrite() will set this flag automatically.
2214 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
2217 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
2219 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
2222 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
2225 * When writing streams to the resulting WIM file, combine multiple streams into
2226 * a single compressed resource instead of compressing them independently. This
2227 * is also known as creating a "solid archive". This tends to produce a better
2228 * compression ratio at the cost of much slower random access.
2230 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
2231 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
2232 * created with this flag use a different version number in their header (3584
2233 * instead of 68864) and are also called "ESD files".
2235 * If this flag is passed to wimlib_overwrite(), any new data streams will be
2236 * written in solid mode. Use both ::WIMLIB_WRITE_FLAG_REBUILD and
2237 * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
2238 * all streams recompressed in solid mode.
2240 * Currently, new solid resources will, by default, be written using LZMS
2241 * compression with 64 MiB (67108864 byte) chunks. Use
2242 * wimlib_set_output_pack_compression_type() and/or
2243 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
2244 * the WIM's main compression type and chunk size; you can have a WIM that
2245 * nominally uses LZX compression and 32768 byte chunks but actually contains
2246 * LZMS-compressed solid resources, for example. However, if including solid
2247 * resources, I suggest that you set the WIM's main compression type to LZMS as
2248 * well, either by creating the WIM with
2249 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
2250 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
2252 * This flag will be set by default when writing or overwriting a WIM file that
2253 * either already contains solid resources, or has had solid resources exported
2254 * into it and the WIM's main compression type is LZMS.
2256 #define WIMLIB_WRITE_FLAG_SOLID 0x00001000
2259 * Deprecated: this is the old name for ::WIMLIB_WRITE_FLAG_SOLID, retained for
2260 * source compatibility.
2262 #define WIMLIB_WRITE_FLAG_PACK_STREAMS WIMLIB_WRITE_FLAG_SOLID
2265 * Send ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE messages while writing the WIM
2266 * file. This is only needed in the unusual case that the library user needs to
2267 * know exactly when wimlib has read each file for the last time.
2269 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
2272 * If using solid compression, do not sort the streams ("files") to compress by
2273 * estimated content similarily. This flag only has an effect if
2274 * ::WIMLIB_WRITE_FLAG_SOLID is also specified.
2276 #define WIMLIB_WRITE_FLAG_NO_SOLID_SORT 0x00004000
2279 /** @addtogroup G_general
2282 /** Assume that strings are represented in UTF-8, even if this is not the
2283 * locale's character encoding. This flag is ignored on Windows, where wimlib
2284 * always uses UTF-16LE. */
2285 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
2287 /** Windows-only: do not attempt to acquire additional privileges (currently
2288 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
2289 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
2290 * for the case where the calling program manages these privileges itself.
2291 * Note: no error is issued if privileges cannot be acquired, although related
2292 * errors may be reported later, depending on if the operations performed
2293 * actually require additional privileges or not. */
2294 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
2296 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2297 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2298 * to read all possible data and metadata for a capture operation could not be
2299 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
2301 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
2303 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2304 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2305 * to restore all possible data and metadata for an apply operation could not be
2306 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
2308 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
2310 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
2312 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
2314 /** Default to interpreting WIM paths case insensitively (default on Windows).
2315 * This does not apply to mounted images. */
2316 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
2319 /** @addtogroup G_nonstandalone_wims
2322 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
2323 * Ignored by wimlib_reference_resources(). */
2324 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
2326 /** For wimlib_reference_resource_files(), issue an error
2327 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
2328 * default behavior without this flag is to issue no error at that point, but
2329 * then attempt to open the glob as a literal path, which of course will fail
2330 * anyway if no file exists at that path. No effect if
2331 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
2332 * wimlib_reference_resources(). */
2333 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
2336 /** @addtogroup G_modifying_wims
2339 /** The specific type of update to perform. */
2340 enum wimlib_update_op {
2341 /** Add a new file or directory tree to the WIM image in a
2342 * certain location. */
2343 WIMLIB_UPDATE_OP_ADD = 0,
2345 /** Delete a file or directory tree from the WIM image. */
2346 WIMLIB_UPDATE_OP_DELETE,
2348 /** Rename a file or directory tree in the WIM image. */
2349 WIMLIB_UPDATE_OP_RENAME,
2352 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2353 struct wimlib_add_command {
2354 /** Filesystem path to the file or directory tree to add. */
2355 wimlib_tchar *fs_source_path;
2357 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
2358 * specify the root directory of the WIM image. */
2359 wimlib_tchar *wim_target_path;
2361 /** Path to capture configuration file to use, or @c NULL for default.
2363 wimlib_tchar *config_file;
2365 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2369 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2370 struct wimlib_delete_command {
2372 /** Path, specified from the root of the WIM image, for the file or
2373 * directory tree within the WIM image to be deleted. */
2374 wimlib_tchar *wim_path;
2376 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2380 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2381 struct wimlib_rename_command {
2383 /** Path, specified from the root of the WIM image, for the source file
2384 * or directory tree within the WIM image. */
2385 wimlib_tchar *wim_source_path;
2387 /** Path, specified from the root of the WIM image, for the destination
2388 * file or directory tree within the WIM image. */
2389 wimlib_tchar *wim_target_path;
2391 /** Reserved; set to 0. */
2395 /** Specification of an update to perform on a WIM image. */
2396 struct wimlib_update_command {
2398 enum wimlib_update_op op;
2401 struct wimlib_add_command add;
2402 struct wimlib_delete_command delete_; /* Underscore is for C++
2404 struct wimlib_rename_command rename;
2409 /** @addtogroup G_general
2413 * Possible values of the error code returned by many functions in wimlib.
2415 * See the documentation for each wimlib function to see specifically what error
2416 * codes can be returned by a given function, and what they mean.
2418 enum wimlib_error_code {
2419 WIMLIB_ERR_SUCCESS = 0,
2420 WIMLIB_ERR_ALREADY_LOCKED = 1,
2421 WIMLIB_ERR_DECOMPRESSION = 2,
2422 WIMLIB_ERR_FUSE = 6,
2423 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2424 WIMLIB_ERR_ICONV_NOT_AVAILABLE = 9,
2425 WIMLIB_ERR_IMAGE_COUNT = 10,
2426 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2427 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2428 WIMLIB_ERR_INTEGRITY = 13,
2429 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2430 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2431 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2432 WIMLIB_ERR_INVALID_HEADER = 17,
2433 WIMLIB_ERR_INVALID_IMAGE = 18,
2434 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2435 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2436 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2437 WIMLIB_ERR_INVALID_MULTIBYTE_STRING = 22,
2438 WIMLIB_ERR_INVALID_OVERLAY = 23,
2439 WIMLIB_ERR_INVALID_PARAM = 24,
2440 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2441 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2442 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2443 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2444 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2445 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2446 WIMLIB_ERR_IS_DIRECTORY = 32,
2447 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2448 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE = 34,
2449 WIMLIB_ERR_LINK = 35,
2450 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2451 WIMLIB_ERR_MKDIR = 37,
2452 WIMLIB_ERR_MQUEUE = 38,
2453 WIMLIB_ERR_NOMEM = 39,
2454 WIMLIB_ERR_NOTDIR = 40,
2455 WIMLIB_ERR_NOTEMPTY = 41,
2456 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2457 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2458 WIMLIB_ERR_NOT_PIPABLE = 44,
2459 WIMLIB_ERR_NO_FILENAME = 45,
2460 WIMLIB_ERR_NTFS_3G = 46,
2461 WIMLIB_ERR_OPEN = 47,
2462 WIMLIB_ERR_OPENDIR = 48,
2463 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2464 WIMLIB_ERR_READ = 50,
2465 WIMLIB_ERR_READLINK = 51,
2466 WIMLIB_ERR_RENAME = 52,
2467 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2468 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2469 WIMLIB_ERR_RESOURCE_ORDER = 56,
2470 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2471 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2472 WIMLIB_ERR_SET_SECURITY = 59,
2473 WIMLIB_ERR_SET_SHORT_NAME = 60,
2474 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2475 WIMLIB_ERR_SPLIT_INVALID = 62,
2476 WIMLIB_ERR_STAT = 63,
2477 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2478 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2479 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2480 WIMLIB_ERR_UNSUPPORTED = 68,
2481 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2482 WIMLIB_ERR_WIM_IS_READONLY = 71,
2483 WIMLIB_ERR_WRITE = 72,
2484 WIMLIB_ERR_XML = 73,
2485 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2486 WIMLIB_ERR_WIMBOOT = 75,
2487 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2488 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2489 WIMLIB_ERR_MKNOD = 78,
2490 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2491 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2492 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2493 WIMLIB_ERR_FVE_LOCKED_VOLUME = 82,
2497 /** Used to indicate no WIM image or an invalid WIM image. */
2498 #define WIMLIB_NO_IMAGE 0
2500 /** Used to specify all images in the WIM. */
2501 #define WIMLIB_ALL_IMAGES (-1)
2506 * @ingroup G_modifying_wims
2508 * Appends an empty image to a WIM file. This empty image will initially
2509 * contain no files or directories, although if written without further
2510 * modifications, a root directory will be created automatically for it. After
2511 * calling this function, you can use wimlib_update_image() to add files to the
2512 * new WIM image. This gives you slightly more control over making the new
2513 * image compared to calling wimlib_add_image() or
2514 * wimlib_add_image_multisource() directly.
2517 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2520 * Name to give the new image. If @c NULL or empty, the new image is given
2521 * no name. If nonempty, it must specify a name that does not already
2523 * @param new_idx_ret
2524 * If non-<code>NULL</code>, the index of the newly added image is returned
2527 * @return 0 on success; nonzero on failure. The possible error codes are:
2529 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2530 * There is already an image in @p wim named @p name.
2531 * @retval ::WIMLIB_ERR_NOMEM
2532 * Failed to allocate the memory needed to add the new image.
2535 wimlib_add_empty_image(WIMStruct *wim,
2536 const wimlib_tchar *name,
2540 * @ingroup G_modifying_wims
2542 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2544 * The directory tree or NTFS volume is scanned immediately to load the dentry
2545 * tree into memory, and file attributes and symbolic links are read. However,
2546 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2549 * See the manual page for the @b wimlib-imagex program for more information
2550 * about the "normal" capture mode versus the NTFS capture mode (entered by
2551 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2553 * Note that @b no changes are committed to the underlying WIM file (if
2554 * any) until wimlib_write() or wimlib_overwrite() is called.
2557 * Pointer to the ::WIMStruct to which to add the image.
2559 * A path to a directory or unmounted NTFS volume that will be captured as
2562 * Name to give the new image. If @c NULL or empty, the new image is given
2563 * no name. If nonempty, it must specify a name that does not already
2565 * @param config_file
2566 * Path to capture configuration file, or @c NULL. This file may specify,
2567 * among other things, which files to exclude from capture. See the man
2568 * page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2569 * details of the file format. If @c NULL, the default capture
2570 * configuration shall be used. Ordinarily, the default capture
2571 * configuration will result in no files being excluded from capture purely
2572 * based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2573 * ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2575 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2577 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2578 * discarded so that it appears to be in the same state as when this function
2581 * This function is implemented by calling wimlib_add_empty_image(), then
2582 * calling wimlib_update_image() with a single "add" command, so any error code
2583 * returned by wimlib_add_empty_image() may be returned, as well as any error
2584 * codes returned by wimlib_update_image() other than ones documented as only
2585 * being returned specifically by an update involving delete or rename commands.
2587 * If a progress function is registered with @p wim, it will receive the
2588 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2589 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2590 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2593 wimlib_add_image(WIMStruct *wim,
2594 const wimlib_tchar *source,
2595 const wimlib_tchar *name,
2596 const wimlib_tchar *config_file,
2600 * @ingroup G_modifying_wims
2602 * This function is equivalent to wimlib_add_image() except it allows for
2603 * multiple sources to be combined into a single WIM image. This is done by
2604 * specifying the @p sources and @p num_sources parameters instead of the @p
2605 * source parameter of wimlib_add_image(). The rest of the parameters are the
2606 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2607 * capture</b> for full details on how this mode works.
2609 * In addition to the error codes that wimlib_add_image() can return,
2610 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2611 * when trying to overlay a non-directory on a directory or when otherwise
2612 * trying to overlay multiple conflicting files to the same location in the WIM
2613 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2614 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2615 * was not exactly one capture source with the target being the root directory.
2616 * (In this respect, there is no advantage to using
2617 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2620 wimlib_add_image_multisource(WIMStruct *wim,
2621 const struct wimlib_capture_source *sources,
2623 const wimlib_tchar *name,
2624 const wimlib_tchar *config_file,
2628 * @ingroup G_modifying_wims
2630 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2631 * location @p wim_target_path within the specified @p image of the @p wim.
2633 * This just builds an appropriate ::wimlib_add_command and passes it to
2634 * wimlib_update_image().
2637 wimlib_add_tree(WIMStruct *wim, int image,
2638 const wimlib_tchar *fs_source_path,
2639 const wimlib_tchar *wim_target_path, int add_flags);
2642 * @ingroup G_creating_and_opening_wims
2644 * Creates a ::WIMStruct for a new WIM file.
2646 * This only creates an in-memory structure for a WIM that initially contains no
2647 * images. No on-disk file is created until wimlib_write() is called.
2650 * The type of compression to be used in the new WIM file, as one of the
2651 * ::wimlib_compression_type constants.
2653 * This choice is not necessarily final; if desired, it can still be
2654 * changed at any time before the WIM is written to disk, using
2655 * wimlib_set_output_compression_type(). In addition, if you wish to use a
2656 * non-default chunk size, you will need to call
2657 * wimlib_set_output_chunk_size().
2659 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2660 * written to the memory location pointed to by this parameter. The
2661 * ::WIMStruct must be freed using using wimlib_free() when finished with
2663 * @return 0 on success; nonzero on error.
2664 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2665 * @p ctype was not a supported compression type.
2666 * @retval ::WIMLIB_ERR_NOMEM
2667 * Failed to allocate needed memory.
2670 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2673 * @ingroup G_modifying_wims
2675 * Deletes an image, or all images, from a WIM file.
2677 * Note: no changes are committed to the underlying WIM file (if any) until
2678 * wimlib_write() or wimlib_overwrite() is called.
2681 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2684 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2687 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2688 * to be left unmodified only if @p image specified a single image. If instead
2689 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2690 * possible for some but not all of the images to have been deleted when a
2691 * failure status is returned.
2693 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2694 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2696 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2697 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2698 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2699 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2700 * different reasons) to read the metadata resource for an image that needed to
2704 wimlib_delete_image(WIMStruct *wim, int image);
2707 * @ingroup G_modifying_wims
2709 * Delete the @p path from the specified @p image of the @p wim.
2711 * This just builds an appropriate ::wimlib_delete_command and passes it to
2712 * wimlib_update_image().
2715 wimlib_delete_path(WIMStruct *wim, int image,
2716 const wimlib_tchar *path, int delete_flags);
2719 * @ingroup G_modifying_wims
2721 * Exports an image, or all the images, from a WIM file, into another WIM file.
2723 * The destination image is made to share the same dentry tree and security data
2724 * structure as the source image. This places some restrictions on additional
2725 * functions that may be called. For example, you may not call wimlib_free() on
2726 * @p src_wim before calling wimlib_write() or wimlib_overwrite() on @p dest_wim
2727 * because @p dest_wim will have references back to @p src_wim.
2729 * If this function fails, all changes to @p dest_wim are rolled back.
2731 * Please note that no changes are committed to the underlying WIM file of @p
2732 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2735 * The WIM from which to export the images, specified as a pointer to the
2736 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2737 * split WIM. In the case of a WIM file that is not standalone, this
2738 * ::WIMStruct must have had any needed external resources previously
2739 * referenced using wimlib_reference_resources() or
2740 * wimlib_reference_resource_files().
2742 * The image to export from @p src_wim, as either a 1-based image index to
2743 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2745 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2748 * For single-image exports, the name to give the exported image in @p
2749 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2750 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2751 * that case, the names are all taken from @p src_wim. This parameter is
2752 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2753 * @param dest_description
2754 * For single-image exports, the description to give the exported image in
2755 * the new WIM file. If left @c NULL, the description from @p src_wim is
2756 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2757 * NULL; in that case, the description are all taken from @p src_wim. This
2758 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2759 * @param export_flags
2760 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2762 * @return 0 on success; nonzero on error.
2763 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2764 * One or more of the names being given to an exported image was already in
2765 * use in the destination WIM.
2766 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2767 * @p src_image does not exist in @p src_wim and was not
2768 * ::WIMLIB_ALL_IMAGES.
2769 * @retval ::WIMLIB_ERR_INVALID_PARAM
2770 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2771 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2773 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2774 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2775 * example, one of them was a non-first part of a split WIM.
2776 * @retval ::WIMLIB_ERR_NOMEM
2777 * Failed to allocate needed memory.
2778 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2779 * A resource that needed to be exported could not be found in either the
2780 * source or destination WIMs. This error can occur if, for example, @p
2781 * src_wim is part of a split WIM but needed resources from the other split
2782 * WIM parts were not referenced with wimlib_reference_resources() or
2783 * wimlib_reference_resource_files() before the call to
2784 * wimlib_export_image().
2786 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2787 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2788 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2789 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2790 * different reasons) to read the metadata resource for an image in @p src_wim
2791 * that needed to be exported.
2794 wimlib_export_image(WIMStruct *src_wim, int src_image,
2795 WIMStruct *dest_wim,
2796 const wimlib_tchar *dest_name,
2797 const wimlib_tchar *dest_description,
2801 * @ingroup G_extracting_wims
2803 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2806 * The exact behavior of how wimlib extracts files from a WIM image is
2807 * controllable by the @p extract_flags parameter, but there also are
2808 * differences depending on the platform (UNIX-like vs Windows). See the manual
2809 * page for <b>wimlib-imagex apply</b> for more information, including about the
2810 * NTFS-3g extraction mode.
2813 * The WIM from which to extract the image(s), specified as a pointer to
2814 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2815 * of a split WIM. In the case of a WIM file that is not standalone, this
2816 * ::WIMStruct must have had any needed external resources previously
2817 * referenced using wimlib_reference_resources() or
2818 * wimlib_reference_resource_files().
2820 * The image to extract, specified as either the 1-based index of a single
2821 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2822 * to be extracted. However, ::WIMLIB_ALL_IMAGES cannot be used if
2823 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2825 * Directory to extract the WIM image(s) to; or, with
2826 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2827 * the unmounted NTFS volume to which to extract the image.
2828 * @param extract_flags
2829 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2831 * @return 0 on success; nonzero on error.
2832 * @retval ::WIMLIB_ERR_DECOMPRESSION
2833 * Failed to decompress data contained in the WIM.
2834 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2835 * The metadata for one of the images to extract was invalid.
2836 * @retval ::WIMLIB_ERR_INVALID_PARAM
2837 * The extraction flags were invalid; more details may be found in the
2838 * documentation for the specific extraction flags that were specified. Or
2839 * @p target was @c NULL or an empty string, or @p wim was @c NULL.
2840 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2841 * The SHA1 message digest of an extracted stream did not match the SHA1
2842 * message digest given in the WIM. In other words, the WIM file is
2843 * corrupted, so the data cannot be extracted in its original form.
2844 * @retval ::WIMLIB_ERR_LINK
2845 * Failed to create a symbolic link or a hard link.
2846 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2847 * The metadata resource for one of the images to extract was not found.
2848 * This can happen if @p wim represents a non-first part of a split WIM.
2849 * @retval ::WIMLIB_ERR_MKDIR
2850 * Failed create a directory.
2851 * @retval ::WIMLIB_ERR_NOMEM
2852 * Failed to allocate needed memory.
2853 * @retval ::WIMLIB_ERR_OPEN
2854 * Could not create a file, or failed to open an already-extracted file.
2855 * @retval ::WIMLIB_ERR_READ
2856 * Failed to read data from the WIM.
2857 * @retval ::WIMLIB_ERR_READLINK
2858 * Failed to determine the target of a symbolic link in the WIM.
2859 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2860 * Failed to fix the target of an absolute symbolic link (e.g. if the
2861 * target would have exceeded the maximum allowed length). (Only if
2862 * reparse data was supported by the extraction mode and
2863 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2865 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2866 * One of the files or directories that needed to be extracted referenced a
2867 * stream not present in the WIM's lookup table (or in any of the lookup
2868 * tables of the split WIM parts). This can happen if the WIM is not
2869 * standalone and the necessary resource WIMs, or split WIM parts, were not
2870 * referenced with wimlib_reference_resource_files().
2871 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2872 * Failed to set attributes on a file.
2873 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2874 * Failed to set reparse data on a file (only if reparse data was supported
2875 * by the extraction mode).
2876 * @retval ::WIMLIB_ERR_SET_SECURITY
2877 * Failed to set security descriptor on a file.
2878 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2879 * Failed to set the short name of a file.
2880 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2881 * Failed to set timestamps on a file.
2882 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2883 * Unexpected end-of-file occurred when reading data from the WIM.
2884 * @retval ::WIMLIB_ERR_UNSUPPORTED
2885 * A requested extraction flag, or the data or metadata that must be
2886 * extracted to support it, is unsupported in the build and configuration
2887 * of wimlib, or on the current platform or extraction mode or target
2888 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2889 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2890 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2891 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2892 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2893 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2894 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2895 * image contains one or more files with short names, but extracting short
2896 * names is not supported --- on Windows, this occurs if the target volume
2897 * does not support short names, while on non-Windows, this occurs if
2898 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2899 * @retval ::WIMLIB_ERR_WIMBOOT
2900 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2901 * there was a problem creating WIMBoot pointer files.
2902 * @retval ::WIMLIB_ERR_WRITE
2903 * Failed to write data to a file being extracted.
2905 * If a progress function is registered with @p wim, then as each image is
2906 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2907 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE messages, then zero
2908 * or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then zero or more
2909 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, then
2910 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2913 wimlib_extract_image(WIMStruct *wim, int image,
2914 const wimlib_tchar *target, int extract_flags);
2917 * @ingroup G_extracting_wims
2919 * Extract one image from a pipe on which a pipable WIM is being sent.
2921 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE, and @ref
2922 * subsec_pipable_wims, for more information about pipable WIMs.
2924 * This function operates in a special way to read the WIM fully sequentially.
2925 * As a result, there is no ::WIMStruct is made visible to library users, and
2926 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2927 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2928 * seekable file, not a pipe.)
2931 * File descriptor, which may be a pipe, opened for reading and positioned
2932 * at the start of the pipable WIM.
2933 * @param image_num_or_name
2934 * String that specifies the 1-based index or name of the image to extract.
2935 * It is translated to an image index using the same rules that
2936 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2937 * only a single image (not all images) can be specified. Alternatively,
2938 * specify @p NULL here to use the first image in the WIM if it contains
2939 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2941 * Same as the corresponding parameter to wimlib_extract_image().
2942 * @param extract_flags
2943 * Same as the corresponding parameter to wimlib_extract_image().
2945 * @return 0 on success; nonzero on error. The possible error codes include
2946 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2949 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2950 * Data read from the pipable WIM was invalid.
2951 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2952 * The WIM being piped over @p pipe_fd is a normal WIM, not a pipable WIM.
2955 wimlib_extract_image_from_pipe(int pipe_fd,
2956 const wimlib_tchar *image_num_or_name,
2957 const wimlib_tchar *target, int extract_flags);
2960 * @ingroup G_extracting_wims
2962 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2963 * function. The progress function will be used while extracting the WIM image
2964 * and will receive the normal extraction progress messages, such as
2965 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2966 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2969 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2970 const wimlib_tchar *image_num_or_name,
2971 const wimlib_tchar *target,
2973 wimlib_progress_func_t progfunc,
2977 * @ingroup G_extracting_wims
2979 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
2980 * image are specified in the ASCII, UTF-8, or UTF-16LE text file named by @p
2981 * path_list_file which itself contains the list of paths to use, one per line.
2982 * Leading and trailing whitespace is ignored. Empty lines and lines beginning
2983 * with the ';' or '#' characters are ignored. No quotes are needed, as paths
2984 * are otherwise delimited by the newline character. However, quotes will be
2985 * stripped if present.
2987 * The error codes are the same as those returned by wimlib_extract_paths(),
2988 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2989 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2990 * ::WIMLIB_ERR_READ).
2993 wimlib_extract_pathlist(WIMStruct *wim, int image,
2994 const wimlib_tchar *target,
2995 const wimlib_tchar *path_list_file,
2999 * @ingroup G_extracting_wims
3001 * Extract zero or more paths (files or directory trees) from the specified WIM
3004 * By default, each path will be extracted to a corresponding subdirectory of
3005 * the target based on its location in the WIM image. For example, if one of
3006 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
3007 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
3008 * can be changed by providing the flag
3009 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
3010 * or directory tree to be placed directly in the target directory --- so the
3011 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
3013 * Symbolic links will not be dereferenced when paths in the WIM image are
3017 * WIM from which to extract the paths, specified as a pointer to the
3018 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
3019 * split WIM. In the case of a WIM file that is not standalone, this
3020 * ::WIMStruct must have had any needed external resources previously
3021 * referenced using wimlib_reference_resources() or
3022 * wimlib_reference_resource_files().
3024 * 1-based index of the WIM image from which to extract the paths.
3026 * Array of paths to extract. Each element must be the absolute path to a
3027 * file or directory within the WIM image. Separators may be either
3028 * forwards or backwards slashes, and leading path separators are optional.
3029 * The paths will be interpreted either case-sensitively (UNIX default) or
3030 * case-insensitively (Windows default); however, the behavior can be
3031 * configured explicitly at library initialization time by passing an
3032 * appropriate flag to wimlib_global_init().
3034 * By default, the characters @c * and @c ? are interpreted literally.
3035 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
3038 * By default, if any paths to extract do not exist, the error code
3039 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
3040 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
3042 * Number of paths specified in @p paths.
3044 * Directory to which to extract the paths; or with
3045 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
3046 * unmounted NTFS volume to which to extract the paths. Unlike the @p
3047 * paths being extracted, the @p target must be native path. On UNIX-like
3048 * systems it may not contain backslashes, for example.
3049 * @param extract_flags
3050 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
3052 * @return 0 on success; nonzero on error. Most of the error codes are the same
3053 * as those returned by wimlib_extract_image(). Below, some of the error codes
3054 * returned in situations specific to path-mode extraction are documented:
3056 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3057 * One of the paths to extract did not exist in the WIM image. This error
3058 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
3059 * specified in @p extract_flags, or if both
3060 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
3061 * were specified in @p extract_flags.
3062 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
3063 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
3064 * one of the paths to extract did not name a regular file.
3066 * If a progress function is registered with @p wim, it will receive
3067 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. Note that because the extraction code
3068 * is stream-based and not file-based, there is no way to get information about
3069 * which path is currently being extracted, but based on byte count you can
3070 * still calculate an approximate percentage complete for the extraction overall
3071 * which may be all you really need anyway.
3074 wimlib_extract_paths(WIMStruct *wim,
3076 const wimlib_tchar *target,
3077 const wimlib_tchar * const *paths,
3082 * @ingroup G_wim_information
3084 * Extracts the XML data of a WIM file to a file stream. Every WIM file
3085 * includes a string of XML that describes the images contained in the WIM.
3087 * See wimlib_get_xml_data() to read the XML data into memory instead.
3090 * Pointer to the ::WIMStruct to query. This need not represent a
3091 * standalone WIM (e.g. it could represent part of a split WIM).
3093 * @c stdout, or a FILE* opened for writing, to extract the data to.
3095 * @return 0 on success; nonzero on error.
3096 * @retval ::WIMLIB_ERR_INVALID_PARAM
3097 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
3098 * @retval ::WIMLIB_ERR_NOMEM
3099 * Failed to allocate needed memory.
3100 * @retval ::WIMLIB_ERR_READ
3101 * Error reading the XML data from the WIM file.
3102 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3103 * Error reading the XML data from the WIM file.
3104 * @retval ::WIMLIB_ERR_WRITE
3105 * Failed to completely write the XML data to @p fp.
3108 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
3111 * @ingroup G_general
3113 * Frees all memory allocated for a WIMStruct and closes all files associated
3117 * Pointer to the ::WIMStruct to free.
3119 * @return This function has no return value.
3122 wimlib_free(WIMStruct *wim);
3125 * @ingroup G_general
3127 * Converts a ::wimlib_compression_type value into a string.
3130 * The ::wimlib_compression_type value to convert.
3133 * A statically allocated string naming the compression algorithm,
3134 * such as "None", "LZX", "XPRESS", or "Invalid".
3136 extern const wimlib_tchar *
3137 wimlib_get_compression_type_string(int ctype);
3140 * @ingroup G_general
3142 * Converts an error code into a string describing it.
3145 * The error code returned by one of wimlib's functions.
3148 * Pointer to a statically allocated string describing the error code. If
3149 * the error code is for some reason not recognized by the library, the
3150 * string will be "Unknown error".
3152 extern const wimlib_tchar *
3153 wimlib_get_error_string(enum wimlib_error_code code);
3156 * @ingroup G_wim_information
3158 * Returns the description of the specified image.
3161 * Pointer to the ::WIMStruct to query. This need not represent a
3162 * standalone WIM (e.g. it could represent part of a split WIM).
3164 * The number of the image, numbered starting at 1.
3167 * The description of the image, or @c NULL if there is no such image, or
3168 * @c NULL if the specified image has no description. The description
3169 * string is in library-internal memory and may not be modified or freed;
3170 * in addition, the string will become invalid if the description of the
3171 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
3173 extern const wimlib_tchar *
3174 wimlib_get_image_description(const WIMStruct *wim, int image);
3177 * @ingroup G_wim_information
3179 * Returns the name of the specified image.
3182 * Pointer to the ::WIMStruct to query. This need not represent a
3183 * standalone WIM (e.g. it could represent part of a split WIM).
3185 * The number of the image, numbered starting at 1.
3188 * The name of the image, or @c NULL if there is no such image, or an empty
3189 * string if the image is unnamed. The name string is in
3190 * library-internal memory and may not be modified or freed; in addition,
3191 * the string will become invalid if the name of the image is changed, the
3192 * image is deleted, or the ::WIMStruct is destroyed.
3194 extern const wimlib_tchar *
3195 wimlib_get_image_name(const WIMStruct *wim, int image);
3198 * @ingroup G_general
3200 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
3201 * the major version, the next 10 bits contain the minor version, and the low 10
3202 * bits contain the patch version.
3204 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
3205 * << 20) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
3206 * corresponding header file.
3209 wimlib_get_version(void);
3212 * @ingroup G_wim_information
3214 * Get basic information about a WIM file.
3217 * Pointer to the ::WIMStruct to query. This need not represent a
3218 * standalone WIM (e.g. it could represent part of a split WIM).
3220 * A ::wimlib_wim_info structure that will be filled in with information
3221 * about the WIM file.
3226 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
3229 * @ingroup G_wim_information
3231 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
3232 * includes a string of XML that describes the images contained in the WIM.
3234 * See wimlib_extract_xml_data() to extract the XML data to a file stream
3238 * Pointer to the ::WIMStruct to query. This need not represent a
3239 * standalone WIM (e.g. it could represent part of a split WIM).
3241 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
3242 * XML data is written to this location.
3243 * @param bufsize_ret
3244 * The size of the XML data in bytes is written to this location.
3246 * @return 0 on success; nonzero on error.
3247 * @retval ::WIMLIB_ERR_INVALID_PARAM
3248 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
3249 * @p buf_ret or @p bufsize_ret was @c NULL.
3250 * @retval ::WIMLIB_ERR_NOMEM
3251 * @retval ::WIMLIB_ERR_READ
3252 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3253 * Failed to read the XML data from the WIM.
3256 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
3259 * @ingroup G_general
3261 * Initialization function for wimlib. Call before using any other wimlib
3262 * function except wimlib_set_print_errors(). If not done manually, this
3263 * function will be called automatically with @p init_flags set to
3264 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
3265 * after it has already successfully run.
3268 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
3270 * @return 0 on success; nonzero on failure. Currently, only the following
3271 * error code is defined:
3273 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
3274 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
3275 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
3276 * init_flags, but the corresponding privileges could not be acquired.
3279 wimlib_global_init(int init_flags);
3282 * @ingroup G_general
3284 * Cleanup function for wimlib. You are not required to call this function, but
3285 * it will release any global resources allocated by the library.
3288 wimlib_global_cleanup(void);
3291 * @ingroup G_wim_information
3293 * Determines if an image name is already used by some image in the WIM.
3296 * Pointer to the ::WIMStruct to query. This need not represent a
3297 * standalone WIM (e.g. it could represent part of a split WIM).
3299 * The name to check.
3302 * @c true if there is already an image in @p wim named @p name; @c false
3303 * if there is no image named @p name in @p wim. If @p name is @c NULL or
3304 * the empty string, @c false is returned.
3307 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
3310 * @ingroup G_wim_information
3312 * Iterate through a file or directory tree in the WIM image. By specifying
3313 * appropriate flags and a callback function, you can get the attributes of a
3314 * file in the WIM, get a directory listing, or even get a listing of the entire
3318 * The WIM containing the image(s) over which to iterate, specified as a
3319 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
3320 * or part 1 of a split WIM. In the case of a WIM file that is not
3321 * standalone, this ::WIMStruct should have had any needed external
3322 * resources previously referenced using wimlib_reference_resources() or
3323 * wimlib_reference_resource_files(). If not, see
3324 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
3325 * the behavior when resources are missing.
3328 * The 1-based number of the image in @p wim that contains the files or
3329 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
3330 * iteration on all images in the WIM.
3333 * Path in the WIM image at which to do the iteration.
3336 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3339 * A callback function that will receive each directory entry.
3342 * An extra parameter that will always be passed to the callback function
3345 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3346 * first nonzero value that was returned from @p cb. However, additional error
3347 * codes may be returned, including the following:
3349 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3350 * @p path did not exist in the WIM image.
3351 * @retval ::WIMLIB_ERR_NOMEM
3352 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
3354 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3355 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3356 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3357 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3358 * different reasons) to read the metadata resource for an image over which
3359 * iteration needed to be done.
3362 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3364 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3367 * @ingroup G_wim_information
3369 * Iterate through the lookup table of a WIM file. This can be used to directly
3370 * get a listing of the unique resources contained in a WIM file over all
3371 * images. Both file resources and metadata resources are included. However,
3372 * only resources actually included in the file represented by @a wim, plus
3373 * explicitly referenced external resources (via wimlib_reference_resources() or
3374 * wimlib_reference_resource_files()) are included in the iteration. For
3375 * example, if @p wim represents just one part of a split WIM, then only
3376 * resources in that part will be included, unless other resources were
3377 * explicitly referenced.
3380 * Pointer to the ::WIMStruct to query. This need not represent a
3381 * standalone WIM (e.g. it could represent part of a split WIM).
3384 * Reserved; set to 0.
3387 * A callback function that will receive each resource.
3390 * An extra parameter that will always be passed to the callback function
3393 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3394 * that was returned from @p cb.
3397 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3398 wimlib_iterate_lookup_table_callback_t cb,
3402 * @ingroup G_nonstandalone_wims
3404 * Joins a split WIM into a stand-alone one-part WIM.
3407 * An array of strings that gives the filenames of all parts of the split
3408 * WIM. No specific order is required, but all parts must be included with
3411 * Number of filenames in @p swms.
3412 * @param swm_open_flags
3413 * Open flags for the split WIM parts (e.g.
3414 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3415 * @param wim_write_flags
3416 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3417 * be used to write the joined WIM.
3418 * @param output_path
3419 * The path to write the joined WIM file to.
3421 * @return 0 on success; nonzero on error. This function may return most error
3422 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
3423 * as the following error code:
3425 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3426 * The split WIMs do not form a valid WIM because they do not include all
3427 * the parts of the original WIM, there are duplicate parts, or not all the
3428 * parts have the same GUID and compression type.
3430 * Note: wimlib is generalized enough that this function is not actually needed
3431 * to join a split WIM; instead, you could open the first part of the split WIM,
3432 * then reference the other parts with wimlib_reference_resource_files(), then
3433 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3434 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3438 wimlib_join(const wimlib_tchar * const *swms,
3440 const wimlib_tchar *output_path,
3442 int wim_write_flags);
3445 * @ingroup G_nonstandalone_wims
3447 * Same as wimlib_join(), but allows specifying a progress function. The
3448 * progress function will receive the write progress messages, such as
3449 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3450 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3451 * swm_open_flags, the progress function will receive a series of
3452 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3456 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3458 const wimlib_tchar *output_path,
3460 int wim_write_flags,
3461 wimlib_progress_func_t progfunc,
3466 * @ingroup G_mounting_wim_images
3468 * Mounts an image from a WIM file on a directory read-only or read-write.
3471 * Pointer to the ::WIMStruct containing the image to be mounted.
3473 * The 1-based index of the image to mount.
3475 * The path to an existing empty directory on which to mount the WIM image.
3476 * @param mount_flags
3477 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3478 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3480 * @param staging_dir
3481 * If non-NULL, the name of a directory in which a temporary directory for
3482 * storing modified or added files will be created. Ignored if
3483 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3484 * left @c NULL, the staging directory is created in the same directory as
3485 * the WIM file that @p wim was originally read from. The staging
3486 * directory is automatically deleted when the image is unmounted.
3488 * @return 0 on success; nonzero on error. The possible error codes include:
3490 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3491 * An image from the WIM file is already mounted read-write, or another
3492 * process is currently appending data to the WIM file.
3493 * @retval ::WIMLIB_ERR_FUSE
3494 * A non-zero status code was returned by @c fuse_main().
3495 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3496 * @p image does not specify an existing, single image in @p wim.
3497 * @retval ::WIMLIB_ERR_INVALID_PARAM
3498 * @p wim was @c NULL; or @p dir was NULL or an empty string; or an
3499 * unrecognized flag was specified in @p mount_flags; or the WIM image has
3500 * already been modified in memory (e.g. by wimlib_update_image()).
3501 * @retval ::WIMLIB_ERR_MKDIR
3502 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3503 * staging directory could not be created.
3504 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3505 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3506 * WIM file is considered read-only because of any of the reasons mentioned
3507 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3508 * @retval ::WIMLIB_ERR_UNSUPPORTED
3509 * Mounting is not supported in this build of the library.
3511 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3512 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3513 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3514 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3515 * different reasons) to read the metadata resource for the image to mount.
3517 * The ability to mount WIM image is implemented using FUSE (Filesystem in
3518 * UserSpacE). Depending on how FUSE is set up on your system, this function
3519 * may work as normal users in addition to the root user.
3521 * Mounting WIM images is not supported if wimlib was configured
3522 * <code>--without-fuse</code>. This includes Windows builds of wimlib;
3523 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3525 * Calling this function daemonizes the process, unless
3526 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3528 * It is safe to mount multiple images from the same underlying WIM file
3529 * read-only at the same time, but only if different ::WIMStruct's are used. It
3530 * is @b not safe to mount multiple images from the same WIM file read-write at
3533 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3534 * different process.
3537 wimlib_mount_image(WIMStruct *wim,
3539 const wimlib_tchar *dir,
3541 const wimlib_tchar *staging_dir);
3544 * @ingroup G_creating_and_opening_wims
3546 * Opens a WIM file and creates a ::WIMStruct for it.
3549 * The path to the WIM file to open.
3552 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3555 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3556 * is written to the memory location pointed to by this parameter. The
3557 * ::WIMStruct must be freed using using wimlib_free() when finished with
3560 * @return 0 on success; nonzero on error.
3561 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3562 * The number of metadata resources found in the WIM did not match the
3563 * image count specified in the WIM header, or the number of <IMAGE>
3564 * elements in the XML data of the WIM did not match the image count
3565 * specified in the WIM header.
3566 * @retval ::WIMLIB_ERR_INTEGRITY
3567 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3568 * the WIM contained an integrity table, but the SHA1 message digest for a
3569 * chunk of the WIM did not match the corresponding value in the integrity
3571 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3572 * The library did not recognize the compression chunk size of the WIM as
3573 * valid for its compression type.
3574 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3575 * The library did not recognize the compression type of the WIM.
3576 * @retval ::WIMLIB_ERR_INVALID_HEADER
3577 * The header of the WIM was otherwise invalid.
3578 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3579 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3580 * the WIM contained an integrity table, but the integrity table was
3582 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3583 * The lookup table of the WIM was invalid.
3584 * @retval ::WIMLIB_ERR_INVALID_PARAM
3585 * @p wim_ret was @c NULL; or, @p wim_file was not a nonempty string.
3586 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3587 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3588 * specified in @p open_flags.
3589 * @retval ::WIMLIB_ERR_NOMEM
3590 * Failed to allocated needed memory.
3591 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3592 * The file did not begin with the magic characters that identify a WIM
3594 * @retval ::WIMLIB_ERR_OPEN
3595 * Failed to open the WIM file for reading. Some possible reasons: the WIM
3596 * file does not exist, or the calling process does not have permission to
3598 * @retval ::WIMLIB_ERR_READ
3599 * Failed to read data from the WIM file.
3600 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3601 * Unexpected end-of-file while reading data from the WIM file.
3602 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3603 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3604 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3605 * The WIM cannot be opened because it contains encrypted segments. (It
3606 * may be a Windows 8 "ESD" file.)
3607 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3608 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3609 * considered read-only because of any of the reasons mentioned in the
3610 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3611 * @retval ::WIMLIB_ERR_XML
3612 * The XML data of the WIM was invalid.
3615 wimlib_open_wim(const wimlib_tchar *wim_file,
3617 WIMStruct **wim_ret);
3620 * @ingroup G_creating_and_opening_wims
3622 * Same as wimlib_open_wim(), but allows specifying a progress function and
3623 * progress context. If successful, the progress function will be registered in
3624 * the newly open ::WIMStruct, as if by an automatic call to
3625 * wimlib_register_progress_function(). In addition, if
3626 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, the
3627 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3628 * messages while checking the WIM file's integrity.
3631 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3633 WIMStruct **wim_ret,
3634 wimlib_progress_func_t progfunc,
3638 * @ingroup G_writing_and_overwriting_wims
3640 * Overwrites the file that the WIM was originally read from, with changes made.
3641 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3642 * rather than wimlib_create_new_wim().
3644 * There are two ways that a WIM may be overwritten. The first is to do a full
3645 * rebuild. In this mode, the new WIM is written to a temporary file and then
3646 * renamed to the original file after it is has been completely written. The
3647 * temporary file is made in the same directory as the original WIM file. A
3648 * full rebuild may take a while, but it will save space by producing a WIM with
3651 * The second way to overwrite a WIM is by appending to the end of it and
3652 * overwriting the header. This can be much faster than a full rebuild, but the
3653 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3654 * begins with writing any new file resources *after* everything in the old WIM,
3655 * even though this will leave a hole where the old lookup table, XML data, and
3656 * integrity were. This is done so that the WIM remains valid even if the
3657 * operation is aborted mid-write. The WIM header is only overwritten at the
3658 * very last moment, and up until that point the WIM will be seen as the old
3661 * By default, wimlib_overwrite() does the append-style overwrite described
3662 * above, unless resources in the WIM are arranged in an unusual way or if
3663 * images have been deleted from the WIM. Use the flag
3664 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3665 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3666 * images have been deleted from the WIM.
3668 * If this function completes successfully, no more functions should be called
3669 * on @p wim other than wimlib_free(). If you need to continue using the WIM,
3670 * you must use wimlib_open_wim() to read it anew.
3673 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3674 * been in-memory changes made to it, which are then reflected in the
3676 * @param write_flags
3677 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3678 * @param num_threads
3679 * Number of threads to use for compression, or 0 for the default. (See
3682 * @return 0 on success; nonzero on error. This function may return most error
3683 * codes returned by wimlib_write() as well as the following error codes:
3685 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3686 * The WIM was going to be modified in-place (with no temporary file), but
3687 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3688 * because another thread or process has mounted an image from the WIM
3689 * read-write or is currently modifying the WIM in-place.
3690 * @retval ::WIMLIB_ERR_NO_FILENAME
3691 * @p wim corresponds to a ::WIMStruct created with wimlib_create_new_wim()
3692 * rather than a WIM read with wimlib_open_wim().
3693 * @retval ::WIMLIB_ERR_RENAME
3694 * The temporary file that the WIM was written to could not be renamed to
3695 * the original filename of @p wim.
3696 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3697 * The WIM file is considered read-only because of any of the reasons
3698 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3701 * If a progress function is registered with @p wim, it will receive the
3702 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3703 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3704 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3707 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3710 * @ingroup G_wim_information
3712 * Prints information about one image, or all images, contained in a WIM.
3715 * Pointer to the ::WIMStruct to query. This need not represent a
3716 * standalone WIM (e.g. it could represent part of a split WIM).
3718 * The image about which to print information. Can be the number of an
3719 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3722 * @return This function has no return value. No error checking is done when
3723 * printing the information. If @p image is invalid, an error message is
3727 wimlib_print_available_images(const WIMStruct *wim, int image);
3730 * @ingroup G_wim_information
3732 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3733 * in a way that can be accessed programatically.
3736 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3739 * @ingroup G_nonstandalone_wims
3741 * Reference resources from other WIM files or split WIM parts. This function
3742 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3743 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3744 * from other files, before calling a function such as wimlib_extract_image()
3745 * that requires the resources to be present.
3748 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3749 * necessarily "standalone". In the case of split WIMs, this should be the
3750 * first part, since only the first part contains the metadata resources.
3751 * In the case of delta WIMs, this should be the delta WIM rather than the
3752 * WIM on which it is based.
3753 * @param resource_wimfiles_or_globs
3754 * Array of paths to WIM files and/or split WIM parts to reference.
3755 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3756 * ref_flags, these are treated as globs rather than literal paths. That
3757 * is, using this function you can specify zero or more globs, each of
3758 * which expands to one or more literal paths.
3760 * Number of entries in @p resource_wimfiles_or_globs.
3762 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3763 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3765 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3766 * pass to internal calls to wimlib_open_wim() on the reference files.
3768 * @return 0 on success; nonzero on error.
3770 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3771 * One of the specified globs did not match any paths (only with both
3772 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3773 * specified in @p ref_flags).
3774 * @retval ::WIMLIB_ERR_NOMEM
3775 * Failed to allocate memory.
3776 * @retval ::WIMLIB_ERR_READ
3777 * I/O or permissions error while processing a file glob.
3779 * This function can additionally return most values that can be returned by
3780 * wimlib_open_wim().
3783 wimlib_reference_resource_files(WIMStruct *wim,
3784 const wimlib_tchar * const *resource_wimfiles_or_globs,
3790 * @ingroup G_nonstandalone_wims
3792 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3793 * where the caller must open the ::WIMStruct for each referenced file itself.
3796 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3797 * necessarily "standalone". In the case of split WIMs, this should be the
3798 * first part, since only the first part contains the metadata resources.
3799 * @param resource_wims
3800 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3801 * split WIM parts to reference.
3802 * @param num_resource_wims
3803 * Number of entries in @p resource_wims.
3805 * Currently ignored (set to 0).
3807 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3808 * @p resource_wims are referenced internally by @p wim and must not be freed
3809 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3810 * been freed with wimlib_free(), or immediately before freeing @p wim with
3813 * @retval ::WIMLIB_ERR_INVALID_PARAM
3814 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3815 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3816 * @retval ::WIMLIB_ERR_NOMEM
3817 * Failed to allocate memory.
3820 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3821 unsigned num_resource_wims, int ref_flags);
3824 * @ingroup G_modifying_wims
3826 * Declares that a newly added image is mostly the same as a prior image, but
3827 * captured at a later point in time, possibly with some modifications in the
3828 * intervening time. This is designed to be used in incremental backups of the
3829 * same filesystem or directory tree.
3831 * This function compares the metadata of the directory tree of the newly added
3832 * image against that of the old image. Any files that are present in both the
3833 * newly added image and the old image and have timestamps that indicate they
3834 * haven't been modified are deemed not to have been modified and have their
3835 * SHA1 message digest copied from the old image. Because of this and because
3836 * WIM uses single-instance streams, such files need not be read from the
3837 * filesystem when the WIM is being written or overwritten. Note that these
3838 * unchanged files will still be "archived" and will be logically present in the
3839 * new image; the optimization is that they don't need to actually be read from
3840 * the filesystem because the WIM already contains them.
3842 * This function is provided to optimize incremental backups. The resulting WIM
3843 * file will still be the same regardless of whether this function is called.
3844 * (This is, however, assuming that timestamps have not been manipulated or
3845 * unmaintained as to trick this function into thinking a file has not been
3846 * modified when really it has. To partly guard against such cases, other
3847 * metadata such as file sizes will be checked as well.)
3849 * This function must be called after adding the new image (e.g. with
3850 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3851 * wimlib_overwrite()).
3854 * Pointer to the ::WIMStruct for a WIM.
3856 * 1-based index in the WIM of the newly added image. This image can have
3857 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3858 * wimlib_add_empty_image() followed by wimlib_update_image().
3859 * @param template_wim
3860 * The ::WIMStruct for the WIM containing the template image. This can be
3861 * the same as @p wim, or it can be a different ::WIMStruct.
3862 * @param template_image
3863 * 1-based index in the WIM of a template image that reflects a prior state
3864 * of the directory tree being captured.
3866 * Reserved; must be 0.
3868 * @return 0 on success; nonzero on error.
3870 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3871 * @p new_image and/or @p template_image were not a valid image indices in
3873 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3874 * The specified ::WIMStruct did not actually contain the metadata resource
3875 * for the new or template image; for example, it was a non-first part of a
3877 * @retval ::WIMLIB_ERR_NOMEM
3878 * Failed to allocate needed memory.
3879 * @retval ::WIMLIB_ERR_INVALID_PARAM
3880 * @p new_image was equal to @p template_image, or @p new_image specified
3881 * an image that had not been modified since opening the WIM.
3883 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3884 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3885 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3886 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3887 * different reasons) to read the metadata resource for the template image.
3890 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3891 WIMStruct *template_wim, int template_image,
3895 * @ingroup G_general
3897 * Registers a progress function with a ::WIMStruct.
3900 * The ::WIMStruct for which to register the progress function.
3902 * Pointer to the progress function to register. If the WIM already has a
3903 * progress function registered, it will be replaced with this one. If @p
3904 * NULL, the current progress function (if any) will be unregistered.
3906 * The value which will be passed as the third argument to calls to @p
3910 wimlib_register_progress_function(WIMStruct *wim,
3911 wimlib_progress_func_t progfunc,
3915 * @ingroup G_modifying_wims
3917 * Rename the @p source_path to the @p dest_path in the specified @p image of
3920 * This just builds an appropriate ::wimlib_rename_command and passes it to
3921 * wimlib_update_image().
3924 wimlib_rename_path(WIMStruct *wim, int image,
3925 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3928 * @ingroup G_wim_information
3930 * Translates a string specifying the name or number of an image in the WIM into
3931 * the number of the image. The images are numbered starting at 1.
3934 * Pointer to the ::WIMStruct for a WIM.
3935 * @param image_name_or_num
3936 * A string specifying the name or number of an image in the WIM. If it
3937 * parses to a positive integer, this integer is taken to specify the
3938 * number of the image, indexed starting at 1. Otherwise, it is taken to
3939 * be the name of an image, as given in the XML data for the WIM file. It
3940 * also may be the keyword "all" or the string "*", both of which will
3941 * resolve to ::WIMLIB_ALL_IMAGES.
3943 * There is no way to search for an image actually named "all", "*", or an
3944 * integer number, or an image that has no name. However, you can use
3945 * wimlib_get_image_name() to get the name of any image.
3948 * If the string resolved to a single existing image, the number of that
3949 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3950 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3951 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3952 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3953 * images in @p wim has no name.
3956 wimlib_resolve_image(WIMStruct *wim,
3957 const wimlib_tchar *image_name_or_num);
3960 * @ingroup G_general
3962 * Sets the file to which the library will print error and warning messages.
3964 * This version of the function takes a C library <c>FILE *</c> opened for
3965 * writing (or appending). Use wimlib_set_error_file_by_name() to specify the
3966 * file by name instead.
3968 * This also enables error messages, as if by a call to
3969 * wimlib_set_print_errors(true).
3971 * @return 0 on success; nonzero on error.
3972 * @retval ::WIMLIB_ERR_UNSUPPORTED
3973 * wimlib was compiled using the <c>--without-error-messages</c> option.
3976 wimlib_set_error_file(FILE *fp);
3979 * @ingroup G_general
3981 * Sets the path to the file to which the library will print error and warning
3982 * messages. The library will open this file for appending.
3984 * This also enables error messages, as if by a call to
3985 * wimlib_set_print_errors(true).
3987 * @return 0 on success; nonzero on error.
3988 * @retval ::WIMLIB_ERR_OPEN
3989 * The file named by @p path could not be opened for appending.
3990 * @retval ::WIMLIB_ERR_UNSUPPORTED
3991 * wimlib was compiled using the <c>--without-error-messages</c> option.
3994 wimlib_set_error_file_by_name(const wimlib_tchar *path);
3997 * @ingroup G_modifying_wims
3999 * Changes the description of an image in the WIM.
4002 * Pointer to the ::WIMStruct for a WIM.
4004 * The number of the image for which to change the description.
4005 * @param description
4006 * The new description to give the image. It may be @c NULL, which
4007 * indicates that the image is to be given no description.
4009 * @return 0 on success; nonzero on error.
4010 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4011 * @p image does not specify a single existing image in @p wim.
4012 * @retval ::WIMLIB_ERR_NOMEM
4013 * Failed to allocate the memory needed to duplicate the @p description
4017 wimlib_set_image_descripton(WIMStruct *wim, int image,
4018 const wimlib_tchar *description);
4021 * @ingroup G_writing_and_overwriting_wims
4023 * Set the compression chunk size of a WIM to use in subsequent calls to
4024 * wimlib_write() or wimlib_overwrite().
4026 * A larger compression chunk size will likely result in a better compression
4027 * ratio, but the speed of random access to the WIM will be reduced.
4028 * Furthermore, the effect of a larger compression chunk size is limited by the
4029 * size of each stream ("file") being compressed.
4032 * ::WIMStruct for a WIM.
4034 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
4035 * on the compression format. See the documentation for each
4036 * ::wimlib_compression_type constant for more information. As a special
4037 * case, if @p chunk_size is specified as 0, the chunk size is set to the
4038 * default for the currently selected output compression type.
4040 * @return 0 on success; nonzero on error.
4042 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
4043 * @p chunk_size is not a supported chunk size for the currently selected
4044 * output compression type.
4047 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4050 * @ingroup G_writing_and_overwriting_wims
4052 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
4056 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4059 * @ingroup G_writing_and_overwriting_wims
4061 * Set the compression type of a WIM to use in subsequent calls to
4062 * wimlib_write() or wimlib_overwrite().
4065 * ::WIMStruct for a WIM.
4067 * The compression type to set (one of ::wimlib_compression_type). If this
4068 * compression type is incompatible with the current output chunk size
4069 * (either the default or as set with wimlib_set_output_chunk_size()), the
4070 * output chunk size is reset to the default for that compression type.
4072 * @return 0 on success; nonzero on error.
4074 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4075 * @p ctype did not specify a valid compression type.
4078 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
4081 * @ingroup G_writing_and_overwriting_wims
4083 * Similar to wimlib_set_output_compression_type(), but set the compression type
4084 * for writing solid resources.
4087 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
4090 * @ingroup G_modifying_wims
4092 * Set basic information about a WIM.
4095 * Pointer to the ::WIMStruct for a WIM.
4097 * A struct ::wimlib_wim_info that contains the information to set. Only
4098 * the information explicitly specified in the @p which flags need be
4101 * Flags that specify which information to set. This is a bitwise OR of
4102 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
4103 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
4105 * @return 0 on success; nonzero on failure.
4106 * @retval ::WIMLIB_ERR_IMAGE_COUNT
4107 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
4108 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
4112 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
4116 * @ingroup G_modifying_wims
4118 * Changes what is written in the \<FLAGS\> element in the WIM XML data
4119 * (something like "Core" or "Ultimate")
4122 * Pointer to the ::WIMStruct for a WIM.
4124 * The number of the image for which to change the description.
4126 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
4127 * indicates that the image is to be given no \<FLAGS\> element.
4129 * @return 0 on success; nonzero on error.
4130 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4131 * @p image does not specify a single existing image in @p wim.
4132 * @retval ::WIMLIB_ERR_NOMEM
4133 * Failed to allocate the memory needed to duplicate the @p flags string.
4136 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
4139 * @ingroup G_modifying_wims
4141 * Changes the name of an image in the WIM.
4144 * Pointer to the ::WIMStruct for a WIM.
4146 * The number of the image for which to change the name.
4148 * New name to give the new image. If @c NULL or empty, the new image is
4149 * given no name. If nonempty, it must specify a name that does not
4150 * already exist in @p wim.
4152 * @return 0 on success; nonzero on error.
4153 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
4154 * There is already an image named @p name in @p wim.
4155 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4156 * @p image does not specify a single existing image in @p wim.
4157 * @retval ::WIMLIB_ERR_NOMEM
4158 * Failed to allocate the memory needed to duplicate the @p name string.
4161 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
4164 * @ingroup G_general
4166 * Set the functions that wimlib uses to allocate and free memory.
4168 * These settings are global and not per-WIM.
4170 * The default is to use the default @c malloc() and @c free() from the C
4173 * Please note that some external functions, such as those in @c libntfs-3g, may
4174 * use the standard memory allocation functions regardless of this setting.
4176 * @param malloc_func
4177 * A function equivalent to @c malloc() that wimlib will use to allocate
4178 * memory. If @c NULL, the allocator function is set back to the default
4179 * @c malloc() from the C library.
4181 * A function equivalent to @c free() that wimlib will use to free memory.
4182 * If @c NULL, the free function is set back to the default @c free() from
4184 * @param realloc_func
4185 * A function equivalent to @c realloc() that wimlib will use to reallocate
4186 * memory. If @c NULL, the free function is set back to the default @c
4187 * realloc() from the C library.
4191 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
4192 void (*free_func)(void *),
4193 void *(*realloc_func)(void *, size_t));
4196 * @ingroup G_general
4198 * Sets whether wimlib is to print error messages to @c stderr when a function
4199 * fails. These error messages may provide information that cannot be
4200 * determined only from the error code that is returned. Not every error will
4201 * result in an error message being printed.
4203 * This setting is global and not per-WIM.
4205 * By default, error messages are not printed.
4207 * This can be called before wimlib_global_init().
4209 * @param show_messages
4210 * @c true if error messages are to be printed; @c false if error messages
4211 * are not to be printed.
4213 * @return 0 on success; nonzero on error.
4214 * @retval ::WIMLIB_ERR_UNSUPPORTED
4215 * @p show_messages was @c true, but wimlib was compiled with the @c
4216 * --without-error-messages option. Therefore, error messages cannot be
4220 wimlib_set_print_errors(bool show_messages);
4223 * @ingroup G_nonstandalone_wims
4225 * Splits a WIM into multiple parts.
4228 * The ::WIMStruct for the WIM to split.
4230 * Name of the SWM file to create. This will be the name of the first
4231 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
4232 * appended before the suffix.
4234 * The maximum size per part, in bytes. Unfortunately, it is not
4235 * guaranteed that this will really be the maximum size per part, because
4236 * some file resources in the WIM may be larger than this size, and the WIM
4237 * file format provides no way to split up file resources among multiple
4239 * @param write_flags
4240 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
4241 * flags will be used to write each split WIM part. Specify 0 here to get
4242 * the default behavior.
4244 * @return 0 on success; nonzero on error. This function may return most error
4245 * codes that can be returned by wimlib_write() as well as the following error
4248 * @retval ::WIMLIB_ERR_INVALID_PARAM
4249 * @p swm_name was not a nonempty string, or @p part_size was 0.
4251 * If a progress function is registered with @p wim, for each split WIM part
4252 * that is written it will receive the messages
4253 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
4254 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
4257 wimlib_split(WIMStruct *wim,
4258 const wimlib_tchar *swm_name,
4263 * @ingroup G_general
4265 * Perform verification checks on a WIM file.
4268 * The ::WIMStruct for the WIM file to verify. Note: for an extra layer of
4269 * verification, it is a good idea to have used
4270 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
4272 * If verifying a split WIM, specify the first part of the split WIM here,
4273 * and reference the other parts using wimlib_reference_resource_files()
4274 * before calling this function.
4276 * @param verify_flags
4277 * Reserved; must be 0.
4279 * @retval 0 if the WIM file was successfully verified; nonzero if it failed
4280 * verification or another error occurred. Some of the possible error codes
4283 * @retval ::WIMLIB_ERR_DECOMPRESSION
4284 * A compressed resource could not be decompressed.
4285 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
4286 * The metadata resource for an image is invalid.
4287 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4288 * One of the files did not decompress to its original data, as given by a
4289 * cryptographic checksum.
4290 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4291 * One of the files referenced by an image could not be located.
4293 * If a progress function is registered with @p wim, it will receive the
4294 * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
4295 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
4296 * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
4299 wimlib_verify_wim(WIMStruct *wim, int verify_flags);
4302 * @ingroup G_mounting_wim_images
4304 * Unmounts a WIM image that was mounted using wimlib_mount_image().
4306 * When unmounting a read-write mounted image, the default behavior is to
4307 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
4308 * WIM image to be committed.
4311 * The directory the WIM image was mounted on.
4312 * @param unmount_flags
4313 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
4315 * @return 0 on success; nonzero on error. The possible error codes include:
4317 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
4318 * There is no WIM image mounted on the specified directory.
4319 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
4320 * The read-write mounted WIM image cannot be committed because there are
4321 * file descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
4323 * @retval ::WIMLIB_ERR_MQUEUE
4324 * Could not create a POSIX message queue.
4325 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
4326 * The WIM image was mounted by a different user.
4327 * @retval ::WIMLIB_ERR_UNSUPPORTED
4328 * Mounting is not supported in this build of the library.
4330 * Note: you can also unmount the image by using the @c umount() system call, or
4331 * by using the @c umount or @c fusermount programs. However, you need to call
4332 * this function if you want changes to be committed.
4335 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
4338 * @ingroup G_mounting_wim_images
4340 * Same as wimlib_unmount_image(), but allows specifying a progress function.
4341 * If changes are committed from a read-write mount, the progress function will
4342 * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
4345 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
4347 wimlib_progress_func_t progfunc,
4351 * @ingroup G_modifying_wims
4353 * Update a WIM image by adding, deleting, and/or renaming files or directories.
4356 * Pointer to the ::WIMStruct for the WIM file to update.
4358 * The 1-based index of the image in the WIM to update. It cannot be
4359 * ::WIMLIB_ALL_IMAGES.
4361 * An array of ::wimlib_update_command's that specify the update operations
4364 * Number of commands in @p cmds.
4365 * @param update_flags
4366 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
4368 * @return 0 on success; nonzero on error. On failure, all update commands will
4369 * be rolled back, and no visible changes shall have been made to @p wim.
4370 * Possible error codes include:
4372 * @retval ::WIMLIB_ERR_FVE_LOCKED_VOLUME
4373 * Windows-only: One of the "add" commands attempted to add files from an
4374 * encrypted BitLocker volume that hasn't yet been unlocked.
4375 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
4376 * The capture configuration structure specified for an add command was
4378 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4379 * @p image did not specify a single, existing image in @p wim.
4380 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
4381 * Attempted to perform an add command that conflicted with previously
4382 * existing files in the WIM when an overlay was attempted.
4383 * @retval ::WIMLIB_ERR_INVALID_PARAM
4384 * An unknown operation type was specified in the update commands; or,
4385 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
4386 * in the @p add_flags, but the same image had previously already been
4387 * added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
4388 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
4389 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
4390 * specified in the @p add_flags for an add command in which @p
4391 * wim_target_path was not the root directory of the WIM image.
4392 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4393 * (Windows only): While executing an add command, tried to capture a
4394 * reparse point with invalid data.
4395 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4396 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
4397 * for a WIM path that corresponded to a directory; or, a rename command
4398 * attempted to rename a directory to a non-directory.
4399 * @retval ::WIMLIB_ERR_NOMEM
4400 * Failed to allocate needed memory.
4401 * @retval ::WIMLIB_ERR_NOTDIR
4402 * A rename command attempted to rename a directory to a non-directory; or,
4403 * an add command was executed that attempted to set the root of the WIM
4404 * image as a non-directory; or, a path component used as a directory in a
4405 * rename command was not, in fact, a directory.
4406 * @retval ::WIMLIB_ERR_NOTEMPTY
4407 * A rename command attempted to rename a directory to a non-empty
4409 * @retval ::WIMLIB_ERR_NTFS_3G
4410 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4411 * error occurred while reading data from the NTFS volume using libntfs-3g.
4412 * @retval ::WIMLIB_ERR_OPEN
4413 * Failed to open a file to be captured while executing an add command.
4414 * @retval ::WIMLIB_ERR_OPENDIR
4415 * Failed to open a directory to be captured while executing an add command.
4416 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4417 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4418 * WIM path that did not exist; or, a rename command attempted to rename a
4419 * file that does not exist.
4420 * @retval ::WIMLIB_ERR_READ
4421 * While executing an add command, failed to read data from a file or
4422 * directory to be captured.
4423 * @retval ::WIMLIB_ERR_READLINK
4424 * While executing an add command, failed to read the target of a symbolic
4425 * link or junction point.
4426 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
4427 * (Windows only) Failed to perform a reparse point fixup because of
4428 * problems with the data of a reparse point.
4429 * @retval ::WIMLIB_ERR_STAT
4430 * While executing an add command, failed to get attributes for a file or
4432 * @retval ::WIMLIB_ERR_UNSUPPORTED
4433 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
4434 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
4435 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
4436 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
4437 * add_flags for an update command.
4438 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4439 * While executing an add command, attempted to capture a file that was not
4440 * a supported file type (e.g. a device file). Only if
4441 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
4442 * for an update command.
4444 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4445 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4446 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4447 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4448 * different reasons) to read the metadata resource for an image that needed to
4452 wimlib_update_image(WIMStruct *wim,
4454 const struct wimlib_update_command *cmds,
4459 * @ingroup G_writing_and_overwriting_wims
4461 * Writes a WIM to a file.
4463 * This brings in resources from any external locations, such as directory trees
4464 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4465 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
4467 * By default, the new WIM file is written as stand-alone. Using the
4468 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4469 * instead. However, this function cannot directly write a "split" WIM; use
4470 * wimlib_split() for that.
4473 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
4474 * changes made to it, which are then reflected in the output file.
4476 * The path to the file to write the WIM to.
4478 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4479 * images are to be included in the new on-disk WIM file. If for some
4480 * reason you only want to include a single image, specify the index of
4481 * that image instead.
4482 * @param write_flags
4483 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
4484 * @param num_threads
4485 * Number of threads to use for compressing data. If 0, the number of
4486 * threads will be set by the library automatically. This chosen value
4487 * will generally be the number of online processors, but the
4488 * implementation may take into account other information (e.g. available
4489 * memory and overall system activity).
4491 * @return 0 on success; nonzero on error.
4493 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4494 * @p image does not specify a single existing image in @p wim, and is not
4495 * ::WIMLIB_ALL_IMAGES.
4496 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4497 * A file resource failed a SHA-1 message digest check. This can happen if
4498 * a file that had previously been scanned for inclusion in the WIM by was
4499 * concurrently modified.
4500 * @retval ::WIMLIB_ERR_INVALID_PARAM
4501 * @p path was not a nonempty string, or invalid flags were passed.
4502 * @retval ::WIMLIB_ERR_NOMEM
4503 * Failed to allocate needed memory.
4504 * @retval ::WIMLIB_ERR_OPEN
4505 * Failed to open @p path for writing, or some file resources in @p wim
4506 * refer to files in the outside filesystem, and one of these files could
4507 * not be opened for reading.
4508 * @retval ::WIMLIB_ERR_READ
4509 * An error occurred when trying to read data from the WIM file associated
4510 * with @p wim, or some file resources in @p wim refer to files in the
4511 * outside filesystem, and a read error occurred when reading one of these
4513 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4514 * A stream that needed to be written could not be found in the stream
4515 * lookup table of @p wim. This error can occur if, for example, @p wim is
4516 * part of a split WIM but needed resources from the other split WIM parts
4517 * were not referenced with wimlib_reference_resources() or
4518 * wimlib_reference_resource_files() before the call to wimlib_write().
4519 * @retval ::WIMLIB_ERR_WRITE
4520 * An error occurred when trying to write data to the new WIM file.
4522 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4523 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4524 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4525 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4526 * different reasons) to read the data from a WIM archive.
4528 * If a progress function is registered with @p wim, it will receive the
4529 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4530 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4531 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4534 wimlib_write(WIMStruct *wim,
4535 const wimlib_tchar *path,
4538 unsigned num_threads);
4541 * @ingroup G_writing_and_overwriting_wims
4543 * Same as wimlib_write(), but write the WIM directly to a file descriptor,
4544 * which need not be seekable if the write is done in a special pipable WIM
4545 * format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p write_flags. This can,
4546 * for example, allow capturing a WIM image and streaming it over the network.
4547 * See @ref subsec_pipable_wims for more information about pipable WIMs.
4549 * The file descriptor @p fd will @b not be closed when the write is complete;
4550 * the calling code is responsible for this.
4552 * Returns 0 on success; nonzero on failure. The possible error codes include
4553 * those that can be returned by wimlib_write() as well as the following:
4555 * @retval ::WIMLIB_ERR_INVALID_PARAM
4556 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4557 * specified in @p write_flags.
4560 wimlib_write_to_fd(WIMStruct *wim,
4564 unsigned num_threads);
4567 * @defgroup G_compression Compression and decompression functions
4569 * @brief Functions for XPRESS, LZX, and LZMS compression and decompression.
4571 * These functions are already used by wimlib internally when appropriate for
4572 * reading and writing WIM archives. But they are exported and documented so
4573 * that they can be used in other applications or libraries for general-purpose
4574 * lossless data compression. They are implemented in highly optimized C code,
4575 * using state-of-the-art compression techniques. The main limitation is the
4576 * lack of sliding window support; this has, however, allowed the algorithms to
4577 * be optimized for block-based compression.
4582 /** Opaque compressor handle. */
4583 struct wimlib_compressor;
4585 /** Opaque decompressor handle. */
4586 struct wimlib_decompressor;
4589 * Set the default compression level for the specified compression type. This
4590 * is the compression level that wimlib_create_compressor() assumes if it is
4591 * called with @p compression_level specified as 0.
4593 * wimlib's WIM writing code (e.g. wimlib_write()) will pass 0 to
4594 * wimlib_create_compressor() internally. Therefore, calling this function will
4595 * affect the compression level of any data later written to WIM files using the
4596 * specified compression type.
4598 * The initial state, before this function is called, is that all compression
4599 * types have a default compression level of 50.
4602 * Compression type for which to set the default compression level, as one
4603 * of the ::wimlib_compression_type constants. Or, if this is the special
4604 * value -1, the default compression levels for all compression types will
4606 * @param compression_level
4607 * The default compression level to set. If 0, the "default default" level
4608 * of 50 is restored. Otherwise, a higher value indicates higher
4609 * compression, whereas a lower value indicates lower compression. See
4610 * wimlib_create_compressor() for more information.
4612 * @return 0 on success; nonzero on error.
4614 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4615 * @p ctype was neither a supported compression type nor -1.
4618 wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
4621 * Returns the approximate number of bytes needed to allocate a compressor with
4622 * wimlib_create_compressor() for the specified compression type, maximum block
4623 * size, and compression level. @p compression_level may be 0, in which case
4624 * the current default compression level for @p ctype is used. Returns 0 if the
4625 * compression type is invalid, or the @p max_block_size for that compression
4629 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4630 size_t max_block_size,
4631 unsigned int compression_level);
4633 #define WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE 0x80000000
4636 * Allocate a compressor for the specified compression type using the specified
4637 * parameters. This function is part of wimlib's compression API; it is not
4638 * necessary to call this to process a WIM file.
4641 * Compression type for which to create the compressor, as one of the
4642 * ::wimlib_compression_type constants.
4643 * @param max_block_size
4644 * The maximum compression block size to support. This specifies the
4645 * maximum allowed value for the @p uncompressed_size parameter of
4646 * wimlib_compress() when called using this compressor.
4648 * Usually, the amount of memory used by the compressor will scale in
4649 * proportion to the @p max_block_size parameter.
4650 * wimlib_get_compressor_needed_memory() can be used to query the specific
4651 * amount of memory that will be required.
4653 * This parameter must be at least 1 and must be less than or equal to a
4654 * compression-type-specific limit.
4656 * In general, the same value of @p max_block_size must be passed to
4657 * wimlib_create_decompressor() when the data is later decompressed.
4658 * However, some compression types have looser requirements regarding this.
4659 * @param compression_level
4660 * The compression level to use. If 0, the default compression level (50,
4661 * or another value as set through wimlib_set_default_compression_level())
4662 * is used. Otherwise, a higher value indicates higher compression. The
4663 * values are scaled so that 10 is low compression, 50 is medium
4664 * compression, and 100 is high compression. This is not a percentage;
4665 * values above 100 are also valid.
4667 * Using a higher-than-default compression level can result in a better
4668 * compression ratio, but can significantly reduce performance. Similarly,
4669 * using a lower-than-default compression level can result in better
4670 * performance, but can significantly worsen the compression ratio. The
4671 * exact results will depend heavily on the compression type and what
4672 * algorithms are implemented for it. If you are considering using a
4673 * non-default compression level, you should run benchmarks to see if it is
4674 * worthwhile for your application.
4676 * The compression level does not affect the format of the compressed data.
4677 * Therefore, it is a compressor-only parameter and does not need to be
4678 * passed to the decompressor.
4680 * Since wimlib v1.8.0, this parameter can be OR-ed with the flag
4681 * ::WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE. This creates the compressor in a
4682 * mode where it is allowed to modify the input buffer. Specifically, in
4683 * this mode, if compression succeeds, the input buffer may have been
4684 * modified, whereas if compression does not succeed the input buffer still
4685 * may have been written to but will have been restored exactly to its
4686 * original state. This mode is designed to save some memory when using
4687 * large buffer sizes.
4688 * @param compressor_ret
4689 * A location into which to return the pointer to the allocated compressor.
4690 * The allocated compressor can be used for any number of calls to
4691 * wimlib_compress() before being freed with wimlib_free_compressor().
4693 * @return 0 on success; nonzero on error.
4695 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4696 * @p ctype was not a supported compression type.
4697 * @retval ::WIMLIB_ERR_INVALID_PARAM
4698 * @p max_block_size was invalid for the compression type, or @p
4699 * compressor_ret was @c NULL.
4700 * @retval ::WIMLIB_ERR_NOMEM
4701 * Insufficient memory to allocate the compressor.
4704 wimlib_create_compressor(enum wimlib_compression_type ctype,
4705 size_t max_block_size,
4706 unsigned int compression_level,
4707 struct wimlib_compressor **compressor_ret);
4710 * Compress a buffer of data.
4712 * @param uncompressed_data
4713 * Buffer containing the data to compress.
4714 * @param uncompressed_size
4715 * Size, in bytes, of the data to compress. This cannot be greater than
4716 * the @p max_block_size with which wimlib_create_compressor() was called.
4717 * (If it is, the data will not be compressed and 0 will be returned.)
4718 * @param compressed_data
4719 * Buffer into which to write the compressed data.
4720 * @param compressed_size_avail
4721 * Number of bytes available in @p compressed_data.
4723 * A compressor previously allocated with wimlib_create_compressor().
4726 * The size of the compressed data, in bytes, or 0 if the data could not be
4727 * compressed to @p compressed_size_avail or fewer bytes.
4730 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4731 void *compressed_data, size_t compressed_size_avail,
4732 struct wimlib_compressor *compressor);
4735 * Free a compressor previously allocated with wimlib_create_compressor().
4738 * The compressor to free. If @c NULL, no action is taken.
4741 wimlib_free_compressor(struct wimlib_compressor *compressor);
4744 * Allocate a decompressor for the specified compression type. This function is
4745 * part of wimlib's compression API; it is not necessary to call this to process
4749 * Compression type for which to create the decompressor, as one of the
4750 * ::wimlib_compression_type constants.
4751 * @param max_block_size
4752 * The maximum compression block size to support. This specifies the
4753 * maximum allowed value for the @p uncompressed_size parameter of
4754 * wimlib_decompress().
4756 * In general, this parameter must be the same as the @p max_block_size
4757 * that was passed to wimlib_create_compressor() when the data was
4758 * compressed. However, some compression types have looser requirements
4760 * @param decompressor_ret
4761 * A location into which to return the pointer to the allocated
4762 * decompressor. The allocated decompressor can be used for any number of
4763 * calls to wimlib_decompress() before being freed with
4764 * wimlib_free_decompressor().
4766 * @return 0 on success; nonzero on error.
4768 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4769 * @p ctype was not a supported compression type.
4770 * @retval ::WIMLIB_ERR_INVALID_PARAM
4771 * @p max_block_size was invalid for the compression type, or @p
4772 * decompressor_ret was @c NULL.
4773 * @retval ::WIMLIB_ERR_NOMEM
4774 * Insufficient memory to allocate the decompressor.
4777 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4778 size_t max_block_size,
4779 struct wimlib_decompressor **decompressor_ret);
4782 * Decompress a buffer of data.
4784 * @param compressed_data
4785 * Buffer containing the data to decompress.
4786 * @param compressed_size
4787 * Size, in bytes, of the data to decompress.
4788 * @param uncompressed_data
4789 * Buffer into which to write the uncompressed data.
4790 * @param uncompressed_size
4791 * Size, in bytes, of the data when uncompressed. This cannot exceed the
4792 * @p max_block_size with which wimlib_create_decompressor() was called.
4793 * (If it does, the data will not be decompressed and a nonzero value will
4795 * @param decompressor
4796 * A decompressor previously allocated with wimlib_create_decompressor().
4798 * @return 0 on success; nonzero on error.
4800 * No specific error codes are defined; any nonzero value indicates that the
4801 * decompression failed. This can only occur if the data is truly invalid;
4802 * there will never be transient errors like "out of memory", for example.
4804 * This function requires that the exact uncompressed size of the data be passed
4805 * as the @p uncompressed_size parameter. If this is not done correctly,
4806 * decompression may fail or the data may be decompressed incorrectly.
4809 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4810 void *uncompressed_data, size_t uncompressed_size,
4811 struct wimlib_decompressor *decompressor);
4814 * Free a decompressor previously allocated with wimlib_create_decompressor().
4816 * @param decompressor
4817 * The decompressor to free. If @c NULL, no action is taken.
4820 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4832 #endif /* _WIMLIB_H */