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 # if defined(_MSC_VER) && _MSC_VER < 1800 /* VS pre-2013? */
393 typedef unsigned char bool;
395 # include <stdbool.h>
401 /** @addtogroup G_general
404 /** Major version of the library (for example, the 1 in 1.2.5). */
405 #define WIMLIB_MAJOR_VERSION 1
407 /** Minor version of the library (for example, the 2 in 1.2.5). */
408 #define WIMLIB_MINOR_VERSION 10
410 /** Patch version of the library (for example, the 5 in 1.2.5). */
411 #define WIMLIB_PATCH_VERSION 0
418 * To represent file timestamps, wimlib's API uses the POSIX 'struct timespec'.
419 * This was probably a mistake because it doesn't play well with Visual Studio.
420 * In old VS versions it isn't present at all; in newer VS versions it is
421 * supposedly present, but I wouldn't trust it to be the same size as the one
422 * MinGW uses. The solution is to define a compatible structure ourselves when
423 * this header is included on Windows and the compiler is not MinGW.
425 #if defined(_WIN32) && !defined(__GNUC__)
427 /* Seconds since start of UNIX epoch (January 1, 1970) */
433 /* Nanoseconds (0-999999999) */
437 # define wimlib_timespec struct timespec /* standard definition */
441 * Opaque structure that represents a WIM, possibly backed by an on-disk file.
442 * See @ref sec_basic_wim_handling_concepts for more information.
444 #ifndef WIMLIB_WIMSTRUCT_DECLARED
445 typedef struct WIMStruct WIMStruct;
446 #define WIMLIB_WIMSTRUCT_DECLARED
450 typedef wchar_t wimlib_tchar;
452 /** See @ref sec_encodings */
453 typedef char wimlib_tchar;
457 /** Path separator for WIM paths passed back to progress callbacks.
458 * This is forward slash on UNIX and backslash on Windows. */
459 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
460 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
462 /** Path separator for WIM paths passed back to progress callbacks.
463 * This is forward slash on UNIX and backslash on Windows. */
464 # define WIMLIB_WIM_PATH_SEPARATOR '/'
465 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
468 /** A string containing a single path separator; use this to specify the root
469 * directory of a WIM image. */
470 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
472 /** Use this to test if the specified path refers to the root directory of the
474 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
475 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
478 /** Length of a Globally Unique Identifier (GUID), in bytes. */
479 #define WIMLIB_GUID_LEN 16
482 * Specifies a compression type.
484 * A WIM file has a default compression type, indicated by its file header.
485 * Normally, each resource in the WIM file is compressed with this compression
486 * type. However, resources may be stored as uncompressed; for example, wimlib
487 * may do so if a resource does not compress to less than its original size. In
488 * addition, a WIM with the new version number of 3584, or "ESD file", might
489 * contain solid resources with different compression types.
491 enum wimlib_compression_type {
495 * This is a valid argument to wimlib_create_new_wim() and
496 * wimlib_set_output_compression_type(), but not to the functions in the
497 * compression API such as wimlib_create_compressor().
499 WIMLIB_COMPRESSION_TYPE_NONE = 0,
502 * The XPRESS compression format. This format combines Lempel-Ziv
503 * factorization with Huffman encoding. Compression and decompression
504 * are both fast. This format supports chunk sizes that are powers of 2
505 * between <c>2^12</c> and <c>2^16</c>, inclusively.
507 * wimlib's XPRESS compressor will, with the default settings, usually
508 * produce a better compression ratio, and work more quickly, than the
509 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
510 * Non-default compression levels are also supported. For example,
511 * level 80 will enable two-pass optimal parsing, which is significantly
512 * slower but usually improves compression by several percent over the
513 * default level of 50.
515 * If using wimlib_create_compressor() to create an XPRESS compressor
516 * directly, the @p max_block_size parameter may be any positive value
517 * up to and including <c>2^16</c>.
519 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
522 * The LZX compression format. This format combines Lempel-Ziv
523 * factorization with Huffman encoding, but with more features and
524 * complexity than XPRESS. Compression is slow to somewhat fast,
525 * depending on the settings. Decompression is fast but slower than
526 * XPRESS. This format supports chunk sizes that are powers of 2
527 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
528 * other than <c>2^15</c> are not compatible with the Microsoft
531 * wimlib's LZX compressor will, with the default settings, usually
532 * produce a better compression ratio, and work more quickly, than the
533 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
534 * Non-default compression levels are also supported. For example,
535 * level 20 will provide fast compression, almost as fast as XPRESS.
537 * If using wimlib_create_compressor() to create an LZX compressor
538 * directly, the @p max_block_size parameter may be any positive value
539 * up to and including <c>2^21</c>.
541 WIMLIB_COMPRESSION_TYPE_LZX = 2,
544 * The LZMS compression format. This format combines Lempel-Ziv
545 * factorization with adaptive Huffman encoding and range coding.
546 * Compression and decompression are both fairly slow. This format
547 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
548 * <c>2^30</c>, inclusively. This format is best used for large chunk
549 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
550 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
551 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
552 * with the Microsoft implementation.
554 * wimlib's LZMS compressor will, with the default settings, usually
555 * produce a better compression ratio, and work more quickly, than the
556 * implementation in Microsoft's WIMGAPI (as of Windows 8.1). There is
557 * limited support for non-default compression levels, but compression
558 * will be noticeably faster if you choose a level < 35.
560 * If using wimlib_create_compressor() to create an LZMS compressor
561 * directly, the @p max_block_size parameter may be any positive value
562 * up to and including <c>2^30</c>.
564 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
568 /** @addtogroup G_progress
571 /** Possible values of the first parameter to the user-supplied
572 * ::wimlib_progress_func_t progress function */
573 enum wimlib_progress_msg {
575 /** A WIM image is about to be extracted. @p info will point to
576 * ::wimlib_progress_info.extract. This message is received once per
577 * image for calls to wimlib_extract_image() and
578 * wimlib_extract_image_from_pipe(). */
579 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
581 /** One or more file or directory trees within a WIM image is about to
582 * be extracted. @p info will point to ::wimlib_progress_info.extract.
583 * This message is received only once per wimlib_extract_paths() and
584 * wimlib_extract_pathlist(), since wimlib combines all paths into a
585 * single extraction operation for optimization purposes. */
586 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
588 /** This message may be sent periodically (not for every file) while
589 * files and directories are being created, prior to file data
590 * extraction. @p info will point to ::wimlib_progress_info.extract.
591 * In particular, the @p current_file_count and @p end_file_count
592 * members may be used to track the progress of this phase of
594 WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE = 3,
596 /** File data is currently being extracted. @p info will point to
597 * ::wimlib_progress_info.extract. This is the main message to track
598 * the progress of an extraction operation. */
599 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
601 /** Starting to read a new part of a split pipable WIM over the pipe.
602 * @p info will point to ::wimlib_progress_info.extract. */
603 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
605 /** This message may be sent periodically (not necessarily for every
606 * file) while file and directory metadata is being extracted, following
607 * file data extraction. @p info will point to
608 * ::wimlib_progress_info.extract. The @p current_file_count and @p
609 * end_file_count members may be used to track the progress of this
610 * phase of extraction. */
611 WIMLIB_PROGRESS_MSG_EXTRACT_METADATA = 6,
613 /** The image has been successfully extracted. @p info will point to
614 * ::wimlib_progress_info.extract. This is paired with
615 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
616 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
618 /** The files or directory trees have been successfully extracted. @p
619 * info will point to ::wimlib_progress_info.extract. This is paired
620 * with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
621 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
623 /** The directory or NTFS volume is about to be scanned for metadata.
624 * @p info will point to ::wimlib_progress_info.scan. This message is
625 * received once per call to wimlib_add_image(), or once per capture
626 * source passed to wimlib_add_image_multisource(), or once per add
627 * command passed to wimlib_update_image(). */
628 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
630 /** A directory or file has been scanned. @p info will point to
631 * ::wimlib_progress_info.scan, and its @p cur_path member will be
632 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
634 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
636 /** The directory or NTFS volume has been successfully scanned. @p info
637 * will point to ::wimlib_progress_info.scan. This is paired with a
638 * previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message, possibly with many
639 * intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY messages. */
640 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
642 /** File data is currently being written to the WIM. @p info will point
643 * to ::wimlib_progress_info.write_streams. This message may be
644 * received many times while the WIM file is being written or appended
645 * to with wimlib_write(), wimlib_overwrite(), or wimlib_write_to_fd().
647 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
649 /** Per-image metadata is about to be written to the WIM file. @p info
650 * will not be valid. */
651 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
653 /** The per-image metadata has been written to the WIM file. @p info
654 * will not be valid. This message is paired with a preceding
655 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message. */
656 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
658 /** wimlib_overwrite() has successfully renamed the temporary file to
659 * the original WIM file, thereby committing the changes to the WIM
660 * file. @p info will point to ::wimlib_progress_info.rename. Note:
661 * this message is not received if wimlib_overwrite() chose to append to
662 * the WIM file in-place. */
663 WIMLIB_PROGRESS_MSG_RENAME = 15,
665 /** The contents of the WIM file are being checked against the integrity
666 * table. @p info will point to ::wimlib_progress_info.integrity. This
667 * message is only received (and may be received many times) when
668 * wimlib_open_wim_with_progress() is called with the
669 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
670 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
672 /** An integrity table is being calculated for the WIM being written.
673 * @p info will point to ::wimlib_progress_info.integrity. This message
674 * is only received (and may be received many times) when a WIM file is
675 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
676 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
678 /** A wimlib_split() operation is in progress, and a new split part is
679 * about to be started. @p info will point to
680 * ::wimlib_progress_info.split. */
681 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
683 /** A wimlib_split() operation is in progress, and a split part has been
684 * finished. @p info will point to ::wimlib_progress_info.split. */
685 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
687 /** A WIM update command is about to be executed. @p info will point to
688 * ::wimlib_progress_info.update. This message is received once per
689 * update command when wimlib_update_image() is called with the flag
690 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
691 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
693 /** A WIM update command has been executed. @p info will point to
694 * ::wimlib_progress_info.update. This message is received once per
695 * update command when wimlib_update_image() is called with the flag
696 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
697 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
699 /** A file in the image is being replaced as a result of a
700 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
701 * @p info will point to ::wimlib_progress_info.replace. This is only
702 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
704 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
706 /** An image is being extracted with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
707 * a file is being extracted normally (not as a "WIMBoot pointer file")
708 * due to it matching a pattern in the <c>[PrepopulateList]</c> section
709 * of the configuration file
710 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image. @p
711 * info will point to ::wimlib_progress_info.wimboot_exclude. */
712 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
714 /** Starting to unmount an image. @p info will point to
715 * ::wimlib_progress_info.unmount. */
716 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
718 /** wimlib has used a file's data for the last time (including all data
719 * streams, if it has multiple). @p info will point to
720 * ::wimlib_progress_info.done_with_file. This message is only received
721 * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided. */
722 WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
724 /** wimlib_verify_wim() is starting to verify the metadata for an image.
725 * @p info will point to ::wimlib_progress_info.verify_image. */
726 WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
728 /** wimlib_verify_wim() has finished verifying the metadata for an
729 * image. @p info will point to ::wimlib_progress_info.verify_image.
731 WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
733 /** wimlib_verify_wim() is verifying file data integrity. @p info will
734 * point to ::wimlib_progress_info.verify_streams. */
735 WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
738 * The progress function is being asked whether a file should be
739 * excluded from capture or not. @p info will point to
740 * ::wimlib_progress_info.test_file_exclusion. This is a bidirectional
741 * message that allows the progress function to set a flag if the file
742 * should be excluded.
744 * This message is only received if the flag
745 * ::WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION is used. This method for file
746 * exclusions is independent of the "capture configuration file"
749 WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION = 30,
752 * An error has occurred and the progress function is being asked
753 * whether to ignore the error or not. @p info will point to
754 * ::wimlib_progress_info.handle_error. This is a bidirectional
757 * This message provides a limited capability for applications to
758 * recover from "unexpected" errors (i.e. those with no in-library
759 * handling policy) arising from the underlying operating system.
760 * Normally, any such error will cause the library to abort the current
761 * operation. By implementing a handler for this message, the
762 * application can instead choose to ignore a given error.
764 * Currently, only the following types of errors will result in this
765 * progress message being sent:
767 * - Directory tree scan errors, e.g. from wimlib_add_image()
768 * - Most extraction errors; currently restricted to the Windows
769 * build of the library only.
771 WIMLIB_PROGRESS_MSG_HANDLE_ERROR = 31,
774 /** Valid return values from user-provided progress functions
775 * (::wimlib_progress_func_t).
777 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
780 enum wimlib_progress_status {
782 /** The operation should be continued. This is the normal return value.
784 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
786 /** The operation should be aborted. This will cause the current
787 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
788 WIMLIB_PROGRESS_STATUS_ABORT = 1,
792 * A pointer to this union is passed to the user-supplied
793 * ::wimlib_progress_func_t progress function. One (or none) of the structures
794 * contained in this union will be applicable for the operation
795 * (::wimlib_progress_msg) indicated in the first argument to the progress
797 union wimlib_progress_info {
799 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
800 * the primary message for tracking the progress of writing a WIM file.
802 struct wimlib_progress_info_write_streams {
804 /** An upper bound on the number of bytes of file data that will
805 * be written. This number is the uncompressed size; the actual
806 * size may be lower due to compression. In addition, this
807 * number may decrease over time as duplicated file data is
809 uint64_t total_bytes;
811 /** An upper bound on the number of distinct file data "blobs"
812 * that will be written. This will often be similar to the
813 * "number of files", but for several reasons (hard links, named
814 * data streams, empty files, etc.) it can be different. In
815 * addition, this number may decrease over time as duplicated
816 * file data is discovered. */
817 uint64_t total_streams;
819 /** The number of bytes of file data that have been written so
820 * far. This starts at 0 and ends at @p total_bytes. This
821 * number is the uncompressed size; the actual size may be lower
822 * due to compression. */
823 uint64_t completed_bytes;
825 /** The number of distinct file data "blobs" that have been
826 * written so far. This starts at 0 and ends at @p
828 uint64_t completed_streams;
830 /** The number of threads being used for data compression; or,
831 * if no compression is being performed, this will be 1. */
832 uint32_t num_threads;
834 /** The compression type being used, as one of the
835 * ::wimlib_compression_type constants. */
836 int32_t compression_type;
838 /** The number of on-disk WIM files from which file data is
839 * being exported into the output WIM file. This can be 0, 1,
840 * or more than 1, depending on the situation. */
841 uint32_t total_parts;
843 /** This is currently broken and will always be 0. */
844 uint32_t completed_parts;
847 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
848 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
849 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
850 struct wimlib_progress_info_scan {
852 /** Top-level directory being scanned; or, when capturing an NTFS
853 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
854 * to the file or block device that contains the NTFS volume
856 const wimlib_tchar *source;
858 /** Path to the file (or directory) that has been scanned, valid
859 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
860 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
861 * relative to the root of the NTFS volume. */
862 const wimlib_tchar *cur_path;
864 /** Dentry scan status, valid on
865 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
867 /** File looks okay and will be captured. */
868 WIMLIB_SCAN_DENTRY_OK = 0,
870 /** File is being excluded from capture due to the
871 * capture configuration. */
872 WIMLIB_SCAN_DENTRY_EXCLUDED = 1,
874 /** File is being excluded from capture due to being of
875 * an unsupported type. */
876 WIMLIB_SCAN_DENTRY_UNSUPPORTED = 2,
878 /** The file is an absolute symbolic link or junction
879 * that points into the capture directory, and
880 * reparse-point fixups are enabled, so its target is
881 * being adjusted. (Reparse point fixups can be
882 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
884 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK = 3,
886 /** Reparse-point fixups are enabled, but the file is an
887 * absolute symbolic link or junction that does
888 * <b>not</b> point into the capture directory, so its
889 * target is <b>not</b> being adjusted. */
890 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK = 4,
894 /** Target path in the image. Only valid on messages
895 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
896 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
897 const wimlib_tchar *wim_target_path;
899 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
900 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
901 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
902 * target of the absolute symbolic link or junction. */
903 const wimlib_tchar *symlink_target;
906 /** The number of directories scanned so far, not counting
907 * excluded/unsupported files. */
908 uint64_t num_dirs_scanned;
910 /** The number of non-directories scanned so far, not counting
911 * excluded/unsupported files. */
912 uint64_t num_nondirs_scanned;
914 /** The number of bytes of file data detected so far, not
915 * counting excluded/unsupported files. */
916 uint64_t num_bytes_scanned;
919 /** Valid on messages
920 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
921 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
922 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
923 * ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE,
924 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
925 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA,
926 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
927 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
929 * Note: most of the time of an extraction operation will be spent
930 * extracting file data, and the application will receive
931 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
932 * completed_bytes and @p total_bytes, the application can calculate a
933 * percentage complete. However, there is no way for applications to
934 * know which file is currently being extracted. This is by design
935 * because the best way to complete the extraction operation is not
936 * necessarily file-by-file.
938 struct wimlib_progress_info_extract {
940 /** The 1-based index of the image from which files are being
944 /** Extraction flags being used. */
945 uint32_t extract_flags;
947 /** If the ::WIMStruct from which the extraction being performed
948 * has a backing file, then this is an absolute path to that
949 * backing file. Otherwise, this is @c NULL. */
950 const wimlib_tchar *wimfile_name;
952 /** Name of the image from which files are being extracted, or
953 * the empty string if the image is unnamed. */
954 const wimlib_tchar *image_name;
956 /** Path to the directory or NTFS volume to which the files are
957 * being extracted. */
958 const wimlib_tchar *target;
961 const wimlib_tchar *reserved;
963 /** The number of bytes of file data that will be extracted. */
964 uint64_t total_bytes;
966 /** The number of bytes of file data that have been extracted so
967 * far. This starts at 0 and ends at @p total_bytes. */
968 uint64_t completed_bytes;
970 /** The number of file streams that will be extracted. This
971 * will often be similar to the "number of files", but for
972 * several reasons (hard links, named data streams, empty files,
973 * etc.) it can be different. */
974 uint64_t total_streams;
976 /** The number of file streams that have been extracted so far.
977 * This starts at 0 and ends at @p total_streams. */
978 uint64_t completed_streams;
980 /** Currently only used for
981 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
982 uint32_t part_number;
984 /** Currently only used for
985 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
986 uint32_t total_parts;
988 /** Currently only used for
989 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
990 uint8_t guid[WIMLIB_GUID_LEN];
992 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
993 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is the
994 * number of files that have been processed so far. Once the
995 * corresponding phase of extraction is complete, this value
996 * will be equal to @c end_file_count. */
997 uint64_t current_file_count;
999 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
1000 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is
1001 * total number of files that will be processed.
1003 * This number is provided for informational purposes only, e.g.
1004 * for a progress bar. This number will not necessarily be
1005 * equal to the number of files actually being extracted. This
1006 * is because extraction backends are free to implement an
1007 * extraction algorithm that might be more efficient than
1008 * processing every file in the "extract file structure" and
1009 * "extract file metadata" phases. For example, the current
1010 * implementation of the UNIX extraction backend will create
1011 * files on-demand during the "extract file data" phase.
1012 * Therefore, when using that particular extraction backend, @p
1013 * end_file_count will only include directories and empty files.
1015 uint64_t end_file_count;
1018 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
1019 struct wimlib_progress_info_rename {
1020 /** Name of the temporary file that the WIM was written to. */
1021 const wimlib_tchar *from;
1023 /** Name of the original WIM file to which the temporary file is
1025 const wimlib_tchar *to;
1028 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1029 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
1030 struct wimlib_progress_info_update {
1031 /** Pointer to the update command that will be executed or has
1032 * just been executed. */
1033 const struct wimlib_update_command *command;
1035 /** Number of update commands that have been completed so far.
1037 size_t completed_commands;
1039 /** Number of update commands that are being executed as part of
1040 * this call to wimlib_update_image(). */
1041 size_t total_commands;
1044 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
1045 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
1046 struct wimlib_progress_info_integrity {
1048 /** The number of bytes in the WIM file that are covered by
1049 * integrity checks. */
1050 uint64_t total_bytes;
1052 /** The number of bytes that have been checksummed so far. This
1053 * starts at 0 and ends at @p total_bytes. */
1054 uint64_t completed_bytes;
1056 /** The number of individually checksummed "chunks" the
1057 * integrity-checked region is divided into. */
1058 uint32_t total_chunks;
1060 /** The number of chunks that have been checksummed so far.
1061 * This starts at 0 and ends at @p total_chunks. */
1062 uint32_t completed_chunks;
1064 /** The size of each individually checksummed "chunk" in the
1065 * integrity-checked region. */
1066 uint32_t chunk_size;
1068 /** For ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages, this is
1069 * the path to the WIM file being checked. */
1070 const wimlib_tchar *filename;
1073 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
1074 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
1075 struct wimlib_progress_info_split {
1076 /** Total size of the original WIM's file and metadata resources
1078 uint64_t total_bytes;
1080 /** Number of bytes of file and metadata resources that have
1081 * been copied out of the original WIM so far. Will be 0
1082 * initially, and equal to @p total_bytes at the end. */
1083 uint64_t completed_bytes;
1085 /** Number of the split WIM part that is about to be started
1086 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1087 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
1088 unsigned cur_part_number;
1090 /** Total number of split WIM parts that are being written. */
1091 unsigned total_parts;
1093 /** Name of the split WIM part that is about to be started
1094 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1095 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). Since
1096 * wimlib v1.7.0, the library user may change this when
1097 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
1098 * cause the next split WIM part to be written to a different
1100 wimlib_tchar *part_name;
1103 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
1104 struct wimlib_progress_info_replace {
1105 /** Path to the file in the image that is being replaced */
1106 const wimlib_tchar *path_in_wim;
1109 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1110 struct wimlib_progress_info_wimboot_exclude {
1111 /** Path to the file in the image */
1112 const wimlib_tchar *path_in_wim;
1114 /** Path to which the file is being extracted */
1115 const wimlib_tchar *extraction_path;
1118 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1119 struct wimlib_progress_info_unmount {
1120 /** Path to directory being unmounted */
1121 const wimlib_tchar *mountpoint;
1123 /** Path to WIM file being unmounted */
1124 const wimlib_tchar *mounted_wim;
1126 /** 1-based index of image being unmounted. */
1127 uint32_t mounted_image;
1129 /** Flags that were passed to wimlib_mount_image() when the
1130 * mountpoint was set up. */
1131 uint32_t mount_flags;
1133 /** Flags passed to wimlib_unmount_image(). */
1134 uint32_t unmount_flags;
1137 /** Valid on messages ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE. */
1138 struct wimlib_progress_info_done_with_file {
1140 * Path to the file whose data has been written to the WIM file,
1141 * or is currently being asynchronously compressed in memory,
1142 * and therefore is no longer needed by wimlib.
1144 * WARNING: The file data will not actually be accessible in the
1145 * WIM file until the WIM file has been completely written.
1146 * Ordinarily you should <b>not</b> treat this message as a
1147 * green light to go ahead and delete the specified file, since
1148 * that would result in data loss if the WIM file cannot be
1149 * successfully created for any reason.
1151 * If a file has multiple names (hard links),
1152 * ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE will only be received
1153 * for one name. Also, this message will not be received for
1154 * empty files or reparse points (or symbolic links), unless
1155 * they have nonempty named data streams.
1157 const wimlib_tchar *path_to_file;
1160 /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
1161 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE. */
1162 struct wimlib_progress_info_verify_image {
1163 const wimlib_tchar *wimfile;
1164 uint32_t total_images;
1165 uint32_t current_image;
1168 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS. */
1169 struct wimlib_progress_info_verify_streams {
1170 const wimlib_tchar *wimfile;
1171 uint64_t total_streams;
1172 uint64_t total_bytes;
1173 uint64_t completed_streams;
1174 uint64_t completed_bytes;
1177 /** Valid on messages ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION. */
1178 struct wimlib_progress_info_test_file_exclusion {
1181 * Path to the file for which exclusion is being tested.
1183 * UNIX capture mode: The path will be a standard relative or
1184 * absolute UNIX filesystem path.
1186 * NTFS-3G capture mode: The path will be given relative to the
1187 * root of the NTFS volume, with a leading slash.
1189 * Windows capture mode: The path will be a Win32 namespace
1192 const wimlib_tchar *path;
1195 * Indicates whether the file or directory will be excluded from
1196 * capture or not. This will be <c>false</c> by default. The
1197 * progress function can set this to <c>true</c> if it decides
1198 * that the file needs to be excluded.
1201 } test_file_exclusion;
1203 /** Valid on messages ::WIMLIB_PROGRESS_MSG_HANDLE_ERROR. */
1204 struct wimlib_progress_info_handle_error {
1206 /** Path to the file for which the error occurred, or NULL if
1208 const wimlib_tchar *path;
1210 /** The wimlib error code associated with the error. */
1214 * Indicates whether the error will be ignored or not. This
1215 * will be <c>false</c> by default; the progress function may
1216 * set it to <c>true</c>.
1223 * A user-supplied function that will be called periodically during certain WIM
1226 * The first argument will be the type of operation that is being performed or
1227 * is about to be started or has been completed.
1229 * The second argument will be a pointer to one of a number of structures
1230 * depending on the first argument. It may be @c NULL for some message types.
1231 * Note that although this argument is not @c const, users should not modify it
1232 * except in explicitly documented cases.
1234 * The third argument will be a user-supplied value that was provided when
1235 * registering or specifying the progress function.
1237 * This function must return one of the ::wimlib_progress_status values. By
1238 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1240 typedef enum wimlib_progress_status
1241 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1242 union wimlib_progress_info *info,
1246 /** @addtogroup G_modifying_wims
1249 /** An array of these structures is passed to wimlib_add_image_multisource() to
1250 * specify the sources from which to create a WIM image. */
1251 struct wimlib_capture_source {
1252 /** Absolute or relative path to a file or directory on the external
1253 * filesystem to be included in the image. */
1254 wimlib_tchar *fs_source_path;
1256 /** Destination path in the image. To specify the root directory of the
1257 * image, use ::WIMLIB_WIM_ROOT_PATH. */
1258 wimlib_tchar *wim_target_path;
1260 /** Reserved; set to 0. */
1264 /** Set or unset the "readonly" WIM header flag (<c>WIM_HDR_FLAG_READONLY</c> in
1265 * Microsoft's documentation), based on the ::wimlib_wim_info.is_marked_readonly
1266 * member of the @p info parameter. This is distinct from basic file
1267 * permissions; this flag can be set on a WIM file that is physically writable.
1269 * wimlib disallows modifying on-disk WIM files with the readonly flag set.
1270 * However, wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG
1271 * will override this --- and in fact, this is necessary to set the readonly
1272 * flag persistently on an existing WIM file.
1274 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1276 /** Set the GUID (globally unique identifier) of the WIM file to the value
1277 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1278 #define WIMLIB_CHANGE_GUID 0x00000002
1280 /** Change the bootable image of the WIM to the value specified in
1281 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1282 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1284 /** Change the <c>WIM_HDR_FLAG_RP_FIX</c> flag of the WIM file to the value
1285 * specified in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag
1286 * generally indicates whether an image in the WIM has been captured with
1287 * reparse-point fixups enabled. wimlib also treats this flag as specifying
1288 * whether to do reparse-point fixups by default when capturing or applying WIM
1290 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1294 /** @addtogroup G_wim_information */
1299 * General information about a WIM file.
1301 * This info can also be requested for a ::WIMStruct that does not have a
1302 * backing file. In this case, fields that only make sense given a backing file
1303 * are set to default values.
1305 struct wimlib_wim_info {
1307 /** The globally unique identifier for this WIM. (Note: all parts of a
1308 * split WIM normally have identical GUIDs.) */
1309 uint8_t guid[WIMLIB_GUID_LEN];
1311 /** The number of images in this WIM file. */
1312 uint32_t image_count;
1314 /** The 1-based index of the bootable image in this WIM file, or 0 if no
1315 * image is bootable. */
1316 uint32_t boot_index;
1318 /** The version of the WIM file format used in this WIM file. */
1319 uint32_t wim_version;
1321 /** The default compression chunk size of resources in this WIM file.
1323 uint32_t chunk_size;
1325 /** For split WIMs, the 1-based index of this part within the split WIM;
1327 uint16_t part_number;
1329 /** For split WIMs, the total number of parts in the split WIM;
1331 uint16_t total_parts;
1333 /** The default compression type of resources in this WIM file, as one
1334 * of the ::wimlib_compression_type constants. */
1335 int32_t compression_type;
1337 /** The size of this WIM file in bytes, excluding the XML data and
1338 * integrity table. */
1339 uint64_t total_bytes;
1341 /** 1 iff this WIM file has an integrity table. */
1342 uint32_t has_integrity_table : 1;
1344 /** 1 iff this info struct is for a ::WIMStruct that has a backing file.
1346 uint32_t opened_from_file : 1;
1348 /** 1 iff this WIM file is considered readonly for any reason (e.g. the
1349 * "readonly" header flag is set, or this is part of a split WIM, or
1350 * filesystem permissions deny writing) */
1351 uint32_t is_readonly : 1;
1353 /** 1 iff the "reparse point fix" flag is set in this WIM's header */
1354 uint32_t has_rpfix : 1;
1356 /** 1 iff the "readonly" flag is set in this WIM's header */
1357 uint32_t is_marked_readonly : 1;
1359 /** 1 iff the "spanned" flag is set in this WIM's header */
1360 uint32_t spanned : 1;
1362 /** 1 iff the "write in progress" flag is set in this WIM's header */
1363 uint32_t write_in_progress : 1;
1365 /** 1 iff the "metadata only" flag is set in this WIM's header */
1366 uint32_t metadata_only : 1;
1368 /** 1 iff the "resource only" flag is set in this WIM's header */
1369 uint32_t resource_only : 1;
1371 /** 1 iff this WIM file is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1372 uint32_t pipable : 1;
1373 uint32_t reserved_flags : 22;
1374 uint32_t reserved[9];
1378 * Information about a "blob", which is a fixed length sequence of binary data.
1379 * Each nonempty stream of each file in a WIM image is associated with a blob.
1380 * Blobs are deduplicated within a WIM file.
1382 * TODO: this struct needs to be renamed, and perhaps made into a union since
1383 * there are several cases. I'll try to list them below:
1385 * 1. The blob is "missing", meaning that it is referenced by hash but not
1386 * actually present in the WIM file. In this case we only know the
1387 * sha1_hash. This case can only occur with wimlib_iterate_dir_tree(), never
1388 * wimlib_iterate_lookup_table().
1390 * 2. Otherwise we know the sha1_hash, the uncompressed_size, the
1391 * reference_count, and the is_metadata flag. In addition:
1393 * A. If the blob is located in a non-solid WIM resource, then we also know
1394 * the compressed_size and offset.
1396 * B. If the blob is located in a solid WIM resource, then we also know the
1397 * offset, raw_resource_offset_in_wim, raw_resource_compressed_size, and
1398 * raw_resource_uncompressed_size. But the "offset" is actually the
1399 * offset in the uncompressed solid resource rather than the offset from
1400 * the beginning of the WIM file.
1402 * C. If the blob is *not* located in any type of WIM resource, then we don't
1403 * know any additional information.
1405 * Unknown or irrelevant fields are left zeroed.
1407 struct wimlib_resource_entry {
1409 /** If this blob is not missing, then this is the uncompressed size of
1410 * this blob in bytes. */
1411 uint64_t uncompressed_size;
1413 /** If this blob is located in a non-solid WIM resource, then this is
1414 * the compressed size of that resource. */
1415 uint64_t compressed_size;
1417 /** If this blob is located in a non-solid WIM resource, then this is
1418 * the offset of that resource within the WIM file containing it. If
1419 * this blob is located in a solid WIM resource, then this is the offset
1420 * of this blob within that solid resource when uncompressed. */
1423 /** The SHA-1 message digest of the blob's uncompressed contents. */
1424 uint8_t sha1_hash[20];
1426 /** If this blob is located in a WIM resource, then this is the part
1427 * number of the WIM file containing it. */
1428 uint32_t part_number;
1430 /** If this blob is not missing, then this is the number of times this
1431 * blob is referenced over all images in the WIM. This number is not
1432 * guaranteed to be correct. */
1433 uint32_t reference_count;
1435 /** 1 iff this blob is located in a non-solid compressed WIM resource.
1437 uint32_t is_compressed : 1;
1439 /** 1 iff this blob contains the metadata for an image. */
1440 uint32_t is_metadata : 1;
1442 uint32_t is_free : 1;
1443 uint32_t is_spanned : 1;
1445 /** 1 iff a blob with this hash was not found in the blob lookup table
1446 * of the ::WIMStruct. This normally implies a missing call to
1447 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1448 uint32_t is_missing : 1;
1450 /** 1 iff this blob is located in a solid resource. */
1451 uint32_t packed : 1;
1453 uint32_t reserved_flags : 26;
1455 /** If this blob is located in a solid WIM resource, then this is the
1456 * offset of that solid resource within the WIM file containing it. */
1457 uint64_t raw_resource_offset_in_wim;
1459 /** If this blob is located in a solid WIM resource, then this is the
1460 * compressed size of that solid resource. */
1461 uint64_t raw_resource_compressed_size;
1463 /** If this blob is located in a solid WIM resource, then this is the
1464 * uncompressed size of that solid resource. */
1465 uint64_t raw_resource_uncompressed_size;
1467 uint64_t reserved[1];
1471 * Information about a stream of a particular file in the WIM.
1473 * Normally, only WIM images captured from NTFS filesystems will have multiple
1474 * streams per file. In practice, this is a rarely used feature of the
1477 * TODO: the library now explicitly tracks stream types, which allows it to have
1478 * multiple unnamed streams (e.g. both a reparse point stream and unnamed data
1479 * stream). However, this isn't yet exposed by wimlib_iterate_dir_tree().
1481 struct wimlib_stream_entry {
1483 /** Name of the stream, or NULL if the stream is unnamed. */
1484 const wimlib_tchar *stream_name;
1486 /** Info about this stream's data, such as its hash and size if known.*/
1487 struct wimlib_resource_entry resource;
1489 uint64_t reserved[4];
1493 * Since wimlib v1.9.1: an object ID, which is an extra piece of metadata that
1494 * may be associated with a file on NTFS filesystems. See:
1495 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa363997(v=vs.85).aspx
1497 struct wimlib_object_id {
1498 uint8_t object_id[WIMLIB_GUID_LEN];
1499 uint8_t birth_volume_id[WIMLIB_GUID_LEN];
1500 uint8_t birth_object_id[WIMLIB_GUID_LEN];
1501 uint8_t domain_id[WIMLIB_GUID_LEN];
1504 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1505 * Roughly, the information about a "file" in the WIM image --- but really a
1506 * directory entry ("dentry") because hard links are allowed. The
1507 * hard_link_group_id field can be used to distinguish actual file inodes. */
1508 struct wimlib_dir_entry {
1509 /** Name of the file, or NULL if this file is unnamed. Only the root
1510 * directory of an image will be unnamed. */
1511 const wimlib_tchar *filename;
1513 /** 8.3 name (or "DOS name", or "short name") of this file; or NULL if
1514 * this file has no such name. */
1515 const wimlib_tchar *dos_name;
1517 /** Full path to this file within the image. Path separators will be
1518 * ::WIMLIB_WIM_PATH_SEPARATOR. */
1519 const wimlib_tchar *full_path;
1521 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1522 * children, ..., etc. */
1525 /** Pointer to the security descriptor for this file, in Windows
1526 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1527 * security descriptor. */
1528 const char *security_descriptor;
1530 /** Size of the above security descriptor, in bytes. */
1531 size_t security_descriptor_size;
1533 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1534 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1535 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1536 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1537 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1538 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1539 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1540 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1541 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1542 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1543 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1544 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1545 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1546 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1547 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1548 /** File attributes, such as whether the file is a directory or not.
1549 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1550 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1551 * on other platforms. */
1552 uint32_t attributes;
1554 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1555 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1556 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1557 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1558 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1559 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1560 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1561 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1562 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1563 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1564 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1565 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1566 /** If the file is a reparse point (FILE_ATTRIBUTE_REPARSE_POINT set in
1567 * the attributes), this will give the reparse tag. This tells you
1568 * whether the reparse point is a symbolic link, junction point, or some
1569 * other, more unusual kind of reparse point. */
1570 uint32_t reparse_tag;
1572 /** Number of links to this file's inode (hard links).
1574 * Currently, this will always be 1 for directories. However, it can be
1575 * greater than 1 for nondirectory files. */
1578 /** Number of named data streams this file has. Normally 0. */
1579 uint32_t num_named_streams;
1581 /** A unique identifier for this file's inode. However, as a special
1582 * case, if the inode only has a single link (@p num_links == 1), this
1585 * Note: if a WIM image is captured from a filesystem, this value is not
1586 * guaranteed to be the same as the original number of the inode on the
1588 uint64_t hard_link_group_id;
1590 /** Time this file was created. */
1591 wimlib_timespec creation_time;
1593 /** Time this file was last written to. */
1594 wimlib_timespec last_write_time;
1596 /** Time this file was last accessed. */
1597 wimlib_timespec last_access_time;
1599 /** The UNIX user ID of this file. This is a wimlib extension.
1601 * This field is only valid if @p unix_mode != 0. */
1604 /** The UNIX group ID of this file. This is a wimlib extension.
1606 * This field is only valid if @p unix_mode != 0. */
1609 /** The UNIX mode of this file. This is a wimlib extension.
1611 * If this field is 0, then @p unix_uid, @p unix_gid, @p unix_mode, and
1612 * @p unix_rdev are all unknown (fields are not present in the WIM
1616 /** The UNIX device ID (major and minor number) of this file. This is a
1619 * This field is only valid if @p unix_mode != 0. */
1622 /* The object ID of this file, if any. Only valid if
1623 * object_id.object_id is not all zeroes. */
1624 struct wimlib_object_id object_id;
1626 uint64_t reserved[6];
1629 * Variable-length array of streams that make up this file.
1631 * The first entry will always exist and will correspond to the unnamed
1632 * data stream (default file contents), so it will have <c>stream_name
1633 * == NULL</c>. Alternatively, for reparse point files, the first entry
1634 * will correspond to the reparse data stream. Alternatively, for
1635 * encrypted files, the first entry will correspond to the encrypted
1638 * Then, following the first entry, there be @p num_named_streams
1639 * additional entries that specify the named data streams, if any, each
1640 * of which will have <c>stream_name != NULL</c>.
1642 struct wimlib_stream_entry streams[];
1646 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1649 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1653 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1656 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1659 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1660 * just on the specified path. */
1661 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1663 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1664 * itself; only its children (in the case of a non-empty directory) */
1665 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1667 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any file data blobs needed to fill
1668 * in the ::wimlib_resource_entry's for the iteration cannot be found in the
1669 * blob lookup table of the ::WIMStruct. The default behavior without this flag
1670 * is to fill in the @ref wimlib_resource_entry::sha1_hash "sha1_hash" and set
1671 * the @ref wimlib_resource_entry::is_missing "is_missing" flag. */
1672 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1676 /** @addtogroup G_modifying_wims
1679 /** UNIX-like systems only: Directly capture an NTFS volume rather than a
1680 * generic directory. This requires that wimlib was compiled with support for
1683 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1684 * ::WIMLIB_ADD_FLAG_UNIX_DATA.
1686 * Do not use this flag on Windows, where wimlib already supports all
1687 * Windows-native filesystems, including NTFS, through the Windows APIs. */
1688 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1690 /** Follow symbolic links when scanning the directory tree. Currently only
1691 * supported on UNIX-like systems. */
1692 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1694 /** Call the progress function with the message
1695 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1697 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1699 /** Mark the image being added as the bootable image of the WIM. This flag is
1700 * valid only for wimlib_add_image() and wimlib_add_image_multisource().
1702 * Note that you can also change the bootable image of a WIM using
1703 * wimlib_set_wim_info().
1705 * Note: ::WIMLIB_ADD_FLAG_BOOT does something different from, and independent
1706 * from, ::WIMLIB_ADD_FLAG_WIMBOOT. */
1707 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1709 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1710 * (major and minor number) of each file. In addition, capture special files
1711 * such as device nodes and FIFOs. See the documentation for the
1712 * <b>--unix-data</b> option to <b>wimcapture</b> for more information. */
1713 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1715 /** Do not capture security descriptors. Only has an effect in NTFS-3G capture
1716 * mode, or in Windows native builds. */
1717 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1719 /** Fail immediately if the full security descriptor of any file or directory
1720 * cannot be accessed. Only has an effect in Windows native builds. The
1721 * default behavior without this flag is to first try omitting the SACL from the
1722 * security descriptor, then to try omitting the security descriptor entirely.
1724 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1726 /** Call the progress function with the message
1727 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1728 * capture. This is a subset of the messages provided by
1729 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1730 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1732 /** Reparse-point fixups: Modify absolute symbolic links (and junctions, in the
1733 * case of Windows) that point inside the directory being captured to instead be
1734 * absolute relative to the directory being captured.
1736 * Without this flag, the default is to do reparse-point fixups if
1737 * <c>WIM_HDR_FLAG_RP_FIX</c> is set in the WIM header or if this is the first
1738 * image being added. */
1739 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1741 /** Don't do reparse point fixups. See ::WIMLIB_ADD_FLAG_RPFIX. */
1742 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1744 /** Do not automatically exclude unsupported files or directories from capture,
1745 * such as encrypted files in NTFS-3G capture mode, or device files and FIFOs on
1746 * UNIX-like systems when not also using ::WIMLIB_ADD_FLAG_UNIX_DATA. Instead,
1747 * fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when such a file is encountered. */
1748 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1751 * Automatically select a capture configuration appropriate for capturing
1752 * filesystems containing Windows operating systems. For example,
1753 * <c>/pagefile.sys</c> and <c>"/System Volume Information"</c> will be
1756 * When this flag is specified, the corresponding @p config parameter (for
1757 * wimlib_add_image()) or member (for wimlib_update_image()) must be @c NULL.
1758 * Otherwise, ::WIMLIB_ERR_INVALID_PARAM will be returned.
1760 * Note that the default behavior--- that is, when neither
1761 * ::WIMLIB_ADD_FLAG_WINCONFIG nor ::WIMLIB_ADD_FLAG_WIMBOOT is specified and @p
1762 * config is @c NULL--- is to use no capture configuration, meaning that no
1763 * files are excluded from capture.
1765 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1768 * Capture image as "WIMBoot compatible". In addition, if no capture
1769 * configuration file is explicitly specified use the capture configuration file
1770 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1771 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1772 * configuration file is explicitly specified, use it and also place it at
1773 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image.
1775 * This flag does not, by itself, change the compression type or chunk size.
1776 * Before writing the WIM file, you may wish to set the compression format to
1777 * be the same as that used by WIMGAPI and DISM:
1780 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1781 * wimlib_set_output_chunk_size(wim, 4096);
1784 * However, "WIMBoot" also works with other XPRESS chunk sizes as well as LZX
1785 * with 32768 byte chunks.
1787 * Note: ::WIMLIB_ADD_FLAG_WIMBOOT does something different from, and
1788 * independent from, ::WIMLIB_ADD_FLAG_BOOT.
1790 * Since wimlib v1.8.3, ::WIMLIB_ADD_FLAG_WIMBOOT also causes offline WIM-backed
1791 * files to be added as the "real" files rather than as their reparse points,
1792 * provided that their data is already present in the WIM. This feature can be
1793 * useful when updating a backing WIM file in an "offline" state.
1795 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1798 * If the add command involves adding a non-directory file to a location at
1799 * which there already exists a nondirectory file in the image, issue
1800 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This was the
1801 * default behavior before wimlib v1.7.0.
1803 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1806 * Send ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION messages to the progress
1809 * Note: This method for file exclusions is independent from the capture
1810 * configuration file mechanism.
1812 #define WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION 0x00004000
1815 * Since wimlib v1.9.0: create a temporary filesystem snapshot of the source
1816 * directory and add the files from it. Currently, this option is only
1817 * supported on Windows, where it uses the Volume Shadow Copy Service (VSS).
1818 * Using this option, you can create a consistent backup of the system volume of
1819 * a running Windows system without running into problems with locked files.
1820 * For the VSS snapshot to be successfully created, your application must be run
1821 * as an Administrator, and it cannot be run in WoW64 mode (i.e. if Windows is
1822 * 64-bit, then your application must be 64-bit as well).
1824 #define WIMLIB_ADD_FLAG_SNAPSHOT 0x00008000
1827 * Since wimlib v1.9.0: permit the library to discard file paths after the
1828 * initial scan. If the application won't use
1829 * ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES while writing the WIM
1830 * archive, this flag can be used to allow the library to enable optimizations
1831 * such as opening files by inode number rather than by path. Currently this
1832 * only makes a difference on Windows.
1834 #define WIMLIB_ADD_FLAG_FILE_PATHS_UNNEEDED 0x00010000
1837 /** @addtogroup G_modifying_wims
1840 /** Do not issue an error if the path to delete does not exist. */
1841 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1843 /** Delete the file or directory tree recursively; if not specified, an error is
1844 * issued if the path to delete is a directory. */
1845 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1848 /** @addtogroup G_modifying_wims
1852 * If a single image is being exported, mark it bootable in the destination WIM.
1853 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1854 * the image in the source WIM (if any) that is marked as bootable is also
1855 * marked as bootable in the destination WIM.
1857 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1859 /** Give the exported image(s) no names. Avoids problems with image name
1862 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1864 /** Give the exported image(s) no descriptions. */
1865 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1867 /** This advises the library that the program is finished with the source
1868 * WIMStruct and will not attempt to access it after the call to
1869 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1870 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1873 * Mark each exported image as WIMBoot-compatible.
1875 * Note: by itself, this does change the destination WIM's compression type, nor
1876 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1877 * image. Before writing the destination WIM, it's recommended to do something
1881 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1882 * wimlib_set_output_chunk_size(wim, 4096);
1883 * wimlib_add_tree(wim, image, L"myconfig.ini",
1884 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1887 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1890 /** @addtogroup G_extracting_wims
1893 /** Extract the image directly to an NTFS volume rather than a generic directory.
1894 * This mode is only available if wimlib was compiled with libntfs-3g support;
1895 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1896 * extraction target will be interpreted as the path to an NTFS volume image (as
1897 * a regular file or block device) rather than a directory. It will be opened
1898 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1899 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1900 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1901 * wimlib_extract_paths() when passed multiple paths. */
1902 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1904 /** UNIX-like systems only: Extract special UNIX data captured with
1905 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1906 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1907 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1909 /** Do not extract security descriptors. This flag cannot be combined with
1910 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1911 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1914 * Fail immediately if the full security descriptor of any file or directory
1915 * cannot be set exactly as specified in the WIM image. On Windows, the default
1916 * behavior without this flag when wimlib does not have permission to set the
1917 * correct security descriptor is to fall back to setting the security
1918 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1919 * owner omitted, then not at all. This flag cannot be combined with
1920 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS.
1922 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1925 * This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1926 * reparse-point fixups on, so absolute symbolic links or junction points will
1927 * be fixed to be absolute relative to the actual extraction root. Reparse-
1928 * point fixups are done by default for wimlib_extract_image() and
1929 * wimlib_extract_image_from_pipe() if <c>WIM_HDR_FLAG_RP_FIX</c> is set in the
1930 * WIM header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX.
1932 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1934 /** Force reparse-point fixups on extraction off, regardless of the state of the
1935 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1936 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1937 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1939 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1940 * paths, each of which must name a regular file, to standard output. */
1941 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1944 * Instead of ignoring files and directories with names that cannot be
1945 * represented on the current platform (note: Windows has more restrictions on
1946 * filenames than POSIX-compliant systems), try to replace characters or append
1947 * junk to the names so that they can be extracted in some form.
1949 * Note: this flag is unlikely to have any effect when extracting a WIM image
1950 * that was captured on Windows.
1952 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1955 * On Windows, when there exist two or more files with the same case insensitive
1956 * name but different case sensitive names, try to extract them all by appending
1957 * junk to the end of them, rather than arbitrarily extracting only one.
1959 * Note: this flag is unlikely to have any effect when extracting a WIM image
1960 * that was captured on Windows.
1962 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1964 /** Do not ignore failure to set timestamps on extracted files. This flag
1965 * currently only has an effect when extracting to a directory on UNIX-like
1967 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1969 /** Do not ignore failure to set short names on extracted files. This flag
1970 * currently only has an effect on Windows. */
1971 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1973 /** Do not ignore failure to extract symbolic links and junctions due to
1974 * permissions problems. This flag currently only has an effect on Windows. By
1975 * default, such failures are ignored since the default configuration of Windows
1976 * only allows the Administrator to create symbolic links. */
1977 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1980 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1981 * paths to extract as wildcard patterns ("globs") which may contain the
1982 * wildcard characters @c ? and @c *. The @c ? character matches any
1983 * non-path-separator character, whereas the @c * character matches zero or more
1984 * non-path-separator characters. Consequently, each glob may match zero or
1985 * more actual paths in the WIM image.
1987 * By default, if a glob does not match any files, a warning but not an error
1988 * will be issued. This is the case even if the glob did not actually contain
1989 * wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error
1992 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1994 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1995 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1996 * one of the provided globs did not match a file. */
1997 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
2000 * Do not extract Windows file attributes such as readonly, hidden, etc.
2002 * This flag has an effect on Windows as well as in the NTFS-3G extraction mode.
2004 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
2007 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
2008 * preserve the directory structure of the archive when extracting --- that is,
2009 * place each extracted file or directory tree directly in the target directory.
2010 * The target directory will still be created if it does not already exist.
2012 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
2015 * Windows only: Extract files as "pointers" back to the WIM archive.
2017 * The effects of this option are fairly complex. See the documentation for the
2018 * <b>--wimboot</b> option of <b>wimapply</b> for more information.
2020 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
2023 * Since wimlib v1.8.2 and Windows-only: compress the extracted files using
2024 * System Compression, when possible. This only works on either Windows 10 or
2025 * later, or on an older Windows to which Microsoft's wofadk.sys driver has been
2026 * added. Several different compression formats may be used with System
2027 * Compression; this particular flag selects the XPRESS compression format with
2030 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K 0x01000000
2032 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2033 * 8192 byte chunks. */
2034 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K 0x02000000
2036 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2037 * 16384 byte chunks. */
2038 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K 0x04000000
2040 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use LZX compression with
2041 * 32768 byte chunks. */
2042 #define WIMLIB_EXTRACT_FLAG_COMPACT_LZX 0x08000000
2045 /** @addtogroup G_mounting_wim_images
2048 /** Mount the WIM image read-write rather than the default of read-only. */
2049 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
2051 /** Enable FUSE debugging by passing the @c -d option to @c fuse_main(). */
2052 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
2054 /** Do not allow accessing named data streams in the mounted WIM image. */
2055 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
2057 /** Access named data streams in the mounted WIM image through extended file
2058 * attributes named "user.X", where X is the name of a data stream. This is the
2060 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
2062 /** Access named data streams in the mounted WIM image by specifying the file
2063 * name, a colon, then the name of the data stream. */
2064 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
2066 /** Use UNIX metadata if available in the WIM image. See
2067 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
2068 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
2070 /** Allow other users to see the mounted filesystem. This passes the @c
2071 * allow_other option to fuse_main(). */
2072 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
2075 /** @addtogroup G_creating_and_opening_wims
2078 /** Verify the WIM contents against the WIM's integrity table, if present. The
2079 * integrity table stores checksums for the raw data of the WIM file, divided
2080 * into fixed size chunks. Verification will compute checksums and compare them
2081 * with the stored values. If there are any mismatches, then
2082 * ::WIMLIB_ERR_INTEGRITY will be issued. If the WIM file does not contain an
2083 * integrity table, then this flag has no effect. */
2084 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
2086 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
2087 * WIM. Software can provide this flag for convenience if it explicitly does
2088 * not want to support split WIMs. */
2089 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
2091 /** Check if the WIM is writable and issue an error
2092 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
2093 * only if it is writable at the filesystem level, does not have the
2094 * <c>WIM_HDR_FLAG_READONLY</c> flag set in its header, and is not part of a
2095 * spanned set. It is not required to provide this flag before attempting to
2096 * make changes to the WIM, but with this flag you get an error immediately
2097 * rather than potentially much later, when wimlib_overwrite() is finally
2099 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
2102 /** @addtogroup G_mounting_wim_images
2105 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
2106 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2107 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
2109 /** Commit changes to the read-write mounted WIM image.
2110 * If this flag is not specified, changes will be discarded. */
2111 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
2113 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
2114 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2115 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
2117 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
2118 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2119 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
2122 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
2123 * image, forces all file descriptors to the open WIM image to be closed before
2126 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
2127 * this flag has no effect.
2129 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
2131 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
2132 * WIM image, causes the modified image to be committed to the WIM file as a
2133 * new, unnamed image appended to the archive. The original image in the WIM
2134 * file will be unmodified. */
2135 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
2138 /** @addtogroup G_modifying_wims
2141 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
2142 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
2143 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
2146 /** @addtogroup G_writing_and_overwriting_wims
2150 * Include an integrity table in the resulting WIM file.
2152 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2153 * include an integrity table if and only if one was present before. For
2154 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2155 * to not include an integrity table.
2157 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
2160 * Do not include an integrity table in the resulting WIM file. This is the
2161 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
2164 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
2167 * Write the WIM as "pipable". After writing a WIM with this flag specified,
2168 * images from it can be applied directly from a pipe using
2169 * wimlib_extract_image_from_pipe(). See the documentation for the
2170 * <b>--pipable</b> option of <b>wimcapture</b> for more information. Beware:
2171 * WIMs written with this flag will not be compatible with Microsoft's software.
2173 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2174 * write the WIM as pipable if and only if it was pipable before. For
2175 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2176 * to write the WIM as non-pipable.
2178 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
2181 * Do not write the WIM as "pipable". This is the default behavior, unless the
2182 * ::WIMStruct was created by opening a pipable WIM.
2184 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
2187 * When writing data to the WIM file, recompress it, even if the data is already
2188 * available in the desired compressed form (for example, in a WIM file from
2189 * which an image has been exported using wimlib_export_image()).
2191 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
2192 * compression ratio for the same compression type and chunk size. Simply using
2193 * the default compression settings may suffice for this, especially if the WIM
2194 * file was created using another program/library that may not use as
2195 * sophisticated compression algorithms. Or,
2196 * wimlib_set_default_compression_level() can be called beforehand to set an
2197 * even higher compression level than the default.
2199 * If the WIM contains solid resources, then ::WIMLIB_WRITE_FLAG_RECOMPRESS can
2200 * be used in combination with ::WIMLIB_WRITE_FLAG_SOLID to prevent any solid
2201 * resources from being re-used. Otherwise, solid resources are re-used
2202 * somewhat more liberally than normal compressed resources.
2204 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of data
2205 * that would not otherwise be written. For example, a call to
2206 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
2207 * cause already-existing data in the WIM file to be recompressed. To force the
2208 * WIM file to be fully rebuilt and recompressed, combine
2209 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
2211 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
2214 * Immediately before closing the WIM file, sync its data to disk.
2216 * This flag forces the function to wait until the data is safely on disk before
2217 * returning success. Otherwise, modern operating systems tend to cache data
2218 * for some time (in some cases, 30+ seconds) before actually writing it to
2219 * disk, even after reporting to the application that the writes have succeeded.
2221 * wimlib_overwrite() will set this flag automatically if it decides to
2222 * overwrite the WIM file via a temporary file instead of in-place. This is
2223 * necessary on POSIX systems; it will, for example, avoid problems with delayed
2224 * allocation on ext4.
2226 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
2229 * For wimlib_overwrite(): rebuild the entire WIM file, even if it otherwise
2230 * could be updated in-place by appending to it. Any data that existed in the
2231 * original WIM file but is not actually needed by any of the remaining images
2232 * will not be included. This can free up space left over after previous
2233 * in-place modifications to the WIM file.
2235 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
2236 * data to be recompressed. Otherwise, compressed data is re-used if possible.
2238 * wimlib_write() ignores this flag.
2240 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
2243 * For wimlib_overwrite(): override the default behavior after one or more calls
2244 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
2245 * flag, only minimal changes to correctly remove the image from the WIM file
2246 * will be taken. This can be much faster, but it will result in the WIM file
2247 * getting larger rather than smaller.
2249 * wimlib_write() ignores this flag.
2251 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
2254 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
2255 * flag (<c>WIM_HDR_FLAG_READONLY</c>) is set in the WIM header. This can be
2256 * used following a call to wimlib_set_wim_info() with the
2257 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
2260 * wimlib_write() ignores this flag.
2262 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
2265 * Do not include file data already present in other WIMs. This flag can be
2266 * used to write a "delta" WIM after the WIM files on which the delta is to be
2267 * based were referenced with wimlib_reference_resource_files() or
2268 * wimlib_reference_resources().
2270 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
2272 /** Deprecated; this flag should not be used outside of the library itself. */
2273 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
2276 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
2278 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
2281 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
2284 * Concatenate files and compress them together, rather than compress each file
2285 * independently. This is also known as creating a "solid archive". This tends
2286 * to produce a better compression ratio at the cost of much slower random
2289 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
2290 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
2291 * created with this flag use a different version number in their header (3584
2292 * instead of 68864) and are also called "ESD files".
2294 * Note that providing this flag does not affect the "append by default"
2295 * behavior of wimlib_overwrite(). In other words, wimlib_overwrite() with just
2296 * ::WIMLIB_WRITE_FLAG_SOLID can be used to append solid-compressed data to a
2297 * WIM file that originally did not contain any solid-compressed data. But if
2298 * you instead want to rebuild and recompress an entire WIM file in solid mode,
2299 * then also provide ::WIMLIB_WRITE_FLAG_REBUILD and
2300 * ::WIMLIB_WRITE_FLAG_RECOMPRESS.
2302 * Currently, new solid resources will, by default, be written using LZMS
2303 * compression with 64 MiB (67108864 byte) chunks. Use
2304 * wimlib_set_output_pack_compression_type() and/or
2305 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
2306 * the WIM's main compression type and chunk size; you can have a WIM that
2307 * nominally uses LZX compression and 32768 byte chunks but actually contains
2308 * LZMS-compressed solid resources, for example. However, if including solid
2309 * resources, I suggest that you set the WIM's main compression type to LZMS as
2310 * well, either by creating the WIM with
2311 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
2312 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
2314 * This flag will be set by default when writing or overwriting a WIM file that
2315 * either already contains solid resources, or has had solid resources exported
2316 * into it and the WIM's main compression type is LZMS.
2318 #define WIMLIB_WRITE_FLAG_SOLID 0x00001000
2321 * Send ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE messages while writing the WIM
2322 * file. This is only needed in the unusual case that the library user needs to
2323 * know exactly when wimlib has read each file for the last time.
2325 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
2328 * Do not consider content similarity when arranging file data for solid
2329 * compression. Providing this flag will typically worsen the compression
2330 * ratio, so only provide this flag if you know what you are doing.
2332 #define WIMLIB_WRITE_FLAG_NO_SOLID_SORT 0x00004000
2335 * Since wimlib v1.8.3 and for wimlib_overwrite() only: <b>unsafely</b> compact
2336 * the WIM file in-place, without appending. Existing resources are shifted
2337 * down to fill holes and new resources are appended as needed. The WIM file is
2338 * truncated to its final size, which may shrink the on-disk file. <b>This
2339 * operation cannot be safely interrupted. If the operation is interrupted,
2340 * then the WIM file will be corrupted, and it may be impossible (or at least
2341 * very difficult) to recover any data from it. Users of this flag are expected
2342 * to know what they are doing and assume responsibility for any data corruption
2343 * that may result.</b>
2345 * If the WIM file cannot be compacted in-place because of its structure, its
2346 * layout, or other requested write parameters, then wimlib_overwrite() fails
2347 * with ::WIMLIB_ERR_COMPACTION_NOT_POSSIBLE, and the caller may wish to retry
2348 * the operation without this flag.
2350 #define WIMLIB_WRITE_FLAG_UNSAFE_COMPACT 0x00008000
2353 /** @addtogroup G_general
2356 /** Deprecated; no longer has any effect. */
2357 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
2359 /** Windows-only: do not attempt to acquire additional privileges (currently
2360 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege,
2361 * SeTakeOwnershipPrivilege, and SeManageVolumePrivilege) when initializing the
2362 * library. This flag is intended for the case where the calling program
2363 * manages these privileges itself. Note: by default, no error is issued if
2364 * privileges cannot be acquired, although related errors may be reported later,
2365 * depending on if the operations performed actually require additional
2366 * privileges or not. */
2367 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
2369 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2370 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2371 * to read all possible data and metadata for a capture operation could not be
2372 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
2374 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
2376 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2377 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2378 * to restore all possible data and metadata for an apply operation could not be
2379 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
2381 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
2383 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
2385 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
2387 /** Default to interpreting WIM paths case insensitively (default on Windows).
2388 * This does not apply to mounted images. */
2389 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
2392 /** @addtogroup G_nonstandalone_wims
2395 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
2396 * Ignored by wimlib_reference_resources(). */
2397 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
2399 /** For wimlib_reference_resource_files(), issue an error
2400 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
2401 * default behavior without this flag is to issue no error at that point, but
2402 * then attempt to open the glob as a literal path, which of course will fail
2403 * anyway if no file exists at that path. No effect if
2404 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
2405 * wimlib_reference_resources(). */
2406 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
2409 /** @addtogroup G_modifying_wims
2412 /** The specific type of update to perform. */
2413 enum wimlib_update_op {
2414 /** Add a new file or directory tree to the image. */
2415 WIMLIB_UPDATE_OP_ADD = 0,
2417 /** Delete a file or directory tree from the image. */
2418 WIMLIB_UPDATE_OP_DELETE = 1,
2420 /** Rename a file or directory tree in the image. */
2421 WIMLIB_UPDATE_OP_RENAME = 2,
2424 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2425 struct wimlib_add_command {
2426 /** Filesystem path to the file or directory tree to add. */
2427 wimlib_tchar *fs_source_path;
2429 /** Destination path in the image. To specify the root directory of the
2430 * image, use ::WIMLIB_WIM_ROOT_PATH. */
2431 wimlib_tchar *wim_target_path;
2433 /** Path to capture configuration file to use, or @c NULL if not
2435 wimlib_tchar *config_file;
2437 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2441 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2442 struct wimlib_delete_command {
2444 /** The path to the file or directory within the image to delete. */
2445 wimlib_tchar *wim_path;
2447 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2451 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2452 struct wimlib_rename_command {
2454 /** The path to the source file or directory within the image. */
2455 wimlib_tchar *wim_source_path;
2457 /** The path to the destination file or directory within the image. */
2458 wimlib_tchar *wim_target_path;
2460 /** Reserved; set to 0. */
2464 /** Specification of an update to perform on a WIM image. */
2465 struct wimlib_update_command {
2467 enum wimlib_update_op op;
2470 struct wimlib_add_command add;
2471 struct wimlib_delete_command delete_; /* Underscore is for C++
2473 struct wimlib_rename_command rename;
2478 /** @addtogroup G_general
2482 * Possible values of the error code returned by many functions in wimlib.
2484 * See the documentation for each wimlib function to see specifically what error
2485 * codes can be returned by a given function, and what they mean.
2487 enum wimlib_error_code {
2488 WIMLIB_ERR_SUCCESS = 0,
2489 WIMLIB_ERR_ALREADY_LOCKED = 1,
2490 WIMLIB_ERR_DECOMPRESSION = 2,
2491 WIMLIB_ERR_FUSE = 6,
2492 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2493 WIMLIB_ERR_IMAGE_COUNT = 10,
2494 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2495 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2496 WIMLIB_ERR_INTEGRITY = 13,
2497 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2498 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2499 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2500 WIMLIB_ERR_INVALID_HEADER = 17,
2501 WIMLIB_ERR_INVALID_IMAGE = 18,
2502 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2503 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2504 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2505 WIMLIB_ERR_INVALID_OVERLAY = 23,
2506 WIMLIB_ERR_INVALID_PARAM = 24,
2507 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2508 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2509 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2510 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2511 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2512 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2513 WIMLIB_ERR_IS_DIRECTORY = 32,
2514 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2515 WIMLIB_ERR_LINK = 35,
2516 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2517 WIMLIB_ERR_MKDIR = 37,
2518 WIMLIB_ERR_MQUEUE = 38,
2519 WIMLIB_ERR_NOMEM = 39,
2520 WIMLIB_ERR_NOTDIR = 40,
2521 WIMLIB_ERR_NOTEMPTY = 41,
2522 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2523 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2524 WIMLIB_ERR_NOT_PIPABLE = 44,
2525 WIMLIB_ERR_NO_FILENAME = 45,
2526 WIMLIB_ERR_NTFS_3G = 46,
2527 WIMLIB_ERR_OPEN = 47,
2528 WIMLIB_ERR_OPENDIR = 48,
2529 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2530 WIMLIB_ERR_READ = 50,
2531 WIMLIB_ERR_READLINK = 51,
2532 WIMLIB_ERR_RENAME = 52,
2533 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2534 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2535 WIMLIB_ERR_RESOURCE_ORDER = 56,
2536 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2537 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2538 WIMLIB_ERR_SET_SECURITY = 59,
2539 WIMLIB_ERR_SET_SHORT_NAME = 60,
2540 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2541 WIMLIB_ERR_SPLIT_INVALID = 62,
2542 WIMLIB_ERR_STAT = 63,
2543 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2544 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2545 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2546 WIMLIB_ERR_UNSUPPORTED = 68,
2547 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2548 WIMLIB_ERR_WIM_IS_READONLY = 71,
2549 WIMLIB_ERR_WRITE = 72,
2550 WIMLIB_ERR_XML = 73,
2551 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2552 WIMLIB_ERR_WIMBOOT = 75,
2553 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2554 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2555 WIMLIB_ERR_MKNOD = 78,
2556 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2557 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2558 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2559 WIMLIB_ERR_FVE_LOCKED_VOLUME = 82,
2560 WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG = 83,
2561 WIMLIB_ERR_WIM_IS_INCOMPLETE = 84,
2562 WIMLIB_ERR_COMPACTION_NOT_POSSIBLE = 85,
2563 WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES = 86,
2564 WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE = 87,
2565 WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED = 88,
2566 WIMLIB_ERR_SNAPSHOT_FAILURE = 89,
2570 /** Used to indicate no image or an invalid image. */
2571 #define WIMLIB_NO_IMAGE 0
2573 /** Used to specify all images in the WIM. */
2574 #define WIMLIB_ALL_IMAGES (-1)
2579 * @ingroup G_modifying_wims
2581 * Append an empty image to a ::WIMStruct.
2583 * The new image will initially contain no files or directories, although if
2584 * written without further modifications, then a root directory will be created
2585 * automatically for it.
2587 * After calling this function, you can use wimlib_update_image() to add files
2588 * to the new image. This gives you more control over making the new image
2589 * compared to calling wimlib_add_image() or wimlib_add_image_multisource().
2592 * Pointer to the ::WIMStruct to which to add the image.
2594 * Name to give the new image. If @c NULL or empty, the new image is given
2595 * no name. If nonempty, it must specify a name that does not already
2597 * @param new_idx_ret
2598 * If non-<c>NULL</c>, the index of the newly added image is returned in
2601 * @return 0 on success; a ::wimlib_error_code value on failure.
2603 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2604 * The WIM already contains an image with the requested name.
2607 wimlib_add_empty_image(WIMStruct *wim,
2608 const wimlib_tchar *name,
2612 * @ingroup G_modifying_wims
2614 * Add an image to a ::WIMStruct from an on-disk directory tree or NTFS volume.
2616 * The directory tree or NTFS volume is scanned immediately to load the dentry
2617 * tree into memory, and file metadata is read. However, actual file data may
2618 * not be read until the ::WIMStruct is persisted to disk using wimlib_write()
2619 * or wimlib_overwrite().
2621 * See the documentation for the @b wimlib-imagex program for more information
2622 * about the "normal" capture mode versus the NTFS capture mode (entered by
2623 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2625 * Note that no changes are committed to disk until wimlib_write() or
2626 * wimlib_overwrite() is called.
2629 * Pointer to the ::WIMStruct to which to add the image.
2631 * A path to a directory or unmounted NTFS volume that will be captured as
2634 * Name to give the new image. If @c NULL or empty, the new image is given
2635 * no name. If nonempty, it must specify a name that does not already
2637 * @param config_file
2638 * Path to capture configuration file, or @c NULL. This file may specify,
2639 * among other things, which files to exclude from capture. See the
2640 * documentation for <b>wimcapture</b> (<b>--config</b> option) for details
2641 * of the file format. If @c NULL, the default capture configuration will
2642 * be used. Ordinarily, the default capture configuration will result in
2643 * no files being excluded from capture purely based on name; however, the
2644 * ::WIMLIB_ADD_FLAG_WINCONFIG and ::WIMLIB_ADD_FLAG_WIMBOOT flags modify
2647 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2649 * @return 0 on success; a ::wimlib_error_code value on failure.
2651 * This function is implemented by calling wimlib_add_empty_image(), then
2652 * calling wimlib_update_image() with a single "add" command, so any error code
2653 * returned by wimlib_add_empty_image() may be returned, as well as any error
2654 * codes returned by wimlib_update_image() other than ones documented as only
2655 * being returned specifically by an update involving delete or rename commands.
2657 * If a progress function is registered with @p wim, then it will receive the
2658 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2659 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2660 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2663 wimlib_add_image(WIMStruct *wim,
2664 const wimlib_tchar *source,
2665 const wimlib_tchar *name,
2666 const wimlib_tchar *config_file,
2670 * @ingroup G_modifying_wims
2672 * This function is equivalent to wimlib_add_image() except it allows for
2673 * multiple sources to be combined into a single WIM image. This is done by
2674 * specifying the @p sources and @p num_sources parameters instead of the @p
2675 * source parameter of wimlib_add_image(). The rest of the parameters are the
2676 * same as wimlib_add_image(). See the documentation for <b>wimcapture</b> for
2677 * full details on how this mode works.
2680 wimlib_add_image_multisource(WIMStruct *wim,
2681 const struct wimlib_capture_source *sources,
2683 const wimlib_tchar *name,
2684 const wimlib_tchar *config_file,
2688 * @ingroup G_modifying_wims
2690 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2691 * location @p wim_target_path within the specified @p image of the @p wim.
2693 * This just builds an appropriate ::wimlib_add_command and passes it to
2694 * wimlib_update_image().
2697 wimlib_add_tree(WIMStruct *wim, int image,
2698 const wimlib_tchar *fs_source_path,
2699 const wimlib_tchar *wim_target_path, int add_flags);
2702 * @ingroup G_creating_and_opening_wims
2704 * Create a ::WIMStruct which initially contains no images and is not backed by
2708 * The "output compression type" to assign to the ::WIMStruct. This is the
2709 * compression type that will be used if the ::WIMStruct is later persisted
2710 * to an on-disk file using wimlib_write().
2712 * This choice is not necessarily final. If desired, it can still be
2713 * changed at any time before wimlib_write() is called, using
2714 * wimlib_set_output_compression_type(). In addition, if you wish to use a
2715 * non-default compression chunk size, then you will need to call
2716 * wimlib_set_output_chunk_size().
2718 * On success, a pointer to the new ::WIMStruct is written to the memory
2719 * location pointed to by this parameter. This ::WIMStruct must be freed
2720 * using using wimlib_free() when finished with it.
2722 * @return 0 on success; a ::wimlib_error_code value on failure.
2724 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2725 * @p ctype was not a supported compression type.
2726 * @retval ::WIMLIB_ERR_NOMEM
2727 * Insufficient memory to allocate a new ::WIMStruct.
2730 wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret);
2733 * @ingroup G_modifying_wims
2735 * Delete an image, or all images, from a ::WIMStruct.
2737 * Note that no changes are committed to disk until wimlib_write() or
2738 * wimlib_overwrite() is called.
2741 * Pointer to the ::WIMStruct from which to delete the image.
2743 * The 1-based index of the image to delete, or ::WIMLIB_ALL_IMAGES to
2744 * delete all images.
2746 * @return 0 on success; a ::wimlib_error_code value on failure.
2748 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2749 * @p image does not exist in the WIM.
2751 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2752 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2753 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2754 * indicate failure (for different reasons) to read the metadata resource for an
2755 * image that needed to be deleted.
2757 * If this function fails when @p image was ::WIMLIB_ALL_IMAGES, then it's
2758 * possible that some but not all of the images were deleted.
2761 wimlib_delete_image(WIMStruct *wim, int image);
2764 * @ingroup G_modifying_wims
2766 * Delete the @p path from the specified @p image of the @p wim.
2768 * This just builds an appropriate ::wimlib_delete_command and passes it to
2769 * wimlib_update_image().
2772 wimlib_delete_path(WIMStruct *wim, int image,
2773 const wimlib_tchar *path, int delete_flags);
2776 * @ingroup G_modifying_wims
2778 * Export an image, or all images, from a ::WIMStruct into another ::WIMStruct.
2780 * Specifically, if the destination ::WIMStruct contains <tt>n</tt> images, then
2781 * the source image(s) will be appended, in order, starting at destination index
2782 * <tt>n + 1</tt>. By default, all image metadata will be exported verbatim,
2783 * but certain changes can be made by passing appropriate parameters.
2785 * wimlib_export_image() is only an in-memory operation; no changes are
2786 * committed to disk until wimlib_write() or wimlib_overwrite() is called.
2788 * A limitation of the current implementation of wimlib_export_image() is that
2789 * the directory tree of a source or destination image cannot be updated
2790 * following an export until one of the two images has been freed from memory.
2793 * The WIM from which to export the images, specified as a pointer to the
2794 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2795 * split WIM. In the case of a WIM file that is not standalone, this
2796 * ::WIMStruct must have had any needed external resources previously
2797 * referenced using wimlib_reference_resources() or
2798 * wimlib_reference_resource_files().
2800 * The 1-based index of the image from @p src_wim to export, or
2801 * ::WIMLIB_ALL_IMAGES.
2803 * The ::WIMStruct to which to export the images.
2805 * For single-image exports, the name to give the exported image in @p
2806 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2807 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2808 * that case, the names are all taken from @p src_wim. This parameter is
2809 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2810 * @param dest_description
2811 * For single-image exports, the description to give the exported image in
2812 * the new WIM file. If left @c NULL, the description from @p src_wim is
2813 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2814 * NULL; in that case, the description are all taken from @p src_wim. This
2815 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2816 * @param export_flags
2817 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2819 * @return 0 on success; a ::wimlib_error_code value on failure.
2821 * @retval ::WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE
2822 * One or more of the source images had already been exported into the
2824 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2825 * One or more of the names being given to an exported image was already in
2826 * use in the destination WIM.
2827 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2828 * @p src_image does not exist in @p src_wim.
2829 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2830 * At least one of @p src_wim and @p dest_wim does not contain image
2831 * metadata; for example, one of them represents a non-first part of a
2833 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2834 * A file data blob that needed to be exported could not be found in the
2835 * blob lookup table of @p src_wim. See @ref G_nonstandalone_wims.
2837 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2838 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2839 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2840 * indicate failure (for different reasons) to read the metadata resource for an
2841 * image in @p src_wim that needed to be exported.
2844 wimlib_export_image(WIMStruct *src_wim, int src_image,
2845 WIMStruct *dest_wim,
2846 const wimlib_tchar *dest_name,
2847 const wimlib_tchar *dest_description,
2851 * @ingroup G_extracting_wims
2853 * Extract an image, or all images, from a ::WIMStruct.
2855 * The exact behavior of how wimlib extracts files from a WIM image is
2856 * controllable by the @p extract_flags parameter, but there also are
2857 * differences depending on the platform (UNIX-like vs Windows). See the
2858 * documentation for <b>wimapply</b> for more information, including about the
2859 * NTFS-3G extraction mode.
2862 * The WIM from which to extract the image(s), specified as a pointer to the
2863 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2864 * split WIM. In the case of a WIM file that is not standalone, this
2865 * ::WIMStruct must have had any needed external resources previously
2866 * referenced using wimlib_reference_resources() or
2867 * wimlib_reference_resource_files().
2869 * The 1-based index of the image to extract, or ::WIMLIB_ALL_IMAGES to
2870 * extract all images. Note: ::WIMLIB_ALL_IMAGES is unsupported in NTFS-3G
2873 * A null-terminated string which names the location to which the image(s)
2874 * will be extracted. By default, this is interpreted as a path to a
2875 * directory. Alternatively, if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in
2876 * @p extract_flags, then this is interpreted as a path to an unmounted
2878 * @param extract_flags
2879 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2881 * @return 0 on success; a ::wimlib_error_code value on failure.
2883 * @retval ::WIMLIB_ERR_DECOMPRESSION
2884 * The WIM file contains invalid compressed data.
2885 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2886 * @p image does not exist in @p wim.
2887 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2888 * The metadata for an image to extract was invalid.
2889 * @retval ::WIMLIB_ERR_INVALID_PARAM
2890 * The extraction flags were invalid; more details may be found in the
2891 * documentation for the specific extraction flags that were specified. Or
2892 * @p target was @c NULL or an empty string, or @p wim was @c NULL.
2893 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2894 * The data of a file that needed to be extracted was corrupt.
2895 * @retval ::WIMLIB_ERR_LINK
2896 * Failed to create a symbolic link or a hard link.
2897 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2898 * @p wim does not contain image metadata; for example, it represents a
2899 * non-first part of a split WIM.
2900 * @retval ::WIMLIB_ERR_MKDIR
2901 * Failed create a directory.
2902 * @retval ::WIMLIB_ERR_NTFS_3G
2903 * libntfs-3g reported that a problem occurred while writing to the NTFS
2905 * @retval ::WIMLIB_ERR_OPEN
2906 * Could not create a file, or failed to open an already-extracted file.
2907 * @retval ::WIMLIB_ERR_READ
2908 * Failed to read data from the WIM.
2909 * @retval ::WIMLIB_ERR_READLINK
2910 * Failed to determine the target of a symbolic link in the WIM.
2911 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2912 * Failed to fix the target of an absolute symbolic link (e.g. if the
2913 * target would have exceeded the maximum allowed length). (Only if
2914 * reparse data was supported by the extraction mode and
2915 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2917 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2918 * A file data blob that needed to be extracted could not be found in the
2919 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
2920 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2921 * Failed to set attributes on a file.
2922 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2923 * Failed to set reparse data on a file (only if reparse data was supported
2924 * by the extraction mode).
2925 * @retval ::WIMLIB_ERR_SET_SECURITY
2926 * Failed to set security descriptor on a file.
2927 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2928 * Failed to set the short name of a file.
2929 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2930 * Failed to set timestamps on a file.
2931 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2932 * Unexpected end-of-file occurred when reading data from the WIM.
2933 * @retval ::WIMLIB_ERR_UNSUPPORTED
2934 * A requested extraction flag, or the data or metadata that must be
2935 * extracted to support it, is unsupported in the build and configuration
2936 * of wimlib, or on the current platform or extraction mode or target
2937 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2938 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2939 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2940 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2941 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2942 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2943 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2944 * image contains one or more files with short names, but extracting short
2945 * names is not supported --- on Windows, this occurs if the target volume
2946 * does not support short names, while on non-Windows, this occurs if
2947 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2948 * @retval ::WIMLIB_ERR_WIMBOOT
2949 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2950 * there was a problem creating WIMBoot pointer files or registering a
2951 * source WIM file with the Windows Overlay Filesystem (WOF) driver.
2952 * @retval ::WIMLIB_ERR_WRITE
2953 * Failed to write data to a file being extracted.
2955 * If a progress function is registered with @p wim, then as each image is
2956 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2957 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE messages, then zero
2958 * or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then zero or more
2959 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, then
2960 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2963 wimlib_extract_image(WIMStruct *wim, int image,
2964 const wimlib_tchar *target, int extract_flags);
2967 * @ingroup G_extracting_wims
2969 * Extract one image from a pipe on which a pipable WIM is being sent.
2971 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE, and @ref
2972 * subsec_pipable_wims, for more information about pipable WIMs.
2974 * This function operates in a special way to read the WIM fully sequentially.
2975 * As a result, there is no ::WIMStruct is made visible to library users, and
2976 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2977 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2978 * seekable file, not a pipe.)
2981 * File descriptor, which may be a pipe, opened for reading and positioned
2982 * at the start of the pipable WIM.
2983 * @param image_num_or_name
2984 * String that specifies the 1-based index or name of the image to extract.
2985 * It is translated to an image index using the same rules that
2986 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2987 * only a single image (not all images) can be specified. Alternatively,
2988 * specify @p NULL here to use the first image in the WIM if it contains
2989 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2991 * Same as the corresponding parameter to wimlib_extract_image().
2992 * @param extract_flags
2993 * Same as the corresponding parameter to wimlib_extract_image().
2995 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
2996 * error codes include those returned by wimlib_extract_image() and
2997 * wimlib_open_wim() as well as the following:
2999 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
3000 * Data read from the pipable WIM was invalid.
3001 * @retval ::WIMLIB_ERR_NOT_PIPABLE
3002 * The WIM being piped over @p pipe_fd is a normal WIM, not a pipable WIM.
3005 wimlib_extract_image_from_pipe(int pipe_fd,
3006 const wimlib_tchar *image_num_or_name,
3007 const wimlib_tchar *target, int extract_flags);
3010 * @ingroup G_extracting_wims
3012 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
3013 * function. The progress function will be used while extracting the image and
3014 * will receive the normal extraction progress messages, such as
3015 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
3016 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
3019 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
3020 const wimlib_tchar *image_num_or_name,
3021 const wimlib_tchar *target,
3023 wimlib_progress_func_t progfunc,
3027 * @ingroup G_extracting_wims
3029 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
3030 * image are specified in the ASCII, UTF-8, or UTF-16LE text file named by @p
3031 * path_list_file which itself contains the list of paths to use, one per line.
3032 * Leading and trailing whitespace is ignored. Empty lines and lines beginning
3033 * with the ';' or '#' characters are ignored. No quotes are needed, as paths
3034 * are otherwise delimited by the newline character. However, quotes will be
3035 * stripped if present.
3037 * The error codes are the same as those returned by wimlib_extract_paths(),
3038 * except that wimlib_extract_pathlist() returns an appropriate error code if it
3039 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
3040 * ::WIMLIB_ERR_READ).
3043 wimlib_extract_pathlist(WIMStruct *wim, int image,
3044 const wimlib_tchar *target,
3045 const wimlib_tchar *path_list_file,
3049 * @ingroup G_extracting_wims
3051 * Extract zero or more paths (files or directory trees) from the specified WIM
3054 * By default, each path will be extracted to a corresponding subdirectory of
3055 * the target based on its location in the image. For example, if one of the
3056 * paths to extract is <c>/Windows/explorer.exe</c> and the target is
3057 * <c>outdir</c>, the file will be extracted to
3058 * <c>outdir/Windows/explorer.exe</c>. This behavior can be changed by
3059 * providing the flag ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which
3060 * will cause each file or directory tree to be placed directly in the target
3061 * directory --- so the same example would extract <c>/Windows/explorer.exe</c>
3062 * to <c>outdir/explorer.exe</c>.
3064 * With globbing turned off (the default), paths are always checked for
3065 * existence strictly; that is, if any path to extract does not exist in the
3066 * image, then nothing is extracted and the function fails with
3067 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST. But with globbing turned on
3068 * (::WIMLIB_EXTRACT_FLAG_GLOB_PATHS specified), globs are by default permitted
3069 * to match no files, and there is a flag (::WIMLIB_EXTRACT_FLAG_STRICT_GLOB) to
3070 * enable the strict behavior if desired.
3072 * Symbolic links are not dereferenced when paths in the image are interpreted.
3075 * WIM from which to extract the paths, specified as a pointer to the
3076 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
3077 * split WIM. In the case of a WIM file that is not standalone, this
3078 * ::WIMStruct must have had any needed external resources previously
3079 * referenced using wimlib_reference_resources() or
3080 * wimlib_reference_resource_files().
3082 * The 1-based index of the WIM image from which to extract the paths.
3084 * Array of paths to extract. Each element must be the absolute path to a
3085 * file or directory within the image. Path separators may be either
3086 * forwards or backwards slashes, and leading path separators are optional.
3087 * The paths will be interpreted either case-sensitively (UNIX default) or
3088 * case-insensitively (Windows default); however, the case sensitivity can
3089 * be configured explicitly at library initialization time by passing an
3090 * appropriate flag to wimlib_global_init().
3092 * By default, "globbing" is disabled, so the characters @c * and @c ? are
3093 * interpreted literally. This can be changed by specifying
3094 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p extract_flags.
3096 * Number of paths specified in @p paths.
3098 * Directory to which to extract the paths.
3099 * @param extract_flags
3100 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
3102 * @return 0 on success; a ::wimlib_error_code value on failure. Most of the
3103 * error codes are the same as those returned by wimlib_extract_image(). Below,
3104 * some of the error codes returned in situations specific to path-mode
3105 * extraction are documented:
3107 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
3108 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
3109 * one of the paths to extract did not name a regular file.
3110 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3111 * One of the paths to extract does not exist in the image; see discussion
3112 * above about strict vs. non-strict behavior.
3114 * If a progress function is registered with @p wim, then it will receive
3115 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS.
3118 wimlib_extract_paths(WIMStruct *wim,
3120 const wimlib_tchar *target,
3121 const wimlib_tchar * const *paths,
3126 * @ingroup G_wim_information
3128 * Similar to wimlib_get_xml_data(), but the XML document will be written to the
3129 * specified standard C <c>FILE*</c> instead of retrieved in an in-memory
3132 * @return 0 on success; a ::wimlib_error_code value on failure. This may
3133 * return any error code which can be returned by wimlib_get_xml_data() as well
3134 * as the following error codes:
3136 * @retval ::WIMLIB_ERR_WRITE
3137 * Failed to write the data to the requested file.
3140 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
3143 * @ingroup G_general
3145 * Release a reference to a ::WIMStruct. If the ::WIMStruct is still referenced
3146 * by other ::WIMStruct's (e.g. following calls to wimlib_export_image() or
3147 * wimlib_reference_resources()), then the library will free it later, when the
3148 * last reference is released; otherwise it is freed immediately and any
3149 * associated file descriptors are closed.
3152 * Pointer to the ::WIMStruct to release. If @c NULL, no action is taken.
3155 wimlib_free(WIMStruct *wim);
3158 * @ingroup G_general
3160 * Convert a ::wimlib_compression_type value into a string.
3163 * The compression type value to convert.
3166 * A statically allocated string naming the compression type, such as
3167 * "None", "LZX", or "XPRESS". If the value was unrecognized, then
3168 * the resulting string will be "Invalid".
3170 extern const wimlib_tchar *
3171 wimlib_get_compression_type_string(enum wimlib_compression_type ctype);
3174 * @ingroup G_general
3176 * Convert a wimlib error code into a string describing it.
3179 * An error code returned by one of wimlib's functions.
3182 * Pointer to a statically allocated string describing the error code. If
3183 * the value was unrecognized, then the resulting string will be "Unknown
3186 extern const wimlib_tchar *
3187 wimlib_get_error_string(enum wimlib_error_code code);
3190 * @ingroup G_wim_information
3192 * Get the description of the specified image. Equivalent to
3193 * <tt>wimlib_get_image_property(wim, image, "DESCRIPTION")</tt>.
3195 extern const wimlib_tchar *
3196 wimlib_get_image_description(const WIMStruct *wim, int image);
3199 * @ingroup G_wim_information
3201 * Get the name of the specified image. Equivalent to
3202 * <tt>wimlib_get_image_property(wim, image, "NAME")</tt>, except that
3203 * wimlib_get_image_name() will return an empty string if the image is unnamed
3204 * whereas wimlib_get_image_property() may return @c NULL in that case.
3206 extern const wimlib_tchar *
3207 wimlib_get_image_name(const WIMStruct *wim, int image);
3210 * @ingroup G_wim_information
3212 * Since wimlib v1.8.3: get a per-image property from the WIM's XML document.
3213 * This is an alternative to wimlib_get_image_name() and
3214 * wimlib_get_image_description() which allows getting any simple string
3218 * Pointer to the ::WIMStruct for the WIM.
3220 * The 1-based index of the image for which to get the property.
3221 * @param property_name
3222 * The name of the image property, for example "NAME", "DESCRIPTION", or
3223 * "TOTALBYTES". The name can contain forward slashes to indicate a nested
3224 * XML element; for example, "WINDOWS/VERSION/BUILD" indicates the BUILD
3225 * element nested within the VERSION element nested within the WINDOWS
3226 * element. Since wimlib v1.9.0, a bracketed number can be used to
3227 * indicate one of several identically-named elements; for example,
3228 * "WINDOWS/LANGUAGES/LANGUAGE[2]" indicates the second "LANGUAGE" element
3229 * nested within the "WINDOWS/LANGUAGES" element. Note that element names
3230 * are case sensitive.
3233 * The property's value as a ::wimlib_tchar string, or @c NULL if there is
3234 * no such property. The string may not remain valid after later library
3235 * calls, so the caller should duplicate it if needed.
3237 extern const wimlib_tchar *
3238 wimlib_get_image_property(const WIMStruct *wim, int image,
3239 const wimlib_tchar *property_name);
3242 * @ingroup G_general
3244 * Return the version of wimlib as a 32-bit number whose top 12 bits contain the
3245 * major version, the next 10 bits contain the minor version, and the low 10
3246 * bits contain the patch version.
3248 * In other words, the returned value is equal to <c>((WIMLIB_MAJOR_VERSION <<
3249 * 20) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</c> for the
3250 * corresponding header file.
3253 wimlib_get_version(void);
3256 * @ingroup G_wim_information
3258 * Get basic information about a WIM file.
3261 * Pointer to the ::WIMStruct to query. This need not represent a
3262 * standalone WIM (e.g. it could represent part of a split WIM).
3264 * A ::wimlib_wim_info structure that will be filled in with information
3265 * about the WIM file.
3270 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
3273 * @ingroup G_wim_information
3275 * Read a WIM file's XML document into an in-memory buffer.
3277 * The XML document contains metadata about the WIM file and the images stored
3281 * Pointer to the ::WIMStruct to query. This need not represent a
3282 * standalone WIM (e.g. it could represent part of a split WIM).
3284 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
3285 * XML document is written to this location.
3286 * @param bufsize_ret
3287 * The size of the XML document in bytes is written to this location.
3289 * @return 0 on success; a ::wimlib_error_code value on failure.
3291 * @retval ::WIMLIB_ERR_NO_FILENAME
3292 * @p wim is not backed by a file and therefore does not have an XML
3294 * @retval ::WIMLIB_ERR_READ
3295 * Failed to read the XML document from the WIM file.
3296 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3297 * Failed to read the XML document from the WIM file.
3300 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
3303 * @ingroup G_general
3305 * Initialization function for wimlib. Call before using any other wimlib
3306 * function (except possibly wimlib_set_print_errors()). If not done manually,
3307 * this function will be called automatically with a flags argument of 0. This
3308 * function does nothing if called again after it has already successfully run.
3311 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
3313 * @return 0 on success; a ::wimlib_error_code value on failure.
3315 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
3316 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
3317 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
3318 * init_flags, but the corresponding privileges could not be acquired.
3321 wimlib_global_init(int init_flags);
3324 * @ingroup G_general
3326 * Cleanup function for wimlib. You are not required to call this function, but
3327 * it will release any global resources allocated by the library.
3330 wimlib_global_cleanup(void);
3333 * @ingroup G_wim_information
3335 * Determine if an image name is already used by some image in the WIM.
3338 * Pointer to the ::WIMStruct to query. This need not represent a
3339 * standalone WIM (e.g. it could represent part of a split WIM).
3341 * The name to check.
3344 * @c true if there is already an image in @p wim named @p name; @c false
3345 * if there is no image named @p name in @p wim. If @p name is @c NULL or
3346 * the empty string, then @c false is returned.
3349 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
3352 * @ingroup G_wim_information
3354 * Iterate through a file or directory tree in a WIM image. By specifying
3355 * appropriate flags and a callback function, you can get the attributes of a
3356 * file in the image, get a directory listing, or even get a listing of the
3360 * The ::WIMStruct containing the image(s) over which to iterate. This
3361 * ::WIMStruct must contain image metadata, so it cannot be the non-first
3362 * part of a split WIM (for example).
3364 * The 1-based index of the image that contains the files or directories to
3365 * iterate over, or ::WIMLIB_ALL_IMAGES to iterate over all images.
3367 * Path in the image at which to do the iteration.
3369 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3371 * A callback function that will receive each directory entry.
3373 * An extra parameter that will always be passed to the callback function
3376 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3377 * first nonzero value that was returned from @p cb. However, additional
3378 * ::wimlib_error_code values may be returned, including the following:
3380 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3381 * @p image does not exist in @p wim.
3382 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3383 * @p path does not exist in the image.
3384 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3385 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED was specified, but the
3386 * data for some files could not be found in the blob lookup table of @p
3389 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3390 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3391 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3392 * indicate failure (for different reasons) to read the metadata resource for an
3393 * image over which iteration needed to be done.
3396 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3398 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3401 * @ingroup G_wim_information
3403 * Iterate through the blob lookup table of a ::WIMStruct. This can be used to
3404 * directly get a listing of the unique "blobs" contained in a WIM file, which
3405 * are deduplicated over all images.
3407 * Specifically, each listed blob may be from any of the following sources:
3409 * - Metadata blobs, if the ::WIMStruct contains image metadata
3410 * - File blobs from the on-disk WIM file (if any) backing the ::WIMStruct
3411 * - File blobs from files that have been added to the in-memory ::WIMStruct,
3412 * e.g. by using wimlib_add_image()
3413 * - File blobs from external WIMs referenced by
3414 * wimlib_reference_resource_files() or wimlib_reference_resources()
3417 * Pointer to the ::WIMStruct for which to get the blob listing.
3419 * Reserved; set to 0.
3421 * A callback function that will receive each blob.
3423 * An extra parameter that will always be passed to the callback function
3426 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3427 * that was returned from @p cb.
3430 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3431 wimlib_iterate_lookup_table_callback_t cb,
3435 * @ingroup G_nonstandalone_wims
3437 * Join a split WIM into a stand-alone (one-part) WIM.
3440 * An array of strings that gives the filenames of all parts of the split
3441 * WIM. No specific order is required, but all parts must be included with
3444 * Number of filenames in @p swms.
3445 * @param swm_open_flags
3446 * Open flags for the split WIM parts (e.g.
3447 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3448 * @param wim_write_flags
3449 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3450 * be used to write the joined WIM.
3451 * @param output_path
3452 * The path to write the joined WIM file to.
3454 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3455 * may return most error codes that can be returned by wimlib_open_wim() and
3456 * wimlib_write(), as well as the following error codes:
3458 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3459 * The split WIMs do not form a valid WIM because they do not include all
3460 * the parts of the original WIM, there are duplicate parts, or not all the
3461 * parts have the same GUID and compression type.
3463 * Note: wimlib is generalized enough that this function is not actually needed
3464 * to join a split WIM; instead, you could open the first part of the split WIM,
3465 * then reference the other parts with wimlib_reference_resource_files(), then
3466 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3467 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3471 wimlib_join(const wimlib_tchar * const *swms,
3473 const wimlib_tchar *output_path,
3475 int wim_write_flags);
3478 * @ingroup G_nonstandalone_wims
3480 * Same as wimlib_join(), but allows specifying a progress function. The
3481 * progress function will receive the write progress messages, such as
3482 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3483 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3484 * swm_open_flags, the progress function will receive a series of
3485 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3489 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3491 const wimlib_tchar *output_path,
3493 int wim_write_flags,
3494 wimlib_progress_func_t progfunc,
3499 * @ingroup G_mounting_wim_images
3501 * Mount an image from a WIM file on a directory read-only or read-write.
3504 * Pointer to the ::WIMStruct containing the image to be mounted. This
3505 * ::WIMStruct must have a backing file.
3507 * The 1-based index of the image to mount. This image cannot have been
3508 * previously modified in memory.
3510 * The path to an existing empty directory on which to mount the image.
3511 * @param mount_flags
3512 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3513 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3515 * @param staging_dir
3516 * If non-NULL, the name of a directory in which a temporary directory for
3517 * storing modified or added files will be created. Ignored if
3518 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3519 * left @c NULL, the staging directory is created in the same directory as
3520 * the backing WIM file. The staging directory is automatically deleted
3521 * when the image is unmounted.
3523 * @return 0 on success; a ::wimlib_error_code value on failure.
3525 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3526 * Another process is currently modifying the WIM file.
3527 * @retval ::WIMLIB_ERR_FUSE
3528 * A non-zero status code was returned by @c fuse_main().
3529 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
3530 * There are currently multiple references to the image as a result of a
3531 * call to wimlib_export_image(). Free one before attempting the
3533 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3534 * @p image does not exist in @p wim.
3535 * @retval ::WIMLIB_ERR_INVALID_PARAM
3536 * @p wim was @c NULL; or @p dir was NULL or an empty string; or an
3537 * unrecognized flag was specified in @p mount_flags; or the image has
3538 * already been modified in memory (e.g. by wimlib_update_image()).
3539 * @retval ::WIMLIB_ERR_MKDIR
3540 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3541 * staging directory could not be created.
3542 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3543 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3544 * WIM file is considered read-only because of any of the reasons mentioned
3545 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3546 * @retval ::WIMLIB_ERR_UNSUPPORTED
3547 * Mounting is not supported in this build of the library.
3549 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3550 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3551 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3552 * indicate failure (for different reasons) to read the metadata resource for
3553 * the image to mount.
3555 * The ability to mount WIM images is implemented using FUSE (Filesystem in
3556 * UserSpacE). Depending on how FUSE is set up on your system, this function
3557 * may work as normal users in addition to the root user.
3559 * Mounting WIM images is not supported if wimlib was configured
3560 * <c>--without-fuse</c>. This includes Windows builds of wimlib;
3561 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3563 * Calling this function daemonizes the process, unless
3564 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3566 * It is safe to mount multiple images from the same WIM file read-only at the
3567 * same time, but only if different ::WIMStruct's are used. It is @b not safe
3568 * to mount multiple images from the same WIM file read-write at the same time.
3570 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3571 * different process.
3574 wimlib_mount_image(WIMStruct *wim,
3576 const wimlib_tchar *dir,
3578 const wimlib_tchar *staging_dir);
3581 * @ingroup G_creating_and_opening_wims
3583 * Open a WIM file and create a ::WIMStruct for it.
3586 * The path to the WIM file to open.
3588 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3590 * On success, a pointer to a new ::WIMStruct backed by the specified
3591 * on-disk WIM file is written to the memory location pointed to by this
3592 * parameter. This ::WIMStruct must be freed using using wimlib_free()
3593 * when finished with it.
3595 * @return 0 on success; a ::wimlib_error_code value on failure.
3597 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3598 * The number of metadata resources found in the WIM did not match the
3599 * image count specified in the WIM header, or the number of <IMAGE>
3600 * elements in the XML data of the WIM did not match the image count
3601 * specified in the WIM header.
3602 * @retval ::WIMLIB_ERR_INTEGRITY
3603 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags, and
3604 * the WIM file failed the integrity check.
3605 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3606 * The library did not recognize the compression chunk size of the WIM as
3607 * valid for its compression type.
3608 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3609 * The library did not recognize the compression type of the WIM.
3610 * @retval ::WIMLIB_ERR_INVALID_HEADER
3611 * The header of the WIM was otherwise invalid.
3612 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3613 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3614 * the WIM contained an integrity table, but the integrity table was
3616 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3617 * The lookup table of the WIM was invalid.
3618 * @retval ::WIMLIB_ERR_INVALID_PARAM
3619 * @p wim_ret was @c NULL; or, @p wim_file was not a nonempty string.
3620 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3621 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3622 * specified in @p open_flags.
3623 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3624 * The file did not begin with the magic characters that identify a WIM
3626 * @retval ::WIMLIB_ERR_OPEN
3627 * Failed to open the WIM file for reading. Some possible reasons: the WIM
3628 * file does not exist, or the calling process does not have permission to
3630 * @retval ::WIMLIB_ERR_READ
3631 * Failed to read data from the WIM file.
3632 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3633 * Unexpected end-of-file while reading data from the WIM file.
3634 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3635 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3636 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3637 * The WIM cannot be opened because it contains encrypted segments. (It
3638 * may be a Windows 8 "ESD" file.)
3639 * @retval ::WIMLIB_ERR_WIM_IS_INCOMPLETE
3640 * The WIM file is not complete (e.g. the program which wrote it was
3641 * terminated before it finished)
3642 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3643 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3644 * considered read-only because of any of the reasons mentioned in the
3645 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3646 * @retval ::WIMLIB_ERR_XML
3647 * The XML data of the WIM was invalid.
3650 wimlib_open_wim(const wimlib_tchar *wim_file,
3652 WIMStruct **wim_ret);
3655 * @ingroup G_creating_and_opening_wims
3657 * Same as wimlib_open_wim(), but allows specifying a progress function and
3658 * progress context. If successful, the progress function will be registered in
3659 * the newly open ::WIMStruct, as if by an automatic call to
3660 * wimlib_register_progress_function(). In addition, if
3661 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, then the
3662 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3663 * messages while checking the WIM file's integrity.
3666 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3668 WIMStruct **wim_ret,
3669 wimlib_progress_func_t progfunc,
3673 * @ingroup G_writing_and_overwriting_wims
3675 * Commit a ::WIMStruct to disk, updating its backing file.
3677 * There are several alternative ways in which changes may be committed:
3679 * 1. Full rebuild: write the updated WIM to a temporary file, then rename the
3680 * temporary file to the original.
3681 * 2. Appending: append updates to the new original WIM file, then overwrite
3682 * its header such that those changes become visible to new readers.
3683 * 3. Compaction: normally should not be used; see
3684 * ::WIMLIB_WRITE_FLAG_UNSAFE_COMPACT for details.
3686 * Append mode is often much faster than a full rebuild, but it wastes some
3687 * amount of space due to leaving "holes" in the WIM file. Because of the
3688 * greater efficiency, wimlib_overwrite() normally defaults to append mode.
3689 * However, ::WIMLIB_WRITE_FLAG_REBUILD can be used to explicitly request a full
3690 * rebuild. In addition, if wimlib_delete_image() has been used on the
3691 * ::WIMStruct, then the default mode switches to rebuild mode, and
3692 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE can be used to explicitly request append
3695 * If this function completes successfully, then no more functions can be called
3696 * on the ::WIMStruct other than wimlib_free(). If you need to continue using
3697 * the WIM file, you must use wimlib_open_wim() to open a new ::WIMStruct for
3701 * Pointer to a ::WIMStruct to commit to its backing file.
3702 * @param write_flags
3703 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3704 * @param num_threads
3705 * The number of threads to use for compressing data, or 0 to have the
3706 * library automatically choose an appropriate number.
3708 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3709 * may return most error codes returned by wimlib_write() as well as the
3710 * following error codes:
3712 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3713 * Another process is currently modifying the WIM file.
3714 * @retval ::WIMLIB_ERR_NO_FILENAME
3715 * @p wim is not backed by an on-disk file. In other words, it is a
3716 * ::WIMStruct created by wimlib_create_new_wim() rather than
3717 * wimlib_open_wim().
3718 * @retval ::WIMLIB_ERR_RENAME
3719 * The temporary file to which the WIM was written could not be renamed to
3720 * the original file.
3721 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3722 * The WIM file is considered read-only because of any of the reasons
3723 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3726 * If a progress function is registered with @p wim, then it will receive the
3727 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3728 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3729 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3732 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3735 * @ingroup G_wim_information
3737 * (Deprecated) Print information about one image, or all images, contained in a
3741 * Pointer to the ::WIMStruct to query. This need not represent a
3742 * standalone WIM (e.g. it could represent part of a split WIM).
3744 * The 1-based index of the image for which to print information, or
3745 * ::WIMLIB_ALL_IMAGES to print information about all images.
3747 * @return This function has no return value. No error checking is done when
3748 * printing the information. If @p image is invalid, an error message is
3751 * This function is deprecated; use wimlib_get_xml_data() or
3752 * wimlib_get_image_property() to query image information instead.
3755 wimlib_print_available_images(const WIMStruct *wim, int image);
3758 * @ingroup G_wim_information
3760 * Print the header of the WIM file (intended for debugging only).
3763 wimlib_print_header(const WIMStruct *wim);
3766 * @ingroup G_nonstandalone_wims
3768 * Reference file data from other WIM files or split WIM parts. This function
3769 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3770 * to load additional file data before calling a function such as
3771 * wimlib_extract_image() that requires the file data to be present.
3774 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3775 * necessarily "standalone". In the case of split WIMs, this should be the
3776 * first part, since only the first part contains the metadata resources.
3777 * In the case of delta WIMs, this should be the delta WIM rather than the
3778 * WIM on which it is based.
3779 * @param resource_wimfiles_or_globs
3780 * Array of paths to WIM files and/or split WIM parts to reference.
3781 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3782 * ref_flags, these are treated as globs rather than literal paths. That
3783 * is, using this function you can specify zero or more globs, each of
3784 * which expands to one or more literal paths.
3786 * Number of entries in @p resource_wimfiles_or_globs.
3788 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3789 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3791 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3792 * pass to internal calls to wimlib_open_wim() on the reference files.
3794 * @return 0 on success; a ::wimlib_error_code value on failure.
3796 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3797 * One of the specified globs did not match any paths (only with both
3798 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3799 * specified in @p ref_flags).
3800 * @retval ::WIMLIB_ERR_READ
3801 * I/O or permissions error while processing a file glob.
3803 * This function can additionally return most values that can be returned by
3804 * wimlib_open_wim().
3807 wimlib_reference_resource_files(WIMStruct *wim,
3808 const wimlib_tchar * const *resource_wimfiles_or_globs,
3814 * @ingroup G_nonstandalone_wims
3816 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3817 * where the caller must open the ::WIMStruct for each referenced file itself.
3820 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3821 * necessarily "standalone". In the case of split WIMs, this should be the
3822 * first part, since only the first part contains the metadata resources.
3823 * @param resource_wims
3824 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3825 * split WIM parts to reference.
3826 * @param num_resource_wims
3827 * Number of entries in @p resource_wims.
3829 * Reserved; must be 0.
3831 * @return 0 on success; a ::wimlib_error_code value on failure.
3834 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3835 unsigned num_resource_wims, int ref_flags);
3838 * @ingroup G_modifying_wims
3840 * Declare that a newly added image is mostly the same as a prior image, but
3841 * captured at a later point in time, possibly with some modifications in the
3842 * intervening time. This is designed to be used in incremental backups of the
3843 * same filesystem or directory tree.
3845 * This function compares the metadata of the directory tree of the newly added
3846 * image against that of the old image. Any files that are present in both the
3847 * newly added image and the old image and have timestamps that indicate they
3848 * haven't been modified are deemed not to have been modified and have their
3849 * checksums copied from the old image. Because of this and because WIM uses
3850 * single-instance streams, such files need not be read from the filesystem when
3851 * the WIM is being written or overwritten. Note that these unchanged files
3852 * will still be "archived" and will be logically present in the new image; the
3853 * optimization is that they don't need to actually be read from the filesystem
3854 * because the WIM already contains them.
3856 * This function is provided to optimize incremental backups. The resulting WIM
3857 * file will still be the same regardless of whether this function is called.
3858 * (This is, however, assuming that timestamps have not been manipulated or
3859 * unmaintained as to trick this function into thinking a file has not been
3860 * modified when really it has. To partly guard against such cases, other
3861 * metadata such as file sizes will be checked as well.)
3863 * This function must be called after adding the new image (e.g. with
3864 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3865 * wimlib_overwrite()).
3868 * Pointer to the ::WIMStruct containing the newly added image.
3870 * The 1-based index in @p wim of the newly added image.
3871 * @param template_wim
3872 * Pointer to the ::WIMStruct containing the template image. This can be,
3873 * but does not have to be, the same ::WIMStruct as @p wim.
3874 * @param template_image
3875 * The 1-based index in @p template_wim of the template image.
3877 * Reserved; must be 0.
3879 * @return 0 on success; a ::wimlib_error_code value on failure.
3881 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3882 * @p new_image does not exist in @p wim or @p template_image does not
3883 * exist in @p template_wim.
3884 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3885 * At least one of @p wim and @p template_wim does not contain image
3886 * metadata; for example, one of them represents a non-first part of a
3888 * @retval ::WIMLIB_ERR_INVALID_PARAM
3889 * Identical values were provided for the template and new image; or @p
3890 * new_image specified an image that had not been modified since opening
3893 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3894 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3895 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3896 * indicate failure (for different reasons) to read the metadata resource for
3897 * the template image.
3900 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3901 WIMStruct *template_wim, int template_image,
3905 * @ingroup G_general
3907 * Register a progress function with a ::WIMStruct.
3910 * The ::WIMStruct for which to register the progress function.
3912 * Pointer to the progress function to register. If the WIM already has a
3913 * progress function registered, it will be replaced with this one. If @p
3914 * NULL, the current progress function (if any) will be unregistered.
3916 * The value which will be passed as the third argument to calls to @p
3920 wimlib_register_progress_function(WIMStruct *wim,
3921 wimlib_progress_func_t progfunc,
3925 * @ingroup G_modifying_wims
3927 * Rename the @p source_path to the @p dest_path in the specified @p image of
3930 * This just builds an appropriate ::wimlib_rename_command and passes it to
3931 * wimlib_update_image().
3934 wimlib_rename_path(WIMStruct *wim, int image,
3935 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3938 * @ingroup G_wim_information
3940 * Translate a string specifying the name or number of an image in the WIM into
3941 * the number of the image. The images are numbered starting at 1.
3944 * Pointer to the ::WIMStruct for a WIM.
3945 * @param image_name_or_num
3946 * A string specifying the name or number of an image in the WIM. If it
3947 * parses to a positive integer, this integer is taken to specify the
3948 * number of the image, indexed starting at 1. Otherwise, it is taken to
3949 * be the name of an image, as given in the XML data for the WIM file. It
3950 * also may be the keyword "all" or the string "*", both of which will
3951 * resolve to ::WIMLIB_ALL_IMAGES.
3953 * There is no way to search for an image actually named "all", "*", or an
3954 * integer number, or an image that has no name. However, you can use
3955 * wimlib_get_image_name() to get the name of any image.
3958 * If the string resolved to a single existing image, the number of that
3959 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3960 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3961 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3962 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3963 * images in @p wim has no name. (Since a WIM may have multiple unnamed
3964 * images, an unnamed image must be specified by index to eliminate the
3968 wimlib_resolve_image(WIMStruct *wim,
3969 const wimlib_tchar *image_name_or_num);
3972 * @ingroup G_general
3974 * Set the file to which the library will print error and warning messages.
3976 * This version of the function takes a C library <c>FILE*</c> opened for
3977 * writing (or appending). Use wimlib_set_error_file_by_name() to specify the
3978 * file by name instead.
3980 * This also enables error messages, as if by a call to
3981 * wimlib_set_print_errors(true).
3983 * @return 0 on success; a ::wimlib_error_code value on failure.
3985 * @retval ::WIMLIB_ERR_UNSUPPORTED
3986 * wimlib was compiled using the <c>--without-error-messages</c> option.
3989 wimlib_set_error_file(FILE *fp);
3992 * @ingroup G_general
3994 * Set the path to the file to which the library will print error and warning
3995 * messages. The library will open this file for appending.
3997 * This also enables error messages, as if by a call to
3998 * wimlib_set_print_errors(true).
4000 * @return 0 on success; a ::wimlib_error_code value on failure.
4002 * @retval ::WIMLIB_ERR_OPEN
4003 * The file named by @p path could not be opened for appending.
4004 * @retval ::WIMLIB_ERR_UNSUPPORTED
4005 * wimlib was compiled using the <c>--without-error-messages</c> option.
4008 wimlib_set_error_file_by_name(const wimlib_tchar *path);
4011 * @ingroup G_modifying_wims
4013 * Change the description of a WIM image. Equivalent to
4014 * <tt>wimlib_set_image_property(wim, image, "DESCRIPTION", description)</tt>.
4016 * Note that "description" is misspelled in the name of this function.
4019 wimlib_set_image_descripton(WIMStruct *wim, int image,
4020 const wimlib_tchar *description);
4023 * @ingroup G_modifying_wims
4025 * Change what is stored in the \<FLAGS\> element in the WIM XML document
4026 * (usually something like "Core" or "Ultimate"). Equivalent to
4027 * <tt>wimlib_set_image_property(wim, image, "FLAGS", flags)</tt>.
4030 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
4033 * @ingroup G_modifying_wims
4035 * Change the name of a WIM image. Equivalent to
4036 * <tt>wimlib_set_image_property(wim, image, "NAME", name)</tt>.
4039 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
4042 * @ingroup G_modifying_wims
4044 * Since wimlib v1.8.3: add, modify, or remove a per-image property from the
4045 * WIM's XML document. This is an alternative to wimlib_set_image_name(),
4046 * wimlib_set_image_descripton(), and wimlib_set_image_flags() which allows
4047 * manipulating any simple string property.
4050 * Pointer to the ::WIMStruct for the WIM.
4052 * The 1-based index of the image for which to set the property.
4053 * @param property_name
4054 * The name of the image property in the same format documented for
4055 * wimlib_get_image_property().
4057 * Note: if creating a new element using a bracketed index such as
4058 * "WINDOWS/LANGUAGES/LANGUAGE[2]", the highest index that can be specified
4059 * is one greater than the number of existing elements with that same name,
4060 * excluding the index. That means that if you are adding a list of new
4061 * elements, they must be added sequentially from the first index (1) to
4062 * the last index (n).
4063 * @param property_value
4064 * If not NULL and not empty, the property is set to this value.
4065 * Otherwise, the property is removed from the XML document.
4067 * @return 0 on success; a ::wimlib_error_code value on failure.
4069 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
4070 * The user requested to set the image name (the <tt>NAME</tt> property),
4071 * but another image in the WIM already had the requested name.
4072 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4073 * @p image does not exist in @p wim.
4074 * @retval ::WIMLIB_ERR_INVALID_PARAM
4075 * @p property_name has an unsupported format, or @p property_name included
4076 * a bracketed index that was too high.
4079 wimlib_set_image_property(WIMStruct *wim, int image,
4080 const wimlib_tchar *property_name,
4081 const wimlib_tchar *property_value);
4084 * @ingroup G_general
4086 * Set the functions that wimlib uses to allocate and free memory.
4088 * These settings are global and not per-WIM.
4090 * The default is to use the default @c malloc(), @c free(), and @c realloc()
4091 * from the standard C library.
4093 * Note: some external functions, such as those in @c libntfs-3g, may use the
4094 * standard memory allocation functions regardless of this setting.
4096 * @param malloc_func
4097 * A function equivalent to @c malloc() that wimlib will use to allocate
4098 * memory. If @c NULL, the allocator function is set back to the default
4099 * @c malloc() from the C library.
4101 * A function equivalent to @c free() that wimlib will use to free memory.
4102 * If @c NULL, the free function is set back to the default @c free() from
4104 * @param realloc_func
4105 * A function equivalent to @c realloc() that wimlib will use to reallocate
4106 * memory. If @c NULL, the free function is set back to the default @c
4107 * realloc() from the C library.
4112 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
4113 void (*free_func)(void *),
4114 void *(*realloc_func)(void *, size_t));
4117 * @ingroup G_writing_and_overwriting_wims
4119 * Set a ::WIMStruct's output compression chunk size. This is the compression
4120 * chunk size that will be used for writing non-solid resources in subsequent
4121 * calls to wimlib_write() or wimlib_overwrite(). A larger compression chunk
4122 * size often results in a better compression ratio, but compression may be
4123 * slower and the speed of random access to data may be reduced. In addition,
4124 * some chunk sizes are not compatible with Microsoft software.
4127 * The ::WIMStruct for which to set the output chunk size.
4129 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
4130 * on the compression type. See the documentation for each
4131 * ::wimlib_compression_type constant for more information. As a special
4132 * case, if @p chunk_size is specified as 0, then the chunk size will be
4133 * reset to the default for the currently selected output compression type.
4135 * @return 0 on success; a ::wimlib_error_code value on failure.
4137 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
4138 * @p chunk_size was not 0 or a supported chunk size for the currently
4139 * selected output compression type.
4142 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4145 * @ingroup G_writing_and_overwriting_wims
4147 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
4151 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4154 * @ingroup G_writing_and_overwriting_wims
4156 * Set a ::WIMStruct's output compression type. This is the compression type
4157 * that will be used for writing non-solid resources in subsequent calls to
4158 * wimlib_write() or wimlib_overwrite().
4161 * The ::WIMStruct for which to set the output compression type.
4163 * The compression type to set. If this compression type is incompatible
4164 * with the current output chunk size, then the output chunk size will be
4165 * reset to the default for the new compression type.
4167 * @return 0 on success; a ::wimlib_error_code value on failure.
4169 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4170 * @p ctype did not specify a valid compression type.
4173 wimlib_set_output_compression_type(WIMStruct *wim,
4174 enum wimlib_compression_type ctype);
4177 * @ingroup G_writing_and_overwriting_wims
4179 * Similar to wimlib_set_output_compression_type(), but set the compression type
4180 * for writing solid resources. This cannot be ::WIMLIB_COMPRESSION_TYPE_NONE.
4183 wimlib_set_output_pack_compression_type(WIMStruct *wim,
4184 enum wimlib_compression_type ctype);
4187 * @ingroup G_general
4189 * Set whether wimlib can print error and warning messages to the error file,
4190 * which defaults to standard error. Error and warning messages may provide
4191 * information that cannot be determined only from returned error codes.
4193 * By default, error messages are not printed.
4195 * This setting applies globally (it is not per-WIM).
4197 * This can be called before wimlib_global_init().
4199 * @param show_messages
4200 * @c true if messages are to be printed; @c false if messages are not to
4203 * @return 0 on success; a ::wimlib_error_code value on failure.
4205 * @retval ::WIMLIB_ERR_UNSUPPORTED
4206 * wimlib was compiled using the <c>--without-error-messages</c> option.
4209 wimlib_set_print_errors(bool show_messages);
4212 * @ingroup G_modifying_wims
4214 * Set basic information about a WIM.
4217 * Pointer to the ::WIMStruct for a WIM.
4219 * Pointer to a ::wimlib_wim_info structure that contains the information
4220 * to set. Only the information explicitly specified in the @p which flags
4223 * Flags that specify which information to set. This is a bitwise OR of
4224 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
4225 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
4227 * @return 0 on success; a ::wimlib_error_code value on failure.
4229 * @retval ::WIMLIB_ERR_IMAGE_COUNT
4230 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
4231 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
4235 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
4239 * @ingroup G_nonstandalone_wims
4241 * Split a WIM into multiple parts.
4244 * The ::WIMStruct for the WIM to split.
4246 * Name of the split WIM (SWM) file to create. This will be the name of
4247 * the first part. The other parts will, by default, have the same name
4248 * with 2, 3, 4, ..., etc. appended before the suffix. However, the exact
4249 * names can be customized using the progress function.
4251 * The maximum size per part, in bytes. Unfortunately, it is not
4252 * guaranteed that this will really be the maximum size per part, because
4253 * some file resources in the WIM may be larger than this size, and the WIM
4254 * file format provides no way to split up file resources among multiple
4256 * @param write_flags
4257 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
4258 * flags will be used to write each split WIM part. Specify 0 here to get
4259 * the default behavior.
4261 * @return 0 on success; a ::wimlib_error_code value on failure. This function
4262 * may return most error codes that can be returned by wimlib_write() as well as
4263 * the following error codes:
4265 * @retval ::WIMLIB_ERR_INVALID_PARAM
4266 * @p swm_name was not a nonempty string, or @p part_size was 0.
4267 * @retval ::WIMLIB_ERR_UNSUPPORTED
4268 * The WIM contains solid resources. Splitting a WIM containing solid
4269 * resources is not supported.
4271 * If a progress function is registered with @p wim, then for each split WIM
4272 * part that is written it will receive the messages
4273 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
4274 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
4277 wimlib_split(WIMStruct *wim,
4278 const wimlib_tchar *swm_name,
4283 * @ingroup G_general
4285 * Perform verification checks on a WIM file.
4287 * This function is intended for safety checking and/or debugging. If used on a
4288 * well-formed WIM file, it should always succeed.
4291 * The ::WIMStruct for the WIM file to verify. Note: for an extra layer of
4292 * verification, it is a good idea to have used
4293 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
4295 * If verifying a split WIM, specify the first part of the split WIM here,
4296 * and reference the other parts using wimlib_reference_resource_files()
4297 * before calling this function.
4298 * @param verify_flags
4299 * Reserved; must be 0.
4301 * @return 0 if the WIM file was successfully verified; a ::wimlib_error_code
4302 * value if it failed verification or another error occurred.
4304 * @retval ::WIMLIB_ERR_DECOMPRESSION
4305 * The WIM file contains invalid compressed data.
4306 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
4307 * The metadata resource for an image is invalid.
4308 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4309 * File data stored in the WIM file is corrupt.
4310 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4311 * The data for a file in an image could not be found. See @ref
4312 * G_nonstandalone_wims.
4314 * If a progress function is registered with @p wim, then it will receive the
4315 * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
4316 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
4317 * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
4320 wimlib_verify_wim(WIMStruct *wim, int verify_flags);
4323 * @ingroup G_mounting_wim_images
4325 * Unmount a WIM image that was mounted using wimlib_mount_image().
4327 * When unmounting a read-write mounted image, the default behavior is to
4328 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
4329 * image to be committed.
4332 * The directory on which the WIM image is mounted.
4333 * @param unmount_flags
4334 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
4336 * @return 0 on success; a ::wimlib_error_code value on failure.
4338 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
4339 * There is no WIM image mounted on the specified directory.
4340 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
4341 * The read-write mounted image cannot be committed because there are file
4342 * descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
4344 * @retval ::WIMLIB_ERR_MQUEUE
4345 * Could not create a POSIX message queue.
4346 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
4347 * The image was mounted by a different user.
4348 * @retval ::WIMLIB_ERR_UNSUPPORTED
4349 * Mounting is not supported in this build of the library.
4351 * Note: you can also unmount the image by using the @c umount() system call, or
4352 * by using the @c umount or @c fusermount programs. However, you need to call
4353 * this function if you want changes to be committed.
4356 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
4359 * @ingroup G_mounting_wim_images
4361 * Same as wimlib_unmount_image(), but allows specifying a progress function.
4362 * The progress function will receive a ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN
4363 * message. In addition, if changes are committed from a read-write mount, the
4364 * progress function will receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
4367 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
4369 wimlib_progress_func_t progfunc,
4373 * @ingroup G_modifying_wims
4375 * Update a WIM image by adding, deleting, and/or renaming files or directories.
4378 * Pointer to the ::WIMStruct containing the image to update.
4380 * The 1-based index of the image to update.
4382 * An array of ::wimlib_update_command's that specify the update operations
4385 * Number of commands in @p cmds.
4386 * @param update_flags
4387 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
4389 * @return 0 on success; a ::wimlib_error_code value on failure. On failure,
4390 * all update commands will be rolled back, and no visible changes will have
4391 * been made to @p wim.
4393 * @retval ::WIMLIB_ERR_FVE_LOCKED_VOLUME
4394 * Windows-only: One of the "add" commands attempted to add files from an
4395 * encrypted BitLocker volume that hasn't yet been unlocked.
4396 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
4397 * There are currently multiple references to the image as a result of a
4398 * call to wimlib_export_image(). Free one before attempting the update.
4399 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
4400 * The contents of a capture configuration file were invalid.
4401 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4402 * @p image did not exist in @p wim.
4403 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
4404 * An add command with ::WIMLIB_ADD_FLAG_NO_REPLACE specified attempted to
4405 * replace an existing nondirectory file.
4406 * @retval ::WIMLIB_ERR_INVALID_PARAM
4407 * An unknown operation type was provided in the update commands; or
4408 * unknown or incompatible flags were provided in a flags parameter; or
4409 * there was another problem with the provided parameters.
4410 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4411 * While executing an add command, a reparse point had invalid data.
4412 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4413 * An add command attempted to replace a directory with a non-directory; or
4414 * a delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE attempted to
4415 * delete a directory; or a rename command attempted to rename a directory
4416 * to a non-directory.
4417 * @retval ::WIMLIB_ERR_NOTDIR
4418 * An add command attempted to replace a non-directory with a directory; or
4419 * an add command attempted to set the root of the image to a
4420 * non-directory; or a rename command attempted to rename a directory to a
4421 * non-directory; or a component of an image path that was used as a
4422 * directory was not, in fact, a directory.
4423 * @retval ::WIMLIB_ERR_NOTEMPTY
4424 * A rename command attempted to rename a directory to a non-empty
4425 * directory; or a rename command would have created a loop.
4426 * @retval ::WIMLIB_ERR_NTFS_3G
4427 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4428 * error occurred while reading data from the NTFS volume using libntfs-3g.
4429 * @retval ::WIMLIB_ERR_OPEN
4430 * Failed to open a file to be captured while executing an add command.
4431 * @retval ::WIMLIB_ERR_OPENDIR
4432 * Failed to open a directory to be captured while executing an add
4434 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4435 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4436 * WIM path that did not exist; or a rename command attempted to rename a
4437 * file that does not exist.
4438 * @retval ::WIMLIB_ERR_READ
4439 * While executing an add command, failed to read data from a file or
4440 * directory to be captured.
4441 * @retval ::WIMLIB_ERR_READLINK
4442 * While executing an add command, failed to read the target of a symbolic
4443 * link, junction, or other reparse point.
4444 * @retval ::WIMLIB_ERR_STAT
4445 * While executing an add command, failed to read metadata for a file or
4447 * @retval ::WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG
4448 * A capture configuration file could not be read.
4449 * @retval ::WIMLIB_ERR_UNSUPPORTED
4450 * A command had flags provided that are not supported on this platform or
4451 * in this build of the library.
4452 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4453 * An add command with ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified
4454 * discovered a file that was not of a supported type.
4456 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4457 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4458 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4459 * indicate failure (for different reasons) to read the metadata resource for an
4460 * image that needed to be updated.
4463 wimlib_update_image(WIMStruct *wim,
4465 const struct wimlib_update_command *cmds,
4470 * @ingroup G_writing_and_overwriting_wims
4472 * Persist a ::WIMStruct to a new on-disk WIM file.
4474 * This brings in file data from any external locations, such as directory trees
4475 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4476 * wimlib_export_image(), and incorporates it into a new on-disk WIM file.
4478 * By default, the new WIM file is written as stand-alone. Using the
4479 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4480 * instead. However, this function cannot directly write a "split" WIM; use
4481 * wimlib_split() for that.
4484 * Pointer to the ::WIMStruct being persisted.
4486 * The path to the on-disk file to write.
4488 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4489 * images are to be included in the new on-disk WIM file. If for some
4490 * reason you only want to include a single image, specify the 1-based
4491 * index of that image instead.
4492 * @param write_flags
4493 * Bitwise OR of flags prefixed with @c WIMLIB_WRITE_FLAG.
4494 * @param num_threads
4495 * The number of threads to use for compressing data, or 0 to have the
4496 * library automatically choose an appropriate number.
4498 * @return 0 on success; a ::wimlib_error_code value on failure.
4500 * @retval ::WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED
4501 * A file that had previously been scanned for inclusion in the WIM was
4502 * concurrently modified.
4503 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4504 * @p image did not exist in @p wim.
4505 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4506 * A file, stored in another WIM, which needed to be written was corrupt.
4507 * @retval ::WIMLIB_ERR_INVALID_PARAM
4508 * @p path was not a nonempty string, or invalid flags were passed.
4509 * @retval ::WIMLIB_ERR_OPEN
4510 * Failed to open the output WIM file for writing, or failed to open a file
4511 * whose data needed to be included in the WIM.
4512 * @retval ::WIMLIB_ERR_READ
4513 * Failed to read data that needed to be included in the WIM.
4514 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4515 * A file data blob that needed to be written could not be found in the
4516 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
4517 * @retval ::WIMLIB_ERR_WRITE
4518 * An error occurred when trying to write data to the new WIM file.
4520 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4521 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4522 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4523 * indicate failure (for different reasons) to read the data from a WIM file.
4525 * If a progress function is registered with @p wim, then it will receive the
4526 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4527 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4528 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4531 wimlib_write(WIMStruct *wim,
4532 const wimlib_tchar *path,
4535 unsigned num_threads);
4538 * @ingroup G_writing_and_overwriting_wims
4540 * Same as wimlib_write(), but write the WIM directly to a file descriptor,
4541 * which need not be seekable if the write is done in a special pipable WIM
4542 * format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p write_flags. This can,
4543 * for example, allow capturing a WIM image and streaming it over the network.
4544 * See @ref subsec_pipable_wims for more information about pipable WIMs.
4546 * The file descriptor @p fd will @b not be closed when the write is complete;
4547 * the calling code is responsible for this.
4549 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
4550 * error codes include those that can be returned by wimlib_write() as well as
4553 * @retval ::WIMLIB_ERR_INVALID_PARAM
4554 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4555 * specified in @p write_flags.
4558 wimlib_write_to_fd(WIMStruct *wim,
4562 unsigned num_threads);
4565 * @defgroup G_compression Compression and decompression functions
4567 * @brief Functions for XPRESS, LZX, and LZMS compression and decompression.
4569 * These functions are already used by wimlib internally when appropriate for
4570 * reading and writing WIM archives. But they are exported and documented so
4571 * that they can be used in other applications or libraries for general-purpose
4572 * lossless data compression. They are implemented in highly optimized C code,
4573 * using state-of-the-art compression techniques. The main limitation is the
4574 * lack of sliding window support; this has, however, allowed the algorithms to
4575 * be optimized for block-based compression.
4580 /** Opaque compressor handle. */
4581 struct wimlib_compressor;
4583 /** Opaque decompressor handle. */
4584 struct wimlib_decompressor;
4587 * Set the default compression level for the specified compression type. This
4588 * is the compression level that wimlib_create_compressor() assumes if it is
4589 * called with @p compression_level specified as 0.
4591 * wimlib's WIM writing code (e.g. wimlib_write()) will pass 0 to
4592 * wimlib_create_compressor() internally. Therefore, calling this function will
4593 * affect the compression level of any data later written to WIM files using the
4594 * specified compression type.
4596 * The initial state, before this function is called, is that all compression
4597 * types have a default compression level of 50.
4600 * Compression type for which to set the default compression level, as one
4601 * of the ::wimlib_compression_type constants. Or, if this is the special
4602 * value -1, the default compression levels for all compression types will
4604 * @param compression_level
4605 * The default compression level to set. If 0, the "default default" level
4606 * of 50 is restored. Otherwise, a higher value indicates higher
4607 * compression, whereas a lower value indicates lower compression. See
4608 * wimlib_create_compressor() for more information.
4610 * @return 0 on success; a ::wimlib_error_code value on failure.
4612 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4613 * @p ctype was neither a supported compression type nor -1.
4616 wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
4619 * Return the approximate number of bytes needed to allocate a compressor with
4620 * wimlib_create_compressor() for the specified compression type, maximum block
4621 * size, and compression level. @p compression_level may be 0, in which case
4622 * the current default compression level for @p ctype is used. Returns 0 if the
4623 * compression type is invalid, or the @p max_block_size for that compression
4627 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4628 size_t max_block_size,
4629 unsigned int compression_level);
4631 #define WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE 0x80000000
4634 * Allocate a compressor for the specified compression type using the specified
4635 * parameters. This function is part of wimlib's compression API; it is not
4636 * necessary to call this to process a WIM file.
4639 * Compression type for which to create the compressor, as one of the
4640 * ::wimlib_compression_type constants.
4641 * @param max_block_size
4642 * The maximum compression block size to support. This specifies the
4643 * maximum allowed value for the @p uncompressed_size parameter of
4644 * wimlib_compress() when called using this compressor.
4646 * Usually, the amount of memory used by the compressor will scale in
4647 * proportion to the @p max_block_size parameter.
4648 * wimlib_get_compressor_needed_memory() can be used to query the specific
4649 * amount of memory that will be required.
4651 * This parameter must be at least 1 and must be less than or equal to a
4652 * compression-type-specific limit.
4654 * In general, the same value of @p max_block_size must be passed to
4655 * wimlib_create_decompressor() when the data is later decompressed.
4656 * However, some compression types have looser requirements regarding this.
4657 * @param compression_level
4658 * The compression level to use. If 0, the default compression level (50,
4659 * or another value as set through wimlib_set_default_compression_level())
4660 * is used. Otherwise, a higher value indicates higher compression. The
4661 * values are scaled so that 10 is low compression, 50 is medium
4662 * compression, and 100 is high compression. This is not a percentage;
4663 * values above 100 are also valid.
4665 * Using a higher-than-default compression level can result in a better
4666 * compression ratio, but can significantly reduce performance. Similarly,
4667 * using a lower-than-default compression level can result in better
4668 * performance, but can significantly worsen the compression ratio. The
4669 * exact results will depend heavily on the compression type and what
4670 * algorithms are implemented for it. If you are considering using a
4671 * non-default compression level, you should run benchmarks to see if it is
4672 * worthwhile for your application.
4674 * The compression level does not affect the format of the compressed data.
4675 * Therefore, it is a compressor-only parameter and does not need to be
4676 * passed to the decompressor.
4678 * Since wimlib v1.8.0, this parameter can be OR-ed with the flag
4679 * ::WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE. This creates the compressor in a
4680 * mode where it is allowed to modify the input buffer. Specifically, in
4681 * this mode, if compression succeeds, the input buffer may have been
4682 * modified, whereas if compression does not succeed the input buffer still
4683 * may have been written to but will have been restored exactly to its
4684 * original state. This mode is designed to save some memory when using
4685 * large buffer sizes.
4686 * @param compressor_ret
4687 * A location into which to return the pointer to the allocated compressor.
4688 * The allocated compressor can be used for any number of calls to
4689 * wimlib_compress() before being freed with wimlib_free_compressor().
4691 * @return 0 on success; a ::wimlib_error_code value on failure.
4693 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4694 * @p ctype was not a supported compression type.
4695 * @retval ::WIMLIB_ERR_INVALID_PARAM
4696 * @p max_block_size was invalid for the compression type, or @p
4697 * compressor_ret was @c NULL.
4698 * @retval ::WIMLIB_ERR_NOMEM
4699 * Insufficient memory to allocate the compressor.
4702 wimlib_create_compressor(enum wimlib_compression_type ctype,
4703 size_t max_block_size,
4704 unsigned int compression_level,
4705 struct wimlib_compressor **compressor_ret);
4708 * Compress a buffer of data.
4710 * @param uncompressed_data
4711 * Buffer containing the data to compress.
4712 * @param uncompressed_size
4713 * Size, in bytes, of the data to compress. This cannot be greater than
4714 * the @p max_block_size with which wimlib_create_compressor() was called.
4715 * (If it is, the data will not be compressed and 0 will be returned.)
4716 * @param compressed_data
4717 * Buffer into which to write the compressed data.
4718 * @param compressed_size_avail
4719 * Number of bytes available in @p compressed_data.
4721 * A compressor previously allocated with wimlib_create_compressor().
4724 * The size of the compressed data, in bytes, or 0 if the data could not be
4725 * compressed to @p compressed_size_avail or fewer bytes.
4728 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4729 void *compressed_data, size_t compressed_size_avail,
4730 struct wimlib_compressor *compressor);
4733 * Free a compressor previously allocated with wimlib_create_compressor().
4736 * The compressor to free. If @c NULL, no action is taken.
4739 wimlib_free_compressor(struct wimlib_compressor *compressor);
4742 * Allocate a decompressor for the specified compression type. This function is
4743 * part of wimlib's compression API; it is not necessary to call this to process
4747 * Compression type for which to create the decompressor, as one of the
4748 * ::wimlib_compression_type constants.
4749 * @param max_block_size
4750 * The maximum compression block size to support. This specifies the
4751 * maximum allowed value for the @p uncompressed_size parameter of
4752 * wimlib_decompress().
4754 * In general, this parameter must be the same as the @p max_block_size
4755 * that was passed to wimlib_create_compressor() when the data was
4756 * compressed. However, some compression types have looser requirements
4758 * @param decompressor_ret
4759 * A location into which to return the pointer to the allocated
4760 * decompressor. The allocated decompressor can be used for any number of
4761 * calls to wimlib_decompress() before being freed with
4762 * wimlib_free_decompressor().
4764 * @return 0 on success; a ::wimlib_error_code value on failure.
4766 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4767 * @p ctype was not a supported compression type.
4768 * @retval ::WIMLIB_ERR_INVALID_PARAM
4769 * @p max_block_size was invalid for the compression type, or @p
4770 * decompressor_ret was @c NULL.
4771 * @retval ::WIMLIB_ERR_NOMEM
4772 * Insufficient memory to allocate the decompressor.
4775 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4776 size_t max_block_size,
4777 struct wimlib_decompressor **decompressor_ret);
4780 * Decompress a buffer of data.
4782 * @param compressed_data
4783 * Buffer containing the data to decompress.
4784 * @param compressed_size
4785 * Size, in bytes, of the data to decompress.
4786 * @param uncompressed_data
4787 * Buffer into which to write the uncompressed data.
4788 * @param uncompressed_size
4789 * Size, in bytes, of the data when uncompressed. This cannot exceed the
4790 * @p max_block_size with which wimlib_create_decompressor() was called.
4791 * (If it does, the data will not be decompressed and a nonzero value will
4793 * @param decompressor
4794 * A decompressor previously allocated with wimlib_create_decompressor().
4796 * @return 0 on success; nonzero on failure.
4798 * No specific error codes are defined; any nonzero value indicates that the
4799 * decompression failed. This can only occur if the data is truly invalid;
4800 * there will never be transient errors like "out of memory", for example.
4802 * This function requires that the exact uncompressed size of the data be passed
4803 * as the @p uncompressed_size parameter. If this is not done correctly,
4804 * decompression may fail or the data may be decompressed incorrectly.
4807 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4808 void *uncompressed_data, size_t uncompressed_size,
4809 struct wimlib_decompressor *decompressor);
4812 * Free a decompressor previously allocated with wimlib_create_decompressor().
4814 * @param decompressor
4815 * The decompressor to free. If @c NULL, no action is taken.
4818 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4830 #endif /* _WIMLIB_H */