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.13.6, a C
15 * library for creating, modifying, extracting, and mounting files in the
16 * Windows Imaging (WIM) format. This documentation is intended for developers
17 * only. If you have installed wimlib and want to know how to use the @b
18 * wimlib-imagex program, please see the manual pages and also the <a
19 * href="https://wimlib.net/git/?p=wimlib;a=blob;f=README.md">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 * from https://wimlib.net. Link your program with libwim-15.dll. If needed by
34 * your programming language or development environment, the import library
35 * libwim.lib and C/C++ header wimlib.h can be found in the directory "devel" in
38 * If you need to access the DLL from non-C/C++ programming languages, note that
39 * the calling convention is "cdecl".
41 * If you want to build wimlib from source on Windows, see README.WINDOWS. This
42 * is only needed if you are making modifications to wimlib.
44 * @section sec_examples Examples
46 * Several examples are located in the "examples" directory of the source
47 * distribution. Also see @ref sec_basic_wim_handling_concepts below.
49 * There is also the <a
50 * href="https://wimlib.net/git/?p=wimlib;a=blob;f=programs/imagex.c">
51 * source code of <b>wimlib-imagex</b></a>, which is complicated but uses most
52 * capabilities of wimlib.
54 * @section backward_compatibility Backward Compatibility
56 * New releases of wimlib are intended to be backward compatible with old
57 * releases, except when the libtool "age" is reset. This most recently
58 * occurred for the v1.7.0 (libwim15) release (June 2014). Since the library is
59 * becoming increasingly stable, the goal is to maintain the current API/ABI for
60 * as long as possible unless there is a strong reason not to.
62 * As with any other library, applications should not rely on internal
63 * implementation details that may be subject to change.
65 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
67 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
68 * two ways to create such a structure:
70 * 1. wimlib_open_wim() opens an on-disk WIM file and creates a ::WIMStruct for
72 * 2. wimlib_create_new_wim() creates a new ::WIMStruct that initially contains
73 * no images and does not yet have a backing on-disk file.
75 * A ::WIMStruct contains zero or more independent directory trees called @a
76 * images. Images may be extracted, added, deleted, exported, and updated using
77 * various API functions. (See @ref G_extracting_wims and @ref G_modifying_wims
80 * Changes made to a WIM represented by a ::WIMStruct have no persistent effect
81 * until the WIM is actually written to an on-disk file. This can be done using
82 * wimlib_write(), but if the WIM was originally opened using wimlib_open_wim(),
83 * then wimlib_overwrite() can be used instead. (See @ref
84 * G_writing_and_overwriting_wims for more details.)
86 * wimlib's API is designed to let you combine functions to accomplish tasks in
87 * a flexible way. Here are some example sequences of function calls:
89 * Apply an image from a WIM file, similar to the command-line program
92 * 1. wimlib_open_wim()
93 * 2. wimlib_extract_image()
95 * Capture an image into a new WIM file, similar to <b>wimcapture</b>:
97 * 1. wimlib_create_new_wim()
98 * 2. wimlib_add_image()
101 * Append an image to an existing WIM file, similar to <b>wimappend</b>:
103 * 1. wimlib_open_wim()
104 * 2. wimlib_add_image()
105 * 3. wimlib_overwrite()
107 * Delete an image from an existing WIM file, similar to <b>wimdelete</b>:
109 * 1. wimlib_open_wim()
110 * 2. wimlib_delete_image()
111 * 3. wimlib_overwrite()
113 * Export an image from one WIM file to another, similar to <b>wimexport</b>:
115 * 1. wimlib_open_wim() (on source)
116 * 2. wimlib_open_wim() (on destination)
117 * 3. wimlib_export_image()
118 * 4. wimlib_overwrite() (on destination)
120 * The API also lets you do things the command-line tools don't directly allow.
121 * For example, you could make multiple changes to a WIM before efficiently
122 * committing the changes with just one call to wimlib_overwrite(). Perhaps you
123 * want to both delete an image and add a new one; or perhaps you want to
124 * customize an image with wimlib_update_image() after adding it. All these use
125 * cases are supported by the API.
127 * @section sec_cleaning_up Cleaning up
129 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
130 * all resources associated with it. Also, when you are completely done with
131 * using wimlib in your program, you can call wimlib_global_cleanup() to free
132 * any other resources allocated by the library.
134 * @section sec_error_handling Error Handling
136 * Most functions in wimlib return 0 on success and a positive
137 * ::wimlib_error_code value on failure. Use wimlib_get_error_string() to get a
138 * string that describes an error code. wimlib also can print error messages to
139 * standard error or a custom file when an error occurs, and these may be more
140 * informative than the error code; to enable this, call
141 * wimlib_set_print_errors(). Please note that this is for convenience only,
142 * and some errors can occur without a message being printed. Currently, error
143 * messages and strings (as well as all documentation, for that matter) are only
144 * available in English.
146 * @section sec_encodings Character encoding
148 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
149 * and returns strings of ::wimlib_tchar which have a platform-dependent type
152 * On Windows, each ::wimlib_tchar is a 2-byte <tt>wchar_t</tt>. The encoding
153 * is meant to be UTF-16LE. However, unpaired surrogates are permitted because
154 * neither Windows nor the NTFS filesystem forbids them in filenames.
156 * On UNIX-like systems, each ::wimlib_tchar is a 1 byte <tt>char</tt>. The
157 * encoding is meant to be UTF-8. However, for compatibility with Windows-style
158 * filenames that are not valid UTF-16LE, surrogate codepoints are permitted.
159 * Other multibyte encodings (e.g. ISO-8859-1) or garbage sequences of bytes are
162 * @section sec_advanced Additional information and features
165 * @subsection subsec_mounting_wim_images Mounting WIM images
167 * See @ref G_mounting_wim_images.
169 * @subsection subsec_progress_functions Progress Messages
171 * See @ref G_progress.
173 * @subsection subsec_non_standalone_wims Non-standalone WIMs
175 * See @ref G_nonstandalone_wims.
177 * @subsection subsec_pipable_wims Pipable WIMs
179 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
180 * compatible with Microsoft's software. To create a pipable WIM, call
181 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
182 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
183 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
184 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
185 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
186 * s using a seekable file descriptor using the regular function calls (e.g.
187 * wimlib_open_wim(), wimlib_extract_image()).
189 * See the documentation for the <b>--pipable</b> flag of <b>wimcapture</b> for
190 * more information about pipable WIMs.
192 * @subsection subsec_thread_safety Thread Safety
194 * A ::WIMStruct is not thread-safe and cannot be accessed by multiple threads
195 * concurrently, even for "read-only" operations such as extraction. However,
196 * users are free to use <i>different</i> ::WIMStruct's from different threads
197 * concurrently. It is even allowed for multiple ::WIMStruct's to be backed by
198 * the same on-disk WIM file, although "overwrites" should never be done in such
201 * In addition, several functions change global state and should only be called
202 * when a single thread is active in the library. These functions are:
204 * - wimlib_global_init()
205 * - wimlib_global_cleanup()
206 * - wimlib_set_memory_allocator()
207 * - wimlib_set_print_errors()
208 * - wimlib_set_error_file()
209 * - wimlib_set_error_file_by_name()
211 * @subsection subsec_limitations Limitations
213 * This section documents some technical limitations of wimlib not already
214 * described in the documentation for @b wimlib-imagex.
216 * - The old WIM format from Vista pre-releases is not supported.
217 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
218 * functionality other than that already present in @b ImageX, that allows you
219 * to make certain Windows-specific modifications to a Windows PE image, such
220 * as adding a driver or Windows component. Such a tool could be implemented
223 * @subsection more_info More information
225 * You are advised to read the README as well as the documentation for
226 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
227 * the API documentation.
230 /** @defgroup G_general General
232 * @brief Declarations and structures shared across the library.
235 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
237 * @brief Open an existing WIM file as a ::WIMStruct, or create a new
238 * ::WIMStruct which can be used to create a new WIM file.
241 /** @defgroup G_wim_information Retrieving WIM information and directory listings
243 * @brief Retrieve information about a WIM or WIM image.
246 /** @defgroup G_modifying_wims Modifying WIMs
248 * @brief Make changes to a ::WIMStruct, in preparation of persisting the
249 * ::WIMStruct to an on-disk file.
251 * @section sec_adding_images Capturing and adding WIM images
253 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
254 * appending an image to an existing WIM is a multi-step process, but at its
255 * core is wimlib_add_image() or an equivalent function. Normally,
256 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
257 * ::WIMStruct as a new image. However, when supported by the build of the
258 * library, there is also a special NTFS volume capture mode (entered when
259 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
260 * from an unmounted NTFS volume.
262 * Another function, wimlib_add_image_multisource() is also provided. It
263 * generalizes wimlib_add_image() to allow combining multiple files or directory
264 * trees into a single WIM image in a configurable way.
266 * For maximum customization of WIM image creation, it is also possible to add a
267 * completely empty WIM image with wimlib_add_empty_image(), then update it with
268 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
269 * wimlib_add_image_multisource() do internally.)
271 * Note that some details of how image addition/capture works are documented
272 * more fully in the documentation for <b>wimcapture</b>.
274 * @section sec_deleting_images Deleting WIM images
276 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
277 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
278 * be made persistent in an on-disk WIM file.
280 * @section sec_exporting_images Exporting WIM images
282 * wimlib_export_image() can copy, or "export", an image from one WIM to
285 * @section sec_other_modifications Other modifications
287 * wimlib_update_image() can add, delete, and rename files in a WIM image.
289 * wimlib_set_image_property() can change other image metadata.
291 * wimlib_set_wim_info() can change information about the WIM file itself, such
295 /** @defgroup G_extracting_wims Extracting WIMs
297 * @brief Extract files, directories, and images from a WIM.
299 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
300 * represented by a ::WIMStruct. This normally extracts the image to a
301 * directory, but when supported by the build of the library there is also a
302 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
303 * is specified) that allows extracting a WIM image directly to an unmounted
304 * NTFS volume. Various other flags allow further customization of image
307 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
308 * of (possibly wildcard) paths from a WIM image.
310 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
311 * over a pipe; see @ref subsec_pipable_wims.
313 * Some details of how WIM extraction works are described more fully in the
314 * documentation for <b>wimapply</b> and <b>wimextract</b>.
317 /** @defgroup G_mounting_wim_images Mounting WIM images
319 * @brief Mount and unmount WIM images.
321 * On Linux, wimlib supports mounting images from WIM files either read-only or
322 * read-write. To mount an image, call wimlib_mount_image(). To unmount an
323 * image, call wimlib_unmount_image(). Mounting can be done without root
324 * privileges because it is implemented using FUSE (Filesystem in Userspace).
326 * If wimlib is compiled using the <c>--without-fuse</c> flag, these functions
327 * will be available but will fail with ::WIMLIB_ERR_UNSUPPORTED.
329 * Note: if mounting is unsupported, wimlib still provides another way to modify
330 * a WIM image (wimlib_update_image()).
334 * @defgroup G_progress Progress Messages
336 * @brief Track the progress of long WIM operations.
338 * Library users can provide a progress function which will be called
339 * periodically during operations such as extracting a WIM image or writing a
340 * WIM image. A ::WIMStruct can have a progress function of type
341 * ::wimlib_progress_func_t associated with it by calling
342 * wimlib_register_progress_function() or by opening the ::WIMStruct using
343 * wimlib_open_wim_with_progress(). Once this is done, the progress function
344 * will be called automatically during many operations, such as
345 * wimlib_extract_image() and wimlib_write().
347 * Some functions that do not operate directly on a user-provided ::WIMStruct,
348 * such as wimlib_join(), also take the progress function directly using an
349 * extended version of the function, such as wimlib_join_with_progress().
351 * Since wimlib v1.7.0, progress functions are no longer just unidirectional.
352 * You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause the current
353 * operation to be aborted. wimlib v1.7.0 also added the third argument to
354 * ::wimlib_progress_func_t, which is a user-supplied context.
357 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
359 * @brief Create or update an on-disk WIM file.
361 * wimlib_write() creates a new on-disk WIM file, whereas wimlib_overwrite()
362 * updates an existing WIM file. See @ref sec_basic_wim_handling_concepts for
363 * more information about the API design.
366 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
368 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
370 * A ::WIMStruct backed by an on-disk file normally represents a fully
371 * standalone WIM archive. However, WIM archives can also be arranged in
372 * non-standalone ways, such as a set of on-disk files that together form a
373 * single "split WIM" or "delta WIM". Such arrangements are fully supported by
374 * wimlib. However, as a result, in such cases a ::WIMStruct created from one
375 * of these on-disk files initially only partially represents the full WIM and
376 * needs to, in effect, be logically combined with other ::WIMStruct's before
377 * performing certain operations, such as extracting files with
378 * wimlib_extract_image() or wimlib_extract_paths(). This is done by calling
379 * wimlib_reference_resource_files() or wimlib_reference_resources(). Note: if
380 * you fail to do so, you may see the error code
381 * ::WIMLIB_ERR_RESOURCE_NOT_FOUND; this just indicates that data is not
382 * available because the appropriate WIM files have not yet been referenced.
384 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
385 * specialized function (wimlib_split()) is needed to create a split WIM.
394 # if defined(_MSC_VER) && _MSC_VER < 1800 /* VS pre-2013? */
395 typedef unsigned char bool;
397 # include <stdbool.h>
403 #ifdef BUILDING_WIMLIB
405 # define WIMLIBAPI __declspec(dllexport)
407 # define WIMLIBAPI __attribute__((visibility("default")))
413 /** @addtogroup G_general
416 /** Major version of the library (for example, the 1 in 1.2.5). */
417 #define WIMLIB_MAJOR_VERSION 1
419 /** Minor version of the library (for example, the 2 in 1.2.5). */
420 #define WIMLIB_MINOR_VERSION 13
422 /** Patch version of the library (for example, the 5 in 1.2.5). */
423 #define WIMLIB_PATCH_VERSION 6
430 * To represent file timestamps, wimlib's API originally used the POSIX 'struct
431 * timespec'. This was a mistake because when building wimlib for 32-bit
432 * Windows with MinGW we ended up originally using 32-bit time_t which isn't
433 * year 2038-safe, and therefore we had to later add fields like
434 * 'creation_time_high' to hold the high 32 bits of each timestamp. Moreover,
435 * old Visual Studio versions did not define struct timespec, while newer ones
436 * define it but with 64-bit tv_sec. So to at least avoid a missing or
437 * incompatible 'struct timespec' definition, define the correct struct
438 * ourselves when this header is included on Windows.
441 struct wimlib_timespec {
442 /* Seconds since start of UNIX epoch (January 1, 1970) */
448 /* Nanoseconds (0-999999999) */
452 # define wimlib_timespec timespec /* standard definition */
456 * Opaque structure that represents a WIM, possibly backed by an on-disk file.
457 * See @ref sec_basic_wim_handling_concepts for more information.
459 #ifndef WIMLIB_WIMSTRUCT_DECLARED
460 typedef struct WIMStruct WIMStruct;
461 #define WIMLIB_WIMSTRUCT_DECLARED
465 typedef wchar_t wimlib_tchar;
467 /** See @ref sec_encodings */
468 typedef char wimlib_tchar;
472 /** Path separator for WIM paths passed back to progress callbacks.
473 * This is forward slash on UNIX and backslash on Windows. */
474 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
475 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
477 /** Path separator for WIM paths passed back to progress callbacks.
478 * This is forward slash on UNIX and backslash on Windows. */
479 # define WIMLIB_WIM_PATH_SEPARATOR '/'
480 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
483 /** A string containing a single path separator; use this to specify the root
484 * directory of a WIM image. */
485 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
487 /** Use this to test if the specified path refers to the root directory of the
489 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
490 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
493 /** Length of a Globally Unique Identifier (GUID), in bytes. */
494 #define WIMLIB_GUID_LEN 16
497 * Specifies a compression type.
499 * A WIM file has a default compression type, indicated by its file header.
500 * Normally, each resource in the WIM file is compressed with this compression
501 * type. However, resources may be stored as uncompressed; for example, wimlib
502 * may do so if a resource does not compress to less than its original size. In
503 * addition, a WIM with the new version number of 3584, or "ESD file", might
504 * contain solid resources with different compression types.
506 enum wimlib_compression_type {
510 * This is a valid argument to wimlib_create_new_wim() and
511 * wimlib_set_output_compression_type(), but not to the functions in the
512 * compression API such as wimlib_create_compressor().
514 WIMLIB_COMPRESSION_TYPE_NONE = 0,
517 * The XPRESS compression format. This format combines Lempel-Ziv
518 * factorization with Huffman encoding. Compression and decompression
519 * are both fast. This format supports chunk sizes that are powers of 2
520 * between <c>2^12</c> and <c>2^16</c>, inclusively.
522 * wimlib's XPRESS compressor will, with the default settings, usually
523 * produce a better compression ratio, and work more quickly, than the
524 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
525 * Non-default compression levels are also supported. For example,
526 * level 80 will enable two-pass optimal parsing, which is significantly
527 * slower but usually improves compression by several percent over the
528 * default level of 50.
530 * If using wimlib_create_compressor() to create an XPRESS compressor
531 * directly, the @p max_block_size parameter may be any positive value
532 * up to and including <c>2^16</c>.
534 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
537 * The LZX compression format. This format combines Lempel-Ziv
538 * factorization with Huffman encoding, but with more features and
539 * complexity than XPRESS. Compression is slow to somewhat fast,
540 * depending on the settings. Decompression is fast but slower than
541 * XPRESS. This format supports chunk sizes that are powers of 2
542 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
543 * other than <c>2^15</c> are not compatible with the Microsoft
546 * wimlib's LZX compressor will, with the default settings, usually
547 * produce a better compression ratio, and work more quickly, than the
548 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
549 * Non-default compression levels are also supported. For example,
550 * level 20 will provide fast compression, almost as fast as XPRESS.
552 * If using wimlib_create_compressor() to create an LZX compressor
553 * directly, the @p max_block_size parameter may be any positive value
554 * up to and including <c>2^21</c>.
556 WIMLIB_COMPRESSION_TYPE_LZX = 2,
559 * The LZMS compression format. This format combines Lempel-Ziv
560 * factorization with adaptive Huffman encoding and range coding.
561 * Compression and decompression are both fairly slow. This format
562 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
563 * <c>2^30</c>, inclusively. This format is best used for large chunk
564 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
565 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
566 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
567 * with the Microsoft implementation.
569 * wimlib's LZMS compressor will, with the default settings, usually
570 * produce a better compression ratio, and work more quickly, than the
571 * implementation in Microsoft's WIMGAPI (as of Windows 8.1). There is
572 * limited support for non-default compression levels, but compression
573 * will be noticeably faster if you choose a level < 35.
575 * If using wimlib_create_compressor() to create an LZMS compressor
576 * directly, the @p max_block_size parameter may be any positive value
577 * up to and including <c>2^30</c>.
579 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
583 /** @addtogroup G_progress
586 /** Possible values of the first parameter to the user-supplied
587 * ::wimlib_progress_func_t progress function */
588 enum wimlib_progress_msg {
590 /** A WIM image is about to be extracted. @p info will point to
591 * ::wimlib_progress_info.extract. This message is received once per
592 * image for calls to wimlib_extract_image() and
593 * wimlib_extract_image_from_pipe(). */
594 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
596 /** One or more file or directory trees within a WIM image is about to
597 * be extracted. @p info will point to ::wimlib_progress_info.extract.
598 * This message is received only once per wimlib_extract_paths() and
599 * wimlib_extract_pathlist(), since wimlib combines all paths into a
600 * single extraction operation for optimization purposes. */
601 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
603 /** This message may be sent periodically (not for every file) while
604 * files and directories are being created, prior to file data
605 * extraction. @p info will point to ::wimlib_progress_info.extract.
606 * In particular, the @p current_file_count and @p end_file_count
607 * members may be used to track the progress of this phase of
609 WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE = 3,
611 /** File data is currently being extracted. @p info will point to
612 * ::wimlib_progress_info.extract. This is the main message to track
613 * the progress of an extraction operation. */
614 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
616 /** Starting to read a new part of a split pipable WIM over the pipe.
617 * @p info will point to ::wimlib_progress_info.extract. */
618 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
620 /** This message may be sent periodically (not necessarily for every
621 * file) while file and directory metadata is being extracted, following
622 * file data extraction. @p info will point to
623 * ::wimlib_progress_info.extract. The @p current_file_count and @p
624 * end_file_count members may be used to track the progress of this
625 * phase of extraction. */
626 WIMLIB_PROGRESS_MSG_EXTRACT_METADATA = 6,
628 /** The image has been successfully extracted. @p info will point to
629 * ::wimlib_progress_info.extract. This is paired with
630 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
631 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
633 /** The files or directory trees have been successfully extracted. @p
634 * info will point to ::wimlib_progress_info.extract. This is paired
635 * with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
636 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
638 /** The directory or NTFS volume is about to be scanned for metadata.
639 * @p info will point to ::wimlib_progress_info.scan. This message is
640 * received once per call to wimlib_add_image(), or once per capture
641 * source passed to wimlib_add_image_multisource(), or once per add
642 * command passed to wimlib_update_image(). */
643 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
645 /** A directory or file has been scanned. @p info will point to
646 * ::wimlib_progress_info.scan, and its @p cur_path member will be
647 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
649 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
651 /** The directory or NTFS volume has been successfully scanned. @p info
652 * will point to ::wimlib_progress_info.scan. This is paired with a
653 * previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message, possibly with many
654 * intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY messages. */
655 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
657 /** File data is currently being written to the WIM. @p info will point
658 * to ::wimlib_progress_info.write_streams. This message may be
659 * received many times while the WIM file is being written or appended
660 * to with wimlib_write(), wimlib_overwrite(), or wimlib_write_to_fd().
661 * Since wimlib v1.13.4 it will also be received when a split WIM part
662 * is being written by wimlib_split(). */
663 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
665 /** Per-image metadata is about to be written to the WIM file. @p info
666 * will not be valid. */
667 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
669 /** The per-image metadata has been written to the WIM file. @p info
670 * will not be valid. This message is paired with a preceding
671 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message. */
672 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
674 /** wimlib_overwrite() has successfully renamed the temporary file to
675 * the original WIM file, thereby committing the changes to the WIM
676 * file. @p info will point to ::wimlib_progress_info.rename. Note:
677 * this message is not received if wimlib_overwrite() chose to append to
678 * the WIM file in-place. */
679 WIMLIB_PROGRESS_MSG_RENAME = 15,
681 /** The contents of the WIM file are being checked against the integrity
682 * table. @p info will point to ::wimlib_progress_info.integrity. This
683 * message is only received (and may be received many times) when
684 * wimlib_open_wim_with_progress() is called with the
685 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
686 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
688 /** An integrity table is being calculated for the WIM being written.
689 * @p info will point to ::wimlib_progress_info.integrity. This message
690 * is only received (and may be received many times) when a WIM file is
691 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
692 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
694 /** A wimlib_split() operation is in progress, and a new split part is
695 * about to be started. @p info will point to
696 * ::wimlib_progress_info.split. */
697 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
699 /** A wimlib_split() operation is in progress, and a split part has been
700 * finished. @p info will point to ::wimlib_progress_info.split. */
701 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
703 /** A WIM update command is about to be executed. @p info will point to
704 * ::wimlib_progress_info.update. This message is received once per
705 * update command when wimlib_update_image() is called with the flag
706 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
707 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
709 /** A WIM update command has been executed. @p info will point to
710 * ::wimlib_progress_info.update. This message is received once per
711 * update command when wimlib_update_image() is called with the flag
712 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
713 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
715 /** A file in the image is being replaced as a result of a
716 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
717 * @p info will point to ::wimlib_progress_info.replace. This is only
718 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
720 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
722 /** An image is being extracted with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
723 * a file is being extracted normally (not as a "WIMBoot pointer file")
724 * due to it matching a pattern in the <c>[PrepopulateList]</c> section
725 * of the configuration file
726 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image. @p
727 * info will point to ::wimlib_progress_info.wimboot_exclude. */
728 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
730 /** Starting to unmount an image. @p info will point to
731 * ::wimlib_progress_info.unmount. */
732 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
734 /** wimlib has used a file's data for the last time (including all data
735 * streams, if it has multiple). @p info will point to
736 * ::wimlib_progress_info.done_with_file. This message is only received
737 * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided. */
738 WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
740 /** wimlib_verify_wim() is starting to verify the metadata for an image.
741 * @p info will point to ::wimlib_progress_info.verify_image. */
742 WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
744 /** wimlib_verify_wim() has finished verifying the metadata for an
745 * image. @p info will point to ::wimlib_progress_info.verify_image.
747 WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
749 /** wimlib_verify_wim() is verifying file data integrity. @p info will
750 * point to ::wimlib_progress_info.verify_streams. */
751 WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
754 * The progress function is being asked whether a file should be
755 * excluded from capture or not. @p info will point to
756 * ::wimlib_progress_info.test_file_exclusion. This is a bidirectional
757 * message that allows the progress function to set a flag if the file
758 * should be excluded.
760 * This message is only received if the flag
761 * ::WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION is used. This method for file
762 * exclusions is independent of the "capture configuration file"
765 WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION = 30,
768 * An error has occurred and the progress function is being asked
769 * whether to ignore the error or not. @p info will point to
770 * ::wimlib_progress_info.handle_error. This is a bidirectional
773 * This message provides a limited capability for applications to
774 * recover from "unexpected" errors (i.e. those with no in-library
775 * handling policy) arising from the underlying operating system.
776 * Normally, any such error will cause the library to abort the current
777 * operation. By implementing a handler for this message, the
778 * application can instead choose to ignore a given error.
780 * Currently, only the following types of errors will result in this
781 * progress message being sent:
783 * - Directory tree scan errors, e.g. from wimlib_add_image()
784 * - Most extraction errors; currently restricted to the Windows
785 * build of the library only.
787 WIMLIB_PROGRESS_MSG_HANDLE_ERROR = 31,
790 /** Valid return values from user-provided progress functions
791 * (::wimlib_progress_func_t).
793 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
796 enum wimlib_progress_status {
798 /** The operation should be continued. This is the normal return value.
800 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
802 /** The operation should be aborted. This will cause the current
803 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
804 WIMLIB_PROGRESS_STATUS_ABORT = 1,
808 * A pointer to this union is passed to the user-supplied
809 * ::wimlib_progress_func_t progress function. One (or none) of the structures
810 * contained in this union will be applicable for the operation
811 * (::wimlib_progress_msg) indicated in the first argument to the progress
813 union wimlib_progress_info {
815 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
816 * the primary message for tracking the progress of writing a WIM file.
818 struct wimlib_progress_info_write_streams {
820 /** An upper bound on the number of bytes of file data that will
821 * be written. This number is the uncompressed size; the actual
822 * size may be lower due to compression. In addition, this
823 * number may decrease over time as duplicated file data is
825 uint64_t total_bytes;
827 /** An upper bound on the number of distinct file data "blobs"
828 * that will be written. This will often be similar to the
829 * "number of files", but for several reasons (hard links, named
830 * data streams, empty files, etc.) it can be different. In
831 * addition, this number may decrease over time as duplicated
832 * file data is discovered. */
833 uint64_t total_streams;
835 /** The number of bytes of file data that have been written so
836 * far. This starts at 0 and ends at @p total_bytes. This
837 * number is the uncompressed size; the actual size may be lower
838 * due to compression. See @p completed_compressed_bytes for
839 * the compressed size. */
840 uint64_t completed_bytes;
842 /** The number of distinct file data "blobs" that have been
843 * written so far. This starts at 0 and ends at @p
845 uint64_t completed_streams;
847 /** The number of threads being used for data compression; or,
848 * if no compression is being performed, this will be 1. */
849 uint32_t num_threads;
851 /** The compression type being used, as one of the
852 * ::wimlib_compression_type constants. */
853 int32_t compression_type;
855 /** The number of on-disk WIM files from which file data is
856 * being exported into the output WIM file. This can be 0, 1,
857 * or more than 1, depending on the situation. */
858 uint32_t total_parts;
860 /** This is currently broken and will always be 0. */
861 uint32_t completed_parts;
863 /** Since wimlib v1.13.4: Like @p completed_bytes, but counts
864 * the compressed size. */
865 uint64_t completed_compressed_bytes;
868 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
869 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
870 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
871 struct wimlib_progress_info_scan {
873 /** Top-level directory being scanned; or, when capturing an NTFS
874 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
875 * to the file or block device that contains the NTFS volume
877 const wimlib_tchar *source;
879 /** Path to the file (or directory) that has been scanned, valid
880 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
881 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
882 * relative to the root of the NTFS volume. */
883 const wimlib_tchar *cur_path;
885 /** Dentry scan status, valid on
886 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
888 /** File looks okay and will be captured. */
889 WIMLIB_SCAN_DENTRY_OK = 0,
891 /** File is being excluded from capture due to the
892 * capture configuration. */
893 WIMLIB_SCAN_DENTRY_EXCLUDED = 1,
895 /** File is being excluded from capture due to being of
896 * an unsupported type. */
897 WIMLIB_SCAN_DENTRY_UNSUPPORTED = 2,
899 /** The file is an absolute symbolic link or junction
900 * that points into the capture directory, and
901 * reparse-point fixups are enabled, so its target is
902 * being adjusted. (Reparse point fixups can be
903 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
905 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK = 3,
907 /** Reparse-point fixups are enabled, but the file is an
908 * absolute symbolic link or junction that does
909 * <b>not</b> point into the capture directory, so its
910 * target is <b>not</b> being adjusted. */
911 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK = 4,
915 /** Target path in the image. Only valid on messages
916 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
917 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
918 const wimlib_tchar *wim_target_path;
920 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
921 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
922 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
923 * target of the absolute symbolic link or junction. */
924 const wimlib_tchar *symlink_target;
927 /** The number of directories scanned so far, not counting
928 * excluded/unsupported files. */
929 uint64_t num_dirs_scanned;
931 /** The number of non-directories scanned so far, not counting
932 * excluded/unsupported files. */
933 uint64_t num_nondirs_scanned;
935 /** The number of bytes of file data detected so far, not
936 * counting excluded/unsupported files. */
937 uint64_t num_bytes_scanned;
940 /** Valid on messages
941 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
942 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
943 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
944 * ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE,
945 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
946 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA,
947 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
948 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
950 * Note: most of the time of an extraction operation will be spent
951 * extracting file data, and the application will receive
952 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
953 * completed_bytes and @p total_bytes, the application can calculate a
954 * percentage complete. However, there is no way for applications to
955 * know which file is currently being extracted. This is by design
956 * because the best way to complete the extraction operation is not
957 * necessarily file-by-file.
959 struct wimlib_progress_info_extract {
961 /** The 1-based index of the image from which files are being
965 /** Extraction flags being used. */
966 uint32_t extract_flags;
968 /** If the ::WIMStruct from which the extraction being performed
969 * has a backing file, then this is an absolute path to that
970 * backing file. Otherwise, this is @c NULL. */
971 const wimlib_tchar *wimfile_name;
973 /** Name of the image from which files are being extracted, or
974 * the empty string if the image is unnamed. */
975 const wimlib_tchar *image_name;
977 /** Path to the directory or NTFS volume to which the files are
978 * being extracted. */
979 const wimlib_tchar *target;
982 const wimlib_tchar *reserved;
984 /** The number of bytes of file data that will be extracted. */
985 uint64_t total_bytes;
987 /** The number of bytes of file data that have been extracted so
988 * far. This starts at 0 and ends at @p total_bytes. */
989 uint64_t completed_bytes;
991 /** The number of file streams that will be extracted. This
992 * will often be similar to the "number of files", but for
993 * several reasons (hard links, named data streams, empty files,
994 * etc.) it can be different. */
995 uint64_t total_streams;
997 /** The number of file streams that have been extracted so far.
998 * This starts at 0 and ends at @p total_streams. */
999 uint64_t completed_streams;
1001 /** Currently only used for
1002 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
1003 uint32_t part_number;
1005 /** Currently only used for
1006 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
1007 uint32_t total_parts;
1009 /** Currently only used for
1010 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
1011 uint8_t guid[WIMLIB_GUID_LEN];
1013 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
1014 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is the
1015 * number of files that have been processed so far. Once the
1016 * corresponding phase of extraction is complete, this value
1017 * will be equal to @c end_file_count. */
1018 uint64_t current_file_count;
1020 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
1021 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is
1022 * total number of files that will be processed.
1024 * This number is provided for informational purposes only, e.g.
1025 * for a progress bar. This number will not necessarily be
1026 * equal to the number of files actually being extracted. This
1027 * is because extraction backends are free to implement an
1028 * extraction algorithm that might be more efficient than
1029 * processing every file in the "extract file structure" and
1030 * "extract file metadata" phases. For example, the current
1031 * implementation of the UNIX extraction backend will create
1032 * files on-demand during the "extract file data" phase.
1033 * Therefore, when using that particular extraction backend, @p
1034 * end_file_count will only include directories and empty files.
1036 uint64_t end_file_count;
1039 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
1040 struct wimlib_progress_info_rename {
1041 /** Name of the temporary file that the WIM was written to. */
1042 const wimlib_tchar *from;
1044 /** Name of the original WIM file to which the temporary file is
1046 const wimlib_tchar *to;
1049 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1050 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
1051 struct wimlib_progress_info_update {
1052 /** Pointer to the update command that will be executed or has
1053 * just been executed. */
1054 const struct wimlib_update_command *command;
1056 /** Number of update commands that have been completed so far.
1058 size_t completed_commands;
1060 /** Number of update commands that are being executed as part of
1061 * this call to wimlib_update_image(). */
1062 size_t total_commands;
1065 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
1066 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
1067 struct wimlib_progress_info_integrity {
1069 /** The number of bytes in the WIM file that are covered by
1070 * integrity checks. */
1071 uint64_t total_bytes;
1073 /** The number of bytes that have been checksummed so far. This
1074 * starts at 0 and ends at @p total_bytes. */
1075 uint64_t completed_bytes;
1077 /** The number of individually checksummed "chunks" the
1078 * integrity-checked region is divided into. */
1079 uint32_t total_chunks;
1081 /** The number of chunks that have been checksummed so far.
1082 * This starts at 0 and ends at @p total_chunks. */
1083 uint32_t completed_chunks;
1085 /** The size of each individually checksummed "chunk" in the
1086 * integrity-checked region. */
1087 uint32_t chunk_size;
1089 /** For ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages, this is
1090 * the path to the WIM file being checked. */
1091 const wimlib_tchar *filename;
1094 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
1095 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
1096 struct wimlib_progress_info_split {
1097 /** Total size of the original WIM's file and metadata resources
1099 uint64_t total_bytes;
1101 /** Number of bytes of file and metadata resources that have
1102 * been copied out of the original WIM so far. Will be 0
1103 * initially, and equal to @p total_bytes at the end. */
1104 uint64_t completed_bytes;
1106 /** Number of the split WIM part that is about to be started
1107 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1108 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
1109 unsigned cur_part_number;
1111 /** Total number of split WIM parts that are being written. */
1112 unsigned total_parts;
1114 /** Name of the split WIM part that is about to be started
1115 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1116 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). Since
1117 * wimlib v1.7.0, the library user may change this when
1118 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
1119 * cause the next split WIM part to be written to a different
1121 wimlib_tchar *part_name;
1124 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
1125 struct wimlib_progress_info_replace {
1126 /** Path to the file in the image that is being replaced */
1127 const wimlib_tchar *path_in_wim;
1130 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1131 struct wimlib_progress_info_wimboot_exclude {
1132 /** Path to the file in the image */
1133 const wimlib_tchar *path_in_wim;
1135 /** Path to which the file is being extracted */
1136 const wimlib_tchar *extraction_path;
1139 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1140 struct wimlib_progress_info_unmount {
1141 /** Path to directory being unmounted */
1142 const wimlib_tchar *mountpoint;
1144 /** Path to WIM file being unmounted */
1145 const wimlib_tchar *mounted_wim;
1147 /** 1-based index of image being unmounted. */
1148 uint32_t mounted_image;
1150 /** Flags that were passed to wimlib_mount_image() when the
1151 * mountpoint was set up. */
1152 uint32_t mount_flags;
1154 /** Flags passed to wimlib_unmount_image(). */
1155 uint32_t unmount_flags;
1158 /** Valid on messages ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE. */
1159 struct wimlib_progress_info_done_with_file {
1161 * Path to the file whose data has been written to the WIM file,
1162 * or is currently being asynchronously compressed in memory,
1163 * and therefore is no longer needed by wimlib.
1165 * WARNING: The file data will not actually be accessible in the
1166 * WIM file until the WIM file has been completely written.
1167 * Ordinarily you should <b>not</b> treat this message as a
1168 * green light to go ahead and delete the specified file, since
1169 * that would result in data loss if the WIM file cannot be
1170 * successfully created for any reason.
1172 * If a file has multiple names (hard links),
1173 * ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE will only be received
1174 * for one name. Also, this message will not be received for
1175 * empty files or reparse points (or symbolic links), unless
1176 * they have nonempty named data streams.
1178 const wimlib_tchar *path_to_file;
1181 /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
1182 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE. */
1183 struct wimlib_progress_info_verify_image {
1184 const wimlib_tchar *wimfile;
1185 uint32_t total_images;
1186 uint32_t current_image;
1189 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS. */
1190 struct wimlib_progress_info_verify_streams {
1191 const wimlib_tchar *wimfile;
1192 uint64_t total_streams;
1193 uint64_t total_bytes;
1194 uint64_t completed_streams;
1195 uint64_t completed_bytes;
1198 /** Valid on messages ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION. */
1199 struct wimlib_progress_info_test_file_exclusion {
1202 * Path to the file for which exclusion is being tested.
1204 * UNIX capture mode: The path will be a standard relative or
1205 * absolute UNIX filesystem path.
1207 * NTFS-3G capture mode: The path will be given relative to the
1208 * root of the NTFS volume, with a leading slash.
1210 * Windows capture mode: The path will be a Win32 namespace
1213 const wimlib_tchar *path;
1216 * Indicates whether the file or directory will be excluded from
1217 * capture or not. This will be <c>false</c> by default. The
1218 * progress function can set this to <c>true</c> if it decides
1219 * that the file needs to be excluded.
1222 } test_file_exclusion;
1224 /** Valid on messages ::WIMLIB_PROGRESS_MSG_HANDLE_ERROR. */
1225 struct wimlib_progress_info_handle_error {
1227 /** Path to the file for which the error occurred, or NULL if
1229 const wimlib_tchar *path;
1231 /** The wimlib error code associated with the error. */
1235 * Indicates whether the error will be ignored or not. This
1236 * will be <c>false</c> by default; the progress function may
1237 * set it to <c>true</c>.
1244 * A user-supplied function that will be called periodically during certain WIM
1247 * The first argument will be the type of operation that is being performed or
1248 * is about to be started or has been completed.
1250 * The second argument will be a pointer to one of a number of structures
1251 * depending on the first argument. It may be @c NULL for some message types.
1252 * Note that although this argument is not @c const, users should not modify it
1253 * except in explicitly documented cases.
1255 * The third argument will be a user-supplied value that was provided when
1256 * registering or specifying the progress function.
1258 * This function must return one of the ::wimlib_progress_status values. By
1259 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1261 typedef enum wimlib_progress_status
1262 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1263 union wimlib_progress_info *info,
1267 /** @addtogroup G_modifying_wims
1270 /** An array of these structures is passed to wimlib_add_image_multisource() to
1271 * specify the sources from which to create a WIM image. */
1272 struct wimlib_capture_source {
1273 /** Absolute or relative path to a file or directory on the external
1274 * filesystem to be included in the image. */
1275 wimlib_tchar *fs_source_path;
1277 /** Destination path in the image. To specify the root directory of the
1278 * image, use ::WIMLIB_WIM_ROOT_PATH. */
1279 wimlib_tchar *wim_target_path;
1281 /** Reserved; set to 0. */
1285 /** Set or unset the "readonly" WIM header flag (<c>WIM_HDR_FLAG_READONLY</c> in
1286 * Microsoft's documentation), based on the ::wimlib_wim_info.is_marked_readonly
1287 * member of the @p info parameter. This is distinct from basic file
1288 * permissions; this flag can be set on a WIM file that is physically writable.
1290 * wimlib disallows modifying on-disk WIM files with the readonly flag set.
1291 * However, wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG
1292 * will override this --- and in fact, this is necessary to set the readonly
1293 * flag persistently on an existing WIM file.
1295 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1297 /** Set the GUID (globally unique identifier) of the WIM file to the value
1298 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1299 #define WIMLIB_CHANGE_GUID 0x00000002
1301 /** Change the bootable image of the WIM to the value specified in
1302 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1303 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1305 /** Change the <c>WIM_HDR_FLAG_RP_FIX</c> flag of the WIM file to the value
1306 * specified in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag
1307 * generally indicates whether an image in the WIM has been captured with
1308 * reparse-point fixups enabled. wimlib also treats this flag as specifying
1309 * whether to do reparse-point fixups by default when capturing or applying WIM
1311 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1315 /** @addtogroup G_wim_information */
1320 * General information about a WIM file.
1322 * This info can also be requested for a ::WIMStruct that does not have a
1323 * backing file. In this case, fields that only make sense given a backing file
1324 * are set to default values.
1326 struct wimlib_wim_info {
1328 /** The globally unique identifier for this WIM. (Note: all parts of a
1329 * split WIM normally have identical GUIDs.) */
1330 uint8_t guid[WIMLIB_GUID_LEN];
1332 /** The number of images in this WIM file. */
1333 uint32_t image_count;
1335 /** The 1-based index of the bootable image in this WIM file, or 0 if no
1336 * image is bootable. */
1337 uint32_t boot_index;
1339 /** The version of the WIM file format used in this WIM file. */
1340 uint32_t wim_version;
1342 /** The default compression chunk size of resources in this WIM file.
1344 uint32_t chunk_size;
1346 /** For split WIMs, the 1-based index of this part within the split WIM;
1348 uint16_t part_number;
1350 /** For split WIMs, the total number of parts in the split WIM;
1352 uint16_t total_parts;
1354 /** The default compression type of resources in this WIM file, as one
1355 * of the ::wimlib_compression_type constants. */
1356 int32_t compression_type;
1358 /** The size of this WIM file in bytes, excluding the XML data and
1359 * integrity table. */
1360 uint64_t total_bytes;
1362 /** 1 iff this WIM file has an integrity table. */
1363 uint32_t has_integrity_table : 1;
1365 /** 1 iff this info struct is for a ::WIMStruct that has a backing file.
1367 uint32_t opened_from_file : 1;
1369 /** 1 iff this WIM file is considered readonly for any reason (e.g. the
1370 * "readonly" header flag is set, or this is part of a split WIM, or
1371 * filesystem permissions deny writing) */
1372 uint32_t is_readonly : 1;
1374 /** 1 iff the "reparse point fix" flag is set in this WIM's header */
1375 uint32_t has_rpfix : 1;
1377 /** 1 iff the "readonly" flag is set in this WIM's header */
1378 uint32_t is_marked_readonly : 1;
1380 /** 1 iff the "spanned" flag is set in this WIM's header */
1381 uint32_t spanned : 1;
1383 /** 1 iff the "write in progress" flag is set in this WIM's header */
1384 uint32_t write_in_progress : 1;
1386 /** 1 iff the "metadata only" flag is set in this WIM's header */
1387 uint32_t metadata_only : 1;
1389 /** 1 iff the "resource only" flag is set in this WIM's header */
1390 uint32_t resource_only : 1;
1392 /** 1 iff this WIM file is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1393 uint32_t pipable : 1;
1394 uint32_t reserved_flags : 22;
1395 uint32_t reserved[9];
1399 * Information about a "blob", which is a fixed length sequence of binary data.
1400 * Each nonempty stream of each file in a WIM image is associated with a blob.
1401 * Blobs are deduplicated within a WIM file.
1403 * TODO: this struct needs to be renamed, and perhaps made into a union since
1404 * there are several cases. I'll try to list them below:
1406 * 1. The blob is "missing", meaning that it is referenced by hash but not
1407 * actually present in the WIM file. In this case we only know the
1408 * sha1_hash. This case can only occur with wimlib_iterate_dir_tree(), never
1409 * wimlib_iterate_lookup_table().
1411 * 2. Otherwise we know the uncompressed_size, the reference_count, and the
1412 * is_metadata flag. In addition:
1414 * A. If the blob is located in a non-solid WIM resource, then we also know
1415 * the sha1_hash, compressed_size, and offset.
1417 * B. If the blob is located in a solid WIM resource, then we also know the
1418 * sha1_hash, offset, raw_resource_offset_in_wim,
1419 * raw_resource_compressed_size, and raw_resource_uncompressed_size. But
1420 * the "offset" is actually the offset in the uncompressed solid resource
1421 * rather than the offset from the beginning of the WIM file.
1423 * C. If the blob is *not* located in any type of WIM resource, for example
1424 * if it's in a external file that was scanned by wimlib_add_image(), then
1425 * we usually won't know any more information. The sha1_hash might be
1426 * known, and prior to wimlib v1.13.6 it always was; however, in wimlib
1427 * v1.13.6 and later, the sha1_hash might not be known in this case.
1429 * Unknown or irrelevant fields are left zeroed.
1431 struct wimlib_resource_entry {
1433 /** If this blob is not missing, then this is the uncompressed size of
1434 * this blob in bytes. */
1435 uint64_t uncompressed_size;
1437 /** If this blob is located in a non-solid WIM resource, then this is
1438 * the compressed size of that resource. */
1439 uint64_t compressed_size;
1441 /** If this blob is located in a non-solid WIM resource, then this is
1442 * the offset of that resource within the WIM file containing it. If
1443 * this blob is located in a solid WIM resource, then this is the offset
1444 * of this blob within that solid resource when uncompressed. */
1447 /** If this blob is located in a WIM resource, then this is the SHA-1
1448 * message digest of the blob's uncompressed contents. */
1449 uint8_t sha1_hash[20];
1451 /** If this blob is located in a WIM resource, then this is the part
1452 * number of the WIM file containing it. */
1453 uint32_t part_number;
1455 /** If this blob is not missing, then this is the number of times this
1456 * blob is referenced over all images in the WIM. This number is not
1457 * guaranteed to be correct. */
1458 uint32_t reference_count;
1460 /** 1 iff this blob is located in a non-solid compressed WIM resource.
1462 uint32_t is_compressed : 1;
1464 /** 1 iff this blob contains the metadata for an image. */
1465 uint32_t is_metadata : 1;
1467 uint32_t is_free : 1;
1468 uint32_t is_spanned : 1;
1470 /** 1 iff a blob with this hash was not found in the blob lookup table
1471 * of the ::WIMStruct. This normally implies a missing call to
1472 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1473 uint32_t is_missing : 1;
1475 /** 1 iff this blob is located in a solid resource. */
1476 uint32_t packed : 1;
1478 uint32_t reserved_flags : 26;
1480 /** If this blob is located in a solid WIM resource, then this is the
1481 * offset of that solid resource within the WIM file containing it. */
1482 uint64_t raw_resource_offset_in_wim;
1484 /** If this blob is located in a solid WIM resource, then this is the
1485 * compressed size of that solid resource. */
1486 uint64_t raw_resource_compressed_size;
1488 /** If this blob is located in a solid WIM resource, then this is the
1489 * uncompressed size of that solid resource. */
1490 uint64_t raw_resource_uncompressed_size;
1492 uint64_t reserved[1];
1496 * Information about a stream of a particular file in the WIM.
1498 * Normally, only WIM images captured from NTFS filesystems will have multiple
1499 * streams per file. In practice, this is a rarely used feature of the
1502 * TODO: the library now explicitly tracks stream types, which allows it to have
1503 * multiple unnamed streams (e.g. both a reparse point stream and unnamed data
1504 * stream). However, this isn't yet exposed by wimlib_iterate_dir_tree().
1506 struct wimlib_stream_entry {
1508 /** Name of the stream, or NULL if the stream is unnamed. */
1509 const wimlib_tchar *stream_name;
1511 /** Info about this stream's data, such as its hash and size if known.*/
1512 struct wimlib_resource_entry resource;
1514 uint64_t reserved[4];
1518 * Since wimlib v1.9.1: an object ID, which is an extra piece of metadata that
1519 * may be associated with a file on NTFS filesystems. See:
1520 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa363997(v=vs.85).aspx
1522 struct wimlib_object_id {
1523 uint8_t object_id[WIMLIB_GUID_LEN];
1524 uint8_t birth_volume_id[WIMLIB_GUID_LEN];
1525 uint8_t birth_object_id[WIMLIB_GUID_LEN];
1526 uint8_t domain_id[WIMLIB_GUID_LEN];
1529 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1530 * Roughly, the information about a "file" in the WIM image --- but really a
1531 * directory entry ("dentry") because hard links are allowed. The
1532 * hard_link_group_id field can be used to distinguish actual file inodes. */
1533 struct wimlib_dir_entry {
1534 /** Name of the file, or NULL if this file is unnamed. Only the root
1535 * directory of an image will be unnamed. */
1536 const wimlib_tchar *filename;
1538 /** 8.3 name (or "DOS name", or "short name") of this file; or NULL if
1539 * this file has no such name. */
1540 const wimlib_tchar *dos_name;
1542 /** Full path to this file within the image. Path separators will be
1543 * ::WIMLIB_WIM_PATH_SEPARATOR. */
1544 const wimlib_tchar *full_path;
1546 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1547 * children, ..., etc. */
1550 /** Pointer to the security descriptor for this file, in Windows
1551 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1552 * security descriptor. */
1553 const char *security_descriptor;
1555 /** Size of the above security descriptor, in bytes. */
1556 size_t security_descriptor_size;
1558 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1559 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1560 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1561 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1562 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1563 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1564 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1565 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1566 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1567 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1568 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1569 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1570 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1571 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1572 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1573 /** File attributes, such as whether the file is a directory or not.
1574 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1575 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1576 * on other platforms. */
1577 uint32_t attributes;
1579 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1580 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1581 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1582 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1583 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1584 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1585 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1586 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1587 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1588 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1589 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1590 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1591 /** If the file is a reparse point (FILE_ATTRIBUTE_REPARSE_POINT set in
1592 * the attributes), this will give the reparse tag. This tells you
1593 * whether the reparse point is a symbolic link, junction point, or some
1594 * other, more unusual kind of reparse point. */
1595 uint32_t reparse_tag;
1597 /** Number of links to this file's inode (hard links).
1599 * Currently, this will always be 1 for directories. However, it can be
1600 * greater than 1 for nondirectory files. */
1603 /** Number of named data streams this file has. Normally 0. */
1604 uint32_t num_named_streams;
1606 /** A unique identifier for this file's inode. However, as a special
1607 * case, if the inode only has a single link (@p num_links == 1), this
1610 * Note: if a WIM image is captured from a filesystem, this value is not
1611 * guaranteed to be the same as the original number of the inode on the
1613 uint64_t hard_link_group_id;
1615 /** Time this file was created. */
1616 struct wimlib_timespec creation_time;
1618 /** Time this file was last written to. */
1619 struct wimlib_timespec last_write_time;
1621 /** Time this file was last accessed. */
1622 struct wimlib_timespec last_access_time;
1624 /** The UNIX user ID of this file. This is a wimlib extension.
1626 * This field is only valid if @p unix_mode != 0. */
1629 /** The UNIX group ID of this file. This is a wimlib extension.
1631 * This field is only valid if @p unix_mode != 0. */
1634 /** The UNIX mode of this file. This is a wimlib extension.
1636 * If this field is 0, then @p unix_uid, @p unix_gid, @p unix_mode, and
1637 * @p unix_rdev are all unknown (fields are not present in the WIM
1641 /** The UNIX device ID (major and minor number) of this file. This is a
1644 * This field is only valid if @p unix_mode != 0. */
1647 /* The object ID of this file, if any. Only valid if
1648 * object_id.object_id is not all zeroes. */
1649 struct wimlib_object_id object_id;
1651 /** High 32 bits of the seconds portion of the creation timestamp,
1652 * filled in if @p wimlib_timespec.tv_sec is only 32-bit. */
1653 int32_t creation_time_high;
1655 /** High 32 bits of the seconds portion of the last write timestamp,
1656 * filled in if @p wimlib_timespec.tv_sec is only 32-bit. */
1657 int32_t last_write_time_high;
1659 /** High 32 bits of the seconds portion of the last access timestamp,
1660 * filled in if @p wimlib_timespec.tv_sec is only 32-bit. */
1661 int32_t last_access_time_high;
1665 uint64_t reserved[4];
1668 * Variable-length array of streams that make up this file.
1670 * The first entry will always exist and will correspond to the unnamed
1671 * data stream (default file contents), so it will have <c>stream_name
1672 * == NULL</c>. Alternatively, for reparse point files, the first entry
1673 * will correspond to the reparse data stream. Alternatively, for
1674 * encrypted files, the first entry will correspond to the encrypted
1677 * Then, following the first entry, there be @p num_named_streams
1678 * additional entries that specify the named data streams, if any, each
1679 * of which will have <c>stream_name != NULL</c>.
1681 struct wimlib_stream_entry streams[];
1685 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1688 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1692 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1695 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1698 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1699 * just on the specified path. */
1700 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1702 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1703 * itself; only its children (in the case of a non-empty directory) */
1704 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1706 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any file data blobs needed to fill
1707 * in the ::wimlib_resource_entry's for the iteration cannot be found in the
1708 * blob lookup table of the ::WIMStruct. The default behavior without this flag
1709 * is to fill in the @ref wimlib_resource_entry::sha1_hash "sha1_hash" and set
1710 * the @ref wimlib_resource_entry::is_missing "is_missing" flag. */
1711 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1715 /** @addtogroup G_modifying_wims
1718 /** UNIX-like systems only: Directly capture an NTFS volume rather than a
1719 * generic directory. This requires that wimlib was compiled with support for
1722 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1723 * ::WIMLIB_ADD_FLAG_UNIX_DATA.
1725 * Do not use this flag on Windows, where wimlib already supports all
1726 * Windows-native filesystems, including NTFS, through the Windows APIs. */
1727 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1729 /** Follow symbolic links when scanning the directory tree. Currently only
1730 * supported on UNIX-like systems. */
1731 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1733 /** Call the progress function with the message
1734 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1736 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1738 /** Mark the image being added as the bootable image of the WIM. This flag is
1739 * valid only for wimlib_add_image() and wimlib_add_image_multisource().
1741 * Note that you can also change the bootable image of a WIM using
1742 * wimlib_set_wim_info().
1744 * Note: ::WIMLIB_ADD_FLAG_BOOT does something different from, and independent
1745 * from, ::WIMLIB_ADD_FLAG_WIMBOOT. */
1746 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1748 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1749 * (major and minor number) of each file. In addition, capture special files
1750 * such as device nodes and FIFOs. Since wimlib v1.11.0, on Linux also capture
1751 * extended attributes. See the documentation for the <b>--unix-data</b> option
1752 * to <b>wimcapture</b> for more information. */
1753 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1755 /** Do not capture security descriptors. Only has an effect in NTFS-3G capture
1756 * mode, or in Windows native builds. */
1757 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1759 /** Fail immediately if the full security descriptor of any file or directory
1760 * cannot be accessed. Only has an effect in Windows native builds. The
1761 * default behavior without this flag is to first try omitting the SACL from the
1762 * security descriptor, then to try omitting the security descriptor entirely.
1764 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1766 /** Call the progress function with the message
1767 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1768 * capture. This is a subset of the messages provided by
1769 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1770 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1772 /** Reparse-point fixups: Modify absolute symbolic links (and junctions, in the
1773 * case of Windows) that point inside the directory being captured to instead be
1774 * absolute relative to the directory being captured.
1776 * Without this flag, the default is to do reparse-point fixups if
1777 * <c>WIM_HDR_FLAG_RP_FIX</c> is set in the WIM header or if this is the first
1778 * image being added. */
1779 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1781 /** Don't do reparse point fixups. See ::WIMLIB_ADD_FLAG_RPFIX. */
1782 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1784 /** Do not automatically exclude unsupported files or directories from capture,
1785 * such as encrypted files in NTFS-3G capture mode, or device files and FIFOs on
1786 * UNIX-like systems when not also using ::WIMLIB_ADD_FLAG_UNIX_DATA. Instead,
1787 * fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when such a file is encountered. */
1788 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1791 * Automatically select a capture configuration appropriate for capturing
1792 * filesystems containing Windows operating systems. For example,
1793 * <c>/pagefile.sys</c> and <c>"/System Volume Information"</c> will be
1796 * When this flag is specified, the corresponding @p config parameter (for
1797 * wimlib_add_image()) or member (for wimlib_update_image()) must be @c NULL.
1798 * Otherwise, ::WIMLIB_ERR_INVALID_PARAM will be returned.
1800 * Note that the default behavior--- that is, when neither
1801 * ::WIMLIB_ADD_FLAG_WINCONFIG nor ::WIMLIB_ADD_FLAG_WIMBOOT is specified and @p
1802 * config is @c NULL--- is to use no capture configuration, meaning that no
1803 * files are excluded from capture.
1805 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1808 * Capture image as "WIMBoot compatible". In addition, if no capture
1809 * configuration file is explicitly specified use the capture configuration file
1810 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1811 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1812 * configuration file is explicitly specified, use it and also place it at
1813 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image.
1815 * This flag does not, by itself, change the compression type or chunk size.
1816 * Before writing the WIM file, you may wish to set the compression format to
1817 * be the same as that used by WIMGAPI and DISM:
1820 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1821 * wimlib_set_output_chunk_size(wim, 4096);
1824 * However, "WIMBoot" also works with other XPRESS chunk sizes as well as LZX
1825 * with 32768 byte chunks.
1827 * Note: ::WIMLIB_ADD_FLAG_WIMBOOT does something different from, and
1828 * independent from, ::WIMLIB_ADD_FLAG_BOOT.
1830 * Since wimlib v1.8.3, ::WIMLIB_ADD_FLAG_WIMBOOT also causes offline WIM-backed
1831 * files to be added as the "real" files rather than as their reparse points,
1832 * provided that their data is already present in the WIM. This feature can be
1833 * useful when updating a backing WIM file in an "offline" state.
1835 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1838 * If the add command involves adding a non-directory file to a location at
1839 * which there already exists a nondirectory file in the image, issue
1840 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This was the
1841 * default behavior before wimlib v1.7.0.
1843 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1846 * Send ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION messages to the progress
1849 * Note: This method for file exclusions is independent from the capture
1850 * configuration file mechanism.
1852 #define WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION 0x00004000
1855 * Since wimlib v1.9.0: create a temporary filesystem snapshot of the source
1856 * directory and add the files from it. Currently, this option is only
1857 * supported on Windows, where it uses the Volume Shadow Copy Service (VSS).
1858 * Using this option, you can create a consistent backup of the system volume of
1859 * a running Windows system without running into problems with locked files.
1860 * For the VSS snapshot to be successfully created, your application must be run
1861 * as an Administrator, and it cannot be run in WoW64 mode (i.e. if Windows is
1862 * 64-bit, then your application must be 64-bit as well).
1864 #define WIMLIB_ADD_FLAG_SNAPSHOT 0x00008000
1867 * Since wimlib v1.9.0: permit the library to discard file paths after the
1868 * initial scan. If the application won't use
1869 * ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES while writing the WIM
1870 * archive, this flag can be used to allow the library to enable optimizations
1871 * such as opening files by inode number rather than by path. Currently this
1872 * only makes a difference on Windows.
1874 #define WIMLIB_ADD_FLAG_FILE_PATHS_UNNEEDED 0x00010000
1877 /** @addtogroup G_modifying_wims
1880 /** Do not issue an error if the path to delete does not exist. */
1881 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1883 /** Delete the file or directory tree recursively; if not specified, an error is
1884 * issued if the path to delete is a directory. */
1885 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1888 /** @addtogroup G_modifying_wims
1892 * If a single image is being exported, mark it bootable in the destination WIM.
1893 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1894 * the image in the source WIM (if any) that is marked as bootable is also
1895 * marked as bootable in the destination WIM.
1897 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1899 /** Give the exported image(s) no names. Avoids problems with image name
1902 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1904 /** Give the exported image(s) no descriptions. */
1905 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1907 /** This advises the library that the program is finished with the source
1908 * WIMStruct and will not attempt to access it after the call to
1909 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1910 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1913 * Mark each exported image as WIMBoot-compatible.
1915 * Note: by itself, this does change the destination WIM's compression type, nor
1916 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1917 * image. Before writing the destination WIM, it's recommended to do something
1921 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1922 * wimlib_set_output_chunk_size(wim, 4096);
1923 * wimlib_add_tree(wim, image, L"myconfig.ini",
1924 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1927 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1930 /** @addtogroup G_extracting_wims
1933 /** Extract the image directly to an NTFS volume rather than a generic directory.
1934 * This mode is only available if wimlib was compiled with libntfs-3g support;
1935 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1936 * extraction target will be interpreted as the path to an NTFS volume image (as
1937 * a regular file or block device) rather than a directory. It will be opened
1938 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1939 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1940 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1941 * wimlib_extract_paths() when passed multiple paths. */
1942 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1944 /** Since wimlib v1.13.4: Don't consider corrupted files to be an error. Just
1945 * extract them in whatever form we can. */
1946 #define WIMLIB_EXTRACT_FLAG_RECOVER_DATA 0x00000002
1948 /** UNIX-like systems only: Extract UNIX-specific metadata captured with
1949 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1950 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1952 /** Do not extract security descriptors. This flag cannot be combined with
1953 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1954 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1957 * Fail immediately if the full security descriptor of any file or directory
1958 * cannot be set exactly as specified in the WIM image. On Windows, the default
1959 * behavior without this flag when wimlib does not have permission to set the
1960 * correct security descriptor is to fall back to setting the security
1961 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1962 * owner omitted, then not at all. This flag cannot be combined with
1963 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS.
1965 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1968 * This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1969 * reparse-point fixups on, so absolute symbolic links or junction points will
1970 * be fixed to be absolute relative to the actual extraction root. Reparse-
1971 * point fixups are done by default for wimlib_extract_image() and
1972 * wimlib_extract_image_from_pipe() if <c>WIM_HDR_FLAG_RP_FIX</c> is set in the
1973 * WIM header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX.
1975 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1977 /** Force reparse-point fixups on extraction off, regardless of the state of the
1978 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1979 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1980 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1982 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1983 * paths, each of which must name a regular file, to standard output. */
1984 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1987 * Instead of ignoring files and directories with names that cannot be
1988 * represented on the current platform (note: Windows has more restrictions on
1989 * filenames than POSIX-compliant systems), try to replace characters or append
1990 * junk to the names so that they can be extracted in some form.
1992 * Note: this flag is unlikely to have any effect when extracting a WIM image
1993 * that was captured on Windows.
1995 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1998 * On Windows, when there exist two or more files with the same case insensitive
1999 * name but different case sensitive names, try to extract them all by appending
2000 * junk to the end of them, rather than arbitrarily extracting only one.
2002 * Note: this flag is unlikely to have any effect when extracting a WIM image
2003 * that was captured on Windows.
2005 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
2007 /** Do not ignore failure to set timestamps on extracted files. This flag
2008 * currently only has an effect when extracting to a directory on UNIX-like
2010 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
2012 /** Do not ignore failure to set short names on extracted files. This flag
2013 * currently only has an effect on Windows. */
2014 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
2016 /** Do not ignore failure to extract symbolic links and junctions due to
2017 * permissions problems. This flag currently only has an effect on Windows. By
2018 * default, such failures are ignored since the default configuration of Windows
2019 * only allows the Administrator to create symbolic links. */
2020 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
2023 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
2024 * paths to extract as wildcard patterns ("globs") which may contain the
2025 * wildcard characters @c ? and @c *. The @c ? character matches any
2026 * non-path-separator character, whereas the @c * character matches zero or more
2027 * non-path-separator characters. Consequently, each glob may match zero or
2028 * more actual paths in the WIM image.
2030 * By default, if a glob does not match any files, a warning but not an error
2031 * will be issued. This is the case even if the glob did not actually contain
2032 * wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error
2035 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
2037 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
2038 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
2039 * one of the provided globs did not match a file. */
2040 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
2043 * Do not extract Windows file attributes such as readonly, hidden, etc.
2045 * This flag has an effect on Windows as well as in the NTFS-3G extraction mode.
2047 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
2050 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
2051 * preserve the directory structure of the archive when extracting --- that is,
2052 * place each extracted file or directory tree directly in the target directory.
2053 * The target directory will still be created if it does not already exist.
2055 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
2058 * Windows only: Extract files as "pointers" back to the WIM archive.
2060 * The effects of this option are fairly complex. See the documentation for the
2061 * <b>--wimboot</b> option of <b>wimapply</b> for more information.
2063 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
2066 * Since wimlib v1.8.2 and Windows-only: compress the extracted files using
2067 * System Compression, when possible. This only works on either Windows 10 or
2068 * later, or on an older Windows to which Microsoft's wofadk.sys driver has been
2069 * added. Several different compression formats may be used with System
2070 * Compression; this particular flag selects the XPRESS compression format with
2073 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K 0x01000000
2075 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2076 * 8192 byte chunks. */
2077 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K 0x02000000
2079 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2080 * 16384 byte chunks. */
2081 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K 0x04000000
2083 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use LZX compression with
2084 * 32768 byte chunks. */
2085 #define WIMLIB_EXTRACT_FLAG_COMPACT_LZX 0x08000000
2088 /** @addtogroup G_mounting_wim_images
2091 /** Mount the WIM image read-write rather than the default of read-only. */
2092 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
2094 /** Enable FUSE debugging by passing the @c -d option to @c fuse_main(). */
2095 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
2097 /** Do not allow accessing named data streams in the mounted WIM image. */
2098 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
2100 /** Access named data streams in the mounted WIM image through extended file
2101 * attributes named "user.X", where X is the name of a data stream. This is the
2103 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
2105 /** Access named data streams in the mounted WIM image by specifying the file
2106 * name, a colon, then the name of the data stream. */
2107 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
2109 /** Support UNIX owners, groups, modes, and special files. */
2110 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
2112 /** Allow other users to see the mounted filesystem. This passes the @c
2113 * allow_other option to fuse_main(). */
2114 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
2117 /** @addtogroup G_creating_and_opening_wims
2120 /** Verify the WIM contents against the WIM's integrity table, if present. The
2121 * integrity table stores checksums for the raw data of the WIM file, divided
2122 * into fixed size chunks. Verification will compute checksums and compare them
2123 * with the stored values. If there are any mismatches, then
2124 * ::WIMLIB_ERR_INTEGRITY will be issued. If the WIM file does not contain an
2125 * integrity table, then this flag has no effect. */
2126 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
2128 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
2129 * WIM. Software can provide this flag for convenience if it explicitly does
2130 * not want to support split WIMs. */
2131 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
2133 /** Check if the WIM is writable and issue an error
2134 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
2135 * only if it is writable at the filesystem level, does not have the
2136 * <c>WIM_HDR_FLAG_READONLY</c> flag set in its header, and is not part of a
2137 * spanned set. It is not required to provide this flag before attempting to
2138 * make changes to the WIM, but with this flag you get an error immediately
2139 * rather than potentially much later, when wimlib_overwrite() is finally
2141 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
2144 /** @addtogroup G_mounting_wim_images
2147 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
2148 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2149 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
2151 /** Commit changes to the read-write mounted WIM image.
2152 * If this flag is not specified, changes will be discarded. */
2153 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
2155 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
2156 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2157 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
2159 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
2160 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2161 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
2164 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
2165 * image, forces all file descriptors to the open WIM image to be closed before
2168 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
2169 * this flag has no effect.
2171 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
2173 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
2174 * WIM image, causes the modified image to be committed to the WIM file as a
2175 * new, unnamed image appended to the archive. The original image in the WIM
2176 * file will be unmodified. */
2177 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
2180 /** @addtogroup G_modifying_wims
2183 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
2184 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
2185 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
2188 /** @addtogroup G_writing_and_overwriting_wims
2192 * Include an integrity table in the resulting WIM file.
2194 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2195 * include an integrity table if and only if one was present before. For
2196 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2197 * to not include an integrity table.
2199 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
2202 * Do not include an integrity table in the resulting WIM file. This is the
2203 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
2206 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
2209 * Write the WIM as "pipable". After writing a WIM with this flag specified,
2210 * images from it can be applied directly from a pipe using
2211 * wimlib_extract_image_from_pipe(). See the documentation for the
2212 * <b>--pipable</b> option of <b>wimcapture</b> for more information. Beware:
2213 * WIMs written with this flag will not be compatible with Microsoft's software.
2215 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2216 * write the WIM as pipable if and only if it was pipable before. For
2217 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2218 * to write the WIM as non-pipable.
2220 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
2223 * Do not write the WIM as "pipable". This is the default behavior, unless the
2224 * ::WIMStruct was created by opening a pipable WIM.
2226 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
2229 * When writing data to the WIM file, recompress it, even if the data is already
2230 * available in the desired compressed form (for example, in a WIM file from
2231 * which an image has been exported using wimlib_export_image()).
2233 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
2234 * compression ratio for the same compression type and chunk size. Simply using
2235 * the default compression settings may suffice for this, especially if the WIM
2236 * file was created using another program/library that may not use as
2237 * sophisticated compression algorithms. Or,
2238 * wimlib_set_default_compression_level() can be called beforehand to set an
2239 * even higher compression level than the default.
2241 * If the WIM contains solid resources, then ::WIMLIB_WRITE_FLAG_RECOMPRESS can
2242 * be used in combination with ::WIMLIB_WRITE_FLAG_SOLID to prevent any solid
2243 * resources from being re-used. Otherwise, solid resources are re-used
2244 * somewhat more liberally than normal compressed resources.
2246 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of data
2247 * that would not otherwise be written. For example, a call to
2248 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
2249 * cause already-existing data in the WIM file to be recompressed. To force the
2250 * WIM file to be fully rebuilt and recompressed, combine
2251 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
2253 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
2256 * Immediately before closing the WIM file, sync its data to disk.
2258 * This flag forces the function to wait until the data is safely on disk before
2259 * returning success. Otherwise, modern operating systems tend to cache data
2260 * for some time (in some cases, 30+ seconds) before actually writing it to
2261 * disk, even after reporting to the application that the writes have succeeded.
2263 * wimlib_overwrite() will set this flag automatically if it decides to
2264 * overwrite the WIM file via a temporary file instead of in-place. This is
2265 * necessary on POSIX systems; it will, for example, avoid problems with delayed
2266 * allocation on ext4.
2268 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
2271 * For wimlib_overwrite(): rebuild the entire WIM file, even if it otherwise
2272 * could be updated in-place by appending to it. Any data that existed in the
2273 * original WIM file but is not actually needed by any of the remaining images
2274 * will not be included. This can free up space left over after previous
2275 * in-place modifications to the WIM file.
2277 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
2278 * data to be recompressed. Otherwise, compressed data is re-used if possible.
2280 * wimlib_write() ignores this flag.
2282 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
2285 * For wimlib_overwrite(): override the default behavior after one or more calls
2286 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
2287 * flag, only minimal changes to correctly remove the image from the WIM file
2288 * will be taken. This can be much faster, but it will result in the WIM file
2289 * getting larger rather than smaller.
2291 * wimlib_write() ignores this flag.
2293 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
2296 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
2297 * flag (<c>WIM_HDR_FLAG_READONLY</c>) is set in the WIM header. This can be
2298 * used following a call to wimlib_set_wim_info() with the
2299 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
2302 * wimlib_write() ignores this flag.
2304 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
2307 * Do not include file data already present in other WIMs. This flag can be
2308 * used to write a "delta" WIM after the WIM files on which the delta is to be
2309 * based were referenced with wimlib_reference_resource_files() or
2310 * wimlib_reference_resources().
2312 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
2314 /** Deprecated; this flag should not be used outside of the library itself. */
2315 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
2318 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
2320 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
2323 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
2326 * Concatenate files and compress them together, rather than compress each file
2327 * independently. This is also known as creating a "solid archive". This tends
2328 * to produce a better compression ratio at the cost of much slower random
2331 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
2332 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
2333 * created with this flag use a different version number in their header (3584
2334 * instead of 68864) and are also called "ESD files".
2336 * Note that providing this flag does not affect the "append by default"
2337 * behavior of wimlib_overwrite(). In other words, wimlib_overwrite() with just
2338 * ::WIMLIB_WRITE_FLAG_SOLID can be used to append solid-compressed data to a
2339 * WIM file that originally did not contain any solid-compressed data. But if
2340 * you instead want to rebuild and recompress an entire WIM file in solid mode,
2341 * then also provide ::WIMLIB_WRITE_FLAG_REBUILD and
2342 * ::WIMLIB_WRITE_FLAG_RECOMPRESS.
2344 * Currently, new solid resources will, by default, be written using LZMS
2345 * compression with 64 MiB (67108864 byte) chunks. Use
2346 * wimlib_set_output_pack_compression_type() and/or
2347 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
2348 * the WIM's main compression type and chunk size; you can have a WIM that
2349 * nominally uses LZX compression and 32768 byte chunks but actually contains
2350 * LZMS-compressed solid resources, for example. However, if including solid
2351 * resources, I suggest that you set the WIM's main compression type to LZMS as
2352 * well, either by creating the WIM with
2353 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
2354 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
2356 * This flag will be set by default when writing or overwriting a WIM file that
2357 * either already contains solid resources, or has had solid resources exported
2358 * into it and the WIM's main compression type is LZMS.
2360 #define WIMLIB_WRITE_FLAG_SOLID 0x00001000
2363 * Send ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE messages while writing the WIM
2364 * file. This is only needed in the unusual case that the library user needs to
2365 * know exactly when wimlib has read each file for the last time.
2367 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
2370 * Do not consider content similarity when arranging file data for solid
2371 * compression. Providing this flag will typically worsen the compression
2372 * ratio, so only provide this flag if you know what you are doing.
2374 #define WIMLIB_WRITE_FLAG_NO_SOLID_SORT 0x00004000
2377 * Since wimlib v1.8.3 and for wimlib_overwrite() only: <b>unsafely</b> compact
2378 * the WIM file in-place, without appending. Existing resources are shifted
2379 * down to fill holes and new resources are appended as needed. The WIM file is
2380 * truncated to its final size, which may shrink the on-disk file. <b>This
2381 * operation cannot be safely interrupted. If the operation is interrupted,
2382 * then the WIM file will be corrupted, and it may be impossible (or at least
2383 * very difficult) to recover any data from it. Users of this flag are expected
2384 * to know what they are doing and assume responsibility for any data corruption
2385 * that may result.</b>
2387 * If the WIM file cannot be compacted in-place because of its structure, its
2388 * layout, or other requested write parameters, then wimlib_overwrite() fails
2389 * with ::WIMLIB_ERR_COMPACTION_NOT_POSSIBLE, and the caller may wish to retry
2390 * the operation without this flag.
2392 #define WIMLIB_WRITE_FLAG_UNSAFE_COMPACT 0x00008000
2395 /** @addtogroup G_general
2398 /** Deprecated; no longer has any effect. */
2399 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
2401 /** Windows-only: do not attempt to acquire additional privileges (currently
2402 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege,
2403 * SeTakeOwnershipPrivilege, and SeManageVolumePrivilege) when initializing the
2404 * library. This flag is intended for the case where the calling program
2405 * manages these privileges itself. Note: by default, no error is issued if
2406 * privileges cannot be acquired, although related errors may be reported later,
2407 * depending on if the operations performed actually require additional
2408 * privileges or not. */
2409 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
2411 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2412 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2413 * to read all possible data and metadata for a capture operation could not be
2414 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
2416 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
2418 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2419 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2420 * to restore all possible data and metadata for an apply operation could not be
2421 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
2423 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
2425 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
2427 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
2429 /** Default to interpreting WIM paths case insensitively (default on Windows).
2430 * This does not apply to mounted images. */
2431 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
2434 /** @addtogroup G_nonstandalone_wims
2437 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
2438 * Ignored by wimlib_reference_resources(). */
2439 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
2441 /** For wimlib_reference_resource_files(), issue an error
2442 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
2443 * default behavior without this flag is to issue no error at that point, but
2444 * then attempt to open the glob as a literal path, which of course will fail
2445 * anyway if no file exists at that path. No effect if
2446 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
2447 * wimlib_reference_resources(). */
2448 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
2451 /** @addtogroup G_modifying_wims
2454 /** The specific type of update to perform. */
2455 enum wimlib_update_op {
2456 /** Add a new file or directory tree to the image. */
2457 WIMLIB_UPDATE_OP_ADD = 0,
2459 /** Delete a file or directory tree from the image. */
2460 WIMLIB_UPDATE_OP_DELETE = 1,
2462 /** Rename a file or directory tree in the image. */
2463 WIMLIB_UPDATE_OP_RENAME = 2,
2466 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2467 struct wimlib_add_command {
2468 /** Filesystem path to the file or directory tree to add. */
2469 wimlib_tchar *fs_source_path;
2471 /** Destination path in the image. To specify the root directory of the
2472 * image, use ::WIMLIB_WIM_ROOT_PATH. */
2473 wimlib_tchar *wim_target_path;
2475 /** Path to capture configuration file to use, or @c NULL if not
2477 wimlib_tchar *config_file;
2479 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2483 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2484 struct wimlib_delete_command {
2486 /** The path to the file or directory within the image to delete. */
2487 wimlib_tchar *wim_path;
2489 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2493 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2494 struct wimlib_rename_command {
2496 /** The path to the source file or directory within the image. */
2497 wimlib_tchar *wim_source_path;
2499 /** The path to the destination file or directory within the image. */
2500 wimlib_tchar *wim_target_path;
2502 /** Reserved; set to 0. */
2506 /** Specification of an update to perform on a WIM image. */
2507 struct wimlib_update_command {
2509 enum wimlib_update_op op;
2512 struct wimlib_add_command add;
2513 struct wimlib_delete_command delete_; /* Underscore is for C++
2515 struct wimlib_rename_command rename;
2520 /** @addtogroup G_general
2524 * Possible values of the error code returned by many functions in wimlib.
2526 * See the documentation for each wimlib function to see specifically what error
2527 * codes can be returned by a given function, and what they mean.
2529 enum wimlib_error_code {
2530 WIMLIB_ERR_SUCCESS = 0,
2531 WIMLIB_ERR_ALREADY_LOCKED = 1,
2532 WIMLIB_ERR_DECOMPRESSION = 2,
2533 WIMLIB_ERR_FUSE = 6,
2534 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2535 WIMLIB_ERR_IMAGE_COUNT = 10,
2536 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2537 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2538 WIMLIB_ERR_INTEGRITY = 13,
2539 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2540 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2541 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2542 WIMLIB_ERR_INVALID_HEADER = 17,
2543 WIMLIB_ERR_INVALID_IMAGE = 18,
2544 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2545 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2546 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2547 WIMLIB_ERR_INVALID_OVERLAY = 23,
2548 WIMLIB_ERR_INVALID_PARAM = 24,
2549 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2550 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2551 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2552 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2553 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2554 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2555 WIMLIB_ERR_IS_DIRECTORY = 32,
2556 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2557 WIMLIB_ERR_LINK = 35,
2558 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2559 WIMLIB_ERR_MKDIR = 37,
2560 WIMLIB_ERR_MQUEUE = 38,
2561 WIMLIB_ERR_NOMEM = 39,
2562 WIMLIB_ERR_NOTDIR = 40,
2563 WIMLIB_ERR_NOTEMPTY = 41,
2564 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2565 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2566 WIMLIB_ERR_NOT_PIPABLE = 44,
2567 WIMLIB_ERR_NO_FILENAME = 45,
2568 WIMLIB_ERR_NTFS_3G = 46,
2569 WIMLIB_ERR_OPEN = 47,
2570 WIMLIB_ERR_OPENDIR = 48,
2571 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2572 WIMLIB_ERR_READ = 50,
2573 WIMLIB_ERR_READLINK = 51,
2574 WIMLIB_ERR_RENAME = 52,
2575 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2576 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2577 WIMLIB_ERR_RESOURCE_ORDER = 56,
2578 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2579 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2580 WIMLIB_ERR_SET_SECURITY = 59,
2581 WIMLIB_ERR_SET_SHORT_NAME = 60,
2582 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2583 WIMLIB_ERR_SPLIT_INVALID = 62,
2584 WIMLIB_ERR_STAT = 63,
2585 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2586 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2587 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2588 WIMLIB_ERR_UNSUPPORTED = 68,
2589 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2590 WIMLIB_ERR_WIM_IS_READONLY = 71,
2591 WIMLIB_ERR_WRITE = 72,
2592 WIMLIB_ERR_XML = 73,
2593 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2594 WIMLIB_ERR_WIMBOOT = 75,
2595 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2596 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2597 WIMLIB_ERR_MKNOD = 78,
2598 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2599 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2600 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2601 WIMLIB_ERR_FVE_LOCKED_VOLUME = 82,
2602 WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG = 83,
2603 WIMLIB_ERR_WIM_IS_INCOMPLETE = 84,
2604 WIMLIB_ERR_COMPACTION_NOT_POSSIBLE = 85,
2605 WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES = 86,
2606 WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE = 87,
2607 WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED = 88,
2608 WIMLIB_ERR_SNAPSHOT_FAILURE = 89,
2609 WIMLIB_ERR_INVALID_XATTR = 90,
2610 WIMLIB_ERR_SET_XATTR = 91,
2614 /** Used to indicate no image or an invalid image. */
2615 #define WIMLIB_NO_IMAGE 0
2617 /** Used to specify all images in the WIM. */
2618 #define WIMLIB_ALL_IMAGES (-1)
2623 * @ingroup G_modifying_wims
2625 * Append an empty image to a ::WIMStruct.
2627 * The new image will initially contain no files or directories, although if
2628 * written without further modifications, then a root directory will be created
2629 * automatically for it.
2631 * After calling this function, you can use wimlib_update_image() to add files
2632 * to the new image. This gives you more control over making the new image
2633 * compared to calling wimlib_add_image() or wimlib_add_image_multisource().
2636 * Pointer to the ::WIMStruct to which to add the image.
2638 * Name to give the new image. If @c NULL or empty, the new image is given
2639 * no name. If nonempty, it must specify a name that does not already
2641 * @param new_idx_ret
2642 * If non-<c>NULL</c>, the index of the newly added image is returned in
2645 * @return 0 on success; a ::wimlib_error_code value on failure.
2647 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2648 * The WIM already contains an image with the requested name.
2651 wimlib_add_empty_image(WIMStruct *wim,
2652 const wimlib_tchar *name,
2656 * @ingroup G_modifying_wims
2658 * Add an image to a ::WIMStruct from an on-disk directory tree or NTFS volume.
2660 * The directory tree or NTFS volume is scanned immediately to load the dentry
2661 * tree into memory, and file metadata is read. However, actual file data may
2662 * not be read until the ::WIMStruct is persisted to disk using wimlib_write()
2663 * or wimlib_overwrite().
2665 * See the documentation for the @b wimlib-imagex program for more information
2666 * about the "normal" capture mode versus the NTFS capture mode (entered by
2667 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2669 * Note that no changes are committed to disk until wimlib_write() or
2670 * wimlib_overwrite() is called.
2673 * Pointer to the ::WIMStruct to which to add the image.
2675 * A path to a directory or unmounted NTFS volume that will be captured as
2678 * Name to give the new image. If @c NULL or empty, the new image is given
2679 * no name. If nonempty, it must specify a name that does not already
2681 * @param config_file
2682 * Path to capture configuration file, or @c NULL. This file may specify,
2683 * among other things, which files to exclude from capture. See the
2684 * documentation for <b>wimcapture</b> (<b>--config</b> option) for details
2685 * of the file format. If @c NULL, the default capture configuration will
2686 * be used. Ordinarily, the default capture configuration will result in
2687 * no files being excluded from capture purely based on name; however, the
2688 * ::WIMLIB_ADD_FLAG_WINCONFIG and ::WIMLIB_ADD_FLAG_WIMBOOT flags modify
2691 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2693 * @return 0 on success; a ::wimlib_error_code value on failure.
2695 * This function is implemented by calling wimlib_add_empty_image(), then
2696 * calling wimlib_update_image() with a single "add" command, so any error code
2697 * returned by wimlib_add_empty_image() may be returned, as well as any error
2698 * codes returned by wimlib_update_image() other than ones documented as only
2699 * being returned specifically by an update involving delete or rename commands.
2701 * If a progress function is registered with @p wim, then it will receive the
2702 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2703 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2704 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2707 wimlib_add_image(WIMStruct *wim,
2708 const wimlib_tchar *source,
2709 const wimlib_tchar *name,
2710 const wimlib_tchar *config_file,
2714 * @ingroup G_modifying_wims
2716 * This function is equivalent to wimlib_add_image() except it allows for
2717 * multiple sources to be combined into a single WIM image. This is done by
2718 * specifying the @p sources and @p num_sources parameters instead of the @p
2719 * source parameter of wimlib_add_image(). The rest of the parameters are the
2720 * same as wimlib_add_image(). See the documentation for <b>wimcapture</b> for
2721 * full details on how this mode works.
2724 wimlib_add_image_multisource(WIMStruct *wim,
2725 const struct wimlib_capture_source *sources,
2727 const wimlib_tchar *name,
2728 const wimlib_tchar *config_file,
2732 * @ingroup G_modifying_wims
2734 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2735 * location @p wim_target_path within the specified @p image of the @p wim.
2737 * This just builds an appropriate ::wimlib_add_command and passes it to
2738 * wimlib_update_image().
2741 wimlib_add_tree(WIMStruct *wim, int image,
2742 const wimlib_tchar *fs_source_path,
2743 const wimlib_tchar *wim_target_path, int add_flags);
2746 * @ingroup G_creating_and_opening_wims
2748 * Create a ::WIMStruct which initially contains no images and is not backed by
2752 * The "output compression type" to assign to the ::WIMStruct. This is the
2753 * compression type that will be used if the ::WIMStruct is later persisted
2754 * to an on-disk file using wimlib_write().
2756 * This choice is not necessarily final. If desired, it can still be
2757 * changed at any time before wimlib_write() is called, using
2758 * wimlib_set_output_compression_type(). In addition, if you wish to use a
2759 * non-default compression chunk size, then you will need to call
2760 * wimlib_set_output_chunk_size().
2762 * On success, a pointer to the new ::WIMStruct is written to the memory
2763 * location pointed to by this parameter. This ::WIMStruct must be freed
2764 * using wimlib_free() when finished with it.
2766 * @return 0 on success; a ::wimlib_error_code value on failure.
2768 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2769 * @p ctype was not a supported compression type.
2770 * @retval ::WIMLIB_ERR_NOMEM
2771 * Insufficient memory to allocate a new ::WIMStruct.
2774 wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret);
2777 * @ingroup G_modifying_wims
2779 * Delete an image, or all images, from a ::WIMStruct.
2781 * Note that no changes are committed to disk until wimlib_write() or
2782 * wimlib_overwrite() is called.
2785 * Pointer to the ::WIMStruct from which to delete the image.
2787 * The 1-based index of the image to delete, or ::WIMLIB_ALL_IMAGES to
2788 * delete all images.
2790 * @return 0 on success; a ::wimlib_error_code value on failure.
2792 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2793 * @p image does not exist in the WIM.
2795 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2796 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2797 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2798 * indicate failure (for different reasons) to read the metadata resource for an
2799 * image that needed to be deleted.
2801 * If this function fails when @p image was ::WIMLIB_ALL_IMAGES, then it's
2802 * possible that some but not all of the images were deleted.
2805 wimlib_delete_image(WIMStruct *wim, int image);
2808 * @ingroup G_modifying_wims
2810 * Delete the @p path from the specified @p image of the @p wim.
2812 * This just builds an appropriate ::wimlib_delete_command and passes it to
2813 * wimlib_update_image().
2816 wimlib_delete_path(WIMStruct *wim, int image,
2817 const wimlib_tchar *path, int delete_flags);
2820 * @ingroup G_modifying_wims
2822 * Export an image, or all images, from a ::WIMStruct into another ::WIMStruct.
2824 * Specifically, if the destination ::WIMStruct contains <tt>n</tt> images, then
2825 * the source image(s) will be appended, in order, starting at destination index
2826 * <tt>n + 1</tt>. By default, all image metadata will be exported verbatim,
2827 * but certain changes can be made by passing appropriate parameters.
2829 * wimlib_export_image() is only an in-memory operation; no changes are
2830 * committed to disk until wimlib_write() or wimlib_overwrite() is called.
2832 * A limitation of the current implementation of wimlib_export_image() is that
2833 * the directory tree of a source or destination image cannot be updated
2834 * following an export until one of the two images has been freed from memory.
2837 * The WIM from which to export the images, specified as a pointer to the
2838 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2839 * split WIM. In the case of a WIM file that is not standalone, this
2840 * ::WIMStruct must have had any needed external resources previously
2841 * referenced using wimlib_reference_resources() or
2842 * wimlib_reference_resource_files().
2844 * The 1-based index of the image from @p src_wim to export, or
2845 * ::WIMLIB_ALL_IMAGES.
2847 * The ::WIMStruct to which to export the images.
2849 * For single-image exports, the name to give the exported image in @p
2850 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2851 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2852 * that case, the names are all taken from @p src_wim. This parameter is
2853 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2854 * @param dest_description
2855 * For single-image exports, the description to give the exported image in
2856 * the new WIM file. If left @c NULL, the description from @p src_wim is
2857 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2858 * NULL; in that case, the description are all taken from @p src_wim. This
2859 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2860 * @param export_flags
2861 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2863 * @return 0 on success; a ::wimlib_error_code value on failure.
2865 * @retval ::WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE
2866 * One or more of the source images had already been exported into the
2868 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2869 * One or more of the names being given to an exported image was already in
2870 * use in the destination WIM.
2871 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2872 * @p src_image does not exist in @p src_wim.
2873 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2874 * At least one of @p src_wim and @p dest_wim does not contain image
2875 * metadata; for example, one of them represents a non-first part of a
2877 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2878 * A file data blob that needed to be exported could not be found in the
2879 * blob lookup table of @p src_wim. See @ref G_nonstandalone_wims.
2881 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2882 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2883 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2884 * indicate failure (for different reasons) to read the metadata resource for an
2885 * image in @p src_wim that needed to be exported.
2888 wimlib_export_image(WIMStruct *src_wim, int src_image,
2889 WIMStruct *dest_wim,
2890 const wimlib_tchar *dest_name,
2891 const wimlib_tchar *dest_description,
2895 * @ingroup G_extracting_wims
2897 * Extract an image, or all images, from a ::WIMStruct.
2899 * The exact behavior of how wimlib extracts files from a WIM image is
2900 * controllable by the @p extract_flags parameter, but there also are
2901 * differences depending on the platform (UNIX-like vs Windows). See the
2902 * documentation for <b>wimapply</b> for more information, including about the
2903 * NTFS-3G extraction mode.
2906 * The WIM from which to extract the image(s), specified as a pointer to the
2907 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2908 * split WIM. In the case of a WIM file that is not standalone, this
2909 * ::WIMStruct must have had any needed external resources previously
2910 * referenced using wimlib_reference_resources() or
2911 * wimlib_reference_resource_files().
2913 * The 1-based index of the image to extract, or ::WIMLIB_ALL_IMAGES to
2914 * extract all images. Note: ::WIMLIB_ALL_IMAGES is unsupported in NTFS-3G
2917 * A null-terminated string which names the location to which the image(s)
2918 * will be extracted. By default, this is interpreted as a path to a
2919 * directory. Alternatively, if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in
2920 * @p extract_flags, then this is interpreted as a path to an unmounted
2922 * @param extract_flags
2923 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2925 * @return 0 on success; a ::wimlib_error_code value on failure.
2927 * @retval ::WIMLIB_ERR_DECOMPRESSION
2928 * The WIM file contains invalid compressed data.
2929 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2930 * @p image does not exist in @p wim.
2931 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2932 * The metadata for an image to extract was invalid.
2933 * @retval ::WIMLIB_ERR_INVALID_PARAM
2934 * The extraction flags were invalid; more details may be found in the
2935 * documentation for the specific extraction flags that were specified. Or
2936 * @p target was @c NULL or an empty string, or @p wim was @c NULL.
2937 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2938 * The data of a file that needed to be extracted was corrupt.
2939 * @retval ::WIMLIB_ERR_LINK
2940 * Failed to create a symbolic link or a hard link.
2941 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2942 * @p wim does not contain image metadata; for example, it represents a
2943 * non-first part of a split WIM.
2944 * @retval ::WIMLIB_ERR_MKDIR
2945 * Failed create a directory.
2946 * @retval ::WIMLIB_ERR_NTFS_3G
2947 * libntfs-3g reported that a problem occurred while writing to the NTFS
2949 * @retval ::WIMLIB_ERR_OPEN
2950 * Could not create a file, or failed to open an already-extracted file.
2951 * @retval ::WIMLIB_ERR_READ
2952 * Failed to read data from the WIM.
2953 * @retval ::WIMLIB_ERR_READLINK
2954 * Failed to determine the target of a symbolic link in the WIM.
2955 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2956 * Failed to fix the target of an absolute symbolic link (e.g. if the
2957 * target would have exceeded the maximum allowed length). (Only if
2958 * reparse data was supported by the extraction mode and
2959 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2961 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2962 * A file data blob that needed to be extracted could not be found in the
2963 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
2964 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2965 * Failed to set attributes on a file.
2966 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2967 * Failed to set reparse data on a file (only if reparse data was supported
2968 * by the extraction mode).
2969 * @retval ::WIMLIB_ERR_SET_SECURITY
2970 * Failed to set security descriptor on a file.
2971 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2972 * Failed to set the short name of a file.
2973 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2974 * Failed to set timestamps on a file.
2975 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2976 * Unexpected end-of-file occurred when reading data from the WIM.
2977 * @retval ::WIMLIB_ERR_UNSUPPORTED
2978 * A requested extraction flag, or the data or metadata that must be
2979 * extracted to support it, is unsupported in the build and configuration
2980 * of wimlib, or on the current platform or extraction mode or target
2981 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2982 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2983 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2984 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2985 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2986 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2987 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2988 * image contains one or more files with short names, but extracting short
2989 * names is not supported --- on Windows, this occurs if the target volume
2990 * does not support short names, while on non-Windows, this occurs if
2991 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2992 * @retval ::WIMLIB_ERR_WIMBOOT
2993 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2994 * there was a problem creating WIMBoot pointer files or registering a
2995 * source WIM file with the Windows Overlay Filesystem (WOF) driver.
2996 * @retval ::WIMLIB_ERR_WRITE
2997 * Failed to write data to a file being extracted.
2999 * If a progress function is registered with @p wim, then as each image is
3000 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
3001 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE messages, then zero
3002 * or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then zero or more
3003 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, then
3004 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
3007 wimlib_extract_image(WIMStruct *wim, int image,
3008 const wimlib_tchar *target, int extract_flags);
3011 * @ingroup G_extracting_wims
3013 * Extract one image from a pipe on which a pipable WIM is being sent.
3015 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE, and @ref
3016 * subsec_pipable_wims, for more information about pipable WIMs.
3018 * This function operates in a special way to read the WIM fully sequentially.
3019 * As a result, there is no ::WIMStruct is made visible to library users, and
3020 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
3021 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
3022 * seekable file, not a pipe.)
3025 * File descriptor, which may be a pipe, opened for reading and positioned
3026 * at the start of the pipable WIM.
3027 * @param image_num_or_name
3028 * String that specifies the 1-based index or name of the image to extract.
3029 * It is translated to an image index using the same rules that
3030 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
3031 * only a single image (not all images) can be specified. Alternatively,
3032 * specify @p NULL here to use the first image in the WIM if it contains
3033 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
3035 * Same as the corresponding parameter to wimlib_extract_image().
3036 * @param extract_flags
3037 * Same as the corresponding parameter to wimlib_extract_image().
3039 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
3040 * error codes include those returned by wimlib_extract_image() and
3041 * wimlib_open_wim() as well as the following:
3043 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
3044 * Data read from the pipable WIM was invalid.
3045 * @retval ::WIMLIB_ERR_NOT_PIPABLE
3046 * The WIM being piped over @p pipe_fd is a normal WIM, not a pipable WIM.
3049 wimlib_extract_image_from_pipe(int pipe_fd,
3050 const wimlib_tchar *image_num_or_name,
3051 const wimlib_tchar *target, int extract_flags);
3054 * @ingroup G_extracting_wims
3056 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
3057 * function. The progress function will be used while extracting the image and
3058 * will receive the normal extraction progress messages, such as
3059 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
3060 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
3063 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
3064 const wimlib_tchar *image_num_or_name,
3065 const wimlib_tchar *target,
3067 wimlib_progress_func_t progfunc,
3071 * @ingroup G_extracting_wims
3073 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
3074 * image are specified in the ASCII, UTF-8, or UTF-16LE text file named by @p
3075 * path_list_file which itself contains the list of paths to use, one per line.
3076 * Leading and trailing whitespace is ignored. Empty lines and lines beginning
3077 * with the ';' or '#' characters are ignored. No quotes are needed, as paths
3078 * are otherwise delimited by the newline character. However, quotes will be
3079 * stripped if present.
3081 * If @p path_list_file is @c NULL, then the pathlist file is read from standard
3084 * The error codes are the same as those returned by wimlib_extract_paths(),
3085 * except that wimlib_extract_pathlist() returns an appropriate error code if it
3086 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
3087 * ::WIMLIB_ERR_READ).
3090 wimlib_extract_pathlist(WIMStruct *wim, int image,
3091 const wimlib_tchar *target,
3092 const wimlib_tchar *path_list_file,
3096 * @ingroup G_extracting_wims
3098 * Extract zero or more paths (files or directory trees) from the specified WIM
3101 * By default, each path will be extracted to a corresponding subdirectory of
3102 * the target based on its location in the image. For example, if one of the
3103 * paths to extract is <c>/Windows/explorer.exe</c> and the target is
3104 * <c>outdir</c>, the file will be extracted to
3105 * <c>outdir/Windows/explorer.exe</c>. This behavior can be changed by
3106 * providing the flag ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which
3107 * will cause each file or directory tree to be placed directly in the target
3108 * directory --- so the same example would extract <c>/Windows/explorer.exe</c>
3109 * to <c>outdir/explorer.exe</c>.
3111 * With globbing turned off (the default), paths are always checked for
3112 * existence strictly; that is, if any path to extract does not exist in the
3113 * image, then nothing is extracted and the function fails with
3114 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST. But with globbing turned on
3115 * (::WIMLIB_EXTRACT_FLAG_GLOB_PATHS specified), globs are by default permitted
3116 * to match no files, and there is a flag (::WIMLIB_EXTRACT_FLAG_STRICT_GLOB) to
3117 * enable the strict behavior if desired.
3119 * Symbolic links are not dereferenced when paths in the image are interpreted.
3122 * WIM from which to extract the paths, specified as a pointer to the
3123 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
3124 * split WIM. In the case of a WIM file that is not standalone, this
3125 * ::WIMStruct must have had any needed external resources previously
3126 * referenced using wimlib_reference_resources() or
3127 * wimlib_reference_resource_files().
3129 * The 1-based index of the WIM image from which to extract the paths.
3131 * Array of paths to extract. Each element must be the absolute path to a
3132 * file or directory within the image. Path separators may be either
3133 * forwards or backwards slashes, and leading path separators are optional.
3134 * The paths will be interpreted either case-sensitively (UNIX default) or
3135 * case-insensitively (Windows default); however, the case sensitivity can
3136 * be configured explicitly at library initialization time by passing an
3137 * appropriate flag to wimlib_global_init().
3139 * By default, "globbing" is disabled, so the characters @c * and @c ? are
3140 * interpreted literally. This can be changed by specifying
3141 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p extract_flags.
3143 * Number of paths specified in @p paths.
3145 * Directory to which to extract the paths.
3146 * @param extract_flags
3147 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
3149 * @return 0 on success; a ::wimlib_error_code value on failure. Most of the
3150 * error codes are the same as those returned by wimlib_extract_image(). Below,
3151 * some of the error codes returned in situations specific to path-mode
3152 * extraction are documented:
3154 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
3155 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
3156 * one of the paths to extract did not name a regular file.
3157 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3158 * One of the paths to extract does not exist in the image; see discussion
3159 * above about strict vs. non-strict behavior.
3161 * If a progress function is registered with @p wim, then it will receive
3162 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS.
3165 wimlib_extract_paths(WIMStruct *wim,
3167 const wimlib_tchar *target,
3168 const wimlib_tchar * const *paths,
3173 * @ingroup G_wim_information
3175 * Similar to wimlib_get_xml_data(), but the XML document will be written to the
3176 * specified standard C <c>FILE*</c> instead of retrieved in an in-memory
3179 * @return 0 on success; a ::wimlib_error_code value on failure. This may
3180 * return any error code which can be returned by wimlib_get_xml_data() as well
3181 * as the following error codes:
3183 * @retval ::WIMLIB_ERR_WRITE
3184 * Failed to write the data to the requested file.
3187 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
3190 * @ingroup G_general
3192 * Release a reference to a ::WIMStruct. If the ::WIMStruct is still referenced
3193 * by other ::WIMStruct's (e.g. following calls to wimlib_export_image() or
3194 * wimlib_reference_resources()), then the library will free it later, when the
3195 * last reference is released; otherwise it is freed immediately and any
3196 * associated file descriptors are closed.
3199 * Pointer to the ::WIMStruct to release. If @c NULL, no action is taken.
3202 wimlib_free(WIMStruct *wim);
3205 * @ingroup G_general
3207 * Convert a ::wimlib_compression_type value into a string.
3210 * The compression type value to convert.
3213 * A statically allocated string naming the compression type, such as
3214 * "None", "LZX", or "XPRESS". If the value was unrecognized, then
3215 * the resulting string will be "Invalid".
3217 WIMLIBAPI const wimlib_tchar *
3218 wimlib_get_compression_type_string(enum wimlib_compression_type ctype);
3221 * @ingroup G_general
3223 * Convert a wimlib error code into a string describing it.
3226 * An error code returned by one of wimlib's functions.
3229 * Pointer to a statically allocated string describing the error code. If
3230 * the value was unrecognized, then the resulting string will be "Unknown
3233 WIMLIBAPI const wimlib_tchar *
3234 wimlib_get_error_string(enum wimlib_error_code code);
3237 * @ingroup G_wim_information
3239 * Get the description of the specified image. Equivalent to
3240 * <tt>wimlib_get_image_property(wim, image, "DESCRIPTION")</tt>.
3242 WIMLIBAPI const wimlib_tchar *
3243 wimlib_get_image_description(const WIMStruct *wim, int image);
3246 * @ingroup G_wim_information
3248 * Get the name of the specified image. Equivalent to
3249 * <tt>wimlib_get_image_property(wim, image, "NAME")</tt>, except that
3250 * wimlib_get_image_name() will return an empty string if the image is unnamed
3251 * whereas wimlib_get_image_property() may return @c NULL in that case.
3253 WIMLIBAPI const wimlib_tchar *
3254 wimlib_get_image_name(const WIMStruct *wim, int image);
3257 * @ingroup G_wim_information
3259 * Since wimlib v1.8.3: get a per-image property from the WIM's XML document.
3260 * This is an alternative to wimlib_get_image_name() and
3261 * wimlib_get_image_description() which allows getting any simple string
3265 * Pointer to the ::WIMStruct for the WIM.
3267 * The 1-based index of the image for which to get the property.
3268 * @param property_name
3269 * The name of the image property, for example "NAME", "DESCRIPTION", or
3270 * "TOTALBYTES". The name can contain forward slashes to indicate a nested
3271 * XML element; for example, "WINDOWS/VERSION/BUILD" indicates the BUILD
3272 * element nested within the VERSION element nested within the WINDOWS
3273 * element. Since wimlib v1.9.0, a bracketed number can be used to
3274 * indicate one of several identically-named elements; for example,
3275 * "WINDOWS/LANGUAGES/LANGUAGE[2]" indicates the second "LANGUAGE" element
3276 * nested within the "WINDOWS/LANGUAGES" element. Note that element names
3277 * are case sensitive.
3280 * The property's value as a ::wimlib_tchar string, or @c NULL if there is
3281 * no such property. The string may not remain valid after later library
3282 * calls, so the caller should duplicate it if needed.
3284 WIMLIBAPI const wimlib_tchar *
3285 wimlib_get_image_property(const WIMStruct *wim, int image,
3286 const wimlib_tchar *property_name);
3289 * @ingroup G_general
3291 * Return the version of wimlib as a 32-bit number whose top 12 bits contain the
3292 * major version, the next 10 bits contain the minor version, and the low 10
3293 * bits contain the patch version.
3295 * In other words, the returned value is equal to <c>((WIMLIB_MAJOR_VERSION <<
3296 * 20) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</c> for the
3297 * corresponding header file.
3300 wimlib_get_version(void);
3303 * @ingroup G_general
3305 * Since wimlib v1.13.0: like wimlib_get_version(), but returns the full
3306 * PACKAGE_VERSION string that was set at build time. (This allows a beta
3307 * release to be distinguished from an official release.)
3309 WIMLIBAPI const wimlib_tchar *
3310 wimlib_get_version_string(void);
3313 * @ingroup G_wim_information
3315 * Get basic information about a WIM file.
3318 * Pointer to the ::WIMStruct to query. This need not represent a
3319 * standalone WIM (e.g. it could represent part of a split WIM).
3321 * A ::wimlib_wim_info structure that will be filled in with information
3322 * about the WIM file.
3327 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
3330 * @ingroup G_wim_information
3332 * Read a WIM file's XML document into an in-memory buffer.
3334 * The XML document contains metadata about the WIM file and the images stored
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 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
3342 * XML document is written to this location.
3343 * @param bufsize_ret
3344 * The size of the XML document in bytes is written to this location.
3346 * @return 0 on success; a ::wimlib_error_code value on failure.
3348 * @retval ::WIMLIB_ERR_NO_FILENAME
3349 * @p wim is not backed by a file and therefore does not have an XML
3351 * @retval ::WIMLIB_ERR_READ
3352 * Failed to read the XML document from the WIM file.
3353 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3354 * Failed to read the XML document from the WIM file.
3357 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
3360 * @ingroup G_general
3362 * Initialization function for wimlib. Call before using any other wimlib
3363 * function (except possibly wimlib_set_print_errors()). If not done manually,
3364 * this function will be called automatically with a flags argument of 0. This
3365 * function does nothing if called again after it has already successfully run.
3368 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
3370 * @return 0 on success; a ::wimlib_error_code value on failure.
3372 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
3373 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
3374 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
3375 * init_flags, but the corresponding privileges could not be acquired.
3378 wimlib_global_init(int init_flags);
3381 * @ingroup G_general
3383 * Cleanup function for wimlib. You are not required to call this function, but
3384 * it will release any global resources allocated by the library.
3387 wimlib_global_cleanup(void);
3390 * @ingroup G_wim_information
3392 * Determine if an image name is already used by some image in the WIM.
3395 * Pointer to the ::WIMStruct to query. This need not represent a
3396 * standalone WIM (e.g. it could represent part of a split WIM).
3398 * The name to check.
3401 * @c true if there is already an image in @p wim named @p name; @c false
3402 * if there is no image named @p name in @p wim. If @p name is @c NULL or
3403 * the empty string, then @c false is returned.
3406 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
3409 * @ingroup G_wim_information
3411 * Iterate through a file or directory tree in a WIM image. By specifying
3412 * appropriate flags and a callback function, you can get the attributes of a
3413 * file in the image, get a directory listing, or even get a listing of the
3417 * The ::WIMStruct containing the image(s) over which to iterate. This
3418 * ::WIMStruct must contain image metadata, so it cannot be the non-first
3419 * part of a split WIM (for example).
3421 * The 1-based index of the image that contains the files or directories to
3422 * iterate over, or ::WIMLIB_ALL_IMAGES to iterate over all images.
3424 * Path in the image at which to do the iteration.
3426 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3428 * A callback function that will receive each directory entry.
3430 * An extra parameter that will always be passed to the callback function
3433 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3434 * first nonzero value that was returned from @p cb. However, additional
3435 * ::wimlib_error_code values may be returned, including the following:
3437 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3438 * @p image does not exist in @p wim.
3439 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3440 * @p path does not exist in the image.
3441 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3442 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED was specified, but the
3443 * data for some files could not be found in the blob lookup table of @p
3446 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3447 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3448 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3449 * indicate failure (for different reasons) to read the metadata resource for an
3450 * image over which iteration needed to be done.
3453 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3455 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3458 * @ingroup G_wim_information
3460 * Iterate through the blob lookup table of a ::WIMStruct. This can be used to
3461 * directly get a listing of the unique "blobs" contained in a WIM file, which
3462 * are deduplicated over all images.
3464 * Specifically, each listed blob may be from any of the following sources:
3466 * - Metadata blobs, if the ::WIMStruct contains image metadata
3467 * - File blobs from the on-disk WIM file (if any) backing the ::WIMStruct
3468 * - File blobs from files that have been added to the in-memory ::WIMStruct,
3469 * e.g. by using wimlib_add_image()
3470 * - File blobs from external WIMs referenced by
3471 * wimlib_reference_resource_files() or wimlib_reference_resources()
3474 * Pointer to the ::WIMStruct for which to get the blob listing.
3476 * Reserved; set to 0.
3478 * A callback function that will receive each blob.
3480 * An extra parameter that will always be passed to the callback function
3483 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3484 * that was returned from @p cb.
3487 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3488 wimlib_iterate_lookup_table_callback_t cb,
3492 * @ingroup G_nonstandalone_wims
3494 * Join a split WIM into a stand-alone (one-part) WIM.
3497 * An array of strings that gives the filenames of all parts of the split
3498 * WIM. No specific order is required, but all parts must be included with
3501 * Number of filenames in @p swms.
3502 * @param swm_open_flags
3503 * Open flags for the split WIM parts (e.g.
3504 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3505 * @param wim_write_flags
3506 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3507 * be used to write the joined WIM.
3508 * @param output_path
3509 * The path to write the joined WIM file to.
3511 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3512 * may return most error codes that can be returned by wimlib_open_wim() and
3513 * wimlib_write(), as well as the following error codes:
3515 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3516 * The split WIMs do not form a valid WIM because they do not include all
3517 * the parts of the original WIM, there are duplicate parts, or not all the
3518 * parts have the same GUID and compression type.
3520 * Note: wimlib is generalized enough that this function is not actually needed
3521 * to join a split WIM; instead, you could open the first part of the split WIM,
3522 * then reference the other parts with wimlib_reference_resource_files(), then
3523 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3524 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3528 wimlib_join(const wimlib_tchar * const *swms,
3530 const wimlib_tchar *output_path,
3532 int wim_write_flags);
3535 * @ingroup G_nonstandalone_wims
3537 * Same as wimlib_join(), but allows specifying a progress function. The
3538 * progress function will receive the write progress messages, such as
3539 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3540 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3541 * swm_open_flags, the progress function will receive a series of
3542 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3546 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3548 const wimlib_tchar *output_path,
3550 int wim_write_flags,
3551 wimlib_progress_func_t progfunc,
3556 * @ingroup G_mounting_wim_images
3558 * Mount an image from a WIM file on a directory read-only or read-write.
3561 * Pointer to the ::WIMStruct containing the image to be mounted. This
3562 * ::WIMStruct must have a backing file.
3564 * The 1-based index of the image to mount. This image cannot have been
3565 * previously modified in memory.
3567 * The path to an existing empty directory on which to mount the image.
3568 * @param mount_flags
3569 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3570 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3572 * @param staging_dir
3573 * If non-NULL, the name of a directory in which a temporary directory for
3574 * storing modified or added files will be created. Ignored if
3575 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3576 * left @c NULL, the staging directory is created in the same directory as
3577 * the backing WIM file. The staging directory is automatically deleted
3578 * when the image is unmounted.
3580 * @return 0 on success; a ::wimlib_error_code value on failure.
3582 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3583 * Another process is currently modifying the WIM file.
3584 * @retval ::WIMLIB_ERR_FUSE
3585 * A non-zero status code was returned by @c fuse_main().
3586 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
3587 * There are currently multiple references to the image as a result of a
3588 * call to wimlib_export_image(). Free one before attempting the
3590 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3591 * @p image does not exist in @p wim.
3592 * @retval ::WIMLIB_ERR_INVALID_PARAM
3593 * @p wim was @c NULL; or @p dir was NULL or an empty string; or an
3594 * unrecognized flag was specified in @p mount_flags; or the image has
3595 * already been modified in memory (e.g. by wimlib_update_image()).
3596 * @retval ::WIMLIB_ERR_MKDIR
3597 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3598 * staging directory could not be created.
3599 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3600 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3601 * WIM file is considered read-only because of any of the reasons mentioned
3602 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3603 * @retval ::WIMLIB_ERR_UNSUPPORTED
3604 * Mounting is not supported in this build of the library.
3606 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3607 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3608 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3609 * indicate failure (for different reasons) to read the metadata resource for
3610 * the image to mount.
3612 * The ability to mount WIM images is implemented using FUSE (Filesystem in
3613 * UserSpacE). Depending on how FUSE is set up on your system, this function
3614 * may work as normal users in addition to the root user.
3616 * Mounting WIM images is not supported if wimlib was configured
3617 * <c>--without-fuse</c>. This includes Windows builds of wimlib;
3618 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3620 * Calling this function daemonizes the process, unless
3621 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3623 * It is safe to mount multiple images from the same WIM file read-only at the
3624 * same time, but only if different ::WIMStruct's are used. It is @b not safe
3625 * to mount multiple images from the same WIM file read-write at the same time.
3627 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3628 * different process.
3631 wimlib_mount_image(WIMStruct *wim,
3633 const wimlib_tchar *dir,
3635 const wimlib_tchar *staging_dir);
3638 * @ingroup G_creating_and_opening_wims
3640 * Open a WIM file and create a ::WIMStruct for it.
3643 * The path to the WIM file to open.
3645 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3647 * On success, a pointer to a new ::WIMStruct backed by the specified
3648 * on-disk WIM file is written to the memory location pointed to by this
3649 * parameter. This ::WIMStruct must be freed using wimlib_free() when
3652 * @return 0 on success; a ::wimlib_error_code value on failure.
3654 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3655 * The number of metadata resources found in the WIM did not match the
3656 * image count specified in the WIM header, or the number of <IMAGE>
3657 * elements in the XML data of the WIM did not match the image count
3658 * specified in the WIM header.
3659 * @retval ::WIMLIB_ERR_INTEGRITY
3660 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags, and
3661 * the WIM file failed the integrity check.
3662 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3663 * The library did not recognize the compression chunk size of the WIM as
3664 * valid for its compression type.
3665 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3666 * The library did not recognize the compression type of the WIM.
3667 * @retval ::WIMLIB_ERR_INVALID_HEADER
3668 * The header of the WIM was otherwise invalid.
3669 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3670 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3671 * the WIM contained an integrity table, but the integrity table was
3673 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3674 * The lookup table of the WIM was invalid.
3675 * @retval ::WIMLIB_ERR_INVALID_PARAM
3676 * @p wim_ret was @c NULL; or, @p wim_file was not a nonempty string.
3677 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3678 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3679 * specified in @p open_flags.
3680 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3681 * The file did not begin with the magic characters that identify a WIM
3683 * @retval ::WIMLIB_ERR_OPEN
3684 * Failed to open the WIM file for reading. Some possible reasons: the WIM
3685 * file does not exist, or the calling process does not have permission to
3687 * @retval ::WIMLIB_ERR_READ
3688 * Failed to read data from the WIM file.
3689 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3690 * Unexpected end-of-file while reading data from the WIM file.
3691 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3692 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3693 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3694 * The WIM cannot be opened because it contains encrypted segments. (It
3695 * may be a Windows 8 "ESD" file.)
3696 * @retval ::WIMLIB_ERR_WIM_IS_INCOMPLETE
3697 * The WIM file is not complete (e.g. the program which wrote it was
3698 * terminated before it finished)
3699 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3700 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3701 * considered read-only because of any of the reasons mentioned in the
3702 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3703 * @retval ::WIMLIB_ERR_XML
3704 * The XML data of the WIM was invalid.
3707 wimlib_open_wim(const wimlib_tchar *wim_file,
3709 WIMStruct **wim_ret);
3712 * @ingroup G_creating_and_opening_wims
3714 * Same as wimlib_open_wim(), but allows specifying a progress function and
3715 * progress context. If successful, the progress function will be registered in
3716 * the newly open ::WIMStruct, as if by an automatic call to
3717 * wimlib_register_progress_function(). In addition, if
3718 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, then the
3719 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3720 * messages while checking the WIM file's integrity.
3723 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3725 WIMStruct **wim_ret,
3726 wimlib_progress_func_t progfunc,
3730 * @ingroup G_writing_and_overwriting_wims
3732 * Commit a ::WIMStruct to disk, updating its backing file.
3734 * There are several alternative ways in which changes may be committed:
3736 * 1. Full rebuild: write the updated WIM to a temporary file, then rename the
3737 * temporary file to the original.
3738 * 2. Appending: append updates to the new original WIM file, then overwrite
3739 * its header such that those changes become visible to new readers.
3740 * 3. Compaction: normally should not be used; see
3741 * ::WIMLIB_WRITE_FLAG_UNSAFE_COMPACT for details.
3743 * Append mode is often much faster than a full rebuild, but it wastes some
3744 * amount of space due to leaving "holes" in the WIM file. Because of the
3745 * greater efficiency, wimlib_overwrite() normally defaults to append mode.
3746 * However, ::WIMLIB_WRITE_FLAG_REBUILD can be used to explicitly request a full
3747 * rebuild. In addition, if wimlib_delete_image() has been used on the
3748 * ::WIMStruct, then the default mode switches to rebuild mode, and
3749 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE can be used to explicitly request append
3752 * If this function completes successfully, then no more functions can be called
3753 * on the ::WIMStruct other than wimlib_free(). If you need to continue using
3754 * the WIM file, you must use wimlib_open_wim() to open a new ::WIMStruct for
3758 * Pointer to a ::WIMStruct to commit to its backing file.
3759 * @param write_flags
3760 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3761 * @param num_threads
3762 * The number of threads to use for compressing data, or 0 to have the
3763 * library automatically choose an appropriate number.
3765 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3766 * may return most error codes returned by wimlib_write() as well as the
3767 * following error codes:
3769 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3770 * Another process is currently modifying the WIM file.
3771 * @retval ::WIMLIB_ERR_NO_FILENAME
3772 * @p wim is not backed by an on-disk file. In other words, it is a
3773 * ::WIMStruct created by wimlib_create_new_wim() rather than
3774 * wimlib_open_wim().
3775 * @retval ::WIMLIB_ERR_RENAME
3776 * The temporary file to which the WIM was written could not be renamed to
3777 * the original file.
3778 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3779 * The WIM file is considered read-only because of any of the reasons
3780 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3783 * If a progress function is registered with @p wim, then it will receive the
3784 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3785 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3786 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3789 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3792 * @ingroup G_wim_information
3794 * (Deprecated) Print information about one image, or all images, contained in a
3798 * Pointer to the ::WIMStruct to query. This need not represent a
3799 * standalone WIM (e.g. it could represent part of a split WIM).
3801 * The 1-based index of the image for which to print information, or
3802 * ::WIMLIB_ALL_IMAGES to print information about all images.
3804 * @return This function has no return value. No error checking is done when
3805 * printing the information. If @p image is invalid, an error message is
3808 * This function is deprecated; use wimlib_get_xml_data() or
3809 * wimlib_get_image_property() to query image information instead.
3812 wimlib_print_available_images(const WIMStruct *wim, int image);
3815 * @ingroup G_wim_information
3817 * Print the header of the WIM file (intended for debugging only).
3820 wimlib_print_header(const WIMStruct *wim);
3823 * @ingroup G_nonstandalone_wims
3825 * Reference file data from other WIM files or split WIM parts. This function
3826 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3827 * to load additional file data before calling a function such as
3828 * wimlib_extract_image() that requires the file data to be present.
3831 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3832 * necessarily "standalone". In the case of split WIMs, this should be the
3833 * first part, since only the first part contains the metadata resources.
3834 * In the case of delta WIMs, this should be the delta WIM rather than the
3835 * WIM on which it is based.
3836 * @param resource_wimfiles_or_globs
3837 * Array of paths to WIM files and/or split WIM parts to reference.
3838 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3839 * ref_flags, these are treated as globs rather than literal paths. That
3840 * is, using this function you can specify zero or more globs, each of
3841 * which expands to one or more literal paths.
3843 * Number of entries in @p resource_wimfiles_or_globs.
3845 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3846 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3848 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3849 * pass to internal calls to wimlib_open_wim() on the reference files.
3851 * @return 0 on success; a ::wimlib_error_code value on failure.
3853 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3854 * One of the specified globs did not match any paths (only with both
3855 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3856 * specified in @p ref_flags).
3857 * @retval ::WIMLIB_ERR_READ
3858 * I/O or permissions error while processing a file glob.
3860 * This function can additionally return most values that can be returned by
3861 * wimlib_open_wim().
3864 wimlib_reference_resource_files(WIMStruct *wim,
3865 const wimlib_tchar * const *resource_wimfiles_or_globs,
3871 * @ingroup G_nonstandalone_wims
3873 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3874 * where the caller must open the ::WIMStruct for each referenced file itself.
3877 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3878 * necessarily "standalone". In the case of split WIMs, this should be the
3879 * first part, since only the first part contains the metadata resources.
3880 * @param resource_wims
3881 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3882 * split WIM parts to reference.
3883 * @param num_resource_wims
3884 * Number of entries in @p resource_wims.
3886 * Reserved; must be 0.
3888 * @return 0 on success; a ::wimlib_error_code value on failure.
3891 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3892 unsigned num_resource_wims, int ref_flags);
3895 * @ingroup G_modifying_wims
3897 * Declare that a newly added image is mostly the same as a prior image, but
3898 * captured at a later point in time, possibly with some modifications in the
3899 * intervening time. This is designed to be used in incremental backups of the
3900 * same filesystem or directory tree.
3902 * This function compares the metadata of the directory tree of the newly added
3903 * image against that of the old image. Any files that are present in both the
3904 * newly added image and the old image and have timestamps that indicate they
3905 * haven't been modified are deemed not to have been modified and have their
3906 * checksums copied from the old image. Because of this and because WIM uses
3907 * single-instance streams, such files need not be read from the filesystem when
3908 * the WIM is being written or overwritten. Note that these unchanged files
3909 * will still be "archived" and will be logically present in the new image; the
3910 * optimization is that they don't need to actually be read from the filesystem
3911 * because the WIM already contains them.
3913 * This function is provided to optimize incremental backups. The resulting WIM
3914 * file will still be the same regardless of whether this function is called.
3915 * (This is, however, assuming that timestamps have not been manipulated or
3916 * unmaintained as to trick this function into thinking a file has not been
3917 * modified when really it has. To partly guard against such cases, other
3918 * metadata such as file sizes will be checked as well.)
3920 * This function must be called after adding the new image (e.g. with
3921 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3922 * wimlib_overwrite()).
3925 * Pointer to the ::WIMStruct containing the newly added image.
3927 * The 1-based index in @p wim of the newly added image.
3928 * @param template_wim
3929 * Pointer to the ::WIMStruct containing the template image. This can be,
3930 * but does not have to be, the same ::WIMStruct as @p wim.
3931 * @param template_image
3932 * The 1-based index in @p template_wim of the template image.
3934 * Reserved; must be 0.
3936 * @return 0 on success; a ::wimlib_error_code value on failure.
3938 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3939 * @p new_image does not exist in @p wim or @p template_image does not
3940 * exist in @p template_wim.
3941 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3942 * At least one of @p wim and @p template_wim does not contain image
3943 * metadata; for example, one of them represents a non-first part of a
3945 * @retval ::WIMLIB_ERR_INVALID_PARAM
3946 * Identical values were provided for the template and new image; or @p
3947 * new_image specified an image that had not been modified since opening
3950 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3951 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3952 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3953 * indicate failure (for different reasons) to read the metadata resource for
3954 * the template image.
3957 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3958 WIMStruct *template_wim, int template_image,
3962 * @ingroup G_general
3964 * Register a progress function with a ::WIMStruct.
3967 * The ::WIMStruct for which to register the progress function.
3969 * Pointer to the progress function to register. If the WIM already has a
3970 * progress function registered, it will be replaced with this one. If @p
3971 * NULL, the current progress function (if any) will be unregistered.
3973 * The value which will be passed as the third argument to calls to @p
3977 wimlib_register_progress_function(WIMStruct *wim,
3978 wimlib_progress_func_t progfunc,
3982 * @ingroup G_modifying_wims
3984 * Rename the @p source_path to the @p dest_path in the specified @p image of
3987 * This just builds an appropriate ::wimlib_rename_command and passes it to
3988 * wimlib_update_image().
3991 wimlib_rename_path(WIMStruct *wim, int image,
3992 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3995 * @ingroup G_wim_information
3997 * Translate a string specifying the name or number of an image in the WIM into
3998 * the number of the image. The images are numbered starting at 1.
4001 * Pointer to the ::WIMStruct for a WIM.
4002 * @param image_name_or_num
4003 * A string specifying the name or number of an image in the WIM. If it
4004 * parses to a positive integer, this integer is taken to specify the
4005 * number of the image, indexed starting at 1. Otherwise, it is taken to
4006 * be the name of an image, as given in the XML data for the WIM file. It
4007 * also may be the keyword "all" or the string "*", both of which will
4008 * resolve to ::WIMLIB_ALL_IMAGES.
4010 * There is no way to search for an image actually named "all", "*", or an
4011 * integer number, or an image that has no name. However, you can use
4012 * wimlib_get_image_name() to get the name of any image.
4015 * If the string resolved to a single existing image, the number of that
4016 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
4017 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
4018 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
4019 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
4020 * images in @p wim has no name. (Since a WIM may have multiple unnamed
4021 * images, an unnamed image must be specified by index to eliminate the
4025 wimlib_resolve_image(WIMStruct *wim,
4026 const wimlib_tchar *image_name_or_num);
4029 * @ingroup G_general
4031 * Set the file to which the library will print error and warning messages.
4033 * This version of the function takes a C library <c>FILE*</c> opened for
4034 * writing (or appending). Use wimlib_set_error_file_by_name() to specify the
4035 * file by name instead.
4037 * This also enables error messages, as if by a call to
4038 * wimlib_set_print_errors(true).
4043 wimlib_set_error_file(FILE *fp);
4046 * @ingroup G_general
4048 * Set the path to the file to which the library will print error and warning
4049 * messages. The library will open this file for appending.
4051 * This also enables error messages, as if by a call to
4052 * wimlib_set_print_errors(true).
4054 * @return 0 on success; a ::wimlib_error_code value on failure.
4056 * @retval ::WIMLIB_ERR_OPEN
4057 * The file named by @p path could not be opened for appending.
4060 wimlib_set_error_file_by_name(const wimlib_tchar *path);
4063 * @ingroup G_modifying_wims
4065 * Change the description of a WIM image. Equivalent to
4066 * <tt>wimlib_set_image_property(wim, image, "DESCRIPTION", description)</tt>.
4068 * Note that "description" is misspelled in the name of this function.
4071 wimlib_set_image_descripton(WIMStruct *wim, int image,
4072 const wimlib_tchar *description);
4075 * @ingroup G_modifying_wims
4077 * Change what is stored in the \<FLAGS\> element in the WIM XML document
4078 * (usually something like "Core" or "Ultimate"). Equivalent to
4079 * <tt>wimlib_set_image_property(wim, image, "FLAGS", flags)</tt>.
4082 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
4085 * @ingroup G_modifying_wims
4087 * Change the name of a WIM image. Equivalent to
4088 * <tt>wimlib_set_image_property(wim, image, "NAME", name)</tt>.
4091 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
4094 * @ingroup G_modifying_wims
4096 * Since wimlib v1.8.3: add, modify, or remove a per-image property from the
4097 * WIM's XML document. This is an alternative to wimlib_set_image_name(),
4098 * wimlib_set_image_descripton(), and wimlib_set_image_flags() which allows
4099 * manipulating any simple string property.
4102 * Pointer to the ::WIMStruct for the WIM.
4104 * The 1-based index of the image for which to set the property.
4105 * @param property_name
4106 * The name of the image property in the same format documented for
4107 * wimlib_get_image_property().
4109 * Note: if creating a new element using a bracketed index such as
4110 * "WINDOWS/LANGUAGES/LANGUAGE[2]", the highest index that can be specified
4111 * is one greater than the number of existing elements with that same name,
4112 * excluding the index. That means that if you are adding a list of new
4113 * elements, they must be added sequentially from the first index (1) to
4114 * the last index (n).
4115 * @param property_value
4116 * If not NULL and not empty, the property is set to this value.
4117 * Otherwise, the property is removed from the XML document.
4119 * @return 0 on success; a ::wimlib_error_code value on failure.
4121 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
4122 * The user requested to set the image name (the <tt>NAME</tt> property),
4123 * but another image in the WIM already had the requested name.
4124 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4125 * @p image does not exist in @p wim.
4126 * @retval ::WIMLIB_ERR_INVALID_PARAM
4127 * @p property_name has an unsupported format, or @p property_name included
4128 * a bracketed index that was too high.
4131 wimlib_set_image_property(WIMStruct *wim, int image,
4132 const wimlib_tchar *property_name,
4133 const wimlib_tchar *property_value);
4136 * @ingroup G_general
4138 * Set the functions that wimlib uses to allocate and free memory.
4140 * These settings are global and not per-WIM.
4142 * The default is to use the default @c malloc(), @c free(), and @c realloc()
4143 * from the standard C library.
4145 * Note: some external functions, such as those in @c libntfs-3g, may use the
4146 * standard memory allocation functions regardless of this setting.
4148 * @param malloc_func
4149 * A function equivalent to @c malloc() that wimlib will use to allocate
4150 * memory. If @c NULL, the allocator function is set back to the default
4151 * @c malloc() from the C library.
4153 * A function equivalent to @c free() that wimlib will use to free memory.
4154 * If @c NULL, the free function is set back to the default @c free() from
4156 * @param realloc_func
4157 * A function equivalent to @c realloc() that wimlib will use to reallocate
4158 * memory. If @c NULL, the free function is set back to the default @c
4159 * realloc() from the C library.
4164 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
4165 void (*free_func)(void *),
4166 void *(*realloc_func)(void *, size_t));
4169 * @ingroup G_writing_and_overwriting_wims
4171 * Set a ::WIMStruct's output compression chunk size. This is the compression
4172 * chunk size that will be used for writing non-solid resources in subsequent
4173 * calls to wimlib_write() or wimlib_overwrite(). A larger compression chunk
4174 * size often results in a better compression ratio, but compression may be
4175 * slower and the speed of random access to data may be reduced. In addition,
4176 * some chunk sizes are not compatible with Microsoft software.
4179 * The ::WIMStruct for which to set the output chunk size.
4181 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
4182 * on the compression type. See the documentation for each
4183 * ::wimlib_compression_type constant for more information. As a special
4184 * case, if @p chunk_size is specified as 0, then the chunk size will be
4185 * reset to the default for the currently selected output compression type.
4187 * @return 0 on success; a ::wimlib_error_code value on failure.
4189 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
4190 * @p chunk_size was not 0 or a supported chunk size for the currently
4191 * selected output compression type.
4194 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4197 * @ingroup G_writing_and_overwriting_wims
4199 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
4203 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4206 * @ingroup G_writing_and_overwriting_wims
4208 * Set a ::WIMStruct's output compression type. This is the compression type
4209 * that will be used for writing non-solid resources in subsequent calls to
4210 * wimlib_write() or wimlib_overwrite().
4213 * The ::WIMStruct for which to set the output compression type.
4215 * The compression type to set. If this compression type is incompatible
4216 * with the current output chunk size, then the output chunk size will be
4217 * reset to the default for the new compression type.
4219 * @return 0 on success; a ::wimlib_error_code value on failure.
4221 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4222 * @p ctype did not specify a valid compression type.
4225 wimlib_set_output_compression_type(WIMStruct *wim,
4226 enum wimlib_compression_type ctype);
4229 * @ingroup G_writing_and_overwriting_wims
4231 * Similar to wimlib_set_output_compression_type(), but set the compression type
4232 * for writing solid resources. This cannot be ::WIMLIB_COMPRESSION_TYPE_NONE.
4235 wimlib_set_output_pack_compression_type(WIMStruct *wim,
4236 enum wimlib_compression_type ctype);
4239 * @ingroup G_general
4241 * Set whether wimlib can print error and warning messages to the error file,
4242 * which defaults to standard error. Error and warning messages may provide
4243 * information that cannot be determined only from returned error codes.
4245 * By default, error messages are not printed.
4247 * This setting applies globally (it is not per-WIM).
4249 * This can be called before wimlib_global_init().
4251 * @param show_messages
4252 * @c true if messages are to be printed; @c false if messages are not to
4258 wimlib_set_print_errors(bool show_messages);
4261 * @ingroup G_modifying_wims
4263 * Set basic information about a WIM.
4266 * Pointer to the ::WIMStruct for a WIM.
4268 * Pointer to a ::wimlib_wim_info structure that contains the information
4269 * to set. Only the information explicitly specified in the @p which flags
4272 * Flags that specify which information to set. This is a bitwise OR of
4273 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
4274 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
4276 * @return 0 on success; a ::wimlib_error_code value on failure.
4278 * @retval ::WIMLIB_ERR_IMAGE_COUNT
4279 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
4280 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
4284 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
4288 * @ingroup G_nonstandalone_wims
4290 * Split a WIM into multiple parts.
4293 * The ::WIMStruct for the WIM to split.
4295 * Name of the split WIM (SWM) file to create. This will be the name of
4296 * the first part. The other parts will, by default, have the same name
4297 * with 2, 3, 4, ..., etc. appended before the suffix. However, the exact
4298 * names can be customized using the progress function.
4300 * The maximum size per part, in bytes. Unfortunately, it is not
4301 * guaranteed that this will really be the maximum size per part, because
4302 * some file resources in the WIM may be larger than this size, and the WIM
4303 * file format provides no way to split up file resources among multiple
4305 * @param write_flags
4306 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
4307 * flags will be used to write each split WIM part. Specify 0 here to get
4308 * the default behavior.
4310 * @return 0 on success; a ::wimlib_error_code value on failure. This function
4311 * may return most error codes that can be returned by wimlib_write() as well as
4312 * the following error codes:
4314 * @retval ::WIMLIB_ERR_INVALID_PARAM
4315 * @p swm_name was not a nonempty string, or @p part_size was 0.
4316 * @retval ::WIMLIB_ERR_UNSUPPORTED
4317 * The WIM contains solid resources. Splitting a WIM containing solid
4318 * resources is not supported.
4320 * If a progress function is registered with @p wim, then for each split WIM
4321 * part that is written it will receive the messages
4322 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
4323 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. Since wimlib v1.13.4 it will also
4324 * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages while writing each part;
4325 * these messages will report the progress of the current part only.
4328 wimlib_split(WIMStruct *wim,
4329 const wimlib_tchar *swm_name,
4334 * @ingroup G_general
4336 * Perform verification checks on a WIM file.
4338 * This function is intended for safety checking and/or debugging. If used on a
4339 * well-formed WIM file, it should always succeed.
4342 * The ::WIMStruct for the WIM file to verify. Note: for an extra layer of
4343 * verification, it is a good idea to have used
4344 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
4346 * If verifying a split WIM, specify the first part of the split WIM here,
4347 * and reference the other parts using wimlib_reference_resource_files()
4348 * before calling this function.
4349 * @param verify_flags
4350 * Reserved; must be 0.
4352 * @return 0 if the WIM file was successfully verified; a ::wimlib_error_code
4353 * value if it failed verification or another error occurred.
4355 * @retval ::WIMLIB_ERR_DECOMPRESSION
4356 * The WIM file contains invalid compressed data.
4357 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
4358 * The metadata resource for an image is invalid.
4359 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4360 * File data stored in the WIM file is corrupt.
4361 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4362 * The data for a file in an image could not be found. See @ref
4363 * G_nonstandalone_wims.
4365 * If a progress function is registered with @p wim, then it will receive the
4366 * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
4367 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
4368 * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
4371 wimlib_verify_wim(WIMStruct *wim, int verify_flags);
4374 * @ingroup G_mounting_wim_images
4376 * Unmount a WIM image that was mounted using wimlib_mount_image().
4378 * When unmounting a read-write mounted image, the default behavior is to
4379 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
4380 * image to be committed.
4383 * The directory on which the WIM image is mounted.
4384 * @param unmount_flags
4385 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
4387 * @return 0 on success; a ::wimlib_error_code value on failure.
4389 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
4390 * There is no WIM image mounted on the specified directory.
4391 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
4392 * The read-write mounted image cannot be committed because there are file
4393 * descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
4395 * @retval ::WIMLIB_ERR_MQUEUE
4396 * Could not create a POSIX message queue.
4397 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
4398 * The image was mounted by a different user.
4399 * @retval ::WIMLIB_ERR_UNSUPPORTED
4400 * Mounting is not supported in this build of the library.
4402 * Note: you can also unmount the image by using the @c umount() system call, or
4403 * by using the @c umount or @c fusermount programs. However, you need to call
4404 * this function if you want changes to be committed.
4407 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
4410 * @ingroup G_mounting_wim_images
4412 * Same as wimlib_unmount_image(), but allows specifying a progress function.
4413 * The progress function will receive a ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN
4414 * message. In addition, if changes are committed from a read-write mount, the
4415 * progress function will receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
4418 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
4420 wimlib_progress_func_t progfunc,
4424 * @ingroup G_modifying_wims
4426 * Update a WIM image by adding, deleting, and/or renaming files or directories.
4429 * Pointer to the ::WIMStruct containing the image to update.
4431 * The 1-based index of the image to update.
4433 * An array of ::wimlib_update_command's that specify the update operations
4436 * Number of commands in @p cmds.
4437 * @param update_flags
4438 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
4440 * @return 0 on success; a ::wimlib_error_code value on failure. On failure,
4441 * all update commands will be rolled back, and no visible changes will have
4442 * been made to @p wim.
4444 * @retval ::WIMLIB_ERR_FVE_LOCKED_VOLUME
4445 * Windows-only: One of the "add" commands attempted to add files from an
4446 * encrypted BitLocker volume that hasn't yet been unlocked.
4447 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
4448 * There are currently multiple references to the image as a result of a
4449 * call to wimlib_export_image(). Free one before attempting the update.
4450 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
4451 * The contents of a capture configuration file were invalid.
4452 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4453 * @p image did not exist in @p wim.
4454 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
4455 * An add command with ::WIMLIB_ADD_FLAG_NO_REPLACE specified attempted to
4456 * replace an existing nondirectory file.
4457 * @retval ::WIMLIB_ERR_INVALID_PARAM
4458 * An unknown operation type was provided in the update commands; or
4459 * unknown or incompatible flags were provided in a flags parameter; or
4460 * there was another problem with the provided parameters.
4461 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4462 * While executing an add command, a reparse point had invalid data.
4463 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4464 * An add command attempted to replace a directory with a non-directory; or
4465 * a delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE attempted to
4466 * delete a directory; or a rename command attempted to rename a directory
4467 * to a non-directory.
4468 * @retval ::WIMLIB_ERR_NOTDIR
4469 * An add command attempted to replace a non-directory with a directory; or
4470 * an add command attempted to set the root of the image to a
4471 * non-directory; or a rename command attempted to rename a directory to a
4472 * non-directory; or a component of an image path that was used as a
4473 * directory was not, in fact, a directory.
4474 * @retval ::WIMLIB_ERR_NOTEMPTY
4475 * A rename command attempted to rename a directory to a non-empty
4476 * directory; or a rename command would have created a loop.
4477 * @retval ::WIMLIB_ERR_NTFS_3G
4478 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4479 * error occurred while reading data from the NTFS volume using libntfs-3g.
4480 * @retval ::WIMLIB_ERR_OPEN
4481 * Failed to open a file to be captured while executing an add command.
4482 * @retval ::WIMLIB_ERR_OPENDIR
4483 * Failed to open a directory to be captured while executing an add
4485 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4486 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4487 * WIM path that did not exist; or a rename command attempted to rename a
4488 * file that does not exist.
4489 * @retval ::WIMLIB_ERR_READ
4490 * While executing an add command, failed to read data from a file or
4491 * directory to be captured.
4492 * @retval ::WIMLIB_ERR_READLINK
4493 * While executing an add command, failed to read the target of a symbolic
4494 * link, junction, or other reparse point.
4495 * @retval ::WIMLIB_ERR_STAT
4496 * While executing an add command, failed to read metadata for a file or
4498 * @retval ::WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG
4499 * A capture configuration file could not be read.
4500 * @retval ::WIMLIB_ERR_UNSUPPORTED
4501 * A command had flags provided that are not supported on this platform or
4502 * in this build of the library.
4503 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4504 * An add command with ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified
4505 * discovered a file that was not of a supported type.
4507 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4508 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4509 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4510 * indicate failure (for different reasons) to read the metadata resource for an
4511 * image that needed to be updated.
4514 wimlib_update_image(WIMStruct *wim,
4516 const struct wimlib_update_command *cmds,
4521 * @ingroup G_writing_and_overwriting_wims
4523 * Persist a ::WIMStruct to a new on-disk WIM file.
4525 * This brings in file data from any external locations, such as directory trees
4526 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4527 * wimlib_export_image(), and incorporates it into a new on-disk WIM file.
4529 * By default, the new WIM file is written as stand-alone. Using the
4530 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4531 * instead. However, this function cannot directly write a "split" WIM; use
4532 * wimlib_split() for that.
4535 * Pointer to the ::WIMStruct being persisted.
4537 * The path to the on-disk file to write.
4539 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4540 * images are to be included in the new on-disk WIM file. If for some
4541 * reason you only want to include a single image, specify the 1-based
4542 * index of that image instead.
4543 * @param write_flags
4544 * Bitwise OR of flags prefixed with @c WIMLIB_WRITE_FLAG.
4545 * @param num_threads
4546 * The number of threads to use for compressing data, or 0 to have the
4547 * library automatically choose an appropriate number.
4549 * @return 0 on success; a ::wimlib_error_code value on failure.
4551 * @retval ::WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED
4552 * A file that had previously been scanned for inclusion in the WIM was
4553 * concurrently modified.
4554 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4555 * @p image did not exist in @p wim.
4556 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4557 * A file, stored in another WIM, which needed to be written was corrupt.
4558 * @retval ::WIMLIB_ERR_INVALID_PARAM
4559 * @p path was not a nonempty string, or invalid flags were passed.
4560 * @retval ::WIMLIB_ERR_OPEN
4561 * Failed to open the output WIM file for writing, or failed to open a file
4562 * whose data needed to be included in the WIM.
4563 * @retval ::WIMLIB_ERR_READ
4564 * Failed to read data that needed to be included in the WIM.
4565 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4566 * A file data blob that needed to be written could not be found in the
4567 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
4568 * @retval ::WIMLIB_ERR_WRITE
4569 * An error occurred when trying to write data to the new WIM file.
4571 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4572 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4573 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4574 * indicate failure (for different reasons) to read the data from a WIM file.
4576 * If a progress function is registered with @p wim, then it will receive the
4577 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4578 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4579 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4582 wimlib_write(WIMStruct *wim,
4583 const wimlib_tchar *path,
4586 unsigned num_threads);
4589 * @ingroup G_writing_and_overwriting_wims
4591 * Same as wimlib_write(), but write the WIM directly to a file descriptor,
4592 * which need not be seekable if the write is done in a special pipable WIM
4593 * format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p write_flags. This can,
4594 * for example, allow capturing a WIM image and streaming it over the network.
4595 * See @ref subsec_pipable_wims for more information about pipable WIMs.
4597 * The file descriptor @p fd will @b not be closed when the write is complete;
4598 * the calling code is responsible for this.
4600 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
4601 * error codes include those that can be returned by wimlib_write() as well as
4604 * @retval ::WIMLIB_ERR_INVALID_PARAM
4605 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4606 * specified in @p write_flags.
4609 wimlib_write_to_fd(WIMStruct *wim,
4613 unsigned num_threads);
4616 * @defgroup G_compression Compression and decompression functions
4618 * @brief Functions for XPRESS, LZX, and LZMS compression and decompression.
4620 * These functions are already used by wimlib internally when appropriate for
4621 * reading and writing WIM archives. But they are exported and documented so
4622 * that they can be used in other applications or libraries for general-purpose
4623 * lossless data compression. They are implemented in highly optimized C code,
4624 * using state-of-the-art compression techniques. The main limitation is the
4625 * lack of sliding window support; this has, however, allowed the algorithms to
4626 * be optimized for block-based compression.
4631 /** Opaque compressor handle. */
4632 struct wimlib_compressor;
4634 /** Opaque decompressor handle. */
4635 struct wimlib_decompressor;
4638 * Set the default compression level for the specified compression type. This
4639 * is the compression level that wimlib_create_compressor() assumes if it is
4640 * called with @p compression_level specified as 0.
4642 * wimlib's WIM writing code (e.g. wimlib_write()) will pass 0 to
4643 * wimlib_create_compressor() internally. Therefore, calling this function will
4644 * affect the compression level of any data later written to WIM files using the
4645 * specified compression type.
4647 * The initial state, before this function is called, is that all compression
4648 * types have a default compression level of 50.
4651 * Compression type for which to set the default compression level, as one
4652 * of the ::wimlib_compression_type constants. Or, if this is the special
4653 * value -1, the default compression levels for all compression types will
4655 * @param compression_level
4656 * The default compression level to set. If 0, the "default default" level
4657 * of 50 is restored. Otherwise, a higher value indicates higher
4658 * compression, whereas a lower value indicates lower compression. See
4659 * wimlib_create_compressor() for more information.
4661 * @return 0 on success; a ::wimlib_error_code value on failure.
4663 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4664 * @p ctype was neither a supported compression type nor -1.
4667 wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
4670 * Return the approximate number of bytes needed to allocate a compressor with
4671 * wimlib_create_compressor() for the specified compression type, maximum block
4672 * size, and compression level. @p compression_level may be 0, in which case
4673 * the current default compression level for @p ctype is used. Returns 0 if the
4674 * compression type is invalid, or the @p max_block_size for that compression
4678 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4679 size_t max_block_size,
4680 unsigned int compression_level);
4682 #define WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE 0x80000000
4685 * Allocate a compressor for the specified compression type using the specified
4686 * parameters. This function is part of wimlib's compression API; it is not
4687 * necessary to call this to process a WIM file.
4690 * Compression type for which to create the compressor, as one of the
4691 * ::wimlib_compression_type constants.
4692 * @param max_block_size
4693 * The maximum compression block size to support. This specifies the
4694 * maximum allowed value for the @p uncompressed_size parameter of
4695 * wimlib_compress() when called using this compressor.
4697 * Usually, the amount of memory used by the compressor will scale in
4698 * proportion to the @p max_block_size parameter.
4699 * wimlib_get_compressor_needed_memory() can be used to query the specific
4700 * amount of memory that will be required.
4702 * This parameter must be at least 1 and must be less than or equal to a
4703 * compression-type-specific limit.
4705 * In general, the same value of @p max_block_size must be passed to
4706 * wimlib_create_decompressor() when the data is later decompressed.
4707 * However, some compression types have looser requirements regarding this.
4708 * @param compression_level
4709 * The compression level to use. If 0, the default compression level (50,
4710 * or another value as set through wimlib_set_default_compression_level())
4711 * is used. Otherwise, a higher value indicates higher compression. The
4712 * values are scaled so that 10 is low compression, 50 is medium
4713 * compression, and 100 is high compression. This is not a percentage;
4714 * values above 100 are also valid.
4716 * Using a higher-than-default compression level can result in a better
4717 * compression ratio, but can significantly reduce performance. Similarly,
4718 * using a lower-than-default compression level can result in better
4719 * performance, but can significantly worsen the compression ratio. The
4720 * exact results will depend heavily on the compression type and what
4721 * algorithms are implemented for it. If you are considering using a
4722 * non-default compression level, you should run benchmarks to see if it is
4723 * worthwhile for your application.
4725 * The compression level does not affect the format of the compressed data.
4726 * Therefore, it is a compressor-only parameter and does not need to be
4727 * passed to the decompressor.
4729 * Since wimlib v1.8.0, this parameter can be OR-ed with the flag
4730 * ::WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE. This creates the compressor in a
4731 * mode where it is allowed to modify the input buffer. Specifically, in
4732 * this mode, if compression succeeds, the input buffer may have been
4733 * modified, whereas if compression does not succeed the input buffer still
4734 * may have been written to but will have been restored exactly to its
4735 * original state. This mode is designed to save some memory when using
4736 * large buffer sizes.
4737 * @param compressor_ret
4738 * A location into which to return the pointer to the allocated compressor.
4739 * The allocated compressor can be used for any number of calls to
4740 * wimlib_compress() before being freed with wimlib_free_compressor().
4742 * @return 0 on success; a ::wimlib_error_code value on failure.
4744 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4745 * @p ctype was not a supported compression type.
4746 * @retval ::WIMLIB_ERR_INVALID_PARAM
4747 * @p max_block_size was invalid for the compression type, or @p
4748 * compressor_ret was @c NULL.
4749 * @retval ::WIMLIB_ERR_NOMEM
4750 * Insufficient memory to allocate the compressor.
4753 wimlib_create_compressor(enum wimlib_compression_type ctype,
4754 size_t max_block_size,
4755 unsigned int compression_level,
4756 struct wimlib_compressor **compressor_ret);
4759 * Compress a buffer of data.
4761 * @param uncompressed_data
4762 * Buffer containing the data to compress.
4763 * @param uncompressed_size
4764 * Size, in bytes, of the data to compress. This cannot be greater than
4765 * the @p max_block_size with which wimlib_create_compressor() was called.
4766 * (If it is, the data will not be compressed and 0 will be returned.)
4767 * @param compressed_data
4768 * Buffer into which to write the compressed data.
4769 * @param compressed_size_avail
4770 * Number of bytes available in @p compressed_data.
4772 * A compressor previously allocated with wimlib_create_compressor().
4775 * The size of the compressed data, in bytes, or 0 if the data could not be
4776 * compressed to @p compressed_size_avail or fewer bytes.
4779 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4780 void *compressed_data, size_t compressed_size_avail,
4781 struct wimlib_compressor *compressor);
4784 * Free a compressor previously allocated with wimlib_create_compressor().
4787 * The compressor to free. If @c NULL, no action is taken.
4790 wimlib_free_compressor(struct wimlib_compressor *compressor);
4793 * Allocate a decompressor for the specified compression type. This function is
4794 * part of wimlib's compression API; it is not necessary to call this to process
4798 * Compression type for which to create the decompressor, as one of the
4799 * ::wimlib_compression_type constants.
4800 * @param max_block_size
4801 * The maximum compression block size to support. This specifies the
4802 * maximum allowed value for the @p uncompressed_size parameter of
4803 * wimlib_decompress().
4805 * In general, this parameter must be the same as the @p max_block_size
4806 * that was passed to wimlib_create_compressor() when the data was
4807 * compressed. However, some compression types have looser requirements
4809 * @param decompressor_ret
4810 * A location into which to return the pointer to the allocated
4811 * decompressor. The allocated decompressor can be used for any number of
4812 * calls to wimlib_decompress() before being freed with
4813 * wimlib_free_decompressor().
4815 * @return 0 on success; a ::wimlib_error_code value on failure.
4817 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4818 * @p ctype was not a supported compression type.
4819 * @retval ::WIMLIB_ERR_INVALID_PARAM
4820 * @p max_block_size was invalid for the compression type, or @p
4821 * decompressor_ret was @c NULL.
4822 * @retval ::WIMLIB_ERR_NOMEM
4823 * Insufficient memory to allocate the decompressor.
4826 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4827 size_t max_block_size,
4828 struct wimlib_decompressor **decompressor_ret);
4831 * Decompress a buffer of data.
4833 * @param compressed_data
4834 * Buffer containing the data to decompress.
4835 * @param compressed_size
4836 * Size, in bytes, of the data to decompress.
4837 * @param uncompressed_data
4838 * Buffer into which to write the uncompressed data.
4839 * @param uncompressed_size
4840 * Size, in bytes, of the data when uncompressed. This cannot exceed the
4841 * @p max_block_size with which wimlib_create_decompressor() was called.
4842 * (If it does, the data will not be decompressed and a nonzero value will
4844 * @param decompressor
4845 * A decompressor previously allocated with wimlib_create_decompressor().
4847 * @return 0 on success; nonzero on failure.
4849 * No specific error codes are defined; any nonzero value indicates that the
4850 * decompression failed. This can only occur if the data is truly invalid;
4851 * there will never be transient errors like "out of memory", for example.
4853 * This function requires that the exact uncompressed size of the data be passed
4854 * as the @p uncompressed_size parameter. If this is not done correctly,
4855 * decompression may fail or the data may be decompressed incorrectly.
4858 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4859 void *uncompressed_data, size_t uncompressed_size,
4860 struct wimlib_decompressor *decompressor);
4863 * Free a decompressor previously allocated with wimlib_create_decompressor().
4865 * @param decompressor
4866 * The decompressor to free. If @c NULL, no action is taken.
4869 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4881 #endif /* _WIMLIB_H */