3 * @brief External header for wimlib.
5 * This file contains comments for generating documentation with Doxygen. The
6 * built HTML documentation can be viewed at https://wimlib.net/apidoc. Make
7 * sure to see the <a href="modules.html">Modules page</a> to make more sense of
8 * the declarations in this header.
14 * This is the documentation for the library interface of wimlib 1.10.0, a C
15 * library for creating, modifying, extracting, and mounting files in the
16 * Windows Imaging Format. This documentation is intended for developers only.
17 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
18 * program, please see the manual pages and also the <a
19 * href="https://wimlib.net/git/?p=wimlib;a=blob;f=README">README file</a>.
21 * @section sec_installing Installing
25 * Download the source code from https://wimlib.net. Install the library by
26 * running <c>configure && make && sudo make install</c>. See the README for
27 * information about configuration options. To use wimlib in your program after
28 * installing it, include wimlib.h and link your program with <c>-lwim</c>.
32 * Download the Windows binary distribution with the appropriate architecture
33 * (i686 or x86_64 --- also called "x86" and "amd64" respectively) from
34 * https://wimlib.net. Link your program with the libwim-15.dll file. Make
35 * sure to also download the source code so you can get wimlib.h, as it is not
36 * included in the binary distribution. If you need to access the DLL from
37 * other programming languages, note that the calling convention is "cdecl".
39 * Note that wimlib is developed using MinGW-w64, and there may be a little work
40 * required if you plan to use the header and DLL with Visual Studio.
42 * @section sec_examples Examples
44 * Several examples are located in the "examples" directory of the source
45 * distribution. Also see @ref sec_basic_wim_handling_concepts below.
47 * There is also the <a
48 * href="https://wimlib.net/git/?p=wimlib;a=blob;f=programs/imagex.c">
49 * source code of <b>wimlib-imagex</b></a>, which is complicated but uses most
50 * capabilities of wimlib.
52 * @section backward_compatibility Backward Compatibility
54 * New releases of wimlib are intended to be backward compatible with old
55 * releases, except when the libtool "age" is reset. This most recently
56 * occurred for the v1.7.0 (libwim15) release (June 2014). Since the library is
57 * becoming increasingly stable, the goal is to maintain the current API/ABI for
58 * as long as possible unless there is a strong reason not to.
60 * As with any other library, applications should not rely on internal
61 * implementation details that may be subject to change.
63 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
65 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
66 * two ways to create such a structure:
68 * 1. wimlib_open_wim() opens an on-disk WIM file and creates a ::WIMStruct for
70 * 2. wimlib_create_new_wim() creates a new ::WIMStruct that initially contains
71 * no images and does not yet have a backing on-disk file.
73 * A ::WIMStruct contains zero or more independent directory trees called @a
74 * images. Images may be extracted, added, deleted, exported, and updated using
75 * various API functions. (See @ref G_extracting_wims and @ref G_modifying_wims
78 * Changes made to a WIM represented by a ::WIMStruct have no persistent effect
79 * until the WIM is actually written to an on-disk file. This can be done using
80 * wimlib_write(), but if the WIM was originally opened using wimlib_open_wim(),
81 * then wimlib_overwrite() can be used instead. (See @ref
82 * G_writing_and_overwriting_wims for more details.)
84 * wimlib's API is designed to let you combine functions to accomplish tasks in
85 * a flexible way. Here are some example sequences of function calls:
87 * Apply an image from a WIM file, similar to the command-line program
90 * 1. wimlib_open_wim()
91 * 2. wimlib_extract_image()
93 * Capture an image into a new WIM file, similar to <b>wimcapture</b>:
95 * 1. wimlib_create_new_wim()
96 * 2. wimlib_add_image()
99 * Append an image to an existing WIM file, similar to <b>wimappend</b>:
101 * 1. wimlib_open_wim()
102 * 2. wimlib_add_image()
103 * 3. wimlib_overwrite()
105 * Delete an image from an existing WIM file, similar to <b>wimdelete</b>:
107 * 1. wimlib_open_wim()
108 * 2. wimlib_delete_image()
109 * 3. wimlib_overwrite()
111 * Export an image from one WIM file to another, similar to <b>wimexport</b>:
113 * 1. wimlib_open_wim() (on source)
114 * 2. wimlib_open_wim() (on destination)
115 * 3. wimlib_export_image()
116 * 4. wimlib_overwrite() (on destination)
118 * The API also lets you do things the command-line tools don't directly allow.
119 * For example, you could make multiple changes to a WIM before efficiently
120 * committing the changes with just one call to wimlib_overwrite(). Perhaps you
121 * want to both delete an image and add a new one; or perhaps you want to
122 * customize an image with wimlib_update_image() after adding it. All these use
123 * cases are supported by the API.
125 * @section sec_cleaning_up Cleaning up
127 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
128 * all resources associated with it. Also, when you are completely done with
129 * using wimlib in your program, you can call wimlib_global_cleanup() to free
130 * any other resources allocated by the library.
132 * @section sec_error_handling Error Handling
134 * Most functions in wimlib return 0 on success and a positive
135 * ::wimlib_error_code value on failure. Use wimlib_get_error_string() to get a
136 * string that describes an error code. wimlib also can print error messages to
137 * standard error or a custom file when an error occurs, and these may be more
138 * informative than the error code; to enable this, call
139 * wimlib_set_print_errors(). Please note that this is for convenience only,
140 * and some errors can occur without a message being printed. Currently, error
141 * messages and strings (as well as all documentation, for that matter) are only
142 * available in English.
144 * @section sec_encodings Character encoding
146 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
147 * and returns strings of ::wimlib_tchar which have a platform-dependent type
150 * On Windows, each ::wimlib_tchar is a 2-byte <tt>wchar_t</tt>. The encoding
151 * is meant to be UTF-16LE. However, unpaired surrogates are permitted because
152 * neither Windows nor the NTFS filesystem forbids them in filenames.
154 * On UNIX-like systems, each ::wimlib_tchar is a 1 byte <tt>char</tt>. The
155 * encoding is meant to be UTF-8. However, for compatibility with Windows-style
156 * filenames that are not valid UTF-16LE, surrogate codepoints are permitted.
157 * Other multibyte encodings (e.g. ISO-8859-1) or garbage sequences of bytes are
160 * @section sec_advanced Additional information and features
163 * @subsection subsec_mounting_wim_images Mounting WIM images
165 * See @ref G_mounting_wim_images.
167 * @subsection subsec_progress_functions Progress Messages
169 * See @ref G_progress.
171 * @subsection subsec_non_standalone_wims Non-standalone WIMs
173 * See @ref G_nonstandalone_wims.
175 * @subsection subsec_pipable_wims Pipable WIMs
177 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
178 * compatible with Microsoft's software. To create a pipable WIM, call
179 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
180 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
181 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
182 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
183 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
184 * s using a seekable file descriptor using the regular function calls (e.g.
185 * wimlib_open_wim(), wimlib_extract_image()).
187 * See the documentation for the <b>--pipable</b> flag of <b>wimcapture</b> for
188 * more information about pipable WIMs.
190 * @subsection subsec_thread_safety Thread Safety
192 * A ::WIMStruct is not thread-safe and cannot be accessed by multiple threads
193 * concurrently, even for "read-only" operations such as extraction. However,
194 * users are free to use <i>different</i> ::WIMStruct's from different threads
195 * concurrently. It is even allowed for multiple ::WIMStruct's to be backed by
196 * the same on-disk WIM file, although "overwrites" should never be done in such
199 * In addition, several functions change global state and should only be called
200 * when a single thread is active in the library. These functions are:
202 * - wimlib_global_init()
203 * - wimlib_global_cleanup()
204 * - wimlib_set_memory_allocator()
205 * - wimlib_set_print_errors()
206 * - wimlib_set_error_file()
207 * - wimlib_set_error_file_by_name()
209 * @subsection subsec_limitations Limitations
211 * This section documents some technical limitations of wimlib not already
212 * described in the documentation for @b wimlib-imagex.
214 * - The old WIM format from Vista pre-releases is not supported.
215 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
216 * functionality other than that already present in @b ImageX, that allows you
217 * to make certain Windows-specific modifications to a Windows PE image, such
218 * as adding a driver or Windows component. Such a tool could be implemented
221 * @subsection more_info More information
223 * You are advised to read the README as well as the documentation for
224 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
225 * the API documentation.
228 /** @defgroup G_general General
230 * @brief Declarations and structures shared across the library.
233 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
235 * @brief Open an existing WIM file as a ::WIMStruct, or create a new
236 * ::WIMStruct which can be used to create a new WIM file.
239 /** @defgroup G_wim_information Retrieving WIM information and directory listings
241 * @brief Retrieve information about a WIM or WIM image.
244 /** @defgroup G_modifying_wims Modifying WIMs
246 * @brief Make changes to a ::WIMStruct, in preparation of persisting the
247 * ::WIMStruct to an on-disk file.
249 * @section sec_adding_images Capturing and adding WIM images
251 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
252 * appending an image to an existing WIM is a multi-step process, but at its
253 * core is wimlib_add_image() or an equivalent function. Normally,
254 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
255 * ::WIMStruct as a new image. However, when supported by the build of the
256 * library, there is also a special NTFS volume capture mode (entered when
257 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
258 * from an unmounted NTFS volume.
260 * Another function, wimlib_add_image_multisource() is also provided. It
261 * generalizes wimlib_add_image() to allow combining multiple files or directory
262 * trees into a single WIM image in a configurable way.
264 * For maximum customization of WIM image creation, it is also possible to add a
265 * completely empty WIM image with wimlib_add_empty_image(), then update it with
266 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
267 * wimlib_add_image_multisource() do internally.)
269 * Note that some details of how image addition/capture works are documented
270 * more fully in the documentation for <b>wimcapture</b>.
272 * @section sec_deleting_images Deleting WIM images
274 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
275 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
276 * be made persistent in an on-disk WIM file.
278 * @section sec_exporting_images Exporting WIM images
280 * wimlib_export_image() can copy, or "export", an image from one WIM to
283 * @section sec_other_modifications Other modifications
285 * wimlib_update_image() can add, delete, and rename files in a WIM image.
287 * wimlib_set_image_property() can change other image metadata.
289 * wimlib_set_wim_info() can change information about the WIM file itself, such
293 /** @defgroup G_extracting_wims Extracting WIMs
295 * @brief Extract files, directories, and images from a WIM.
297 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
298 * represented by a ::WIMStruct. This normally extracts the image to a
299 * directory, but when supported by the build of the library there is also a
300 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
301 * is specified) that allows extracting a WIM image directly to an unmounted
302 * NTFS volume. Various other flags allow further customization of image
305 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
306 * of (possibly wildcard) paths from a WIM image.
308 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
309 * over a pipe; see @ref subsec_pipable_wims.
311 * Some details of how WIM extraction works are described more fully in the
312 * documentation for <b>wimapply</b> and <b>wimextract</b>.
315 /** @defgroup G_mounting_wim_images Mounting WIM images
317 * @brief Mount and unmount WIM images.
319 * On Linux, wimlib supports mounting images from WIM files either read-only or
320 * read-write. To mount an image, call wimlib_mount_image(). To unmount an
321 * image, call wimlib_unmount_image(). Mounting can be done without root
322 * privileges because it is implemented using FUSE (Filesystem in Userspace).
324 * If wimlib is compiled using the <c>--without-fuse</c> flag, these functions
325 * will be available but will fail with ::WIMLIB_ERR_UNSUPPORTED.
327 * Note: if mounting is unsupported, wimlib still provides another way to modify
328 * a WIM image (wimlib_update_image()).
332 * @defgroup G_progress Progress Messages
334 * @brief Track the progress of long WIM operations.
336 * Library users can provide a progress function which will be called
337 * periodically during operations such as extracting a WIM image or writing a
338 * WIM image. A ::WIMStruct can have a progress function of type
339 * ::wimlib_progress_func_t associated with it by calling
340 * wimlib_register_progress_function() or by opening the ::WIMStruct using
341 * wimlib_open_wim_with_progress(). Once this is done, the progress function
342 * will be called automatically during many operations, such as
343 * wimlib_extract_image() and wimlib_write().
345 * Some functions that do not operate directly on a user-provided ::WIMStruct,
346 * such as wimlib_join(), also take the progress function directly using an
347 * extended version of the function, such as wimlib_join_with_progress().
349 * Since wimlib v1.7.0, progress functions are no longer just unidirectional.
350 * You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause the current
351 * operation to be aborted. wimlib v1.7.0 also added the third argument to
352 * ::wimlib_progress_func_t, which is a user-supplied context.
355 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
357 * @brief Create or update an on-disk WIM file.
359 * wimlib_write() creates a new on-disk WIM file, whereas wimlib_overwrite()
360 * updates an existing WIM file. See @ref sec_basic_wim_handling_concepts for
361 * more information about the API design.
364 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
366 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
368 * A ::WIMStruct backed by an on-disk file normally represents a fully
369 * standalone WIM archive. However, WIM archives can also be arranged in
370 * non-standalone ways, such as a set of on-disk files that together form a
371 * single "split WIM" or "delta WIM". Such arrangements are fully supported by
372 * wimlib. However, as a result, in such cases a ::WIMStruct created from one
373 * of these on-disk files initially only partially represents the full WIM and
374 * needs to, in effect, be logically combined with other ::WIMStruct's before
375 * performing certain operations, such as extracting files with
376 * wimlib_extract_image() or wimlib_extract_paths(). This is done by calling
377 * wimlib_reference_resource_files() or wimlib_reference_resources(). Note: if
378 * you fail to do so, you may see the error code
379 * ::WIMLIB_ERR_RESOURCE_NOT_FOUND; this just indicates that data is not
380 * available because the appropriate WIM files have not yet been referenced.
382 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
383 * specialized function (wimlib_split()) is needed to create a split WIM.
392 #include <inttypes.h>
395 /** @addtogroup G_general
398 /** Major version of the library (for example, the 1 in 1.2.5). */
399 #define WIMLIB_MAJOR_VERSION 1
401 /** Minor version of the library (for example, the 2 in 1.2.5). */
402 #define WIMLIB_MINOR_VERSION 10
404 /** Patch version of the library (for example, the 5 in 1.2.5). */
405 #define WIMLIB_PATCH_VERSION 0
412 * Opaque structure that represents a WIM, possibly backed by an on-disk file.
413 * See @ref sec_basic_wim_handling_concepts for more information.
415 #ifndef WIMLIB_WIMSTRUCT_DECLARED
416 typedef struct WIMStruct WIMStruct;
417 #define WIMLIB_WIMSTRUCT_DECLARED
421 typedef wchar_t wimlib_tchar;
423 /** See @ref sec_encodings */
424 typedef char wimlib_tchar;
428 /** Path separator for WIM paths passed back to progress callbacks.
429 * This is forward slash on UNIX and backslash on Windows. */
430 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
431 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
433 /** Path separator for WIM paths passed back to progress callbacks.
434 * This is forward slash on UNIX and backslash on Windows. */
435 # define WIMLIB_WIM_PATH_SEPARATOR '/'
436 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
439 /** A string containing a single path separator; use this to specify the root
440 * directory of a WIM image. */
441 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
443 /** Use this to test if the specified path refers to the root directory of the
445 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
446 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
449 /** Length of a Globally Unique Identifier (GUID), in bytes. */
450 #define WIMLIB_GUID_LEN 16
453 * Specifies a compression type.
455 * A WIM file has a default compression type, indicated by its file header.
456 * Normally, each resource in the WIM file is compressed with this compression
457 * type. However, resources may be stored as uncompressed; for example, wimlib
458 * may do so if a resource does not compress to less than its original size. In
459 * addition, a WIM with the new version number of 3584, or "ESD file", might
460 * contain solid resources with different compression types.
462 enum wimlib_compression_type {
466 * This is a valid argument to wimlib_create_new_wim() and
467 * wimlib_set_output_compression_type(), but not to the functions in the
468 * compression API such as wimlib_create_compressor().
470 WIMLIB_COMPRESSION_TYPE_NONE = 0,
473 * The XPRESS compression format. This format combines Lempel-Ziv
474 * factorization with Huffman encoding. Compression and decompression
475 * are both fast. This format supports chunk sizes that are powers of 2
476 * between <c>2^12</c> and <c>2^16</c>, inclusively.
478 * wimlib's XPRESS compressor will, with the default settings, usually
479 * produce a better compression ratio, and work more quickly, than the
480 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
481 * Non-default compression levels are also supported. For example,
482 * level 80 will enable two-pass optimal parsing, which is significantly
483 * slower but usually improves compression by several percent over the
484 * default level of 50.
486 * If using wimlib_create_compressor() to create an XPRESS compressor
487 * directly, the @p max_block_size parameter may be any positive value
488 * up to and including <c>2^16</c>.
490 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
493 * The LZX compression format. This format combines Lempel-Ziv
494 * factorization with Huffman encoding, but with more features and
495 * complexity than XPRESS. Compression is slow to somewhat fast,
496 * depending on the settings. Decompression is fast but slower than
497 * XPRESS. This format supports chunk sizes that are powers of 2
498 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
499 * other than <c>2^15</c> are not compatible with the Microsoft
502 * wimlib's LZX compressor will, with the default settings, usually
503 * produce a better compression ratio, and work more quickly, than the
504 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
505 * Non-default compression levels are also supported. For example,
506 * level 20 will provide fast compression, almost as fast as XPRESS.
508 * If using wimlib_create_compressor() to create an LZX compressor
509 * directly, the @p max_block_size parameter may be any positive value
510 * up to and including <c>2^21</c>.
512 WIMLIB_COMPRESSION_TYPE_LZX = 2,
515 * The LZMS compression format. This format combines Lempel-Ziv
516 * factorization with adaptive Huffman encoding and range coding.
517 * Compression and decompression are both fairly slow. This format
518 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
519 * <c>2^30</c>, inclusively. This format is best used for large chunk
520 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
521 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
522 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
523 * with the Microsoft implementation.
525 * wimlib's LZMS compressor will, with the default settings, usually
526 * produce a better compression ratio, and work more quickly, than the
527 * implementation in Microsoft's WIMGAPI (as of Windows 8.1). There is
528 * limited support for non-default compression levels, but compression
529 * will be noticeably faster if you choose a level < 35.
531 * If using wimlib_create_compressor() to create an LZMS compressor
532 * directly, the @p max_block_size parameter may be any positive value
533 * up to and including <c>2^30</c>.
535 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
539 /** @addtogroup G_progress
542 /** Possible values of the first parameter to the user-supplied
543 * ::wimlib_progress_func_t progress function */
544 enum wimlib_progress_msg {
546 /** A WIM image is about to be extracted. @p info will point to
547 * ::wimlib_progress_info.extract. This message is received once per
548 * image for calls to wimlib_extract_image() and
549 * wimlib_extract_image_from_pipe(). */
550 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
552 /** One or more file or directory trees within a WIM image is about to
553 * be extracted. @p info will point to ::wimlib_progress_info.extract.
554 * This message is received only once per wimlib_extract_paths() and
555 * wimlib_extract_pathlist(), since wimlib combines all paths into a
556 * single extraction operation for optimization purposes. */
557 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
559 /** This message may be sent periodically (not for every file) while
560 * files and directories are being created, prior to file data
561 * extraction. @p info will point to ::wimlib_progress_info.extract.
562 * In particular, the @p current_file_count and @p end_file_count
563 * members may be used to track the progress of this phase of
565 WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE = 3,
567 /** File data is currently being extracted. @p info will point to
568 * ::wimlib_progress_info.extract. This is the main message to track
569 * the progress of an extraction operation. */
570 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
572 /** Starting to read a new part of a split pipable WIM over the pipe.
573 * @p info will point to ::wimlib_progress_info.extract. */
574 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
576 /** This message may be sent periodically (not necessarily for every
577 * file) while file and directory metadata is being extracted, following
578 * file data extraction. @p info will point to
579 * ::wimlib_progress_info.extract. The @p current_file_count and @p
580 * end_file_count members may be used to track the progress of this
581 * phase of extraction. */
582 WIMLIB_PROGRESS_MSG_EXTRACT_METADATA = 6,
584 /** The image has been successfully extracted. @p info will point to
585 * ::wimlib_progress_info.extract. This is paired with
586 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
587 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
589 /** The files or directory trees have been successfully extracted. @p
590 * info will point to ::wimlib_progress_info.extract. This is paired
591 * with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
592 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
594 /** The directory or NTFS volume is about to be scanned for metadata.
595 * @p info will point to ::wimlib_progress_info.scan. This message is
596 * received once per call to wimlib_add_image(), or once per capture
597 * source passed to wimlib_add_image_multisource(), or once per add
598 * command passed to wimlib_update_image(). */
599 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
601 /** A directory or file has been scanned. @p info will point to
602 * ::wimlib_progress_info.scan, and its @p cur_path member will be
603 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
605 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
607 /** The directory or NTFS volume has been successfully scanned. @p info
608 * will point to ::wimlib_progress_info.scan. This is paired with a
609 * previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message, possibly with many
610 * intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY messages. */
611 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
613 /** File data is currently being written to the WIM. @p info will point
614 * to ::wimlib_progress_info.write_streams. This message may be
615 * received many times while the WIM file is being written or appended
616 * to with wimlib_write(), wimlib_overwrite(), or wimlib_write_to_fd().
618 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
620 /** Per-image metadata is about to be written to the WIM file. @p info
621 * will not be valid. */
622 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
624 /** The per-image metadata has been written to the WIM file. @p info
625 * will not be valid. This message is paired with a preceding
626 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message. */
627 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
629 /** wimlib_overwrite() has successfully renamed the temporary file to
630 * the original WIM file, thereby committing the changes to the WIM
631 * file. @p info will point to ::wimlib_progress_info.rename. Note:
632 * this message is not received if wimlib_overwrite() chose to append to
633 * the WIM file in-place. */
634 WIMLIB_PROGRESS_MSG_RENAME = 15,
636 /** The contents of the WIM file are being checked against the integrity
637 * table. @p info will point to ::wimlib_progress_info.integrity. This
638 * message is only received (and may be received many times) when
639 * wimlib_open_wim_with_progress() is called with the
640 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
641 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
643 /** An integrity table is being calculated for the WIM being written.
644 * @p info will point to ::wimlib_progress_info.integrity. This message
645 * is only received (and may be received many times) when a WIM file is
646 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
647 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
649 /** A wimlib_split() operation is in progress, and a new split part is
650 * about to be started. @p info will point to
651 * ::wimlib_progress_info.split. */
652 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
654 /** A wimlib_split() operation is in progress, and a split part has been
655 * finished. @p info will point to ::wimlib_progress_info.split. */
656 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
658 /** A WIM update command is about to be executed. @p info will point to
659 * ::wimlib_progress_info.update. This message is received once per
660 * update command when wimlib_update_image() is called with the flag
661 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
662 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
664 /** A WIM update command has been executed. @p info will point to
665 * ::wimlib_progress_info.update. This message is received once per
666 * update command when wimlib_update_image() is called with the flag
667 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
668 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
670 /** A file in the image is being replaced as a result of a
671 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
672 * @p info will point to ::wimlib_progress_info.replace. This is only
673 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
675 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
677 /** An image is being extracted with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
678 * a file is being extracted normally (not as a "WIMBoot pointer file")
679 * due to it matching a pattern in the <c>[PrepopulateList]</c> section
680 * of the configuration file
681 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image. @p
682 * info will point to ::wimlib_progress_info.wimboot_exclude. */
683 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
685 /** Starting to unmount an image. @p info will point to
686 * ::wimlib_progress_info.unmount. */
687 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
689 /** wimlib has used a file's data for the last time (including all data
690 * streams, if it has multiple). @p info will point to
691 * ::wimlib_progress_info.done_with_file. This message is only received
692 * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided. */
693 WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
695 /** wimlib_verify_wim() is starting to verify the metadata for an image.
696 * @p info will point to ::wimlib_progress_info.verify_image. */
697 WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
699 /** wimlib_verify_wim() has finished verifying the metadata for an
700 * image. @p info will point to ::wimlib_progress_info.verify_image.
702 WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
704 /** wimlib_verify_wim() is verifying file data integrity. @p info will
705 * point to ::wimlib_progress_info.verify_streams. */
706 WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
709 * The progress function is being asked whether a file should be
710 * excluded from capture or not. @p info will point to
711 * ::wimlib_progress_info.test_file_exclusion. This is a bidirectional
712 * message that allows the progress function to set a flag if the file
713 * should be excluded.
715 * This message is only received if the flag
716 * ::WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION is used. This method for file
717 * exclusions is independent of the "capture configuration file"
720 WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION = 30,
723 * An error has occurred and the progress function is being asked
724 * whether to ignore the error or not. @p info will point to
725 * ::wimlib_progress_info.handle_error. This is a bidirectional
728 * This message provides a limited capability for applications to
729 * recover from "unexpected" errors (i.e. those with no in-library
730 * handling policy) arising from the underlying operating system.
731 * Normally, any such error will cause the library to abort the current
732 * operation. By implementing a handler for this message, the
733 * application can instead choose to ignore a given error.
735 * Currently, only the following types of errors will result in this
736 * progress message being sent:
738 * - Directory tree scan errors, e.g. from wimlib_add_image()
739 * - Most extraction errors; currently restricted to the Windows
740 * build of the library only.
742 WIMLIB_PROGRESS_MSG_HANDLE_ERROR = 31,
745 /** Valid return values from user-provided progress functions
746 * (::wimlib_progress_func_t).
748 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
751 enum wimlib_progress_status {
753 /** The operation should be continued. This is the normal return value.
755 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
757 /** The operation should be aborted. This will cause the current
758 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
759 WIMLIB_PROGRESS_STATUS_ABORT = 1,
763 * A pointer to this union is passed to the user-supplied
764 * ::wimlib_progress_func_t progress function. One (or none) of the structures
765 * contained in this union will be applicable for the operation
766 * (::wimlib_progress_msg) indicated in the first argument to the progress
768 union wimlib_progress_info {
770 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
771 * the primary message for tracking the progress of writing a WIM file.
773 struct wimlib_progress_info_write_streams {
775 /** An upper bound on the number of bytes of file data that will
776 * be written. This number is the uncompressed size; the actual
777 * size may be lower due to compression. In addition, this
778 * number may decrease over time as duplicated file data is
780 uint64_t total_bytes;
782 /** An upper bound on the number of distinct file data "blobs"
783 * that will be written. This will often be similar to the
784 * "number of files", but for several reasons (hard links, named
785 * data streams, empty files, etc.) it can be different. In
786 * addition, this number may decrease over time as duplicated
787 * file data is discovered. */
788 uint64_t total_streams;
790 /** The number of bytes of file data that have been written so
791 * far. This starts at 0 and ends at @p total_bytes. This
792 * number is the uncompressed size; the actual size may be lower
793 * due to compression. */
794 uint64_t completed_bytes;
796 /** The number of distinct file data "blobs" that have been
797 * written so far. This starts at 0 and ends at @p
799 uint64_t completed_streams;
801 /** The number of threads being used for data compression; or,
802 * if no compression is being performed, this will be 1. */
803 uint32_t num_threads;
805 /** The compression type being used, as one of the
806 * ::wimlib_compression_type constants. */
807 int32_t compression_type;
809 /** The number of on-disk WIM files from which file data is
810 * being exported into the output WIM file. This can be 0, 1,
811 * or more than 1, depending on the situation. */
812 uint32_t total_parts;
814 /** This is currently broken and will always be 0. */
815 uint32_t completed_parts;
818 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
819 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
820 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
821 struct wimlib_progress_info_scan {
823 /** Top-level directory being scanned; or, when capturing an NTFS
824 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
825 * to the file or block device that contains the NTFS volume
827 const wimlib_tchar *source;
829 /** Path to the file (or directory) that has been scanned, valid
830 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
831 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
832 * relative to the root of the NTFS volume. */
833 const wimlib_tchar *cur_path;
835 /** Dentry scan status, valid on
836 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
838 /** File looks okay and will be captured. */
839 WIMLIB_SCAN_DENTRY_OK = 0,
841 /** File is being excluded from capture due to the
842 * capture configuration. */
843 WIMLIB_SCAN_DENTRY_EXCLUDED = 1,
845 /** File is being excluded from capture due to being of
846 * an unsupported type. */
847 WIMLIB_SCAN_DENTRY_UNSUPPORTED = 2,
849 /** The file is an absolute symbolic link or junction
850 * that points into the capture directory, and
851 * reparse-point fixups are enabled, so its target is
852 * being adjusted. (Reparse point fixups can be
853 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
855 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK = 3,
857 /** Reparse-point fixups are enabled, but the file is an
858 * absolute symbolic link or junction that does
859 * <b>not</b> point into the capture directory, so its
860 * target is <b>not</b> being adjusted. */
861 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK = 4,
865 /** Target path in the image. Only valid on messages
866 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
867 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
868 const wimlib_tchar *wim_target_path;
870 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
871 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
872 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
873 * target of the absolute symbolic link or junction. */
874 const wimlib_tchar *symlink_target;
877 /** The number of directories scanned so far, not counting
878 * excluded/unsupported files. */
879 uint64_t num_dirs_scanned;
881 /** The number of non-directories scanned so far, not counting
882 * excluded/unsupported files. */
883 uint64_t num_nondirs_scanned;
885 /** The number of bytes of file data detected so far, not
886 * counting excluded/unsupported files. */
887 uint64_t num_bytes_scanned;
890 /** Valid on messages
891 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
892 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
893 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
894 * ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE,
895 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
896 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA,
897 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
898 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
900 * Note: most of the time of an extraction operation will be spent
901 * extracting file data, and the application will receive
902 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
903 * completed_bytes and @p total_bytes, the application can calculate a
904 * percentage complete. However, there is no way for applications to
905 * know which file is currently being extracted. This is by design
906 * because the best way to complete the extraction operation is not
907 * necessarily file-by-file.
909 struct wimlib_progress_info_extract {
911 /** The 1-based index of the image from which files are being
915 /** Extraction flags being used. */
916 uint32_t extract_flags;
918 /** If the ::WIMStruct from which the extraction being performed
919 * has a backing file, then this is an absolute path to that
920 * backing file. Otherwise, this is @c NULL. */
921 const wimlib_tchar *wimfile_name;
923 /** Name of the image from which files are being extracted, or
924 * the empty string if the image is unnamed. */
925 const wimlib_tchar *image_name;
927 /** Path to the directory or NTFS volume to which the files are
928 * being extracted. */
929 const wimlib_tchar *target;
932 const wimlib_tchar *reserved;
934 /** The number of bytes of file data that will be extracted. */
935 uint64_t total_bytes;
937 /** The number of bytes of file data that have been extracted so
938 * far. This starts at 0 and ends at @p total_bytes. */
939 uint64_t completed_bytes;
941 /** The number of file streams that will be extracted. This
942 * will often be similar to the "number of files", but for
943 * several reasons (hard links, named data streams, empty files,
944 * etc.) it can be different. */
945 uint64_t total_streams;
947 /** The number of file streams that have been extracted so far.
948 * This starts at 0 and ends at @p total_streams. */
949 uint64_t completed_streams;
951 /** Currently only used for
952 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
953 uint32_t part_number;
955 /** Currently only used for
956 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
957 uint32_t total_parts;
959 /** Currently only used for
960 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
961 uint8_t guid[WIMLIB_GUID_LEN];
963 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
964 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is the
965 * number of files that have been processed so far. Once the
966 * corresponding phase of extraction is complete, this value
967 * will be equal to @c end_file_count. */
968 uint64_t current_file_count;
970 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
971 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is
972 * total number of files that will be processed.
974 * This number is provided for informational purposes only, e.g.
975 * for a progress bar. This number will not necessarily be
976 * equal to the number of files actually being extracted. This
977 * is because extraction backends are free to implement an
978 * extraction algorithm that might be more efficient than
979 * processing every file in the "extract file structure" and
980 * "extract file metadata" phases. For example, the current
981 * implementation of the UNIX extraction backend will create
982 * files on-demand during the "extract file data" phase.
983 * Therefore, when using that particular extraction backend, @p
984 * end_file_count will only include directories and empty files.
986 uint64_t end_file_count;
989 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
990 struct wimlib_progress_info_rename {
991 /** Name of the temporary file that the WIM was written to. */
992 const wimlib_tchar *from;
994 /** Name of the original WIM file to which the temporary file is
996 const wimlib_tchar *to;
999 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1000 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
1001 struct wimlib_progress_info_update {
1002 /** Pointer to the update command that will be executed or has
1003 * just been executed. */
1004 const struct wimlib_update_command *command;
1006 /** Number of update commands that have been completed so far.
1008 size_t completed_commands;
1010 /** Number of update commands that are being executed as part of
1011 * this call to wimlib_update_image(). */
1012 size_t total_commands;
1015 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
1016 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
1017 struct wimlib_progress_info_integrity {
1019 /** The number of bytes in the WIM file that are covered by
1020 * integrity checks. */
1021 uint64_t total_bytes;
1023 /** The number of bytes that have been checksummed so far. This
1024 * starts at 0 and ends at @p total_bytes. */
1025 uint64_t completed_bytes;
1027 /** The number of individually checksummed "chunks" the
1028 * integrity-checked region is divided into. */
1029 uint32_t total_chunks;
1031 /** The number of chunks that have been checksummed so far.
1032 * This starts at 0 and ends at @p total_chunks. */
1033 uint32_t completed_chunks;
1035 /** The size of each individually checksummed "chunk" in the
1036 * integrity-checked region. */
1037 uint32_t chunk_size;
1039 /** For ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages, this is
1040 * the path to the WIM file being checked. */
1041 const wimlib_tchar *filename;
1044 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
1045 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
1046 struct wimlib_progress_info_split {
1047 /** Total size of the original WIM's file and metadata resources
1049 uint64_t total_bytes;
1051 /** Number of bytes of file and metadata resources that have
1052 * been copied out of the original WIM so far. Will be 0
1053 * initially, and equal to @p total_bytes at the end. */
1054 uint64_t completed_bytes;
1056 /** Number of the split WIM part that is about to be started
1057 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1058 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
1059 unsigned cur_part_number;
1061 /** Total number of split WIM parts that are being written. */
1062 unsigned total_parts;
1064 /** Name of the split WIM part that is about to be started
1065 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1066 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). Since
1067 * wimlib v1.7.0, the library user may change this when
1068 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
1069 * cause the next split WIM part to be written to a different
1071 wimlib_tchar *part_name;
1074 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
1075 struct wimlib_progress_info_replace {
1076 /** Path to the file in the image that is being replaced */
1077 const wimlib_tchar *path_in_wim;
1080 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1081 struct wimlib_progress_info_wimboot_exclude {
1082 /** Path to the file in the image */
1083 const wimlib_tchar *path_in_wim;
1085 /** Path to which the file is being extracted */
1086 const wimlib_tchar *extraction_path;
1089 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1090 struct wimlib_progress_info_unmount {
1091 /** Path to directory being unmounted */
1092 const wimlib_tchar *mountpoint;
1094 /** Path to WIM file being unmounted */
1095 const wimlib_tchar *mounted_wim;
1097 /** 1-based index of image being unmounted. */
1098 uint32_t mounted_image;
1100 /** Flags that were passed to wimlib_mount_image() when the
1101 * mountpoint was set up. */
1102 uint32_t mount_flags;
1104 /** Flags passed to wimlib_unmount_image(). */
1105 uint32_t unmount_flags;
1108 /** Valid on messages ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE. */
1109 struct wimlib_progress_info_done_with_file {
1111 * Path to the file whose data has been written to the WIM file,
1112 * or is currently being asynchronously compressed in memory,
1113 * and therefore is no longer needed by wimlib.
1115 * WARNING: The file data will not actually be accessible in the
1116 * WIM file until the WIM file has been completely written.
1117 * Ordinarily you should <b>not</b> treat this message as a
1118 * green light to go ahead and delete the specified file, since
1119 * that would result in data loss if the WIM file cannot be
1120 * successfully created for any reason.
1122 * If a file has multiple names (hard links),
1123 * ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE will only be received
1124 * for one name. Also, this message will not be received for
1125 * empty files or reparse points (or symbolic links), unless
1126 * they have nonempty named data streams.
1128 const wimlib_tchar *path_to_file;
1131 /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
1132 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE. */
1133 struct wimlib_progress_info_verify_image {
1134 const wimlib_tchar *wimfile;
1135 uint32_t total_images;
1136 uint32_t current_image;
1139 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS. */
1140 struct wimlib_progress_info_verify_streams {
1141 const wimlib_tchar *wimfile;
1142 uint64_t total_streams;
1143 uint64_t total_bytes;
1144 uint64_t completed_streams;
1145 uint64_t completed_bytes;
1148 /** Valid on messages ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION. */
1149 struct wimlib_progress_info_test_file_exclusion {
1152 * Path to the file for which exclusion is being tested.
1154 * UNIX capture mode: The path will be a standard relative or
1155 * absolute UNIX filesystem path.
1157 * NTFS-3G capture mode: The path will be given relative to the
1158 * root of the NTFS volume, with a leading slash.
1160 * Windows capture mode: The path will be a Win32 namespace
1163 const wimlib_tchar *path;
1166 * Indicates whether the file or directory will be excluded from
1167 * capture or not. This will be <c>false</c> by default. The
1168 * progress function can set this to <c>true</c> if it decides
1169 * that the file needs to be excluded.
1172 } test_file_exclusion;
1174 /** Valid on messages ::WIMLIB_PROGRESS_MSG_HANDLE_ERROR. */
1175 struct wimlib_progress_info_handle_error {
1177 /** Path to the file for which the error occurred, or NULL if
1179 const wimlib_tchar *path;
1181 /** The wimlib error code associated with the error. */
1185 * Indicates whether the error will be ignored or not. This
1186 * will be <c>false</c> by default; the progress function may
1187 * set it to <c>true</c>.
1194 * A user-supplied function that will be called periodically during certain WIM
1197 * The first argument will be the type of operation that is being performed or
1198 * is about to be started or has been completed.
1200 * The second argument will be a pointer to one of a number of structures
1201 * depending on the first argument. It may be @c NULL for some message types.
1202 * Note that although this argument is not @c const, users should not modify it
1203 * except in explicitly documented cases.
1205 * The third argument will be a user-supplied value that was provided when
1206 * registering or specifying the progress function.
1208 * This function must return one of the ::wimlib_progress_status values. By
1209 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1211 typedef enum wimlib_progress_status
1212 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1213 union wimlib_progress_info *info,
1217 /** @addtogroup G_modifying_wims
1220 /** An array of these structures is passed to wimlib_add_image_multisource() to
1221 * specify the sources from which to create a WIM image. */
1222 struct wimlib_capture_source {
1223 /** Absolute or relative path to a file or directory on the external
1224 * filesystem to be included in the image. */
1225 wimlib_tchar *fs_source_path;
1227 /** Destination path in the image. To specify the root directory of the
1228 * image, use ::WIMLIB_WIM_ROOT_PATH. */
1229 wimlib_tchar *wim_target_path;
1231 /** Reserved; set to 0. */
1235 /** Set or unset the "readonly" WIM header flag (<c>WIM_HDR_FLAG_READONLY</c> in
1236 * Microsoft's documentation), based on the ::wimlib_wim_info.is_marked_readonly
1237 * member of the @p info parameter. This is distinct from basic file
1238 * permissions; this flag can be set on a WIM file that is physically writable.
1240 * wimlib disallows modifying on-disk WIM files with the readonly flag set.
1241 * However, wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG
1242 * will override this --- and in fact, this is necessary to set the readonly
1243 * flag persistently on an existing WIM file.
1245 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1247 /** Set the GUID (globally unique identifier) of the WIM file to the value
1248 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1249 #define WIMLIB_CHANGE_GUID 0x00000002
1251 /** Change the bootable image of the WIM to the value specified in
1252 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1253 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1255 /** Change the <c>WIM_HDR_FLAG_RP_FIX</c> flag of the WIM file to the value
1256 * specified in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag
1257 * generally indicates whether an image in the WIM has been captured with
1258 * reparse-point fixups enabled. wimlib also treats this flag as specifying
1259 * whether to do reparse-point fixups by default when capturing or applying WIM
1261 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1265 /** @addtogroup G_wim_information */
1270 * General information about a WIM file.
1272 * This info can also be requested for a ::WIMStruct that does not have a
1273 * backing file. In this case, fields that only make sense given a backing file
1274 * are set to default values.
1276 struct wimlib_wim_info {
1278 /** The globally unique identifier for this WIM. (Note: all parts of a
1279 * split WIM normally have identical GUIDs.) */
1280 uint8_t guid[WIMLIB_GUID_LEN];
1282 /** The number of images in this WIM file. */
1283 uint32_t image_count;
1285 /** The 1-based index of the bootable image in this WIM file, or 0 if no
1286 * image is bootable. */
1287 uint32_t boot_index;
1289 /** The version of the WIM file format used in this WIM file. */
1290 uint32_t wim_version;
1292 /** The default compression chunk size of resources in this WIM file.
1294 uint32_t chunk_size;
1296 /** For split WIMs, the 1-based index of this part within the split WIM;
1298 uint16_t part_number;
1300 /** For split WIMs, the total number of parts in the split WIM;
1302 uint16_t total_parts;
1304 /** The default compression type of resources in this WIM file, as one
1305 * of the ::wimlib_compression_type constants. */
1306 int32_t compression_type;
1308 /** The size of this WIM file in bytes, excluding the XML data and
1309 * integrity table. */
1310 uint64_t total_bytes;
1312 /** 1 iff this WIM file has an integrity table. */
1313 uint32_t has_integrity_table : 1;
1315 /** 1 iff this info struct is for a ::WIMStruct that has a backing file.
1317 uint32_t opened_from_file : 1;
1319 /** 1 iff this WIM file is considered readonly for any reason (e.g. the
1320 * "readonly" header flag is set, or this is part of a split WIM, or
1321 * filesystem permissions deny writing) */
1322 uint32_t is_readonly : 1;
1324 /** 1 iff the "reparse point fix" flag is set in this WIM's header */
1325 uint32_t has_rpfix : 1;
1327 /** 1 iff the "readonly" flag is set in this WIM's header */
1328 uint32_t is_marked_readonly : 1;
1330 /** 1 iff the "spanned" flag is set in this WIM's header */
1331 uint32_t spanned : 1;
1333 /** 1 iff the "write in progress" flag is set in this WIM's header */
1334 uint32_t write_in_progress : 1;
1336 /** 1 iff the "metadata only" flag is set in this WIM's header */
1337 uint32_t metadata_only : 1;
1339 /** 1 iff the "resource only" flag is set in this WIM's header */
1340 uint32_t resource_only : 1;
1342 /** 1 iff this WIM file is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1343 uint32_t pipable : 1;
1344 uint32_t reserved_flags : 22;
1345 uint32_t reserved[9];
1349 * Information about a "blob", which is a fixed length sequence of binary data.
1350 * Each nonempty stream of each file in a WIM image is associated with a blob.
1351 * Blobs are deduplicated within a WIM file.
1353 * TODO: this struct needs to be renamed, and perhaps made into a union since
1354 * there are several cases. I'll try to list them below:
1356 * 1. The blob is "missing", meaning that it is referenced by hash but not
1357 * actually present in the WIM file. In this case we only know the
1358 * sha1_hash. This case can only occur with wimlib_iterate_dir_tree(), never
1359 * wimlib_iterate_lookup_table().
1361 * 2. Otherwise we know the sha1_hash, the uncompressed_size, the
1362 * reference_count, and the is_metadata flag. In addition:
1364 * A. If the blob is located in a non-solid WIM resource, then we also know
1365 * the compressed_size and offset.
1367 * B. If the blob is located in a solid WIM resource, then we also know the
1368 * offset, raw_resource_offset_in_wim, raw_resource_compressed_size, and
1369 * raw_resource_uncompressed_size. But the "offset" is actually the
1370 * offset in the uncompressed solid resource rather than the offset from
1371 * the beginning of the WIM file.
1373 * C. If the blob is *not* located in any type of WIM resource, then we don't
1374 * know any additional information.
1376 * Unknown or irrelevant fields are left zeroed.
1378 struct wimlib_resource_entry {
1380 /** If this blob is not missing, then this is the uncompressed size of
1381 * this blob in bytes. */
1382 uint64_t uncompressed_size;
1384 /** If this blob is located in a non-solid WIM resource, then this is
1385 * the compressed size of that resource. */
1386 uint64_t compressed_size;
1388 /** If this blob is located in a non-solid WIM resource, then this is
1389 * the offset of that resource within the WIM file containing it. If
1390 * this blob is located in a solid WIM resource, then this is the offset
1391 * of this blob within that solid resource when uncompressed. */
1394 /** The SHA-1 message digest of the blob's uncompressed contents. */
1395 uint8_t sha1_hash[20];
1397 /** If this blob is located in a WIM resource, then this is the part
1398 * number of the WIM file containing it. */
1399 uint32_t part_number;
1401 /** If this blob is not missing, then this is the number of times this
1402 * blob is referenced over all images in the WIM. This number is not
1403 * guaranteed to be correct. */
1404 uint32_t reference_count;
1406 /** 1 iff this blob is located in a non-solid compressed WIM resource.
1408 uint32_t is_compressed : 1;
1410 /** 1 iff this blob contains the metadata for an image. */
1411 uint32_t is_metadata : 1;
1413 uint32_t is_free : 1;
1414 uint32_t is_spanned : 1;
1416 /** 1 iff a blob with this hash was not found in the blob lookup table
1417 * of the ::WIMStruct. This normally implies a missing call to
1418 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1419 uint32_t is_missing : 1;
1421 /** 1 iff this blob is located in a solid resource. */
1422 uint32_t packed : 1;
1424 uint32_t reserved_flags : 26;
1426 /** If this blob is located in a solid WIM resource, then this is the
1427 * offset of that solid resource within the WIM file containing it. */
1428 uint64_t raw_resource_offset_in_wim;
1430 /** If this blob is located in a solid WIM resource, then this is the
1431 * compressed size of that solid resource. */
1432 uint64_t raw_resource_compressed_size;
1434 /** If this blob is located in a solid WIM resource, then this is the
1435 * uncompressed size of that solid resource. */
1436 uint64_t raw_resource_uncompressed_size;
1438 uint64_t reserved[1];
1442 * Information about a stream of a particular file in the WIM.
1444 * Normally, only WIM images captured from NTFS filesystems will have multiple
1445 * streams per file. In practice, this is a rarely used feature of the
1448 * TODO: the library now explicitly tracks stream types, which allows it to have
1449 * multiple unnamed streams (e.g. both a reparse point stream and unnamed data
1450 * stream). However, this isn't yet exposed by wimlib_iterate_dir_tree().
1452 struct wimlib_stream_entry {
1454 /** Name of the stream, or NULL if the stream is unnamed. */
1455 const wimlib_tchar *stream_name;
1457 /** Info about this stream's data, such as its hash and size if known.*/
1458 struct wimlib_resource_entry resource;
1460 uint64_t reserved[4];
1464 * Since wimlib v1.9.1: an object ID, which is an extra piece of metadata that
1465 * may be associated with a file on NTFS filesystems. See:
1466 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa363997(v=vs.85).aspx
1468 struct wimlib_object_id {
1469 uint8_t object_id[WIMLIB_GUID_LEN];
1470 uint8_t birth_volume_id[WIMLIB_GUID_LEN];
1471 uint8_t birth_object_id[WIMLIB_GUID_LEN];
1472 uint8_t domain_id[WIMLIB_GUID_LEN];
1475 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1476 * Roughly, the information about a "file" in the WIM image --- but really a
1477 * directory entry ("dentry") because hard links are allowed. The
1478 * hard_link_group_id 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 image. Path separators will be
1489 * ::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 /** Size of the above security descriptor, in bytes. */
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 /* The object ID of this file, if any. Only valid if
1594 * object_id.object_id is not all zeroes. */
1595 struct wimlib_object_id object_id;
1597 uint64_t reserved[6];
1600 * Variable-length array of streams that make up this file.
1602 * The first entry will always exist and will correspond to the unnamed
1603 * data stream (default file contents), so it will have <c>stream_name
1604 * == NULL</c>. Alternatively, for reparse point files, the first entry
1605 * will correspond to the reparse data stream. Alternatively, for
1606 * encrypted files, the first entry will correspond to the encrypted
1609 * Then, following the first entry, there be @p num_named_streams
1610 * additional entries that specify the named data streams, if any, each
1611 * of which will have <c>stream_name != NULL</c>.
1613 struct wimlib_stream_entry streams[];
1617 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1620 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1624 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1627 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1630 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1631 * just on the specified path. */
1632 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1634 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1635 * itself; only its children (in the case of a non-empty directory) */
1636 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1638 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any file data blobs needed to fill
1639 * in the ::wimlib_resource_entry's for the iteration cannot be found in the
1640 * blob lookup table of the ::WIMStruct. The default behavior without this flag
1641 * is to fill in the @ref wimlib_resource_entry::sha1_hash "sha1_hash" and set
1642 * the @ref wimlib_resource_entry::is_missing "is_missing" flag. */
1643 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1647 /** @addtogroup G_modifying_wims
1650 /** UNIX-like systems only: Directly capture an NTFS volume rather than a
1651 * generic directory. This requires that wimlib was compiled with support for
1654 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1655 * ::WIMLIB_ADD_FLAG_UNIX_DATA.
1657 * Do not use this flag on Windows, where wimlib already supports all
1658 * Windows-native filesystems, including NTFS, through the Windows APIs. */
1659 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1661 /** Follow symbolic links when scanning the directory tree. Currently only
1662 * supported on UNIX-like systems. */
1663 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1665 /** Call the progress function with the message
1666 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1668 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1670 /** Mark the image being added as the bootable image of the WIM. This flag is
1671 * valid only for wimlib_add_image() and wimlib_add_image_multisource().
1673 * Note that you can also change the bootable image of a WIM using
1674 * wimlib_set_wim_info().
1676 * Note: ::WIMLIB_ADD_FLAG_BOOT does something different from, and independent
1677 * from, ::WIMLIB_ADD_FLAG_WIMBOOT. */
1678 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1680 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1681 * (major and minor number) of each file. In addition, capture special files
1682 * such as device nodes and FIFOs. See the documentation for the
1683 * <b>--unix-data</b> option to <b>wimcapture</b> for more information. */
1684 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1686 /** Do not capture security descriptors. Only has an effect in NTFS-3G capture
1687 * mode, or in Windows native builds. */
1688 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1690 /** Fail immediately if the full security descriptor of any file or directory
1691 * cannot be accessed. Only has an effect in Windows native builds. The
1692 * default behavior without this flag is to first try omitting the SACL from the
1693 * security descriptor, then to try omitting the security descriptor entirely.
1695 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1697 /** Call the progress function with the message
1698 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1699 * capture. This is a subset of the messages provided by
1700 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1701 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1703 /** Reparse-point fixups: Modify absolute symbolic links (and junctions, in the
1704 * case of Windows) that point inside the directory being captured to instead be
1705 * absolute relative to the directory being captured.
1707 * Without this flag, the default is to do reparse-point fixups if
1708 * <c>WIM_HDR_FLAG_RP_FIX</c> is set in the WIM header or if this is the first
1709 * image being added. */
1710 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1712 /** Don't do reparse point fixups. See ::WIMLIB_ADD_FLAG_RPFIX. */
1713 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1715 /** Do not automatically exclude unsupported files or directories from capture,
1716 * such as encrypted files in NTFS-3G capture mode, or device files and FIFOs on
1717 * UNIX-like systems when not also using ::WIMLIB_ADD_FLAG_UNIX_DATA. Instead,
1718 * fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when such a file is encountered. */
1719 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1722 * Automatically select a capture configuration appropriate for capturing
1723 * filesystems containing Windows operating systems. For example,
1724 * <c>/pagefile.sys</c> and <c>"/System Volume Information"</c> will be
1727 * When this flag is specified, the corresponding @p config parameter (for
1728 * wimlib_add_image()) or member (for wimlib_update_image()) must be @c NULL.
1729 * Otherwise, ::WIMLIB_ERR_INVALID_PARAM will be returned.
1731 * Note that the default behavior--- that is, when neither
1732 * ::WIMLIB_ADD_FLAG_WINCONFIG nor ::WIMLIB_ADD_FLAG_WIMBOOT is specified and @p
1733 * config is @c NULL--- is to use no capture configuration, meaning that no
1734 * files are excluded from capture.
1736 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1739 * Capture image as "WIMBoot compatible". In addition, if no capture
1740 * configuration file is explicitly specified use the capture configuration file
1741 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1742 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1743 * configuration file is explicitly specified, use it and also place it at
1744 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image.
1746 * This flag does not, by itself, change the compression type or chunk size.
1747 * Before writing the WIM file, you may wish to set the compression format to
1748 * be the same as that used by WIMGAPI and DISM:
1751 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1752 * wimlib_set_output_chunk_size(wim, 4096);
1755 * However, "WIMBoot" also works with other XPRESS chunk sizes as well as LZX
1756 * with 32768 byte chunks.
1758 * Note: ::WIMLIB_ADD_FLAG_WIMBOOT does something different from, and
1759 * independent from, ::WIMLIB_ADD_FLAG_BOOT.
1761 * Since wimlib v1.8.3, ::WIMLIB_ADD_FLAG_WIMBOOT also causes offline WIM-backed
1762 * files to be added as the "real" files rather than as their reparse points,
1763 * provided that their data is already present in the WIM. This feature can be
1764 * useful when updating a backing WIM file in an "offline" state.
1766 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1769 * If the add command involves adding a non-directory file to a location at
1770 * which there already exists a nondirectory file in the image, issue
1771 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This was the
1772 * default behavior before wimlib v1.7.0.
1774 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1777 * Send ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION messages to the progress
1780 * Note: This method for file exclusions is independent from the capture
1781 * configuration file mechanism.
1783 #define WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION 0x00004000
1786 * Since wimlib v1.9.0: create a temporary filesystem snapshot of the source
1787 * directory and add the files from it. Currently, this option is only
1788 * supported on Windows, where it uses the Volume Shadow Copy Service (VSS).
1789 * Using this option, you can create a consistent backup of the system volume of
1790 * a running Windows system without running into problems with locked files.
1791 * For the VSS snapshot to be successfully created, your application must be run
1792 * as an Administrator, and it cannot be run in WoW64 mode (i.e. if Windows is
1793 * 64-bit, then your application must be 64-bit as well).
1795 #define WIMLIB_ADD_FLAG_SNAPSHOT 0x00008000
1798 * Since wimlib v1.9.0: permit the library to discard file paths after the
1799 * initial scan. If the application won't use
1800 * ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES while writing the WIM
1801 * archive, this flag can be used to allow the library to enable optimizations
1802 * such as opening files by inode number rather than by path. Currently this
1803 * only makes a difference on Windows.
1805 #define WIMLIB_ADD_FLAG_FILE_PATHS_UNNEEDED 0x00010000
1808 /** @addtogroup G_modifying_wims
1811 /** Do not issue an error if the path to delete does not exist. */
1812 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1814 /** Delete the file or directory tree recursively; if not specified, an error is
1815 * issued if the path to delete is a directory. */
1816 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1819 /** @addtogroup G_modifying_wims
1823 * If a single image is being exported, mark it bootable in the destination WIM.
1824 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1825 * the image in the source WIM (if any) that is marked as bootable is also
1826 * marked as bootable in the destination WIM.
1828 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1830 /** Give the exported image(s) no names. Avoids problems with image name
1833 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1835 /** Give the exported image(s) no descriptions. */
1836 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1838 /** This advises the library that the program is finished with the source
1839 * WIMStruct and will not attempt to access it after the call to
1840 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1841 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1844 * Mark each exported image as WIMBoot-compatible.
1846 * Note: by itself, this does change the destination WIM's compression type, nor
1847 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1848 * image. Before writing the destination WIM, it's recommended to do something
1852 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1853 * wimlib_set_output_chunk_size(wim, 4096);
1854 * wimlib_add_tree(wim, image, L"myconfig.ini",
1855 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1858 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1861 /** @addtogroup G_extracting_wims
1864 /** Extract the image directly to an NTFS volume rather than a generic directory.
1865 * This mode is only available if wimlib was compiled with libntfs-3g support;
1866 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1867 * extraction target will be interpreted as the path to an NTFS volume image (as
1868 * a regular file or block device) rather than a directory. It will be opened
1869 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1870 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1871 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1872 * wimlib_extract_paths() when passed multiple paths. */
1873 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1875 /** UNIX-like systems only: Extract special UNIX data captured with
1876 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1877 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1878 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1880 /** Do not extract security descriptors. This flag cannot be combined with
1881 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1882 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1885 * Fail immediately if the full security descriptor of any file or directory
1886 * cannot be set exactly as specified in the WIM image. On Windows, the default
1887 * behavior without this flag when wimlib does not have permission to set the
1888 * correct security descriptor is to fall back to setting the security
1889 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1890 * owner omitted, then not at all. This flag cannot be combined with
1891 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS.
1893 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1896 * This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1897 * reparse-point fixups on, so absolute symbolic links or junction points will
1898 * be fixed to be absolute relative to the actual extraction root. Reparse-
1899 * point fixups are done by default for wimlib_extract_image() and
1900 * wimlib_extract_image_from_pipe() if <c>WIM_HDR_FLAG_RP_FIX</c> is set in the
1901 * WIM header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX.
1903 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1905 /** Force reparse-point fixups on extraction off, regardless of the state of the
1906 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1907 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1908 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1910 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1911 * paths, each of which must name a regular file, to standard output. */
1912 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1915 * Instead of ignoring files and directories with names that cannot be
1916 * represented on the current platform (note: Windows has more restrictions on
1917 * filenames than POSIX-compliant systems), try to replace characters or append
1918 * junk to the names so that they can be extracted in some form.
1920 * Note: this flag is unlikely to have any effect when extracting a WIM image
1921 * that was captured on Windows.
1923 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1926 * On Windows, when there exist two or more files with the same case insensitive
1927 * name but different case sensitive names, try to extract them all by appending
1928 * junk to the end of them, rather than arbitrarily extracting only one.
1930 * Note: this flag is unlikely to have any effect when extracting a WIM image
1931 * that was captured on Windows.
1933 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1935 /** Do not ignore failure to set timestamps on extracted files. This flag
1936 * currently only has an effect when extracting to a directory on UNIX-like
1938 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1940 /** Do not ignore failure to set short names on extracted files. This flag
1941 * currently only has an effect on Windows. */
1942 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1944 /** Do not ignore failure to extract symbolic links and junctions due to
1945 * permissions problems. This flag currently only has an effect on Windows. By
1946 * default, such failures are ignored since the default configuration of Windows
1947 * only allows the Administrator to create symbolic links. */
1948 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1951 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1952 * paths to extract as wildcard patterns ("globs") which may contain the
1953 * wildcard characters @c ? and @c *. The @c ? character matches any
1954 * non-path-separator character, whereas the @c * character matches zero or more
1955 * non-path-separator characters. Consequently, each glob may match zero or
1956 * more actual paths in the WIM image.
1958 * By default, if a glob does not match any files, a warning but not an error
1959 * will be issued. This is the case even if the glob did not actually contain
1960 * wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error
1963 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1965 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1966 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1967 * one of the provided globs did not match a file. */
1968 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1971 * Do not extract Windows file attributes such as readonly, hidden, etc.
1973 * This flag has an effect on Windows as well as in the NTFS-3G extraction mode.
1975 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1978 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1979 * preserve the directory structure of the archive when extracting --- that is,
1980 * place each extracted file or directory tree directly in the target directory.
1981 * The target directory will still be created if it does not already exist.
1983 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1986 * Windows only: Extract files as "pointers" back to the WIM archive.
1988 * The effects of this option are fairly complex. See the documentation for the
1989 * <b>--wimboot</b> option of <b>wimapply</b> for more information.
1991 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1994 * Since wimlib v1.8.2 and Windows-only: compress the extracted files using
1995 * System Compression, when possible. This only works on either Windows 10 or
1996 * later, or on an older Windows to which Microsoft's wofadk.sys driver has been
1997 * added. Several different compression formats may be used with System
1998 * Compression; this particular flag selects the XPRESS compression format with
2001 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K 0x01000000
2003 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2004 * 8192 byte chunks. */
2005 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K 0x02000000
2007 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2008 * 16384 byte chunks. */
2009 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K 0x04000000
2011 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use LZX compression with
2012 * 32768 byte chunks. */
2013 #define WIMLIB_EXTRACT_FLAG_COMPACT_LZX 0x08000000
2016 /** @addtogroup G_mounting_wim_images
2019 /** Mount the WIM image read-write rather than the default of read-only. */
2020 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
2022 /** Enable FUSE debugging by passing the @c -d option to @c fuse_main(). */
2023 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
2025 /** Do not allow accessing named data streams in the mounted WIM image. */
2026 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
2028 /** Access named data streams in the mounted WIM image through extended file
2029 * attributes named "user.X", where X is the name of a data stream. This is the
2031 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
2033 /** Access named data streams in the mounted WIM image by specifying the file
2034 * name, a colon, then the name of the data stream. */
2035 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
2037 /** Use UNIX metadata if available in the WIM image. See
2038 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
2039 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
2041 /** Allow other users to see the mounted filesystem. This passes the @c
2042 * allow_other option to fuse_main(). */
2043 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
2046 /** @addtogroup G_creating_and_opening_wims
2049 /** Verify the WIM contents against the WIM's integrity table, if present. The
2050 * integrity table stores checksums for the raw data of the WIM file, divided
2051 * into fixed size chunks. Verification will compute checksums and compare them
2052 * with the stored values. If there are any mismatches, then
2053 * ::WIMLIB_ERR_INTEGRITY will be issued. If the WIM file does not contain an
2054 * integrity table, then this flag has no effect. */
2055 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
2057 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
2058 * WIM. Software can provide this flag for convenience if it explicitly does
2059 * not want to support split WIMs. */
2060 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
2062 /** Check if the WIM is writable and issue an error
2063 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
2064 * only if it is writable at the filesystem level, does not have the
2065 * <c>WIM_HDR_FLAG_READONLY</c> flag set in its header, and is not part of a
2066 * spanned set. It is not required to provide this flag before attempting to
2067 * make changes to the WIM, but with this flag you get an error immediately
2068 * rather than potentially much later, when wimlib_overwrite() is finally
2070 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
2073 /** @addtogroup G_mounting_wim_images
2076 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
2077 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2078 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
2080 /** Commit changes to the read-write mounted WIM image.
2081 * If this flag is not specified, changes will be discarded. */
2082 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
2084 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
2085 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2086 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
2088 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
2089 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2090 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
2093 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
2094 * image, forces all file descriptors to the open WIM image to be closed before
2097 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
2098 * this flag has no effect.
2100 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
2102 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
2103 * WIM image, causes the modified image to be committed to the WIM file as a
2104 * new, unnamed image appended to the archive. The original image in the WIM
2105 * file will be unmodified. */
2106 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
2109 /** @addtogroup G_modifying_wims
2112 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
2113 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
2114 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
2117 /** @addtogroup G_writing_and_overwriting_wims
2121 * Include an integrity table in the resulting WIM file.
2123 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2124 * include an integrity table if and only if one was present before. For
2125 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2126 * to not include an integrity table.
2128 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
2131 * Do not include an integrity table in the resulting WIM file. This is the
2132 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
2135 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
2138 * Write the WIM as "pipable". After writing a WIM with this flag specified,
2139 * images from it can be applied directly from a pipe using
2140 * wimlib_extract_image_from_pipe(). See the documentation for the
2141 * <b>--pipable</b> option of <b>wimcapture</b> for more information. Beware:
2142 * WIMs written with this flag will not be compatible with Microsoft's software.
2144 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2145 * write the WIM as pipable if and only if it was pipable before. For
2146 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2147 * to write the WIM as non-pipable.
2149 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
2152 * Do not write the WIM as "pipable". This is the default behavior, unless the
2153 * ::WIMStruct was created by opening a pipable WIM.
2155 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
2158 * When writing data to the WIM file, recompress it, even if the data is already
2159 * available in the desired compressed form (for example, in a WIM file from
2160 * which an image has been exported using wimlib_export_image()).
2162 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
2163 * compression ratio for the same compression type and chunk size. Simply using
2164 * the default compression settings may suffice for this, especially if the WIM
2165 * file was created using another program/library that may not use as
2166 * sophisticated compression algorithms. Or,
2167 * wimlib_set_default_compression_level() can be called beforehand to set an
2168 * even higher compression level than the default.
2170 * If the WIM contains solid resources, then ::WIMLIB_WRITE_FLAG_RECOMPRESS can
2171 * be used in combination with ::WIMLIB_WRITE_FLAG_SOLID to prevent any solid
2172 * resources from being re-used. Otherwise, solid resources are re-used
2173 * somewhat more liberally than normal compressed resources.
2175 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of data
2176 * that would not otherwise be written. For example, a call to
2177 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
2178 * cause already-existing data in the WIM file to be recompressed. To force the
2179 * WIM file to be fully rebuilt and recompressed, combine
2180 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
2182 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
2185 * Immediately before closing the WIM file, sync its data to disk.
2187 * This flag forces the function to wait until the data is safely on disk before
2188 * returning success. Otherwise, modern operating systems tend to cache data
2189 * for some time (in some cases, 30+ seconds) before actually writing it to
2190 * disk, even after reporting to the application that the writes have succeeded.
2192 * wimlib_overwrite() will set this flag automatically if it decides to
2193 * overwrite the WIM file via a temporary file instead of in-place. This is
2194 * necessary on POSIX systems; it will, for example, avoid problems with delayed
2195 * allocation on ext4.
2197 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
2200 * For wimlib_overwrite(): rebuild the entire WIM file, even if it otherwise
2201 * could be updated in-place by appending to it. Any data that existed in the
2202 * original WIM file but is not actually needed by any of the remaining images
2203 * will not be included. This can free up space left over after previous
2204 * in-place modifications to the WIM file.
2206 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
2207 * data to be recompressed. Otherwise, compressed data is re-used if possible.
2209 * wimlib_write() ignores this flag.
2211 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
2214 * For wimlib_overwrite(): override the default behavior after one or more calls
2215 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
2216 * flag, only minimal changes to correctly remove the image from the WIM file
2217 * will be taken. This can be much faster, but it will result in the WIM file
2218 * getting larger rather than smaller.
2220 * wimlib_write() ignores this flag.
2222 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
2225 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
2226 * flag (<c>WIM_HDR_FLAG_READONLY</c>) is set in the WIM header. This can be
2227 * used following a call to wimlib_set_wim_info() with the
2228 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
2231 * wimlib_write() ignores this flag.
2233 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
2236 * Do not include file data already present in other WIMs. This flag can be
2237 * used to write a "delta" WIM after the WIM files on which the delta is to be
2238 * based were referenced with wimlib_reference_resource_files() or
2239 * wimlib_reference_resources().
2241 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
2243 /** Deprecated; this flag should not be used outside of the library itself. */
2244 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
2247 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
2249 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
2252 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
2255 * Concatenate files and compress them together, rather than compress each file
2256 * independently. This is also known as creating a "solid archive". This tends
2257 * to produce a better compression ratio at the cost of much slower random
2260 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
2261 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
2262 * created with this flag use a different version number in their header (3584
2263 * instead of 68864) and are also called "ESD files".
2265 * Note that providing this flag does not affect the "append by default"
2266 * behavior of wimlib_overwrite(). In other words, wimlib_overwrite() with just
2267 * ::WIMLIB_WRITE_FLAG_SOLID can be used to append solid-compressed data to a
2268 * WIM file that originally did not contain any solid-compressed data. But if
2269 * you instead want to rebuild and recompress an entire WIM file in solid mode,
2270 * then also provide ::WIMLIB_WRITE_FLAG_REBUILD and
2271 * ::WIMLIB_WRITE_FLAG_RECOMPRESS.
2273 * Currently, new solid resources will, by default, be written using LZMS
2274 * compression with 64 MiB (67108864 byte) chunks. Use
2275 * wimlib_set_output_pack_compression_type() and/or
2276 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
2277 * the WIM's main compression type and chunk size; you can have a WIM that
2278 * nominally uses LZX compression and 32768 byte chunks but actually contains
2279 * LZMS-compressed solid resources, for example. However, if including solid
2280 * resources, I suggest that you set the WIM's main compression type to LZMS as
2281 * well, either by creating the WIM with
2282 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
2283 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
2285 * This flag will be set by default when writing or overwriting a WIM file that
2286 * either already contains solid resources, or has had solid resources exported
2287 * into it and the WIM's main compression type is LZMS.
2289 #define WIMLIB_WRITE_FLAG_SOLID 0x00001000
2292 * Send ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE messages while writing the WIM
2293 * file. This is only needed in the unusual case that the library user needs to
2294 * know exactly when wimlib has read each file for the last time.
2296 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
2299 * Do not consider content similarity when arranging file data for solid
2300 * compression. Providing this flag will typically worsen the compression
2301 * ratio, so only provide this flag if you know what you are doing.
2303 #define WIMLIB_WRITE_FLAG_NO_SOLID_SORT 0x00004000
2306 * Since wimlib v1.8.3 and for wimlib_overwrite() only: <b>unsafely</b> compact
2307 * the WIM file in-place, without appending. Existing resources are shifted
2308 * down to fill holes and new resources are appended as needed. The WIM file is
2309 * truncated to its final size, which may shrink the on-disk file. <b>This
2310 * operation cannot be safely interrupted. If the operation is interrupted,
2311 * then the WIM file will be corrupted, and it may be impossible (or at least
2312 * very difficult) to recover any data from it. Users of this flag are expected
2313 * to know what they are doing and assume responsibility for any data corruption
2314 * that may result.</b>
2316 * If the WIM file cannot be compacted in-place because of its structure, its
2317 * layout, or other requested write parameters, then wimlib_overwrite() fails
2318 * with ::WIMLIB_ERR_COMPACTION_NOT_POSSIBLE, and the caller may wish to retry
2319 * the operation without this flag.
2321 #define WIMLIB_WRITE_FLAG_UNSAFE_COMPACT 0x00008000
2324 /** @addtogroup G_general
2327 /** Deprecated; no longer has any effect. */
2328 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
2330 /** Windows-only: do not attempt to acquire additional privileges (currently
2331 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege,
2332 * SeTakeOwnershipPrivilege, and SeManageVolumePrivilege) when initializing the
2333 * library. This flag is intended for the case where the calling program
2334 * manages these privileges itself. Note: by default, no error is issued if
2335 * privileges cannot be acquired, although related errors may be reported later,
2336 * depending on if the operations performed actually require additional
2337 * privileges or not. */
2338 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
2340 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2341 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2342 * to read all possible data and metadata for a capture operation could not be
2343 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
2345 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
2347 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2348 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2349 * to restore all possible data and metadata for an apply operation could not be
2350 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
2352 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
2354 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
2356 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
2358 /** Default to interpreting WIM paths case insensitively (default on Windows).
2359 * This does not apply to mounted images. */
2360 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
2363 /** @addtogroup G_nonstandalone_wims
2366 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
2367 * Ignored by wimlib_reference_resources(). */
2368 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
2370 /** For wimlib_reference_resource_files(), issue an error
2371 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
2372 * default behavior without this flag is to issue no error at that point, but
2373 * then attempt to open the glob as a literal path, which of course will fail
2374 * anyway if no file exists at that path. No effect if
2375 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
2376 * wimlib_reference_resources(). */
2377 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
2380 /** @addtogroup G_modifying_wims
2383 /** The specific type of update to perform. */
2384 enum wimlib_update_op {
2385 /** Add a new file or directory tree to the image. */
2386 WIMLIB_UPDATE_OP_ADD = 0,
2388 /** Delete a file or directory tree from the image. */
2389 WIMLIB_UPDATE_OP_DELETE = 1,
2391 /** Rename a file or directory tree in the image. */
2392 WIMLIB_UPDATE_OP_RENAME = 2,
2395 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2396 struct wimlib_add_command {
2397 /** Filesystem path to the file or directory tree to add. */
2398 wimlib_tchar *fs_source_path;
2400 /** Destination path in the image. To specify the root directory of the
2401 * image, use ::WIMLIB_WIM_ROOT_PATH. */
2402 wimlib_tchar *wim_target_path;
2404 /** Path to capture configuration file to use, or @c NULL if not
2406 wimlib_tchar *config_file;
2408 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2412 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2413 struct wimlib_delete_command {
2415 /** The path to the file or directory within the image to delete. */
2416 wimlib_tchar *wim_path;
2418 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2422 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2423 struct wimlib_rename_command {
2425 /** The path to the source file or directory within the image. */
2426 wimlib_tchar *wim_source_path;
2428 /** The path to the destination file or directory within the image. */
2429 wimlib_tchar *wim_target_path;
2431 /** Reserved; set to 0. */
2435 /** Specification of an update to perform on a WIM image. */
2436 struct wimlib_update_command {
2438 enum wimlib_update_op op;
2441 struct wimlib_add_command add;
2442 struct wimlib_delete_command delete_; /* Underscore is for C++
2444 struct wimlib_rename_command rename;
2449 /** @addtogroup G_general
2453 * Possible values of the error code returned by many functions in wimlib.
2455 * See the documentation for each wimlib function to see specifically what error
2456 * codes can be returned by a given function, and what they mean.
2458 enum wimlib_error_code {
2459 WIMLIB_ERR_SUCCESS = 0,
2460 WIMLIB_ERR_ALREADY_LOCKED = 1,
2461 WIMLIB_ERR_DECOMPRESSION = 2,
2462 WIMLIB_ERR_FUSE = 6,
2463 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2464 WIMLIB_ERR_IMAGE_COUNT = 10,
2465 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2466 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2467 WIMLIB_ERR_INTEGRITY = 13,
2468 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2469 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2470 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2471 WIMLIB_ERR_INVALID_HEADER = 17,
2472 WIMLIB_ERR_INVALID_IMAGE = 18,
2473 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2474 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2475 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2476 WIMLIB_ERR_INVALID_OVERLAY = 23,
2477 WIMLIB_ERR_INVALID_PARAM = 24,
2478 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2479 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2480 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2481 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2482 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2483 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2484 WIMLIB_ERR_IS_DIRECTORY = 32,
2485 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2486 WIMLIB_ERR_LINK = 35,
2487 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2488 WIMLIB_ERR_MKDIR = 37,
2489 WIMLIB_ERR_MQUEUE = 38,
2490 WIMLIB_ERR_NOMEM = 39,
2491 WIMLIB_ERR_NOTDIR = 40,
2492 WIMLIB_ERR_NOTEMPTY = 41,
2493 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2494 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2495 WIMLIB_ERR_NOT_PIPABLE = 44,
2496 WIMLIB_ERR_NO_FILENAME = 45,
2497 WIMLIB_ERR_NTFS_3G = 46,
2498 WIMLIB_ERR_OPEN = 47,
2499 WIMLIB_ERR_OPENDIR = 48,
2500 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2501 WIMLIB_ERR_READ = 50,
2502 WIMLIB_ERR_READLINK = 51,
2503 WIMLIB_ERR_RENAME = 52,
2504 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2505 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2506 WIMLIB_ERR_RESOURCE_ORDER = 56,
2507 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2508 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2509 WIMLIB_ERR_SET_SECURITY = 59,
2510 WIMLIB_ERR_SET_SHORT_NAME = 60,
2511 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2512 WIMLIB_ERR_SPLIT_INVALID = 62,
2513 WIMLIB_ERR_STAT = 63,
2514 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2515 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2516 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2517 WIMLIB_ERR_UNSUPPORTED = 68,
2518 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2519 WIMLIB_ERR_WIM_IS_READONLY = 71,
2520 WIMLIB_ERR_WRITE = 72,
2521 WIMLIB_ERR_XML = 73,
2522 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2523 WIMLIB_ERR_WIMBOOT = 75,
2524 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2525 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2526 WIMLIB_ERR_MKNOD = 78,
2527 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2528 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2529 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2530 WIMLIB_ERR_FVE_LOCKED_VOLUME = 82,
2531 WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG = 83,
2532 WIMLIB_ERR_WIM_IS_INCOMPLETE = 84,
2533 WIMLIB_ERR_COMPACTION_NOT_POSSIBLE = 85,
2534 WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES = 86,
2535 WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE = 87,
2536 WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED = 88,
2537 WIMLIB_ERR_SNAPSHOT_FAILURE = 89,
2541 /** Used to indicate no image or an invalid image. */
2542 #define WIMLIB_NO_IMAGE 0
2544 /** Used to specify all images in the WIM. */
2545 #define WIMLIB_ALL_IMAGES (-1)
2550 * @ingroup G_modifying_wims
2552 * Append an empty image to a ::WIMStruct.
2554 * The new image will initially contain no files or directories, although if
2555 * written without further modifications, then a root directory will be created
2556 * automatically for it.
2558 * After calling this function, you can use wimlib_update_image() to add files
2559 * to the new image. This gives you more control over making the new image
2560 * compared to calling wimlib_add_image() or wimlib_add_image_multisource().
2563 * Pointer to the ::WIMStruct to which to add the image.
2565 * Name to give the new image. If @c NULL or empty, the new image is given
2566 * no name. If nonempty, it must specify a name that does not already
2568 * @param new_idx_ret
2569 * If non-<c>NULL</c>, the index of the newly added image is returned in
2572 * @return 0 on success; a ::wimlib_error_code value on failure.
2574 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2575 * The WIM already contains an image with the requested name.
2578 wimlib_add_empty_image(WIMStruct *wim,
2579 const wimlib_tchar *name,
2583 * @ingroup G_modifying_wims
2585 * Add an image to a ::WIMStruct from an on-disk directory tree or NTFS volume.
2587 * The directory tree or NTFS volume is scanned immediately to load the dentry
2588 * tree into memory, and file metadata is read. However, actual file data may
2589 * not be read until the ::WIMStruct is persisted to disk using wimlib_write()
2590 * or wimlib_overwrite().
2592 * See the documentation for the @b wimlib-imagex program for more information
2593 * about the "normal" capture mode versus the NTFS capture mode (entered by
2594 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2596 * Note that no changes are committed to disk until wimlib_write() or
2597 * wimlib_overwrite() is called.
2600 * Pointer to the ::WIMStruct to which to add the image.
2602 * A path to a directory or unmounted NTFS volume that will be captured as
2605 * Name to give the new image. If @c NULL or empty, the new image is given
2606 * no name. If nonempty, it must specify a name that does not already
2608 * @param config_file
2609 * Path to capture configuration file, or @c NULL. This file may specify,
2610 * among other things, which files to exclude from capture. See the
2611 * documentation for <b>wimcapture</b> (<b>--config</b> option) for details
2612 * of the file format. If @c NULL, the default capture configuration will
2613 * be used. Ordinarily, the default capture configuration will result in
2614 * no files being excluded from capture purely based on name; however, the
2615 * ::WIMLIB_ADD_FLAG_WINCONFIG and ::WIMLIB_ADD_FLAG_WIMBOOT flags modify
2618 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2620 * @return 0 on success; a ::wimlib_error_code value on failure.
2622 * This function is implemented by calling wimlib_add_empty_image(), then
2623 * calling wimlib_update_image() with a single "add" command, so any error code
2624 * returned by wimlib_add_empty_image() may be returned, as well as any error
2625 * codes returned by wimlib_update_image() other than ones documented as only
2626 * being returned specifically by an update involving delete or rename commands.
2628 * If a progress function is registered with @p wim, then it will receive the
2629 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2630 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2631 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2634 wimlib_add_image(WIMStruct *wim,
2635 const wimlib_tchar *source,
2636 const wimlib_tchar *name,
2637 const wimlib_tchar *config_file,
2641 * @ingroup G_modifying_wims
2643 * This function is equivalent to wimlib_add_image() except it allows for
2644 * multiple sources to be combined into a single WIM image. This is done by
2645 * specifying the @p sources and @p num_sources parameters instead of the @p
2646 * source parameter of wimlib_add_image(). The rest of the parameters are the
2647 * same as wimlib_add_image(). See the documentation for <b>wimcapture</b> for
2648 * full details on how this mode works.
2651 wimlib_add_image_multisource(WIMStruct *wim,
2652 const struct wimlib_capture_source *sources,
2654 const wimlib_tchar *name,
2655 const wimlib_tchar *config_file,
2659 * @ingroup G_modifying_wims
2661 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2662 * location @p wim_target_path within the specified @p image of the @p wim.
2664 * This just builds an appropriate ::wimlib_add_command and passes it to
2665 * wimlib_update_image().
2668 wimlib_add_tree(WIMStruct *wim, int image,
2669 const wimlib_tchar *fs_source_path,
2670 const wimlib_tchar *wim_target_path, int add_flags);
2673 * @ingroup G_creating_and_opening_wims
2675 * Create a ::WIMStruct which initially contains no images and is not backed by
2679 * The "output compression type" to assign to the ::WIMStruct. This is the
2680 * compression type that will be used if the ::WIMStruct is later persisted
2681 * to an on-disk file using wimlib_write().
2683 * This choice is not necessarily final. If desired, it can still be
2684 * changed at any time before wimlib_write() is called, using
2685 * wimlib_set_output_compression_type(). In addition, if you wish to use a
2686 * non-default compression chunk size, then you will need to call
2687 * wimlib_set_output_chunk_size().
2689 * On success, a pointer to the new ::WIMStruct is written to the memory
2690 * location pointed to by this parameter. This ::WIMStruct must be freed
2691 * using using wimlib_free() when finished with it.
2693 * @return 0 on success; a ::wimlib_error_code value on failure.
2695 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2696 * @p ctype was not a supported compression type.
2697 * @retval ::WIMLIB_ERR_NOMEM
2698 * Insufficient memory to allocate a new ::WIMStruct.
2701 wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret);
2704 * @ingroup G_modifying_wims
2706 * Delete an image, or all images, from a ::WIMStruct.
2708 * Note that no changes are committed to disk until wimlib_write() or
2709 * wimlib_overwrite() is called.
2712 * Pointer to the ::WIMStruct from which to delete the image.
2714 * The 1-based index of the image to delete, or ::WIMLIB_ALL_IMAGES to
2715 * delete all images.
2717 * @return 0 on success; a ::wimlib_error_code value on failure.
2719 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2720 * @p image does not exist in the WIM.
2722 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2723 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2724 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2725 * indicate failure (for different reasons) to read the metadata resource for an
2726 * image that needed to be deleted.
2728 * If this function fails when @p image was ::WIMLIB_ALL_IMAGES, then it's
2729 * possible that some but not all of the images were deleted.
2732 wimlib_delete_image(WIMStruct *wim, int image);
2735 * @ingroup G_modifying_wims
2737 * Delete the @p path from the specified @p image of the @p wim.
2739 * This just builds an appropriate ::wimlib_delete_command and passes it to
2740 * wimlib_update_image().
2743 wimlib_delete_path(WIMStruct *wim, int image,
2744 const wimlib_tchar *path, int delete_flags);
2747 * @ingroup G_modifying_wims
2749 * Export an image, or all images, from a ::WIMStruct into another ::WIMStruct.
2751 * Specifically, if the destination ::WIMStruct contains <tt>n</tt> images, then
2752 * the source image(s) will be appended, in order, starting at destination index
2753 * <tt>n + 1</tt>. By default, all image metadata will be exported verbatim,
2754 * but certain changes can be made by passing appropriate parameters.
2756 * wimlib_export_image() is only an in-memory operation; no changes are
2757 * committed to disk until wimlib_write() or wimlib_overwrite() is called.
2759 * A limitation of the current implementation of wimlib_export_image() is that
2760 * the directory tree of a source or destination image cannot be updated
2761 * following an export until one of the two images has been freed from memory.
2764 * The WIM from which to export the images, specified as a pointer to the
2765 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2766 * split WIM. In the case of a WIM file that is not standalone, this
2767 * ::WIMStruct must have had any needed external resources previously
2768 * referenced using wimlib_reference_resources() or
2769 * wimlib_reference_resource_files().
2771 * The 1-based index of the image from @p src_wim to export, or
2772 * ::WIMLIB_ALL_IMAGES.
2774 * The ::WIMStruct to which to export the images.
2776 * For single-image exports, the name to give the exported image in @p
2777 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2778 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2779 * that case, the names are all taken from @p src_wim. This parameter is
2780 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2781 * @param dest_description
2782 * For single-image exports, the description to give the exported image in
2783 * the new WIM file. If left @c NULL, the description from @p src_wim is
2784 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2785 * NULL; in that case, the description are all taken from @p src_wim. This
2786 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2787 * @param export_flags
2788 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2790 * @return 0 on success; a ::wimlib_error_code value on failure.
2792 * @retval ::WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE
2793 * One or more of the source images had already been exported into the
2795 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2796 * One or more of the names being given to an exported image was already in
2797 * use in the destination WIM.
2798 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2799 * @p src_image does not exist in @p src_wim.
2800 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2801 * At least one of @p src_wim and @p dest_wim does not contain image
2802 * metadata; for example, one of them represents a non-first part of a
2804 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2805 * A file data blob that needed to be exported could not be found in the
2806 * blob lookup table of @p src_wim. See @ref G_nonstandalone_wims.
2808 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2809 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2810 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2811 * indicate failure (for different reasons) to read the metadata resource for an
2812 * image in @p src_wim that needed to be exported.
2815 wimlib_export_image(WIMStruct *src_wim, int src_image,
2816 WIMStruct *dest_wim,
2817 const wimlib_tchar *dest_name,
2818 const wimlib_tchar *dest_description,
2822 * @ingroup G_extracting_wims
2824 * Extract an image, or all images, from a ::WIMStruct.
2826 * The exact behavior of how wimlib extracts files from a WIM image is
2827 * controllable by the @p extract_flags parameter, but there also are
2828 * differences depending on the platform (UNIX-like vs Windows). See the
2829 * documentation for <b>wimapply</b> for more information, including about the
2830 * NTFS-3G extraction mode.
2833 * The WIM from which to extract the image(s), specified as a pointer to the
2834 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2835 * split WIM. In the case of a WIM file that is not standalone, this
2836 * ::WIMStruct must have had any needed external resources previously
2837 * referenced using wimlib_reference_resources() or
2838 * wimlib_reference_resource_files().
2840 * The 1-based index of the image to extract, or ::WIMLIB_ALL_IMAGES to
2841 * extract all images. Note: ::WIMLIB_ALL_IMAGES is unsupported in NTFS-3G
2844 * A null-terminated string which names the location to which the image(s)
2845 * will be extracted. By default, this is interpreted as a path to a
2846 * directory. Alternatively, if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in
2847 * @p extract_flags, then this is interpreted as a path to an unmounted
2849 * @param extract_flags
2850 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2852 * @return 0 on success; a ::wimlib_error_code value on failure.
2854 * @retval ::WIMLIB_ERR_DECOMPRESSION
2855 * The WIM file contains invalid compressed data.
2856 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2857 * @p image does not exist in @p wim.
2858 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2859 * The metadata for an image to extract was invalid.
2860 * @retval ::WIMLIB_ERR_INVALID_PARAM
2861 * The extraction flags were invalid; more details may be found in the
2862 * documentation for the specific extraction flags that were specified. Or
2863 * @p target was @c NULL or an empty string, or @p wim was @c NULL.
2864 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2865 * The data of a file that needed to be extracted was corrupt.
2866 * @retval ::WIMLIB_ERR_LINK
2867 * Failed to create a symbolic link or a hard link.
2868 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2869 * @p wim does not contain image metadata; for example, it represents a
2870 * non-first part of a split WIM.
2871 * @retval ::WIMLIB_ERR_MKDIR
2872 * Failed create a directory.
2873 * @retval ::WIMLIB_ERR_NTFS_3G
2874 * libntfs-3g reported that a problem occurred while writing to the NTFS
2876 * @retval ::WIMLIB_ERR_OPEN
2877 * Could not create a file, or failed to open an already-extracted file.
2878 * @retval ::WIMLIB_ERR_READ
2879 * Failed to read data from the WIM.
2880 * @retval ::WIMLIB_ERR_READLINK
2881 * Failed to determine the target of a symbolic link in the WIM.
2882 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2883 * Failed to fix the target of an absolute symbolic link (e.g. if the
2884 * target would have exceeded the maximum allowed length). (Only if
2885 * reparse data was supported by the extraction mode and
2886 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2888 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2889 * A file data blob that needed to be extracted could not be found in the
2890 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
2891 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2892 * Failed to set attributes on a file.
2893 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2894 * Failed to set reparse data on a file (only if reparse data was supported
2895 * by the extraction mode).
2896 * @retval ::WIMLIB_ERR_SET_SECURITY
2897 * Failed to set security descriptor on a file.
2898 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2899 * Failed to set the short name of a file.
2900 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2901 * Failed to set timestamps on a file.
2902 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2903 * Unexpected end-of-file occurred when reading data from the WIM.
2904 * @retval ::WIMLIB_ERR_UNSUPPORTED
2905 * A requested extraction flag, or the data or metadata that must be
2906 * extracted to support it, is unsupported in the build and configuration
2907 * of wimlib, or on the current platform or extraction mode or target
2908 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2909 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2910 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2911 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2912 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2913 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2914 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2915 * image contains one or more files with short names, but extracting short
2916 * names is not supported --- on Windows, this occurs if the target volume
2917 * does not support short names, while on non-Windows, this occurs if
2918 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2919 * @retval ::WIMLIB_ERR_WIMBOOT
2920 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2921 * there was a problem creating WIMBoot pointer files or registering a
2922 * source WIM file with the Windows Overlay Filesystem (WOF) driver.
2923 * @retval ::WIMLIB_ERR_WRITE
2924 * Failed to write data to a file being extracted.
2926 * If a progress function is registered with @p wim, then as each image is
2927 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2928 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE messages, then zero
2929 * or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then zero or more
2930 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, then
2931 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2934 wimlib_extract_image(WIMStruct *wim, int image,
2935 const wimlib_tchar *target, int extract_flags);
2938 * @ingroup G_extracting_wims
2940 * Extract one image from a pipe on which a pipable WIM is being sent.
2942 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE, and @ref
2943 * subsec_pipable_wims, for more information about pipable WIMs.
2945 * This function operates in a special way to read the WIM fully sequentially.
2946 * As a result, there is no ::WIMStruct is made visible to library users, and
2947 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2948 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2949 * seekable file, not a pipe.)
2952 * File descriptor, which may be a pipe, opened for reading and positioned
2953 * at the start of the pipable WIM.
2954 * @param image_num_or_name
2955 * String that specifies the 1-based index or name of the image to extract.
2956 * It is translated to an image index using the same rules that
2957 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2958 * only a single image (not all images) can be specified. Alternatively,
2959 * specify @p NULL here to use the first image in the WIM if it contains
2960 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2962 * Same as the corresponding parameter to wimlib_extract_image().
2963 * @param extract_flags
2964 * Same as the corresponding parameter to wimlib_extract_image().
2966 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
2967 * error codes include those returned by wimlib_extract_image() and
2968 * wimlib_open_wim() as well as the following:
2970 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2971 * Data read from the pipable WIM was invalid.
2972 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2973 * The WIM being piped over @p pipe_fd is a normal WIM, not a pipable WIM.
2976 wimlib_extract_image_from_pipe(int pipe_fd,
2977 const wimlib_tchar *image_num_or_name,
2978 const wimlib_tchar *target, int extract_flags);
2981 * @ingroup G_extracting_wims
2983 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2984 * function. The progress function will be used while extracting the image and
2985 * will receive the normal extraction progress messages, such as
2986 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2987 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2990 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2991 const wimlib_tchar *image_num_or_name,
2992 const wimlib_tchar *target,
2994 wimlib_progress_func_t progfunc,
2998 * @ingroup G_extracting_wims
3000 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
3001 * image are specified in the ASCII, UTF-8, or UTF-16LE text file named by @p
3002 * path_list_file which itself contains the list of paths to use, one per line.
3003 * Leading and trailing whitespace is ignored. Empty lines and lines beginning
3004 * with the ';' or '#' characters are ignored. No quotes are needed, as paths
3005 * are otherwise delimited by the newline character. However, quotes will be
3006 * stripped if present.
3008 * The error codes are the same as those returned by wimlib_extract_paths(),
3009 * except that wimlib_extract_pathlist() returns an appropriate error code if it
3010 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
3011 * ::WIMLIB_ERR_READ).
3014 wimlib_extract_pathlist(WIMStruct *wim, int image,
3015 const wimlib_tchar *target,
3016 const wimlib_tchar *path_list_file,
3020 * @ingroup G_extracting_wims
3022 * Extract zero or more paths (files or directory trees) from the specified WIM
3025 * By default, each path will be extracted to a corresponding subdirectory of
3026 * the target based on its location in the image. For example, if one of the
3027 * paths to extract is <c>/Windows/explorer.exe</c> and the target is
3028 * <c>outdir</c>, the file will be extracted to
3029 * <c>outdir/Windows/explorer.exe</c>. This behavior can be changed by
3030 * providing the flag ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which
3031 * will cause each file or directory tree to be placed directly in the target
3032 * directory --- so the same example would extract <c>/Windows/explorer.exe</c>
3033 * to <c>outdir/explorer.exe</c>.
3035 * With globbing turned off (the default), paths are always checked for
3036 * existence strictly; that is, if any path to extract does not exist in the
3037 * image, then nothing is extracted and the function fails with
3038 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST. But with globbing turned on
3039 * (::WIMLIB_EXTRACT_FLAG_GLOB_PATHS specified), globs are by default permitted
3040 * to match no files, and there is a flag (::WIMLIB_EXTRACT_FLAG_STRICT_GLOB) to
3041 * enable the strict behavior if desired.
3043 * Symbolic links are not dereferenced when paths in the image are interpreted.
3046 * WIM from which to extract the paths, specified as a pointer to the
3047 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
3048 * split WIM. In the case of a WIM file that is not standalone, this
3049 * ::WIMStruct must have had any needed external resources previously
3050 * referenced using wimlib_reference_resources() or
3051 * wimlib_reference_resource_files().
3053 * The 1-based index of the WIM image from which to extract the paths.
3055 * Array of paths to extract. Each element must be the absolute path to a
3056 * file or directory within the image. Path separators may be either
3057 * forwards or backwards slashes, and leading path separators are optional.
3058 * The paths will be interpreted either case-sensitively (UNIX default) or
3059 * case-insensitively (Windows default); however, the case sensitivity can
3060 * be configured explicitly at library initialization time by passing an
3061 * appropriate flag to wimlib_global_init().
3063 * By default, "globbing" is disabled, so the characters @c * and @c ? are
3064 * interpreted literally. This can be changed by specifying
3065 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p extract_flags.
3067 * Number of paths specified in @p paths.
3069 * Directory to which to extract the paths.
3070 * @param extract_flags
3071 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
3073 * @return 0 on success; a ::wimlib_error_code value on failure. Most of the
3074 * error codes are the same as those returned by wimlib_extract_image(). Below,
3075 * some of the error codes returned in situations specific to path-mode
3076 * extraction are documented:
3078 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
3079 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
3080 * one of the paths to extract did not name a regular file.
3081 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3082 * One of the paths to extract does not exist in the image; see discussion
3083 * above about strict vs. non-strict behavior.
3085 * If a progress function is registered with @p wim, then it will receive
3086 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS.
3089 wimlib_extract_paths(WIMStruct *wim,
3091 const wimlib_tchar *target,
3092 const wimlib_tchar * const *paths,
3097 * @ingroup G_wim_information
3099 * Similar to wimlib_get_xml_data(), but the XML document will be written to the
3100 * specified standard C <c>FILE*</c> instead of retrieved in an in-memory
3103 * @return 0 on success; a ::wimlib_error_code value on failure. This may
3104 * return any error code which can be returned by wimlib_get_xml_data() as well
3105 * as the following error codes:
3107 * @retval ::WIMLIB_ERR_WRITE
3108 * Failed to write the data to the requested file.
3111 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
3114 * @ingroup G_general
3116 * Release a reference to a ::WIMStruct. If the ::WIMStruct is still referenced
3117 * by other ::WIMStruct's (e.g. following calls to wimlib_export_image() or
3118 * wimlib_reference_resources()), then the library will free it later, when the
3119 * last reference is released; otherwise it is freed immediately and any
3120 * associated file descriptors are closed.
3123 * Pointer to the ::WIMStruct to release. If @c NULL, no action is taken.
3126 wimlib_free(WIMStruct *wim);
3129 * @ingroup G_general
3131 * Convert a ::wimlib_compression_type value into a string.
3134 * The compression type value to convert.
3137 * A statically allocated string naming the compression type, such as
3138 * "None", "LZX", or "XPRESS". If the value was unrecognized, then
3139 * the resulting string will be "Invalid".
3141 extern const wimlib_tchar *
3142 wimlib_get_compression_type_string(enum wimlib_compression_type ctype);
3145 * @ingroup G_general
3147 * Convert a wimlib error code into a string describing it.
3150 * An error code returned by one of wimlib's functions.
3153 * Pointer to a statically allocated string describing the error code. If
3154 * the value was unrecognized, then the resulting string will be "Unknown
3157 extern const wimlib_tchar *
3158 wimlib_get_error_string(enum wimlib_error_code code);
3161 * @ingroup G_wim_information
3163 * Get the description of the specified image. Equivalent to
3164 * <tt>wimlib_get_image_property(wim, image, "DESCRIPTION")</tt>.
3166 extern const wimlib_tchar *
3167 wimlib_get_image_description(const WIMStruct *wim, int image);
3170 * @ingroup G_wim_information
3172 * Get the name of the specified image. Equivalent to
3173 * <tt>wimlib_get_image_property(wim, image, "NAME")</tt>, except that
3174 * wimlib_get_image_name() will return an empty string if the image is unnamed
3175 * whereas wimlib_get_image_property() may return @c NULL in that case.
3177 extern const wimlib_tchar *
3178 wimlib_get_image_name(const WIMStruct *wim, int image);
3181 * @ingroup G_wim_information
3183 * Since wimlib v1.8.3: get a per-image property from the WIM's XML document.
3184 * This is an alternative to wimlib_get_image_name() and
3185 * wimlib_get_image_description() which allows getting any simple string
3189 * Pointer to the ::WIMStruct for the WIM.
3191 * The 1-based index of the image for which to get the property.
3192 * @param property_name
3193 * The name of the image property, for example "NAME", "DESCRIPTION", or
3194 * "TOTALBYTES". The name can contain forward slashes to indicate a nested
3195 * XML element; for example, "WINDOWS/VERSION/BUILD" indicates the BUILD
3196 * element nested within the VERSION element nested within the WINDOWS
3197 * element. Since wimlib v1.9.0, a bracketed number can be used to
3198 * indicate one of several identically-named elements; for example,
3199 * "WINDOWS/LANGUAGES/LANGUAGE[2]" indicates the second "LANGUAGE" element
3200 * nested within the "WINDOWS/LANGUAGES" element. Note that element names
3201 * are case sensitive.
3204 * The property's value as a ::wimlib_tchar string, or @c NULL if there is
3205 * no such property. The string may not remain valid after later library
3206 * calls, so the caller should duplicate it if needed.
3208 extern const wimlib_tchar *
3209 wimlib_get_image_property(const WIMStruct *wim, int image,
3210 const wimlib_tchar *property_name);
3213 * @ingroup G_general
3215 * Return the version of wimlib as a 32-bit number whose top 12 bits contain the
3216 * major version, the next 10 bits contain the minor version, and the low 10
3217 * bits contain the patch version.
3219 * In other words, the returned value is equal to <c>((WIMLIB_MAJOR_VERSION <<
3220 * 20) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</c> for the
3221 * corresponding header file.
3224 wimlib_get_version(void);
3227 * @ingroup G_wim_information
3229 * Get basic information about a WIM file.
3232 * Pointer to the ::WIMStruct to query. This need not represent a
3233 * standalone WIM (e.g. it could represent part of a split WIM).
3235 * A ::wimlib_wim_info structure that will be filled in with information
3236 * about the WIM file.
3241 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
3244 * @ingroup G_wim_information
3246 * Read a WIM file's XML document into an in-memory buffer.
3248 * The XML document contains metadata about the WIM file and the images stored
3252 * Pointer to the ::WIMStruct to query. This need not represent a
3253 * standalone WIM (e.g. it could represent part of a split WIM).
3255 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
3256 * XML document is written to this location.
3257 * @param bufsize_ret
3258 * The size of the XML document in bytes is written to this location.
3260 * @return 0 on success; a ::wimlib_error_code value on failure.
3262 * @retval ::WIMLIB_ERR_NO_FILENAME
3263 * @p wim is not backed by a file and therefore does not have an XML
3265 * @retval ::WIMLIB_ERR_READ
3266 * Failed to read the XML document from the WIM file.
3267 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3268 * Failed to read the XML document from the WIM file.
3271 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
3274 * @ingroup G_general
3276 * Initialization function for wimlib. Call before using any other wimlib
3277 * function (except possibly wimlib_set_print_errors()). If not done manually,
3278 * this function will be called automatically with a flags argument of 0. This
3279 * function does nothing if called again after it has already successfully run.
3282 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
3284 * @return 0 on success; a ::wimlib_error_code value on failure.
3286 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
3287 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
3288 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
3289 * init_flags, but the corresponding privileges could not be acquired.
3292 wimlib_global_init(int init_flags);
3295 * @ingroup G_general
3297 * Cleanup function for wimlib. You are not required to call this function, but
3298 * it will release any global resources allocated by the library.
3301 wimlib_global_cleanup(void);
3304 * @ingroup G_wim_information
3306 * Determine if an image name is already used by some image in the WIM.
3309 * Pointer to the ::WIMStruct to query. This need not represent a
3310 * standalone WIM (e.g. it could represent part of a split WIM).
3312 * The name to check.
3315 * @c true if there is already an image in @p wim named @p name; @c false
3316 * if there is no image named @p name in @p wim. If @p name is @c NULL or
3317 * the empty string, then @c false is returned.
3320 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
3323 * @ingroup G_wim_information
3325 * Iterate through a file or directory tree in a WIM image. By specifying
3326 * appropriate flags and a callback function, you can get the attributes of a
3327 * file in the image, get a directory listing, or even get a listing of the
3331 * The ::WIMStruct containing the image(s) over which to iterate. This
3332 * ::WIMStruct must contain image metadata, so it cannot be the non-first
3333 * part of a split WIM (for example).
3335 * The 1-based index of the image that contains the files or directories to
3336 * iterate over, or ::WIMLIB_ALL_IMAGES to iterate over all images.
3338 * Path in the image at which to do the iteration.
3340 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3342 * A callback function that will receive each directory entry.
3344 * An extra parameter that will always be passed to the callback function
3347 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3348 * first nonzero value that was returned from @p cb. However, additional
3349 * ::wimlib_error_code values may be returned, including the following:
3351 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3352 * @p image does not exist in @p wim.
3353 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3354 * @p path does not exist in the image.
3355 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3356 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED was specified, but the
3357 * data for some files could not be found in the blob lookup table of @p
3360 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3361 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3362 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3363 * indicate failure (for different reasons) to read the metadata resource for an
3364 * image over which iteration needed to be done.
3367 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3369 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3372 * @ingroup G_wim_information
3374 * Iterate through the blob lookup table of a ::WIMStruct. This can be used to
3375 * directly get a listing of the unique "blobs" contained in a WIM file, which
3376 * are deduplicated over all images.
3378 * Specifically, each listed blob may be from any of the following sources:
3380 * - Metadata blobs, if the ::WIMStruct contains image metadata
3381 * - File blobs from the on-disk WIM file (if any) backing the ::WIMStruct
3382 * - File blobs from files that have been added to the in-memory ::WIMStruct,
3383 * e.g. by using wimlib_add_image()
3384 * - File blobs from external WIMs referenced by
3385 * wimlib_reference_resource_files() or wimlib_reference_resources()
3388 * Pointer to the ::WIMStruct for which to get the blob listing.
3390 * Reserved; set to 0.
3392 * A callback function that will receive each blob.
3394 * An extra parameter that will always be passed to the callback function
3397 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3398 * that was returned from @p cb.
3401 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3402 wimlib_iterate_lookup_table_callback_t cb,
3406 * @ingroup G_nonstandalone_wims
3408 * Join a split WIM into a stand-alone (one-part) WIM.
3411 * An array of strings that gives the filenames of all parts of the split
3412 * WIM. No specific order is required, but all parts must be included with
3415 * Number of filenames in @p swms.
3416 * @param swm_open_flags
3417 * Open flags for the split WIM parts (e.g.
3418 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3419 * @param wim_write_flags
3420 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3421 * be used to write the joined WIM.
3422 * @param output_path
3423 * The path to write the joined WIM file to.
3425 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3426 * may return most error codes that can be returned by wimlib_open_wim() and
3427 * wimlib_write(), as well as the following error codes:
3429 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3430 * The split WIMs do not form a valid WIM because they do not include all
3431 * the parts of the original WIM, there are duplicate parts, or not all the
3432 * parts have the same GUID and compression type.
3434 * Note: wimlib is generalized enough that this function is not actually needed
3435 * to join a split WIM; instead, you could open the first part of the split WIM,
3436 * then reference the other parts with wimlib_reference_resource_files(), then
3437 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3438 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3442 wimlib_join(const wimlib_tchar * const *swms,
3444 const wimlib_tchar *output_path,
3446 int wim_write_flags);
3449 * @ingroup G_nonstandalone_wims
3451 * Same as wimlib_join(), but allows specifying a progress function. The
3452 * progress function will receive the write progress messages, such as
3453 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3454 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3455 * swm_open_flags, the progress function will receive a series of
3456 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3460 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3462 const wimlib_tchar *output_path,
3464 int wim_write_flags,
3465 wimlib_progress_func_t progfunc,
3470 * @ingroup G_mounting_wim_images
3472 * Mount an image from a WIM file on a directory read-only or read-write.
3475 * Pointer to the ::WIMStruct containing the image to be mounted. This
3476 * ::WIMStruct must have a backing file.
3478 * The 1-based index of the image to mount. This image cannot have been
3479 * previously modified in memory.
3481 * The path to an existing empty directory on which to mount the image.
3482 * @param mount_flags
3483 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3484 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3486 * @param staging_dir
3487 * If non-NULL, the name of a directory in which a temporary directory for
3488 * storing modified or added files will be created. Ignored if
3489 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3490 * left @c NULL, the staging directory is created in the same directory as
3491 * the backing WIM file. The staging directory is automatically deleted
3492 * when the image is unmounted.
3494 * @return 0 on success; a ::wimlib_error_code value on failure.
3496 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3497 * Another process is currently modifying the WIM file.
3498 * @retval ::WIMLIB_ERR_FUSE
3499 * A non-zero status code was returned by @c fuse_main().
3500 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
3501 * There are currently multiple references to the image as a result of a
3502 * call to wimlib_export_image(). Free one before attempting the
3504 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3505 * @p image does not exist in @p wim.
3506 * @retval ::WIMLIB_ERR_INVALID_PARAM
3507 * @p wim was @c NULL; or @p dir was NULL or an empty string; or an
3508 * unrecognized flag was specified in @p mount_flags; or the image has
3509 * already been modified in memory (e.g. by wimlib_update_image()).
3510 * @retval ::WIMLIB_ERR_MKDIR
3511 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3512 * staging directory could not be created.
3513 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3514 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3515 * WIM file is considered read-only because of any of the reasons mentioned
3516 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3517 * @retval ::WIMLIB_ERR_UNSUPPORTED
3518 * Mounting is not supported in this build of the library.
3520 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3521 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3522 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3523 * indicate failure (for different reasons) to read the metadata resource for
3524 * the image to mount.
3526 * The ability to mount WIM images is implemented using FUSE (Filesystem in
3527 * UserSpacE). Depending on how FUSE is set up on your system, this function
3528 * may work as normal users in addition to the root user.
3530 * Mounting WIM images is not supported if wimlib was configured
3531 * <c>--without-fuse</c>. This includes Windows builds of wimlib;
3532 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3534 * Calling this function daemonizes the process, unless
3535 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3537 * It is safe to mount multiple images from the same WIM file read-only at the
3538 * same time, but only if different ::WIMStruct's are used. It is @b not safe
3539 * to mount multiple images from the same WIM file read-write at the same time.
3541 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3542 * different process.
3545 wimlib_mount_image(WIMStruct *wim,
3547 const wimlib_tchar *dir,
3549 const wimlib_tchar *staging_dir);
3552 * @ingroup G_creating_and_opening_wims
3554 * Open a WIM file and create a ::WIMStruct for it.
3557 * The path to the WIM file to open.
3559 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3561 * On success, a pointer to a new ::WIMStruct backed by the specified
3562 * on-disk WIM file is written to the memory location pointed to by this
3563 * parameter. This ::WIMStruct must be freed using using wimlib_free()
3564 * when finished with it.
3566 * @return 0 on success; a ::wimlib_error_code value on failure.
3568 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3569 * The number of metadata resources found in the WIM did not match the
3570 * image count specified in the WIM header, or the number of <IMAGE>
3571 * elements in the XML data of the WIM did not match the image count
3572 * specified in the WIM header.
3573 * @retval ::WIMLIB_ERR_INTEGRITY
3574 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags, and
3575 * the WIM file failed the integrity check.
3576 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3577 * The library did not recognize the compression chunk size of the WIM as
3578 * valid for its compression type.
3579 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3580 * The library did not recognize the compression type of the WIM.
3581 * @retval ::WIMLIB_ERR_INVALID_HEADER
3582 * The header of the WIM was otherwise invalid.
3583 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3584 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3585 * the WIM contained an integrity table, but the integrity table was
3587 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3588 * The lookup table of the WIM was invalid.
3589 * @retval ::WIMLIB_ERR_INVALID_PARAM
3590 * @p wim_ret was @c NULL; or, @p wim_file was not a nonempty string.
3591 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3592 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3593 * specified in @p open_flags.
3594 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3595 * The file did not begin with the magic characters that identify a WIM
3597 * @retval ::WIMLIB_ERR_OPEN
3598 * Failed to open the WIM file for reading. Some possible reasons: the WIM
3599 * file does not exist, or the calling process does not have permission to
3601 * @retval ::WIMLIB_ERR_READ
3602 * Failed to read data from the WIM file.
3603 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3604 * Unexpected end-of-file while reading data from the WIM file.
3605 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3606 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3607 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3608 * The WIM cannot be opened because it contains encrypted segments. (It
3609 * may be a Windows 8 "ESD" file.)
3610 * @retval ::WIMLIB_ERR_WIM_IS_INCOMPLETE
3611 * The WIM file is not complete (e.g. the program which wrote it was
3612 * terminated before it finished)
3613 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3614 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3615 * considered read-only because of any of the reasons mentioned in the
3616 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3617 * @retval ::WIMLIB_ERR_XML
3618 * The XML data of the WIM was invalid.
3621 wimlib_open_wim(const wimlib_tchar *wim_file,
3623 WIMStruct **wim_ret);
3626 * @ingroup G_creating_and_opening_wims
3628 * Same as wimlib_open_wim(), but allows specifying a progress function and
3629 * progress context. If successful, the progress function will be registered in
3630 * the newly open ::WIMStruct, as if by an automatic call to
3631 * wimlib_register_progress_function(). In addition, if
3632 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, then the
3633 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3634 * messages while checking the WIM file's integrity.
3637 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3639 WIMStruct **wim_ret,
3640 wimlib_progress_func_t progfunc,
3644 * @ingroup G_writing_and_overwriting_wims
3646 * Commit a ::WIMStruct to disk, updating its backing file.
3648 * There are several alternative ways in which changes may be committed:
3650 * 1. Full rebuild: write the updated WIM to a temporary file, then rename the
3651 * temporary file to the original.
3652 * 2. Appending: append updates to the new original WIM file, then overwrite
3653 * its header such that those changes become visible to new readers.
3654 * 3. Compaction: normally should not be used; see
3655 * ::WIMLIB_WRITE_FLAG_UNSAFE_COMPACT for details.
3657 * Append mode is often much faster than a full rebuild, but it wastes some
3658 * amount of space due to leaving "holes" in the WIM file. Because of the
3659 * greater efficiency, wimlib_overwrite() normally defaults to append mode.
3660 * However, ::WIMLIB_WRITE_FLAG_REBUILD can be used to explicitly request a full
3661 * rebuild. In addition, if wimlib_delete_image() has been used on the
3662 * ::WIMStruct, then the default mode switches to rebuild mode, and
3663 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE can be used to explicitly request append
3666 * If this function completes successfully, then no more functions can be called
3667 * on the ::WIMStruct other than wimlib_free(). If you need to continue using
3668 * the WIM file, you must use wimlib_open_wim() to open a new ::WIMStruct for
3672 * Pointer to a ::WIMStruct to commit to its backing file.
3673 * @param write_flags
3674 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3675 * @param num_threads
3676 * The number of threads to use for compressing data, or 0 to have the
3677 * library automatically choose an appropriate number.
3679 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3680 * may return most error codes returned by wimlib_write() as well as the
3681 * following error codes:
3683 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3684 * Another process is currently modifying the WIM file.
3685 * @retval ::WIMLIB_ERR_NO_FILENAME
3686 * @p wim is not backed by an on-disk file. In other words, it is a
3687 * ::WIMStruct created by wimlib_create_new_wim() rather than
3688 * wimlib_open_wim().
3689 * @retval ::WIMLIB_ERR_RENAME
3690 * The temporary file to which the WIM was written could not be renamed to
3691 * the original file.
3692 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3693 * The WIM file is considered read-only because of any of the reasons
3694 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3697 * If a progress function is registered with @p wim, then it will receive the
3698 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3699 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3700 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3703 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3706 * @ingroup G_wim_information
3708 * (Deprecated) Print information about one image, or all images, contained in a
3712 * Pointer to the ::WIMStruct to query. This need not represent a
3713 * standalone WIM (e.g. it could represent part of a split WIM).
3715 * The 1-based index of the image for which to print information, or
3716 * ::WIMLIB_ALL_IMAGES to print information about all images.
3718 * @return This function has no return value. No error checking is done when
3719 * printing the information. If @p image is invalid, an error message is
3722 * This function is deprecated; use wimlib_get_xml_data() or
3723 * wimlib_get_image_property() to query image information instead.
3726 wimlib_print_available_images(const WIMStruct *wim, int image);
3729 * @ingroup G_wim_information
3731 * Print the header of the WIM file (intended for debugging only).
3734 wimlib_print_header(const WIMStruct *wim);
3737 * @ingroup G_nonstandalone_wims
3739 * Reference file data from other WIM files or split WIM parts. This function
3740 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3741 * to load additional file data before calling a function such as
3742 * wimlib_extract_image() that requires the file data to be present.
3745 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3746 * necessarily "standalone". In the case of split WIMs, this should be the
3747 * first part, since only the first part contains the metadata resources.
3748 * In the case of delta WIMs, this should be the delta WIM rather than the
3749 * WIM on which it is based.
3750 * @param resource_wimfiles_or_globs
3751 * Array of paths to WIM files and/or split WIM parts to reference.
3752 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3753 * ref_flags, these are treated as globs rather than literal paths. That
3754 * is, using this function you can specify zero or more globs, each of
3755 * which expands to one or more literal paths.
3757 * Number of entries in @p resource_wimfiles_or_globs.
3759 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3760 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3762 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3763 * pass to internal calls to wimlib_open_wim() on the reference files.
3765 * @return 0 on success; a ::wimlib_error_code value on failure.
3767 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3768 * One of the specified globs did not match any paths (only with both
3769 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3770 * specified in @p ref_flags).
3771 * @retval ::WIMLIB_ERR_READ
3772 * I/O or permissions error while processing a file glob.
3774 * This function can additionally return most values that can be returned by
3775 * wimlib_open_wim().
3778 wimlib_reference_resource_files(WIMStruct *wim,
3779 const wimlib_tchar * const *resource_wimfiles_or_globs,
3785 * @ingroup G_nonstandalone_wims
3787 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3788 * where the caller must open the ::WIMStruct for each referenced file itself.
3791 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3792 * necessarily "standalone". In the case of split WIMs, this should be the
3793 * first part, since only the first part contains the metadata resources.
3794 * @param resource_wims
3795 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3796 * split WIM parts to reference.
3797 * @param num_resource_wims
3798 * Number of entries in @p resource_wims.
3800 * Reserved; must be 0.
3802 * @return 0 on success; a ::wimlib_error_code value on failure.
3805 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3806 unsigned num_resource_wims, int ref_flags);
3809 * @ingroup G_modifying_wims
3811 * Declare that a newly added image is mostly the same as a prior image, but
3812 * captured at a later point in time, possibly with some modifications in the
3813 * intervening time. This is designed to be used in incremental backups of the
3814 * same filesystem or directory tree.
3816 * This function compares the metadata of the directory tree of the newly added
3817 * image against that of the old image. Any files that are present in both the
3818 * newly added image and the old image and have timestamps that indicate they
3819 * haven't been modified are deemed not to have been modified and have their
3820 * checksums copied from the old image. Because of this and because WIM uses
3821 * single-instance streams, such files need not be read from the filesystem when
3822 * the WIM is being written or overwritten. Note that these unchanged files
3823 * will still be "archived" and will be logically present in the new image; the
3824 * optimization is that they don't need to actually be read from the filesystem
3825 * because the WIM already contains them.
3827 * This function is provided to optimize incremental backups. The resulting WIM
3828 * file will still be the same regardless of whether this function is called.
3829 * (This is, however, assuming that timestamps have not been manipulated or
3830 * unmaintained as to trick this function into thinking a file has not been
3831 * modified when really it has. To partly guard against such cases, other
3832 * metadata such as file sizes will be checked as well.)
3834 * This function must be called after adding the new image (e.g. with
3835 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3836 * wimlib_overwrite()).
3839 * Pointer to the ::WIMStruct containing the newly added image.
3841 * The 1-based index in @p wim of the newly added image.
3842 * @param template_wim
3843 * Pointer to the ::WIMStruct containing the template image. This can be,
3844 * but does not have to be, the same ::WIMStruct as @p wim.
3845 * @param template_image
3846 * The 1-based index in @p template_wim of the template image.
3848 * Reserved; must be 0.
3850 * @return 0 on success; a ::wimlib_error_code value on failure.
3852 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3853 * @p new_image does not exist in @p wim or @p template_image does not
3854 * exist in @p template_wim.
3855 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3856 * At least one of @p wim and @p template_wim does not contain image
3857 * metadata; for example, one of them represents a non-first part of a
3859 * @retval ::WIMLIB_ERR_INVALID_PARAM
3860 * Identical values were provided for the template and new image; or @p
3861 * new_image specified an image that had not been modified since opening
3864 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3865 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3866 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3867 * indicate failure (for different reasons) to read the metadata resource for
3868 * the template image.
3871 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3872 WIMStruct *template_wim, int template_image,
3876 * @ingroup G_general
3878 * Register a progress function with a ::WIMStruct.
3881 * The ::WIMStruct for which to register the progress function.
3883 * Pointer to the progress function to register. If the WIM already has a
3884 * progress function registered, it will be replaced with this one. If @p
3885 * NULL, the current progress function (if any) will be unregistered.
3887 * The value which will be passed as the third argument to calls to @p
3891 wimlib_register_progress_function(WIMStruct *wim,
3892 wimlib_progress_func_t progfunc,
3896 * @ingroup G_modifying_wims
3898 * Rename the @p source_path to the @p dest_path in the specified @p image of
3901 * This just builds an appropriate ::wimlib_rename_command and passes it to
3902 * wimlib_update_image().
3905 wimlib_rename_path(WIMStruct *wim, int image,
3906 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3909 * @ingroup G_wim_information
3911 * Translate a string specifying the name or number of an image in the WIM into
3912 * the number of the image. The images are numbered starting at 1.
3915 * Pointer to the ::WIMStruct for a WIM.
3916 * @param image_name_or_num
3917 * A string specifying the name or number of an image in the WIM. If it
3918 * parses to a positive integer, this integer is taken to specify the
3919 * number of the image, indexed starting at 1. Otherwise, it is taken to
3920 * be the name of an image, as given in the XML data for the WIM file. It
3921 * also may be the keyword "all" or the string "*", both of which will
3922 * resolve to ::WIMLIB_ALL_IMAGES.
3924 * There is no way to search for an image actually named "all", "*", or an
3925 * integer number, or an image that has no name. However, you can use
3926 * wimlib_get_image_name() to get the name of any image.
3929 * If the string resolved to a single existing image, the number of that
3930 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3931 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3932 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3933 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3934 * images in @p wim has no name. (Since a WIM may have multiple unnamed
3935 * images, an unnamed image must be specified by index to eliminate the
3939 wimlib_resolve_image(WIMStruct *wim,
3940 const wimlib_tchar *image_name_or_num);
3943 * @ingroup G_general
3945 * Set the file to which the library will print error and warning messages.
3947 * This version of the function takes a C library <c>FILE*</c> opened for
3948 * writing (or appending). Use wimlib_set_error_file_by_name() to specify the
3949 * file by name instead.
3951 * This also enables error messages, as if by a call to
3952 * wimlib_set_print_errors(true).
3954 * @return 0 on success; a ::wimlib_error_code value on failure.
3956 * @retval ::WIMLIB_ERR_UNSUPPORTED
3957 * wimlib was compiled using the <c>--without-error-messages</c> option.
3960 wimlib_set_error_file(FILE *fp);
3963 * @ingroup G_general
3965 * Set the path to the file to which the library will print error and warning
3966 * messages. The library will open this file for appending.
3968 * This also enables error messages, as if by a call to
3969 * wimlib_set_print_errors(true).
3971 * @return 0 on success; a ::wimlib_error_code value on failure.
3973 * @retval ::WIMLIB_ERR_OPEN
3974 * The file named by @p path could not be opened for appending.
3975 * @retval ::WIMLIB_ERR_UNSUPPORTED
3976 * wimlib was compiled using the <c>--without-error-messages</c> option.
3979 wimlib_set_error_file_by_name(const wimlib_tchar *path);
3982 * @ingroup G_modifying_wims
3984 * Change the description of a WIM image. Equivalent to
3985 * <tt>wimlib_set_image_property(wim, image, "DESCRIPTION", description)</tt>.
3987 * Note that "description" is misspelled in the name of this function.
3990 wimlib_set_image_descripton(WIMStruct *wim, int image,
3991 const wimlib_tchar *description);
3994 * @ingroup G_modifying_wims
3996 * Change what is stored in the \<FLAGS\> element in the WIM XML document
3997 * (usually something like "Core" or "Ultimate"). Equivalent to
3998 * <tt>wimlib_set_image_property(wim, image, "FLAGS", flags)</tt>.
4001 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
4004 * @ingroup G_modifying_wims
4006 * Change the name of a WIM image. Equivalent to
4007 * <tt>wimlib_set_image_property(wim, image, "NAME", name)</tt>.
4010 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
4013 * @ingroup G_modifying_wims
4015 * Since wimlib v1.8.3: add, modify, or remove a per-image property from the
4016 * WIM's XML document. This is an alternative to wimlib_set_image_name(),
4017 * wimlib_set_image_descripton(), and wimlib_set_image_flags() which allows
4018 * manipulating any simple string property.
4021 * Pointer to the ::WIMStruct for the WIM.
4023 * The 1-based index of the image for which to set the property.
4024 * @param property_name
4025 * The name of the image property in the same format documented for
4026 * wimlib_get_image_property().
4028 * Note: if creating a new element using a bracketed index such as
4029 * "WINDOWS/LANGUAGES/LANGUAGE[2]", the highest index that can be specified
4030 * is one greater than the number of existing elements with that same name,
4031 * excluding the index. That means that if you are adding a list of new
4032 * elements, they must be added sequentially from the first index (1) to
4033 * the last index (n).
4034 * @param property_value
4035 * If not NULL and not empty, the property is set to this value.
4036 * Otherwise, the property is removed from the XML document.
4038 * @return 0 on success; a ::wimlib_error_code value on failure.
4040 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
4041 * The user requested to set the image name (the <tt>NAME</tt> property),
4042 * but another image in the WIM already had the requested name.
4043 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4044 * @p image does not exist in @p wim.
4045 * @retval ::WIMLIB_ERR_INVALID_PARAM
4046 * @p property_name has an unsupported format, or @p property_name included
4047 * a bracketed index that was too high.
4050 wimlib_set_image_property(WIMStruct *wim, int image,
4051 const wimlib_tchar *property_name,
4052 const wimlib_tchar *property_value);
4055 * @ingroup G_general
4057 * Set the functions that wimlib uses to allocate and free memory.
4059 * These settings are global and not per-WIM.
4061 * The default is to use the default @c malloc(), @c free(), and @c realloc()
4062 * from the standard C library.
4064 * Note: some external functions, such as those in @c libntfs-3g, may use the
4065 * standard memory allocation functions regardless of this setting.
4067 * @param malloc_func
4068 * A function equivalent to @c malloc() that wimlib will use to allocate
4069 * memory. If @c NULL, the allocator function is set back to the default
4070 * @c malloc() from the C library.
4072 * A function equivalent to @c free() that wimlib will use to free memory.
4073 * If @c NULL, the free function is set back to the default @c free() from
4075 * @param realloc_func
4076 * A function equivalent to @c realloc() that wimlib will use to reallocate
4077 * memory. If @c NULL, the free function is set back to the default @c
4078 * realloc() from the C library.
4083 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
4084 void (*free_func)(void *),
4085 void *(*realloc_func)(void *, size_t));
4088 * @ingroup G_writing_and_overwriting_wims
4090 * Set a ::WIMStruct's output compression chunk size. This is the compression
4091 * chunk size that will be used for writing non-solid resources in subsequent
4092 * calls to wimlib_write() or wimlib_overwrite(). A larger compression chunk
4093 * size often results in a better compression ratio, but compression may be
4094 * slower and the speed of random access to data may be reduced. In addition,
4095 * some chunk sizes are not compatible with Microsoft software.
4098 * The ::WIMStruct for which to set the output chunk size.
4100 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
4101 * on the compression type. See the documentation for each
4102 * ::wimlib_compression_type constant for more information. As a special
4103 * case, if @p chunk_size is specified as 0, then the chunk size will be
4104 * reset to the default for the currently selected output compression type.
4106 * @return 0 on success; a ::wimlib_error_code value on failure.
4108 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
4109 * @p chunk_size was not 0 or a supported chunk size for the currently
4110 * selected output compression type.
4113 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4116 * @ingroup G_writing_and_overwriting_wims
4118 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
4122 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4125 * @ingroup G_writing_and_overwriting_wims
4127 * Set a ::WIMStruct's output compression type. This is the compression type
4128 * that will be used for writing non-solid resources in subsequent calls to
4129 * wimlib_write() or wimlib_overwrite().
4132 * The ::WIMStruct for which to set the output compression type.
4134 * The compression type to set. If this compression type is incompatible
4135 * with the current output chunk size, then the output chunk size will be
4136 * reset to the default for the new compression type.
4138 * @return 0 on success; a ::wimlib_error_code value on failure.
4140 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4141 * @p ctype did not specify a valid compression type.
4144 wimlib_set_output_compression_type(WIMStruct *wim,
4145 enum wimlib_compression_type ctype);
4148 * @ingroup G_writing_and_overwriting_wims
4150 * Similar to wimlib_set_output_compression_type(), but set the compression type
4151 * for writing solid resources. This cannot be ::WIMLIB_COMPRESSION_TYPE_NONE.
4154 wimlib_set_output_pack_compression_type(WIMStruct *wim,
4155 enum wimlib_compression_type ctype);
4158 * @ingroup G_general
4160 * Set whether wimlib can print error and warning messages to the error file,
4161 * which defaults to standard error. Error and warning messages may provide
4162 * information that cannot be determined only from returned error codes.
4164 * By default, error messages are not printed.
4166 * This setting applies globally (it is not per-WIM).
4168 * This can be called before wimlib_global_init().
4170 * @param show_messages
4171 * @c true if messages are to be printed; @c false if messages are not to
4174 * @return 0 on success; a ::wimlib_error_code value on failure.
4176 * @retval ::WIMLIB_ERR_UNSUPPORTED
4177 * wimlib was compiled using the <c>--without-error-messages</c> option.
4180 wimlib_set_print_errors(bool show_messages);
4183 * @ingroup G_modifying_wims
4185 * Set basic information about a WIM.
4188 * Pointer to the ::WIMStruct for a WIM.
4190 * Pointer to a ::wimlib_wim_info structure that contains the information
4191 * to set. Only the information explicitly specified in the @p which flags
4194 * Flags that specify which information to set. This is a bitwise OR of
4195 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
4196 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
4198 * @return 0 on success; a ::wimlib_error_code value on failure.
4200 * @retval ::WIMLIB_ERR_IMAGE_COUNT
4201 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
4202 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
4206 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
4210 * @ingroup G_nonstandalone_wims
4212 * Split a WIM into multiple parts.
4215 * The ::WIMStruct for the WIM to split.
4217 * Name of the split WIM (SWM) file to create. This will be the name of
4218 * the first part. The other parts will, by default, have the same name
4219 * with 2, 3, 4, ..., etc. appended before the suffix. However, the exact
4220 * names can be customized using the progress function.
4222 * The maximum size per part, in bytes. Unfortunately, it is not
4223 * guaranteed that this will really be the maximum size per part, because
4224 * some file resources in the WIM may be larger than this size, and the WIM
4225 * file format provides no way to split up file resources among multiple
4227 * @param write_flags
4228 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
4229 * flags will be used to write each split WIM part. Specify 0 here to get
4230 * the default behavior.
4232 * @return 0 on success; a ::wimlib_error_code value on failure. This function
4233 * may return most error codes that can be returned by wimlib_write() as well as
4234 * the following error codes:
4236 * @retval ::WIMLIB_ERR_INVALID_PARAM
4237 * @p swm_name was not a nonempty string, or @p part_size was 0.
4238 * @retval ::WIMLIB_ERR_UNSUPPORTED
4239 * The WIM contains solid resources. Splitting a WIM containing solid
4240 * resources is not supported.
4242 * If a progress function is registered with @p wim, then for each split WIM
4243 * part that is written it will receive the messages
4244 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
4245 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
4248 wimlib_split(WIMStruct *wim,
4249 const wimlib_tchar *swm_name,
4254 * @ingroup G_general
4256 * Perform verification checks on a WIM file.
4258 * This function is intended for safety checking and/or debugging. If used on a
4259 * well-formed WIM file, it should always succeed.
4262 * The ::WIMStruct for the WIM file to verify. Note: for an extra layer of
4263 * verification, it is a good idea to have used
4264 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
4266 * If verifying a split WIM, specify the first part of the split WIM here,
4267 * and reference the other parts using wimlib_reference_resource_files()
4268 * before calling this function.
4269 * @param verify_flags
4270 * Reserved; must be 0.
4272 * @return 0 if the WIM file was successfully verified; a ::wimlib_error_code
4273 * value if it failed verification or another error occurred.
4275 * @retval ::WIMLIB_ERR_DECOMPRESSION
4276 * The WIM file contains invalid compressed data.
4277 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
4278 * The metadata resource for an image is invalid.
4279 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4280 * File data stored in the WIM file is corrupt.
4281 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4282 * The data for a file in an image could not be found. See @ref
4283 * G_nonstandalone_wims.
4285 * If a progress function is registered with @p wim, then it will receive the
4286 * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
4287 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
4288 * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
4291 wimlib_verify_wim(WIMStruct *wim, int verify_flags);
4294 * @ingroup G_mounting_wim_images
4296 * Unmount a WIM image that was mounted using wimlib_mount_image().
4298 * When unmounting a read-write mounted image, the default behavior is to
4299 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
4300 * image to be committed.
4303 * The directory on which the WIM image is mounted.
4304 * @param unmount_flags
4305 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
4307 * @return 0 on success; a ::wimlib_error_code value on failure.
4309 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
4310 * There is no WIM image mounted on the specified directory.
4311 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
4312 * The read-write mounted image cannot be committed because there are file
4313 * descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
4315 * @retval ::WIMLIB_ERR_MQUEUE
4316 * Could not create a POSIX message queue.
4317 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
4318 * The image was mounted by a different user.
4319 * @retval ::WIMLIB_ERR_UNSUPPORTED
4320 * Mounting is not supported in this build of the library.
4322 * Note: you can also unmount the image by using the @c umount() system call, or
4323 * by using the @c umount or @c fusermount programs. However, you need to call
4324 * this function if you want changes to be committed.
4327 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
4330 * @ingroup G_mounting_wim_images
4332 * Same as wimlib_unmount_image(), but allows specifying a progress function.
4333 * The progress function will receive a ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN
4334 * message. In addition, if changes are committed from a read-write mount, the
4335 * progress function will receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
4338 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
4340 wimlib_progress_func_t progfunc,
4344 * @ingroup G_modifying_wims
4346 * Update a WIM image by adding, deleting, and/or renaming files or directories.
4349 * Pointer to the ::WIMStruct containing the image to update.
4351 * The 1-based index of the image to update.
4353 * An array of ::wimlib_update_command's that specify the update operations
4356 * Number of commands in @p cmds.
4357 * @param update_flags
4358 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
4360 * @return 0 on success; a ::wimlib_error_code value on failure. On failure,
4361 * all update commands will be rolled back, and no visible changes will have
4362 * been made to @p wim.
4364 * @retval ::WIMLIB_ERR_FVE_LOCKED_VOLUME
4365 * Windows-only: One of the "add" commands attempted to add files from an
4366 * encrypted BitLocker volume that hasn't yet been unlocked.
4367 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
4368 * There are currently multiple references to the image as a result of a
4369 * call to wimlib_export_image(). Free one before attempting the update.
4370 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
4371 * The contents of a capture configuration file were invalid.
4372 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4373 * @p image did not exist in @p wim.
4374 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
4375 * An add command with ::WIMLIB_ADD_FLAG_NO_REPLACE specified attempted to
4376 * replace an existing nondirectory file.
4377 * @retval ::WIMLIB_ERR_INVALID_PARAM
4378 * An unknown operation type was provided in the update commands; or
4379 * unknown or incompatible flags were provided in a flags parameter; or
4380 * there was another problem with the provided parameters.
4381 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4382 * While executing an add command, a reparse point had invalid data.
4383 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4384 * An add command attempted to replace a directory with a non-directory; or
4385 * a delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE attempted to
4386 * delete a directory; or a rename command attempted to rename a directory
4387 * to a non-directory.
4388 * @retval ::WIMLIB_ERR_NOTDIR
4389 * An add command attempted to replace a non-directory with a directory; or
4390 * an add command attempted to set the root of the image to a
4391 * non-directory; or a rename command attempted to rename a directory to a
4392 * non-directory; or a component of an image path that was used as a
4393 * directory was not, in fact, a directory.
4394 * @retval ::WIMLIB_ERR_NOTEMPTY
4395 * A rename command attempted to rename a directory to a non-empty
4396 * directory; or a rename command would have created a loop.
4397 * @retval ::WIMLIB_ERR_NTFS_3G
4398 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4399 * error occurred while reading data from the NTFS volume using libntfs-3g.
4400 * @retval ::WIMLIB_ERR_OPEN
4401 * Failed to open a file to be captured while executing an add command.
4402 * @retval ::WIMLIB_ERR_OPENDIR
4403 * Failed to open a directory to be captured while executing an add
4405 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4406 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4407 * WIM path that did not exist; or a rename command attempted to rename a
4408 * file that does not exist.
4409 * @retval ::WIMLIB_ERR_READ
4410 * While executing an add command, failed to read data from a file or
4411 * directory to be captured.
4412 * @retval ::WIMLIB_ERR_READLINK
4413 * While executing an add command, failed to read the target of a symbolic
4414 * link, junction, or other reparse point.
4415 * @retval ::WIMLIB_ERR_STAT
4416 * While executing an add command, failed to read metadata for a file or
4418 * @retval ::WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG
4419 * A capture configuration file could not be read.
4420 * @retval ::WIMLIB_ERR_UNSUPPORTED
4421 * A command had flags provided that are not supported on this platform or
4422 * in this build of the library.
4423 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4424 * An add command with ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified
4425 * discovered a file that was not of a supported type.
4427 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4428 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4429 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4430 * indicate failure (for different reasons) to read the metadata resource for an
4431 * image that needed to be updated.
4434 wimlib_update_image(WIMStruct *wim,
4436 const struct wimlib_update_command *cmds,
4441 * @ingroup G_writing_and_overwriting_wims
4443 * Persist a ::WIMStruct to a new on-disk WIM file.
4445 * This brings in file data from any external locations, such as directory trees
4446 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4447 * wimlib_export_image(), and incorporates it into a new on-disk WIM file.
4449 * By default, the new WIM file is written as stand-alone. Using the
4450 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4451 * instead. However, this function cannot directly write a "split" WIM; use
4452 * wimlib_split() for that.
4455 * Pointer to the ::WIMStruct being persisted.
4457 * The path to the on-disk file to write.
4459 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4460 * images are to be included in the new on-disk WIM file. If for some
4461 * reason you only want to include a single image, specify the 1-based
4462 * index of that image instead.
4463 * @param write_flags
4464 * Bitwise OR of flags prefixed with @c WIMLIB_WRITE_FLAG.
4465 * @param num_threads
4466 * The number of threads to use for compressing data, or 0 to have the
4467 * library automatically choose an appropriate number.
4469 * @return 0 on success; a ::wimlib_error_code value on failure.
4471 * @retval ::WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED
4472 * A file that had previously been scanned for inclusion in the WIM was
4473 * concurrently modified.
4474 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4475 * @p image did not exist in @p wim.
4476 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4477 * A file, stored in another WIM, which needed to be written was corrupt.
4478 * @retval ::WIMLIB_ERR_INVALID_PARAM
4479 * @p path was not a nonempty string, or invalid flags were passed.
4480 * @retval ::WIMLIB_ERR_OPEN
4481 * Failed to open the output WIM file for writing, or failed to open a file
4482 * whose data needed to be included in the WIM.
4483 * @retval ::WIMLIB_ERR_READ
4484 * Failed to read data that needed to be included in the WIM.
4485 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4486 * A file data blob that needed to be written could not be found in the
4487 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
4488 * @retval ::WIMLIB_ERR_WRITE
4489 * An error occurred when trying to write data to the new WIM file.
4491 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4492 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4493 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4494 * indicate failure (for different reasons) to read the data from a WIM file.
4496 * If a progress function is registered with @p wim, then it will receive the
4497 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4498 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4499 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4502 wimlib_write(WIMStruct *wim,
4503 const wimlib_tchar *path,
4506 unsigned num_threads);
4509 * @ingroup G_writing_and_overwriting_wims
4511 * Same as wimlib_write(), but write the WIM directly to a file descriptor,
4512 * which need not be seekable if the write is done in a special pipable WIM
4513 * format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p write_flags. This can,
4514 * for example, allow capturing a WIM image and streaming it over the network.
4515 * See @ref subsec_pipable_wims for more information about pipable WIMs.
4517 * The file descriptor @p fd will @b not be closed when the write is complete;
4518 * the calling code is responsible for this.
4520 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
4521 * error codes include those that can be returned by wimlib_write() as well as
4524 * @retval ::WIMLIB_ERR_INVALID_PARAM
4525 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4526 * specified in @p write_flags.
4529 wimlib_write_to_fd(WIMStruct *wim,
4533 unsigned num_threads);
4536 * @defgroup G_compression Compression and decompression functions
4538 * @brief Functions for XPRESS, LZX, and LZMS compression and decompression.
4540 * These functions are already used by wimlib internally when appropriate for
4541 * reading and writing WIM archives. But they are exported and documented so
4542 * that they can be used in other applications or libraries for general-purpose
4543 * lossless data compression. They are implemented in highly optimized C code,
4544 * using state-of-the-art compression techniques. The main limitation is the
4545 * lack of sliding window support; this has, however, allowed the algorithms to
4546 * be optimized for block-based compression.
4551 /** Opaque compressor handle. */
4552 struct wimlib_compressor;
4554 /** Opaque decompressor handle. */
4555 struct wimlib_decompressor;
4558 * Set the default compression level for the specified compression type. This
4559 * is the compression level that wimlib_create_compressor() assumes if it is
4560 * called with @p compression_level specified as 0.
4562 * wimlib's WIM writing code (e.g. wimlib_write()) will pass 0 to
4563 * wimlib_create_compressor() internally. Therefore, calling this function will
4564 * affect the compression level of any data later written to WIM files using the
4565 * specified compression type.
4567 * The initial state, before this function is called, is that all compression
4568 * types have a default compression level of 50.
4571 * Compression type for which to set the default compression level, as one
4572 * of the ::wimlib_compression_type constants. Or, if this is the special
4573 * value -1, the default compression levels for all compression types will
4575 * @param compression_level
4576 * The default compression level to set. If 0, the "default default" level
4577 * of 50 is restored. Otherwise, a higher value indicates higher
4578 * compression, whereas a lower value indicates lower compression. See
4579 * wimlib_create_compressor() for more information.
4581 * @return 0 on success; a ::wimlib_error_code value on failure.
4583 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4584 * @p ctype was neither a supported compression type nor -1.
4587 wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
4590 * Return the approximate number of bytes needed to allocate a compressor with
4591 * wimlib_create_compressor() for the specified compression type, maximum block
4592 * size, and compression level. @p compression_level may be 0, in which case
4593 * the current default compression level for @p ctype is used. Returns 0 if the
4594 * compression type is invalid, or the @p max_block_size for that compression
4598 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4599 size_t max_block_size,
4600 unsigned int compression_level);
4602 #define WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE 0x80000000
4605 * Allocate a compressor for the specified compression type using the specified
4606 * parameters. This function is part of wimlib's compression API; it is not
4607 * necessary to call this to process a WIM file.
4610 * Compression type for which to create the compressor, as one of the
4611 * ::wimlib_compression_type constants.
4612 * @param max_block_size
4613 * The maximum compression block size to support. This specifies the
4614 * maximum allowed value for the @p uncompressed_size parameter of
4615 * wimlib_compress() when called using this compressor.
4617 * Usually, the amount of memory used by the compressor will scale in
4618 * proportion to the @p max_block_size parameter.
4619 * wimlib_get_compressor_needed_memory() can be used to query the specific
4620 * amount of memory that will be required.
4622 * This parameter must be at least 1 and must be less than or equal to a
4623 * compression-type-specific limit.
4625 * In general, the same value of @p max_block_size must be passed to
4626 * wimlib_create_decompressor() when the data is later decompressed.
4627 * However, some compression types have looser requirements regarding this.
4628 * @param compression_level
4629 * The compression level to use. If 0, the default compression level (50,
4630 * or another value as set through wimlib_set_default_compression_level())
4631 * is used. Otherwise, a higher value indicates higher compression. The
4632 * values are scaled so that 10 is low compression, 50 is medium
4633 * compression, and 100 is high compression. This is not a percentage;
4634 * values above 100 are also valid.
4636 * Using a higher-than-default compression level can result in a better
4637 * compression ratio, but can significantly reduce performance. Similarly,
4638 * using a lower-than-default compression level can result in better
4639 * performance, but can significantly worsen the compression ratio. The
4640 * exact results will depend heavily on the compression type and what
4641 * algorithms are implemented for it. If you are considering using a
4642 * non-default compression level, you should run benchmarks to see if it is
4643 * worthwhile for your application.
4645 * The compression level does not affect the format of the compressed data.
4646 * Therefore, it is a compressor-only parameter and does not need to be
4647 * passed to the decompressor.
4649 * Since wimlib v1.8.0, this parameter can be OR-ed with the flag
4650 * ::WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE. This creates the compressor in a
4651 * mode where it is allowed to modify the input buffer. Specifically, in
4652 * this mode, if compression succeeds, the input buffer may have been
4653 * modified, whereas if compression does not succeed the input buffer still
4654 * may have been written to but will have been restored exactly to its
4655 * original state. This mode is designed to save some memory when using
4656 * large buffer sizes.
4657 * @param compressor_ret
4658 * A location into which to return the pointer to the allocated compressor.
4659 * The allocated compressor can be used for any number of calls to
4660 * wimlib_compress() before being freed with wimlib_free_compressor().
4662 * @return 0 on success; a ::wimlib_error_code value on failure.
4664 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4665 * @p ctype was not a supported compression type.
4666 * @retval ::WIMLIB_ERR_INVALID_PARAM
4667 * @p max_block_size was invalid for the compression type, or @p
4668 * compressor_ret was @c NULL.
4669 * @retval ::WIMLIB_ERR_NOMEM
4670 * Insufficient memory to allocate the compressor.
4673 wimlib_create_compressor(enum wimlib_compression_type ctype,
4674 size_t max_block_size,
4675 unsigned int compression_level,
4676 struct wimlib_compressor **compressor_ret);
4679 * Compress a buffer of data.
4681 * @param uncompressed_data
4682 * Buffer containing the data to compress.
4683 * @param uncompressed_size
4684 * Size, in bytes, of the data to compress. This cannot be greater than
4685 * the @p max_block_size with which wimlib_create_compressor() was called.
4686 * (If it is, the data will not be compressed and 0 will be returned.)
4687 * @param compressed_data
4688 * Buffer into which to write the compressed data.
4689 * @param compressed_size_avail
4690 * Number of bytes available in @p compressed_data.
4692 * A compressor previously allocated with wimlib_create_compressor().
4695 * The size of the compressed data, in bytes, or 0 if the data could not be
4696 * compressed to @p compressed_size_avail or fewer bytes.
4699 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4700 void *compressed_data, size_t compressed_size_avail,
4701 struct wimlib_compressor *compressor);
4704 * Free a compressor previously allocated with wimlib_create_compressor().
4707 * The compressor to free. If @c NULL, no action is taken.
4710 wimlib_free_compressor(struct wimlib_compressor *compressor);
4713 * Allocate a decompressor for the specified compression type. This function is
4714 * part of wimlib's compression API; it is not necessary to call this to process
4718 * Compression type for which to create the decompressor, as one of the
4719 * ::wimlib_compression_type constants.
4720 * @param max_block_size
4721 * The maximum compression block size to support. This specifies the
4722 * maximum allowed value for the @p uncompressed_size parameter of
4723 * wimlib_decompress().
4725 * In general, this parameter must be the same as the @p max_block_size
4726 * that was passed to wimlib_create_compressor() when the data was
4727 * compressed. However, some compression types have looser requirements
4729 * @param decompressor_ret
4730 * A location into which to return the pointer to the allocated
4731 * decompressor. The allocated decompressor can be used for any number of
4732 * calls to wimlib_decompress() before being freed with
4733 * wimlib_free_decompressor().
4735 * @return 0 on success; a ::wimlib_error_code value on failure.
4737 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4738 * @p ctype was not a supported compression type.
4739 * @retval ::WIMLIB_ERR_INVALID_PARAM
4740 * @p max_block_size was invalid for the compression type, or @p
4741 * decompressor_ret was @c NULL.
4742 * @retval ::WIMLIB_ERR_NOMEM
4743 * Insufficient memory to allocate the decompressor.
4746 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4747 size_t max_block_size,
4748 struct wimlib_decompressor **decompressor_ret);
4751 * Decompress a buffer of data.
4753 * @param compressed_data
4754 * Buffer containing the data to decompress.
4755 * @param compressed_size
4756 * Size, in bytes, of the data to decompress.
4757 * @param uncompressed_data
4758 * Buffer into which to write the uncompressed data.
4759 * @param uncompressed_size
4760 * Size, in bytes, of the data when uncompressed. This cannot exceed the
4761 * @p max_block_size with which wimlib_create_decompressor() was called.
4762 * (If it does, the data will not be decompressed and a nonzero value will
4764 * @param decompressor
4765 * A decompressor previously allocated with wimlib_create_decompressor().
4767 * @return 0 on success; nonzero on failure.
4769 * No specific error codes are defined; any nonzero value indicates that the
4770 * decompression failed. This can only occur if the data is truly invalid;
4771 * there will never be transient errors like "out of memory", for example.
4773 * This function requires that the exact uncompressed size of the data be passed
4774 * as the @p uncompressed_size parameter. If this is not done correctly,
4775 * decompression may fail or the data may be decompressed incorrectly.
4778 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4779 void *uncompressed_data, size_t uncompressed_size,
4780 struct wimlib_decompressor *decompressor);
4783 * Free a decompressor previously allocated with wimlib_create_decompressor().
4785 * @param decompressor
4786 * The decompressor to free. If @c NULL, no action is taken.
4789 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4801 #endif /* _WIMLIB_H */