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.9.1, a C
15 * library for creating, modifying, extracting, and mounting files in the
16 * Windows Imaging Format. This documentation is intended for developers only.
17 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
18 * program, please see the manual pages and also the <a
19 * href="https://wimlib.net/gitlist/wimlib/blob/master/README">README file</a>.
21 * @section sec_installing Installing
25 * Download the source code from https://wimlib.net. Install the library by
26 * running <c>configure && make && sudo make install</c>. See the README for
27 * information about configuration options. To use wimlib in your program after
28 * installing it, include wimlib.h and link your program with <c>-lwim</c>.
32 * Download the Windows binary distribution with the appropriate architecture
33 * (i686 or x86_64 --- also called "x86" and "amd64" respectively) from
34 * https://wimlib.net. Link your program with the libwim-15.dll file. Make
35 * sure to also download the source code so you can get wimlib.h, as it is not
36 * included in the binary distribution. If you need to access the DLL from
37 * other programming languages, note that the calling convention is "cdecl".
39 * Note that wimlib is developed using MinGW-w64, and there may be a little work
40 * required if you plan to use the header and DLL with Visual Studio.
42 * @section sec_examples Examples
44 * Several examples are located in the "examples" directory of the source
45 * distribution. Also see @ref sec_basic_wim_handling_concepts below.
47 * There is also the <a
48 * href="https://wimlib.net/gitlist/wimlib/blob/master/programs/imagex.c">
49 * source code of <b>wimlib-imagex</b></a>, which is complicated but uses most
50 * capabilities of wimlib.
52 * @section backward_compatibility Backward Compatibility
54 * New releases of wimlib are intended to be backward compatible with old
55 * releases, except when the libtool "age" is reset. This most recently
56 * occurred for the v1.7.0 (libwim15) release (June 2014). Since the library is
57 * becoming increasingly stable, the goal is to maintain the current API/ABI for
58 * as long as possible unless there is a strong reason not to.
60 * As with any other library, applications should not rely on internal
61 * implementation details that may be subject to change.
63 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
65 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
66 * two ways to create such a structure:
68 * 1. wimlib_open_wim() opens an on-disk WIM file and creates a ::WIMStruct for
70 * 2. wimlib_create_new_wim() creates a new ::WIMStruct that initially contains
71 * no images and does not yet have a backing on-disk file.
73 * A ::WIMStruct contains zero or more independent directory trees called @a
74 * images. Images may be extracted, added, deleted, exported, and updated using
75 * various API functions. (See @ref G_extracting_wims and @ref G_modifying_wims
78 * Changes made to a WIM represented by a ::WIMStruct have no persistent effect
79 * until the WIM is actually written to an on-disk file. This can be done using
80 * wimlib_write(), but if the WIM was originally opened using wimlib_open_wim(),
81 * then wimlib_overwrite() can be used instead. (See @ref
82 * G_writing_and_overwriting_wims for more details.)
84 * wimlib's API is designed to let you combine functions to accomplish tasks in
85 * a flexible way. Here are some example sequences of function calls:
87 * Apply an image from a WIM file, similar to the command-line program
90 * 1. wimlib_open_wim()
91 * 2. wimlib_extract_image()
93 * Capture an image into a new WIM file, similar to <b>wimcapture</b>:
95 * 1. wimlib_create_new_wim()
96 * 2. wimlib_add_image()
99 * Append an image to an existing WIM file, similar to <b>wimappend</b>:
101 * 1. wimlib_open_wim()
102 * 2. wimlib_add_image()
103 * 3. wimlib_overwrite()
105 * Delete an image from an existing WIM file, similar to <b>wimdelete</b>:
107 * 1. wimlib_open_wim()
108 * 2. wimlib_delete_image()
109 * 3. wimlib_overwrite()
111 * Export an image from one WIM file to another, similar to <b>wimexport</b>:
113 * 1. wimlib_open_wim() (on source)
114 * 2. wimlib_open_wim() (on destination)
115 * 3. wimlib_export_image()
116 * 4. wimlib_overwrite() (on destination)
118 * The API also lets you do things the command-line tools don't directly allow.
119 * For example, you could make multiple changes to a WIM before efficiently
120 * committing the changes with just one call to wimlib_overwrite(). Perhaps you
121 * want to both delete an image and add a new one; or perhaps you want to
122 * customize an image with wimlib_update_image() after adding it. All these use
123 * cases are supported by the API.
125 * @section sec_cleaning_up Cleaning up
127 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
128 * all resources associated with it. Also, when you are completely done with
129 * using wimlib in your program, you can call wimlib_global_cleanup() to free
130 * any other resources allocated by the library.
132 * @section sec_error_handling Error Handling
134 * Most functions in wimlib return 0 on success and a positive
135 * ::wimlib_error_code value on failure. Use wimlib_get_error_string() to get a
136 * string that describes an error code. wimlib also can print error messages to
137 * standard error or a custom file when an error occurs, and these may be more
138 * informative than the error code; to enable this, call
139 * wimlib_set_print_errors(). Please note that this is for convenience only,
140 * and some errors can occur without a message being printed. Currently, error
141 * messages and strings (as well as all documentation, for that matter) are only
142 * available in English.
144 * @section sec_encodings Locales and character encodings
146 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
147 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
150 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
151 * and the encoding is UTF-16LE.
153 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
154 * and the encoding is the locale-dependent multibyte encoding. I recommend you
155 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
156 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
157 * call wimlib_global_init() after having set your desired locale.
159 * @section sec_advanced Additional information and features
162 * @subsection subsec_mounting_wim_images Mounting WIM images
164 * See @ref G_mounting_wim_images.
166 * @subsection subsec_progress_functions Progress Messages
168 * See @ref G_progress.
170 * @subsection subsec_non_standalone_wims Non-standalone WIMs
172 * See @ref G_nonstandalone_wims.
174 * @subsection subsec_pipable_wims Pipable WIMs
176 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
177 * compatible with Microsoft's software. To create a pipable WIM, call
178 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
179 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
180 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
181 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
182 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
183 * s using a seekable file descriptor using the regular function calls (e.g.
184 * wimlib_open_wim(), wimlib_extract_image()).
186 * See the documentation for the <b>--pipable</b> flag of <b>wimcapture</b> for
187 * more information about pipable WIMs.
189 * @subsection subsec_thread_safety Thread Safety
191 * A ::WIMStruct is not thread-safe and cannot be accessed by multiple threads
192 * concurrently, even for "read-only" operations such as extraction. However,
193 * users are free to use <i>different</i> ::WIMStruct's from different threads
194 * concurrently. It is even allowed for multiple ::WIMStruct's to be backed by
195 * the same on-disk WIM file, although "overwrites" should never be done in such
198 * In addition, several functions change global state and should only be called
199 * when a single thread is active in the library. These functions are:
201 * - wimlib_global_init()
202 * - wimlib_global_cleanup()
203 * - wimlib_set_memory_allocator()
204 * - wimlib_set_print_errors()
205 * - wimlib_set_error_file()
206 * - wimlib_set_error_file_by_name()
208 * @subsection subsec_limitations Limitations
210 * This section documents some technical limitations of wimlib not already
211 * described in the documentation for @b wimlib-imagex.
213 * - The old WIM format from Vista pre-releases is not supported.
214 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
215 * functionality other than that already present in @b ImageX, that allows you
216 * to make certain Windows-specific modifications to a Windows PE image, such
217 * as adding a driver or Windows component. Such a tool could be implemented
220 * @subsection more_info More information
222 * You are advised to read the README as well as the documentation for
223 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
224 * the API documentation.
227 /** @defgroup G_general General
229 * @brief Declarations and structures shared across the library.
232 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
234 * @brief Open an existing WIM file as a ::WIMStruct, or create a new
235 * ::WIMStruct which can be used to create a new WIM file.
238 /** @defgroup G_wim_information Retrieving WIM information and directory listings
240 * @brief Retrieve information about a WIM or WIM image.
243 /** @defgroup G_modifying_wims Modifying WIMs
245 * @brief Make changes to a ::WIMStruct, in preparation of persisting the
246 * ::WIMStruct to an on-disk file.
248 * @section sec_adding_images Capturing and adding WIM images
250 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
251 * appending an image to an existing WIM is a multi-step process, but at its
252 * core is wimlib_add_image() or an equivalent function. Normally,
253 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
254 * ::WIMStruct as a new image. However, when supported by the build of the
255 * library, there is also a special NTFS volume capture mode (entered when
256 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
257 * from an unmounted NTFS volume.
259 * Another function, wimlib_add_image_multisource() is also provided. It
260 * generalizes wimlib_add_image() to allow combining multiple files or directory
261 * trees into a single WIM image in a configurable way.
263 * For maximum customization of WIM image creation, it is also possible to add a
264 * completely empty WIM image with wimlib_add_empty_image(), then update it with
265 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
266 * wimlib_add_image_multisource() do internally.)
268 * Note that some details of how image addition/capture works are documented
269 * more fully in the documentation for <b>wimcapture</b>.
271 * @section sec_deleting_images Deleting WIM images
273 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
274 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
275 * be made persistent in an on-disk WIM file.
277 * @section sec_exporting_images Exporting WIM images
279 * wimlib_export_image() can copy, or "export", an image from one WIM to
282 * @section sec_other_modifications Other modifications
284 * wimlib_update_image() can add, delete, and rename files in a WIM image.
286 * wimlib_set_image_property() can change other image metadata.
288 * wimlib_set_wim_info() can change information about the WIM file itself, such
292 /** @defgroup G_extracting_wims Extracting WIMs
294 * @brief Extract files, directories, and images from a WIM.
296 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
297 * represented by a ::WIMStruct. This normally extracts the image to a
298 * directory, but when supported by the build of the library there is also a
299 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
300 * is specified) that allows extracting a WIM image directly to an unmounted
301 * NTFS volume. Various other flags allow further customization of image
304 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
305 * of (possibly wildcard) paths from a WIM image.
307 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
308 * over a pipe; see @ref subsec_pipable_wims.
310 * Some details of how WIM extraction works are described more fully in the
311 * documentation for <b>wimapply</b> and <b>wimextract</b>.
314 /** @defgroup G_mounting_wim_images Mounting WIM images
316 * @brief Mount and unmount WIM images.
318 * On Linux, wimlib supports mounting images from WIM files either read-only or
319 * read-write. To mount an image, call wimlib_mount_image(). To unmount an
320 * image, call wimlib_unmount_image(). Mounting can be done without root
321 * privileges because it is implemented using FUSE (Filesystem in Userspace).
323 * If wimlib is compiled using the <c>--without-fuse</c> flag, these functions
324 * will be available but will fail with ::WIMLIB_ERR_UNSUPPORTED.
326 * Note: if mounting is unsupported, wimlib still provides another way to modify
327 * a WIM image (wimlib_update_image()).
331 * @defgroup G_progress Progress Messages
333 * @brief Track the progress of long WIM operations.
335 * Library users can provide a progress function which will be called
336 * periodically during operations such as extracting a WIM image or writing a
337 * WIM image. A ::WIMStruct can have a progress function of type
338 * ::wimlib_progress_func_t associated with it by calling
339 * wimlib_register_progress_function() or by opening the ::WIMStruct using
340 * wimlib_open_wim_with_progress(). Once this is done, the progress function
341 * will be called automatically during many operations, such as
342 * wimlib_extract_image() and wimlib_write().
344 * Some functions that do not operate directly on a user-provided ::WIMStruct,
345 * such as wimlib_join(), also take the progress function directly using an
346 * extended version of the function, such as wimlib_join_with_progress().
348 * Since wimlib v1.7.0, progress functions are no longer just unidirectional.
349 * You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause the current
350 * operation to be aborted. wimlib v1.7.0 also added the third argument to
351 * ::wimlib_progress_func_t, which is a user-supplied context.
354 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
356 * @brief Create or update an on-disk WIM file.
358 * wimlib_write() creates a new on-disk WIM file, whereas wimlib_overwrite()
359 * updates an existing WIM file. See @ref sec_basic_wim_handling_concepts for
360 * more information about the API design.
363 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
365 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
367 * A ::WIMStruct backed by an on-disk file normally represents a fully
368 * standalone WIM archive. However, WIM archives can also be arranged in
369 * non-standalone ways, such as a set of on-disk files that together form a
370 * single "split WIM" or "delta WIM". Such arrangements are fully supported by
371 * wimlib. However, as a result, in such cases a ::WIMStruct created from one
372 * of these on-disk files initially only partially represents the full WIM and
373 * needs to, in effect, be logically combined with other ::WIMStruct's before
374 * performing certain operations, such as extracting files with
375 * wimlib_extract_image() or wimlib_extract_paths(). This is done by calling
376 * wimlib_reference_resource_files() or wimlib_reference_resources(). Note: if
377 * you fail to do so, you may see the error code
378 * ::WIMLIB_ERR_RESOURCE_NOT_FOUND; this just indicates that data is not
379 * available because the appropriate WIM files have not yet been referenced.
381 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
382 * specialized function (wimlib_split()) is needed to create a split WIM.
391 #include <inttypes.h>
394 /** @addtogroup G_general
397 /** Major version of the library (for example, the 1 in 1.2.5). */
398 #define WIMLIB_MAJOR_VERSION 1
400 /** Minor version of the library (for example, the 2 in 1.2.5). */
401 #define WIMLIB_MINOR_VERSION 9
403 /** Patch version of the library (for example, the 5 in 1.2.5). */
404 #define WIMLIB_PATCH_VERSION 1
411 * Opaque structure that represents a WIM, possibly backed by an on-disk file.
412 * See @ref sec_basic_wim_handling_concepts for more information.
414 #ifndef WIMLIB_WIMSTRUCT_DECLARED
415 typedef struct WIMStruct WIMStruct;
416 #define WIMLIB_WIMSTRUCT_DECLARED
420 typedef wchar_t wimlib_tchar;
422 /** See @ref sec_encodings */
423 typedef char wimlib_tchar;
427 /** Path separator for WIM paths passed back to progress callbacks.
428 * This is forward slash on UNIX and backslash on Windows. */
429 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
430 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
432 /** Path separator for WIM paths passed back to progress callbacks.
433 * This is forward slash on UNIX and backslash on Windows. */
434 # define WIMLIB_WIM_PATH_SEPARATOR '/'
435 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
438 /** A string containing a single path separator; use this to specify the root
439 * directory of a WIM image. */
440 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
442 /** Use this to test if the specified path refers to the root directory of the
444 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
445 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
448 /** Length of a Globally Unique Identifier (GUID), in bytes. */
449 #define WIMLIB_GUID_LEN 16
452 * Specifies a compression type.
454 * A WIM file has a default compression type, indicated by its file header.
455 * Normally, each resource in the WIM file is compressed with this compression
456 * type. However, resources may be stored as uncompressed; for example, wimlib
457 * may do so if a resource does not compress to less than its original size. In
458 * addition, a WIM with the new version number of 3584, or "ESD file", might
459 * contain solid resources with different compression types.
461 enum wimlib_compression_type {
465 * This is a valid argument to wimlib_create_new_wim() and
466 * wimlib_set_output_compression_type(), but not to the functions in the
467 * compression API such as wimlib_create_compressor().
469 WIMLIB_COMPRESSION_TYPE_NONE = 0,
472 * The XPRESS compression format. This format combines Lempel-Ziv
473 * factorization with Huffman encoding. Compression and decompression
474 * are both fast. This format supports chunk sizes that are powers of 2
475 * between <c>2^12</c> and <c>2^16</c>, inclusively.
477 * wimlib's XPRESS compressor will, with the default settings, usually
478 * produce a better compression ratio, and work more quickly, than the
479 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
480 * Non-default compression levels are also supported. For example,
481 * level 80 will enable two-pass optimal parsing, which is significantly
482 * slower but usually improves compression by several percent over the
483 * default level of 50.
485 * If using wimlib_create_compressor() to create an XPRESS compressor
486 * directly, the @p max_block_size parameter may be any positive value
487 * up to and including <c>2^16</c>.
489 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
492 * The LZX compression format. This format combines Lempel-Ziv
493 * factorization with Huffman encoding, but with more features and
494 * complexity than XPRESS. Compression is slow to somewhat fast,
495 * depending on the settings. Decompression is fast but slower than
496 * XPRESS. This format supports chunk sizes that are powers of 2
497 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
498 * other than <c>2^15</c> are not compatible with the Microsoft
501 * wimlib's LZX compressor will, with the default settings, usually
502 * produce a better compression ratio, and work more quickly, than the
503 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
504 * Non-default compression levels are also supported. For example,
505 * level 20 will provide fast compression, almost as fast as XPRESS.
507 * If using wimlib_create_compressor() to create an LZX compressor
508 * directly, the @p max_block_size parameter may be any positive value
509 * up to and including <c>2^21</c>.
511 WIMLIB_COMPRESSION_TYPE_LZX = 2,
514 * The LZMS compression format. This format combines Lempel-Ziv
515 * factorization with adaptive Huffman encoding and range coding.
516 * Compression and decompression are both fairly slow. This format
517 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
518 * <c>2^30</c>, inclusively. This format is best used for large chunk
519 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
520 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
521 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
522 * with the Microsoft implementation.
524 * wimlib's LZMS compressor will, with the default settings, usually
525 * produce a better compression ratio, and work more quickly, than the
526 * implementation in Microsoft's WIMGAPI (as of Windows 8.1). There is
527 * limited support for non-default compression levels, but compression
528 * will be noticeably faster if you choose a level < 35.
530 * If using wimlib_create_compressor() to create an LZMS compressor
531 * directly, the @p max_block_size parameter may be any positive value
532 * up to and including <c>2^30</c>.
534 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
538 /** @addtogroup G_progress
541 /** Possible values of the first parameter to the user-supplied
542 * ::wimlib_progress_func_t progress function */
543 enum wimlib_progress_msg {
545 /** A WIM image is about to be extracted. @p info will point to
546 * ::wimlib_progress_info.extract. This message is received once per
547 * image for calls to wimlib_extract_image() and
548 * wimlib_extract_image_from_pipe(). */
549 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
551 /** One or more file or directory trees within a WIM image is about to
552 * be extracted. @p info will point to ::wimlib_progress_info.extract.
553 * This message is received only once per wimlib_extract_paths() and
554 * wimlib_extract_pathlist(), since wimlib combines all paths into a
555 * single extraction operation for optimization purposes. */
556 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
558 /** This message may be sent periodically (not for every file) while
559 * files and directories are being created, prior to file data
560 * extraction. @p info will point to ::wimlib_progress_info.extract.
561 * In particular, the @p current_file_count and @p end_file_count
562 * members may be used to track the progress of this phase of
564 WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE = 3,
566 /** File data is currently being extracted. @p info will point to
567 * ::wimlib_progress_info.extract. This is the main message to track
568 * the progress of an extraction operation. */
569 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
571 /** Starting to read a new part of a split pipable WIM over the pipe.
572 * @p info will point to ::wimlib_progress_info.extract. */
573 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
575 /** This message may be sent periodically (not necessarily for every
576 * file) while file and directory metadata is being extracted, following
577 * file data extraction. @p info will point to
578 * ::wimlib_progress_info.extract. The @p current_file_count and @p
579 * end_file_count members may be used to track the progress of this
580 * phase of extraction. */
581 WIMLIB_PROGRESS_MSG_EXTRACT_METADATA = 6,
583 /** The image has been successfully extracted. @p info will point to
584 * ::wimlib_progress_info.extract. This is paired with
585 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
586 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
588 /** The files or directory trees have been successfully extracted. @p
589 * info will point to ::wimlib_progress_info.extract. This is paired
590 * with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
591 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
593 /** The directory or NTFS volume is about to be scanned for metadata.
594 * @p info will point to ::wimlib_progress_info.scan. This message is
595 * received once per call to wimlib_add_image(), or once per capture
596 * source passed to wimlib_add_image_multisource(), or once per add
597 * command passed to wimlib_update_image(). */
598 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
600 /** A directory or file has been scanned. @p info will point to
601 * ::wimlib_progress_info.scan, and its @p cur_path member will be
602 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
604 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
606 /** The directory or NTFS volume has been successfully scanned. @p info
607 * will point to ::wimlib_progress_info.scan. This is paired with a
608 * previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message, possibly with many
609 * intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY messages. */
610 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
612 /** File data is currently being written to the WIM. @p info will point
613 * to ::wimlib_progress_info.write_streams. This message may be
614 * received many times while the WIM file is being written or appended
615 * to with wimlib_write(), wimlib_overwrite(), or wimlib_write_to_fd().
617 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
619 /** Per-image metadata is about to be written to the WIM file. @p info
620 * will not be valid. */
621 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
623 /** The per-image metadata has been written to the WIM file. @p info
624 * will not be valid. This message is paired with a preceding
625 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message. */
626 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
628 /** wimlib_overwrite() has successfully renamed the temporary file to
629 * the original WIM file, thereby committing the changes to the WIM
630 * file. @p info will point to ::wimlib_progress_info.rename. Note:
631 * this message is not received if wimlib_overwrite() chose to append to
632 * the WIM file in-place. */
633 WIMLIB_PROGRESS_MSG_RENAME = 15,
635 /** The contents of the WIM file are being checked against the integrity
636 * table. @p info will point to ::wimlib_progress_info.integrity. This
637 * message is only received (and may be received many times) when
638 * wimlib_open_wim_with_progress() is called with the
639 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
640 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
642 /** An integrity table is being calculated for the WIM being written.
643 * @p info will point to ::wimlib_progress_info.integrity. This message
644 * is only received (and may be received many times) when a WIM file is
645 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
646 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
648 /** A wimlib_split() operation is in progress, and a new split part is
649 * about to be started. @p info will point to
650 * ::wimlib_progress_info.split. */
651 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
653 /** A wimlib_split() operation is in progress, and a split part has been
654 * finished. @p info will point to ::wimlib_progress_info.split. */
655 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
657 /** A WIM update command is about to be executed. @p info will point to
658 * ::wimlib_progress_info.update. This message is received once per
659 * update command when wimlib_update_image() is called with the flag
660 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
661 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
663 /** A WIM update command has been executed. @p info will point to
664 * ::wimlib_progress_info.update. This message is received once per
665 * update command when wimlib_update_image() is called with the flag
666 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
667 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
669 /** A file in the image is being replaced as a result of a
670 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
671 * @p info will point to ::wimlib_progress_info.replace. This is only
672 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
674 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
676 /** An image is being extracted with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
677 * a file is being extracted normally (not as a "WIMBoot pointer file")
678 * due to it matching a pattern in the <c>[PrepopulateList]</c> section
679 * of the configuration file
680 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image. @p
681 * info will point to ::wimlib_progress_info.wimboot_exclude. */
682 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
684 /** Starting to unmount an image. @p info will point to
685 * ::wimlib_progress_info.unmount. */
686 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
688 /** wimlib has used a file's data for the last time (including all data
689 * streams, if it has multiple). @p info will point to
690 * ::wimlib_progress_info.done_with_file. This message is only received
691 * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided. */
692 WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
694 /** wimlib_verify_wim() is starting to verify the metadata for an image.
695 * @p info will point to ::wimlib_progress_info.verify_image. */
696 WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
698 /** wimlib_verify_wim() has finished verifying the metadata for an
699 * image. @p info will point to ::wimlib_progress_info.verify_image.
701 WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
703 /** wimlib_verify_wim() is verifying file data integrity. @p info will
704 * point to ::wimlib_progress_info.verify_streams. */
705 WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
708 * The progress function is being asked whether a file should be
709 * excluded from capture or not. @p info will point to
710 * ::wimlib_progress_info.test_file_exclusion. This is a bidirectional
711 * message that allows the progress function to set a flag if the file
712 * should be excluded.
714 * This message is only received if the flag
715 * ::WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION is used. This method for file
716 * exclusions is independent of the "capture configuration file"
719 WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION = 30,
722 * An error has occurred and the progress function is being asked
723 * whether to ignore the error or not. @p info will point to
724 * ::wimlib_progress_info.handle_error. This is a bidirectional
727 * This message provides a limited capability for applications to
728 * recover from "unexpected" errors (i.e. those with no in-library
729 * handling policy) arising from the underlying operating system.
730 * Normally, any such error will cause the library to abort the current
731 * operation. By implementing a handler for this message, the
732 * application can instead choose to ignore a given error.
734 * Currently, only the following types of errors will result in this
735 * progress message being sent:
737 * - Directory tree scan errors, e.g. from wimlib_add_image()
738 * - Most extraction errors; currently restricted to the Windows
739 * build of the library only.
741 WIMLIB_PROGRESS_MSG_HANDLE_ERROR = 31,
744 /** Valid return values from user-provided progress functions
745 * (::wimlib_progress_func_t).
747 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
750 enum wimlib_progress_status {
752 /** The operation should be continued. This is the normal return value.
754 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
756 /** The operation should be aborted. This will cause the current
757 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
758 WIMLIB_PROGRESS_STATUS_ABORT = 1,
762 * A pointer to this union is passed to the user-supplied
763 * ::wimlib_progress_func_t progress function. One (or none) of the structures
764 * contained in this union will be applicable for the operation
765 * (::wimlib_progress_msg) indicated in the first argument to the progress
767 union wimlib_progress_info {
769 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
770 * the primary message for tracking the progress of writing a WIM file.
772 struct wimlib_progress_info_write_streams {
774 /** An upper bound on the number of bytes of file data that will
775 * be written. This number is the uncompressed size; the actual
776 * size may be lower due to compression. In addition, this
777 * number may decrease over time as duplicated file data is
779 uint64_t total_bytes;
781 /** An upper bound on the number of distinct file data "blobs"
782 * that will be written. This will often be similar to the
783 * "number of files", but for several reasons (hard links, named
784 * data streams, empty files, etc.) it can be different. In
785 * addition, this number may decrease over time as duplicated
786 * file data is discovered. */
787 uint64_t total_streams;
789 /** The number of bytes of file data that have been written so
790 * far. This starts at 0 and ends at @p total_bytes. This
791 * number is the uncompressed size; the actual size may be lower
792 * due to compression. */
793 uint64_t completed_bytes;
795 /** The number of distinct file data "blobs" that have been
796 * written so far. This starts at 0 and ends at @p
798 uint64_t completed_streams;
800 /** The number of threads being used for data compression; or,
801 * if no compression is being performed, this will be 1. */
802 uint32_t num_threads;
804 /** The compression type being used, as one of the
805 * ::wimlib_compression_type constants. */
806 int32_t compression_type;
808 /** The number of on-disk WIM files from which file data is
809 * being exported into the output WIM file. This can be 0, 1,
810 * or more than 1, depending on the situation. */
811 uint32_t total_parts;
813 /** This is currently broken and will always be 0. */
814 uint32_t completed_parts;
817 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
818 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
819 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
820 struct wimlib_progress_info_scan {
822 /** Top-level directory being scanned; or, when capturing an NTFS
823 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
824 * to the file or block device that contains the NTFS volume
826 const wimlib_tchar *source;
828 /** Path to the file (or directory) that has been scanned, valid
829 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
830 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
831 * relative to the root of the NTFS volume. */
832 const wimlib_tchar *cur_path;
834 /** Dentry scan status, valid on
835 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
837 /** File looks okay and will be captured. */
838 WIMLIB_SCAN_DENTRY_OK = 0,
840 /** File is being excluded from capture due to the
841 * capture configuration. */
842 WIMLIB_SCAN_DENTRY_EXCLUDED = 1,
844 /** File is being excluded from capture due to being of
845 * an unsupported type. */
846 WIMLIB_SCAN_DENTRY_UNSUPPORTED = 2,
848 /** The file is an absolute symbolic link or junction
849 * that points into the capture directory, and
850 * reparse-point fixups are enabled, so its target is
851 * being adjusted. (Reparse point fixups can be
852 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
854 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK = 3,
856 /** Reparse-point fixups are enabled, but the file is an
857 * absolute symbolic link or junction that does
858 * <b>not</b> point into the capture directory, so its
859 * target is <b>not</b> being adjusted. */
860 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK = 4,
864 /** Target path in the image. Only valid on messages
865 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
866 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
867 const wimlib_tchar *wim_target_path;
869 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
870 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
871 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
872 * target of the absolute symbolic link or junction. */
873 const wimlib_tchar *symlink_target;
876 /** The number of directories scanned so far, not counting
877 * excluded/unsupported files. */
878 uint64_t num_dirs_scanned;
880 /** The number of non-directories scanned so far, not counting
881 * excluded/unsupported files. */
882 uint64_t num_nondirs_scanned;
884 /** The number of bytes of file data detected so far, not
885 * counting excluded/unsupported files. */
886 uint64_t num_bytes_scanned;
889 /** Valid on messages
890 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
891 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
892 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
893 * ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE,
894 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
895 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA,
896 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
897 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
899 * Note: most of the time of an extraction operation will be spent
900 * extracting file data, and the application will receive
901 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
902 * completed_bytes and @p total_bytes, the application can calculate a
903 * percentage complete. However, there is no way for applications to
904 * know which file is currently being extracted. This is by design
905 * because the best way to complete the extraction operation is not
906 * necessarily file-by-file.
908 struct wimlib_progress_info_extract {
910 /** The 1-based index of the image from which files are being
914 /** Extraction flags being used. */
915 uint32_t extract_flags;
917 /** If the ::WIMStruct from which the extraction being performed
918 * has a backing file, then this is an absolute path to that
919 * backing file. Otherwise, this is @c NULL. */
920 const wimlib_tchar *wimfile_name;
922 /** Name of the image from which files are being extracted, or
923 * the empty string if the image is unnamed. */
924 const wimlib_tchar *image_name;
926 /** Path to the directory or NTFS volume to which the files are
927 * being extracted. */
928 const wimlib_tchar *target;
931 const wimlib_tchar *reserved;
933 /** The number of bytes of file data that will be extracted. */
934 uint64_t total_bytes;
936 /** The number of bytes of file data that have been extracted so
937 * far. This starts at 0 and ends at @p total_bytes. */
938 uint64_t completed_bytes;
940 /** The number of file streams that will be extracted. This
941 * will often be similar to the "number of files", but for
942 * several reasons (hard links, named data streams, empty files,
943 * etc.) it can be different. */
944 uint64_t total_streams;
946 /** The number of file streams that have been extracted so far.
947 * This starts at 0 and ends at @p total_streams. */
948 uint64_t completed_streams;
950 /** Currently only used for
951 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
952 uint32_t part_number;
954 /** Currently only used for
955 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
956 uint32_t total_parts;
958 /** Currently only used for
959 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
960 uint8_t guid[WIMLIB_GUID_LEN];
962 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
963 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is the
964 * number of files that have been processed so far. Once the
965 * corresponding phase of extraction is complete, this value
966 * will be equal to @c end_file_count. */
967 uint64_t current_file_count;
969 /** For ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE and
970 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, this is
971 * total number of files that will be processed.
973 * This number is provided for informational purposes only, e.g.
974 * for a progress bar. This number will not necessarily be
975 * equal to the number of files actually being extracted. This
976 * is because extraction backends are free to implement an
977 * extraction algorithm that might be more efficient than
978 * processing every file in the "extract file structure" and
979 * "extract file metadata" phases. For example, the current
980 * implementation of the UNIX extraction backend will create
981 * files on-demand during the "extract file data" phase.
982 * Therefore, when using that particular extraction backend, @p
983 * end_file_count will only include directories and empty files.
985 uint64_t end_file_count;
988 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
989 struct wimlib_progress_info_rename {
990 /** Name of the temporary file that the WIM was written to. */
991 const wimlib_tchar *from;
993 /** Name of the original WIM file to which the temporary file is
995 const wimlib_tchar *to;
998 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
999 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
1000 struct wimlib_progress_info_update {
1001 /** Pointer to the update command that will be executed or has
1002 * just been executed. */
1003 const struct wimlib_update_command *command;
1005 /** Number of update commands that have been completed so far.
1007 size_t completed_commands;
1009 /** Number of update commands that are being executed as part of
1010 * this call to wimlib_update_image(). */
1011 size_t total_commands;
1014 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
1015 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
1016 struct wimlib_progress_info_integrity {
1018 /** The number of bytes in the WIM file that are covered by
1019 * integrity checks. */
1020 uint64_t total_bytes;
1022 /** The number of bytes that have been checksummed so far. This
1023 * starts at 0 and ends at @p total_bytes. */
1024 uint64_t completed_bytes;
1026 /** The number of individually checksummed "chunks" the
1027 * integrity-checked region is divided into. */
1028 uint32_t total_chunks;
1030 /** The number of chunks that have been checksummed so far.
1031 * This starts at 0 and ends at @p total_chunks. */
1032 uint32_t completed_chunks;
1034 /** The size of each individually checksummed "chunk" in the
1035 * integrity-checked region. */
1036 uint32_t chunk_size;
1038 /** For ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages, this is
1039 * the path to the WIM file being checked. */
1040 const wimlib_tchar *filename;
1043 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
1044 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
1045 struct wimlib_progress_info_split {
1046 /** Total size of the original WIM's file and metadata resources
1048 uint64_t total_bytes;
1050 /** Number of bytes of file and metadata resources that have
1051 * been copied out of the original WIM so far. Will be 0
1052 * initially, and equal to @p total_bytes at the end. */
1053 uint64_t completed_bytes;
1055 /** Number of the split WIM part that is about to be started
1056 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1057 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
1058 unsigned cur_part_number;
1060 /** Total number of split WIM parts that are being written. */
1061 unsigned total_parts;
1063 /** Name of the split WIM part that is about to be started
1064 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1065 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). Since
1066 * wimlib v1.7.0, the library user may change this when
1067 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
1068 * cause the next split WIM part to be written to a different
1070 wimlib_tchar *part_name;
1073 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
1074 struct wimlib_progress_info_replace {
1075 /** Path to the file in the image that is being replaced */
1076 const wimlib_tchar *path_in_wim;
1079 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1080 struct wimlib_progress_info_wimboot_exclude {
1081 /** Path to the file in the image */
1082 const wimlib_tchar *path_in_wim;
1084 /** Path to which the file is being extracted */
1085 const wimlib_tchar *extraction_path;
1088 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1089 struct wimlib_progress_info_unmount {
1090 /** Path to directory being unmounted */
1091 const wimlib_tchar *mountpoint;
1093 /** Path to WIM file being unmounted */
1094 const wimlib_tchar *mounted_wim;
1096 /** 1-based index of image being unmounted. */
1097 uint32_t mounted_image;
1099 /** Flags that were passed to wimlib_mount_image() when the
1100 * mountpoint was set up. */
1101 uint32_t mount_flags;
1103 /** Flags passed to wimlib_unmount_image(). */
1104 uint32_t unmount_flags;
1107 /** Valid on messages ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE. */
1108 struct wimlib_progress_info_done_with_file {
1110 * Path to the file whose data has been written to the WIM file,
1111 * or is currently being asynchronously compressed in memory,
1112 * and therefore is no longer needed by wimlib.
1114 * WARNING: The file data will not actually be accessible in the
1115 * WIM file until the WIM file has been completely written.
1116 * Ordinarily you should <b>not</b> treat this message as a
1117 * green light to go ahead and delete the specified file, since
1118 * that would result in data loss if the WIM file cannot be
1119 * successfully created for any reason.
1121 * If a file has multiple names (hard links),
1122 * ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE will only be received
1123 * for one name. Also, this message will not be received for
1124 * empty files or reparse points (or symbolic links), unless
1125 * they have nonempty named data streams.
1127 const wimlib_tchar *path_to_file;
1130 /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
1131 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE. */
1132 struct wimlib_progress_info_verify_image {
1133 const wimlib_tchar *wimfile;
1134 uint32_t total_images;
1135 uint32_t current_image;
1138 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS. */
1139 struct wimlib_progress_info_verify_streams {
1140 const wimlib_tchar *wimfile;
1141 uint64_t total_streams;
1142 uint64_t total_bytes;
1143 uint64_t completed_streams;
1144 uint64_t completed_bytes;
1147 /** Valid on messages ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION. */
1148 struct wimlib_progress_info_test_file_exclusion {
1151 * Path to the file for which exclusion is being tested.
1153 * UNIX capture mode: The path will be a standard relative or
1154 * absolute UNIX filesystem path.
1156 * NTFS-3G capture mode: The path will be given relative to the
1157 * root of the NTFS volume, with a leading slash.
1159 * Windows capture mode: The path will be a Win32 namespace
1162 const wimlib_tchar *path;
1165 * Indicates whether the file or directory will be excluded from
1166 * capture or not. This will be <c>false</c> by default. The
1167 * progress function can set this to <c>true</c> if it decides
1168 * that the file needs to be excluded.
1171 } test_file_exclusion;
1173 /** Valid on messages ::WIMLIB_PROGRESS_MSG_HANDLE_ERROR. */
1174 struct wimlib_progress_info_handle_error {
1176 /** Path to the file for which the error occurred, or NULL if
1178 const wimlib_tchar *path;
1180 /** The wimlib error code associated with the error. */
1184 * Indicates whether the error will be ignored or not. This
1185 * will be <c>false</c> by default; the progress function may
1186 * set it to <c>true</c>.
1193 * A user-supplied function that will be called periodically during certain WIM
1196 * The first argument will be the type of operation that is being performed or
1197 * is about to be started or has been completed.
1199 * The second argument will be a pointer to one of a number of structures
1200 * depending on the first argument. It may be @c NULL for some message types.
1201 * Note that although this argument is not @c const, users should not modify it
1202 * except in explicitly documented cases.
1204 * The third argument will be a user-supplied value that was provided when
1205 * registering or specifying the progress function.
1207 * This function must return one of the ::wimlib_progress_status values. By
1208 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1210 typedef enum wimlib_progress_status
1211 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1212 union wimlib_progress_info *info,
1216 /** @addtogroup G_modifying_wims
1219 /** An array of these structures is passed to wimlib_add_image_multisource() to
1220 * specify the sources from which to create a WIM image. */
1221 struct wimlib_capture_source {
1222 /** Absolute or relative path to a file or directory on the external
1223 * filesystem to be included in the image. */
1224 wimlib_tchar *fs_source_path;
1226 /** Destination path in the image. To specify the root directory of the
1227 * image, use ::WIMLIB_WIM_ROOT_PATH. */
1228 wimlib_tchar *wim_target_path;
1230 /** Reserved; set to 0. */
1234 /** Set or unset the "readonly" WIM header flag (<c>WIM_HDR_FLAG_READONLY</c> in
1235 * Microsoft's documentation), based on the ::wimlib_wim_info.is_marked_readonly
1236 * member of the @p info parameter. This is distinct from basic file
1237 * permissions; this flag can be set on a WIM file that is physically writable.
1239 * wimlib disallows modifying on-disk WIM files with the readonly flag set.
1240 * However, wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG
1241 * will override this --- and in fact, this is necessary to set the readonly
1242 * flag persistently on an existing WIM file.
1244 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1246 /** Set the GUID (globally unique identifier) of the WIM file to the value
1247 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1248 #define WIMLIB_CHANGE_GUID 0x00000002
1250 /** Change the bootable image of the WIM to the value specified in
1251 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1252 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1254 /** Change the <c>WIM_HDR_FLAG_RP_FIX</c> flag of the WIM file to the value
1255 * specified in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag
1256 * generally indicates whether an image in the WIM has been captured with
1257 * reparse-point fixups enabled. wimlib also treats this flag as specifying
1258 * whether to do reparse-point fixups by default when capturing or applying WIM
1260 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1264 /** @addtogroup G_wim_information */
1269 * General information about a WIM file.
1271 * This info can also be requested for a ::WIMStruct that does not have a
1272 * backing file. In this case, fields that only make sense given a backing file
1273 * are set to default values.
1275 struct wimlib_wim_info {
1277 /** The globally unique identifier for this WIM. (Note: all parts of a
1278 * split WIM normally have identical GUIDs.) */
1279 uint8_t guid[WIMLIB_GUID_LEN];
1281 /** The number of images in this WIM file. */
1282 uint32_t image_count;
1284 /** The 1-based index of the bootable image in this WIM file, or 0 if no
1285 * image is bootable. */
1286 uint32_t boot_index;
1288 /** The version of the WIM file format used in this WIM file. */
1289 uint32_t wim_version;
1291 /** The default compression chunk size of resources in this WIM file.
1293 uint32_t chunk_size;
1295 /** For split WIMs, the 1-based index of this part within the split WIM;
1297 uint16_t part_number;
1299 /** For split WIMs, the total number of parts in the split WIM;
1301 uint16_t total_parts;
1303 /** The default compression type of resources in this WIM file, as one
1304 * of the ::wimlib_compression_type constants. */
1305 int32_t compression_type;
1307 /** The size of this WIM file in bytes, excluding the XML data and
1308 * integrity table. */
1309 uint64_t total_bytes;
1311 /** 1 iff this WIM file has an integrity table. */
1312 uint32_t has_integrity_table : 1;
1314 /** 1 iff this info struct is for a ::WIMStruct that has a backing file.
1316 uint32_t opened_from_file : 1;
1318 /** 1 iff this WIM file is considered readonly for any reason (e.g. the
1319 * "readonly" header flag is set, or this is part of a split WIM, or
1320 * filesystem permissions deny writing) */
1321 uint32_t is_readonly : 1;
1323 /** 1 iff the "reparse point fix" flag is set in this WIM's header */
1324 uint32_t has_rpfix : 1;
1326 /** 1 iff the "readonly" flag is set in this WIM's header */
1327 uint32_t is_marked_readonly : 1;
1329 /** 1 iff the "spanned" flag is set in this WIM's header */
1330 uint32_t spanned : 1;
1332 /** 1 iff the "write in progress" flag is set in this WIM's header */
1333 uint32_t write_in_progress : 1;
1335 /** 1 iff the "metadata only" flag is set in this WIM's header */
1336 uint32_t metadata_only : 1;
1338 /** 1 iff the "resource only" flag is set in this WIM's header */
1339 uint32_t resource_only : 1;
1341 /** 1 iff this WIM file is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1342 uint32_t pipable : 1;
1343 uint32_t reserved_flags : 22;
1344 uint32_t reserved[9];
1348 * Information about a "blob", which is a fixed length sequence of binary data.
1349 * Each nonempty stream of each file in a WIM image is associated with a blob.
1350 * Blobs are deduplicated within a WIM file.
1352 * TODO: this struct needs to be renamed, and perhaps made into a union since
1353 * there are several cases. I'll try to list them below:
1355 * 1. The blob is "missing", meaning that it is referenced by hash but not
1356 * actually present in the WIM file. In this case we only know the
1357 * sha1_hash. This case can only occur with wimlib_iterate_dir_tree(), never
1358 * wimlib_iterate_lookup_table().
1360 * 2. Otherwise we know the sha1_hash, the uncompressed_size, the
1361 * reference_count, and the is_metadata flag. In addition:
1363 * A. If the blob is located in a non-solid WIM resource, then we also know
1364 * the compressed_size and offset.
1366 * B. If the blob is located in a solid WIM resource, then we also know the
1367 * offset, raw_resource_offset_in_wim, raw_resource_compressed_size, and
1368 * raw_resource_uncompressed_size. But the "offset" is actually the
1369 * offset in the uncompressed solid resource rather than the offset from
1370 * the beginning of the WIM file.
1372 * C. If the blob is *not* located in any type of WIM resource, then we don't
1373 * know any additional information.
1375 * Unknown or irrelevant fields are left zeroed.
1377 struct wimlib_resource_entry {
1379 /** If this blob is not missing, then this is the uncompressed size of
1380 * this blob in bytes. */
1381 uint64_t uncompressed_size;
1383 /** If this blob is located in a non-solid WIM resource, then this is
1384 * the compressed size of that resource. */
1385 uint64_t compressed_size;
1387 /** If this blob is located in a non-solid WIM resource, then this is
1388 * the offset of that resource within the WIM file containing it. If
1389 * this blob is located in a solid WIM resource, then this is the offset
1390 * of this blob within that solid resource when uncompressed. */
1393 /** The SHA-1 message digest of the blob's uncompressed contents. */
1394 uint8_t sha1_hash[20];
1396 /** If this blob is located in a WIM resource, then this is the part
1397 * number of the WIM file containing it. */
1398 uint32_t part_number;
1400 /** If this blob is not missing, then this is the number of times this
1401 * blob is referenced over all images in the WIM. This number is not
1402 * guaranteed to be correct. */
1403 uint32_t reference_count;
1405 /** 1 iff this blob is located in a non-solid compressed WIM resource.
1407 uint32_t is_compressed : 1;
1409 /** 1 iff this blob contains the metadata for an image. */
1410 uint32_t is_metadata : 1;
1412 uint32_t is_free : 1;
1413 uint32_t is_spanned : 1;
1415 /** 1 iff a blob with this hash was not found in the blob lookup table
1416 * of the ::WIMStruct. This normally implies a missing call to
1417 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1418 uint32_t is_missing : 1;
1420 /** 1 iff this blob is located in a solid resource. */
1421 uint32_t packed : 1;
1423 uint32_t reserved_flags : 26;
1425 /** If this blob is located in a solid WIM resource, then this is the
1426 * offset of that solid resource within the WIM file containing it. */
1427 uint64_t raw_resource_offset_in_wim;
1429 /** If this blob is located in a solid WIM resource, then this is the
1430 * compressed size of that solid resource. */
1431 uint64_t raw_resource_compressed_size;
1433 /** If this blob is located in a solid WIM resource, then this is the
1434 * uncompressed size of that solid resource. */
1435 uint64_t raw_resource_uncompressed_size;
1437 uint64_t reserved[1];
1441 * Information about a stream of a particular file in the WIM.
1443 * Normally, only WIM images captured from NTFS filesystems will have multiple
1444 * streams per file. In practice, this is a rarely used feature of the
1447 * TODO: the library now explicitly tracks stream types, which allows it to have
1448 * multiple unnamed streams (e.g. both a reparse point stream and unnamed data
1449 * stream). However, this isn't yet exposed by wimlib_iterate_dir_tree().
1451 struct wimlib_stream_entry {
1453 /** Name of the stream, or NULL if the stream is unnamed. */
1454 const wimlib_tchar *stream_name;
1456 /** Info about this stream's data, such as its hash and size if known.*/
1457 struct wimlib_resource_entry resource;
1459 uint64_t reserved[4];
1463 * Since wimlib v1.9.1: an object ID, which is an extra piece of metadata that
1464 * may be associated with a file on NTFS filesystems. See:
1465 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa363997(v=vs.85).aspx
1467 struct wimlib_object_id {
1468 uint8_t object_id[WIMLIB_GUID_LEN];
1469 uint8_t birth_volume_id[WIMLIB_GUID_LEN];
1470 uint8_t birth_object_id[WIMLIB_GUID_LEN];
1471 uint8_t domain_id[WIMLIB_GUID_LEN];
1474 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1475 * Roughly, the information about a "file" in the WIM image --- but really a
1476 * directory entry ("dentry") because hard links are allowed. The
1477 * hard_link_group_id field can be used to distinguish actual file inodes. */
1478 struct wimlib_dir_entry {
1479 /** Name of the file, or NULL if this file is unnamed. Only the root
1480 * directory of an image will be unnamed. */
1481 const wimlib_tchar *filename;
1483 /** 8.3 name (or "DOS name", or "short name") of this file; or NULL if
1484 * this file has no such name. */
1485 const wimlib_tchar *dos_name;
1487 /** Full path to this file within the image. Path separators will be
1488 * ::WIMLIB_WIM_PATH_SEPARATOR. */
1489 const wimlib_tchar *full_path;
1491 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1492 * children, ..., etc. */
1495 /** Pointer to the security descriptor for this file, in Windows
1496 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1497 * security descriptor. */
1498 const char *security_descriptor;
1500 /** Size of the above security descriptor, in bytes. */
1501 size_t security_descriptor_size;
1503 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1504 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1505 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1506 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1507 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1508 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1509 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1510 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1511 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1512 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1513 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1514 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1515 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1516 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1517 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1518 /** File attributes, such as whether the file is a directory or not.
1519 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1520 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1521 * on other platforms. */
1522 uint32_t attributes;
1524 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1525 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1526 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1527 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1528 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1529 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1530 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1531 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1532 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1533 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1534 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1535 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1536 /** If the file is a reparse point (FILE_ATTRIBUTE_REPARSE_POINT set in
1537 * the attributes), this will give the reparse tag. This tells you
1538 * whether the reparse point is a symbolic link, junction point, or some
1539 * other, more unusual kind of reparse point. */
1540 uint32_t reparse_tag;
1542 /** Number of links to this file's inode (hard links).
1544 * Currently, this will always be 1 for directories. However, it can be
1545 * greater than 1 for nondirectory files. */
1548 /** Number of named data streams this file has. Normally 0. */
1549 uint32_t num_named_streams;
1551 /** A unique identifier for this file's inode. However, as a special
1552 * case, if the inode only has a single link (@p num_links == 1), this
1555 * Note: if a WIM image is captured from a filesystem, this value is not
1556 * guaranteed to be the same as the original number of the inode on the
1558 uint64_t hard_link_group_id;
1560 /** Time this file was created. */
1561 struct timespec creation_time;
1563 /** Time this file was last written to. */
1564 struct timespec last_write_time;
1566 /** Time this file was last accessed. */
1567 struct timespec last_access_time;
1569 /** The UNIX user ID of this file. This is a wimlib extension.
1571 * This field is only valid if @p unix_mode != 0. */
1574 /** The UNIX group ID of this file. This is a wimlib extension.
1576 * This field is only valid if @p unix_mode != 0. */
1579 /** The UNIX mode of this file. This is a wimlib extension.
1581 * If this field is 0, then @p unix_uid, @p unix_gid, @p unix_mode, and
1582 * @p unix_rdev are all unknown (fields are not present in the WIM
1586 /** The UNIX device ID (major and minor number) of this file. This is a
1589 * This field is only valid if @p unix_mode != 0. */
1592 /* The object ID of this file, if any. Only valid if
1593 * object_id.object_id is not all zeroes. */
1594 struct wimlib_object_id object_id;
1596 uint64_t reserved[6];
1599 * Variable-length array of streams that make up this file.
1601 * The first entry will always exist and will correspond to the unnamed
1602 * data stream (default file contents), so it will have <c>stream_name
1603 * == NULL</c>. Alternatively, for reparse point files, the first entry
1604 * will correspond to the reparse data stream. Alternatively, for
1605 * encrypted files, the first entry will correspond to the encrypted
1608 * Then, following the first entry, there be @p num_named_streams
1609 * additional entries that specify the named data streams, if any, each
1610 * of which will have <c>stream_name != NULL</c>.
1612 struct wimlib_stream_entry streams[];
1616 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1619 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1623 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1626 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1629 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1630 * just on the specified path. */
1631 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1633 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1634 * itself; only its children (in the case of a non-empty directory) */
1635 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1637 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any file data blobs needed to fill
1638 * in the ::wimlib_resource_entry's for the iteration cannot be found in the
1639 * blob lookup table of the ::WIMStruct. The default behavior without this flag
1640 * is to fill in the @ref wimlib_resource_entry::sha1_hash "sha1_hash" and set
1641 * the @ref wimlib_resource_entry::is_missing "is_missing" flag. */
1642 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1646 /** @addtogroup G_modifying_wims
1649 /** UNIX-like systems only: Directly capture an NTFS volume rather than a
1650 * generic directory. This requires that wimlib was compiled with support for
1653 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1654 * ::WIMLIB_ADD_FLAG_UNIX_DATA.
1656 * Do not use this flag on Windows, where wimlib already supports all
1657 * Windows-native filesystems, including NTFS, through the Windows APIs. */
1658 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1660 /** Follow symbolic links when scanning the directory tree. Currently only
1661 * supported on UNIX-like systems. */
1662 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1664 /** Call the progress function with the message
1665 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1667 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1669 /** Mark the image being added as the bootable image of the WIM. This flag is
1670 * valid only for wimlib_add_image() and wimlib_add_image_multisource().
1672 * Note that you can also change the bootable image of a WIM using
1673 * wimlib_set_wim_info().
1675 * Note: ::WIMLIB_ADD_FLAG_BOOT does something different from, and independent
1676 * from, ::WIMLIB_ADD_FLAG_WIMBOOT. */
1677 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1679 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1680 * (major and minor number) of each file. In addition, capture special files
1681 * such as device nodes and FIFOs. See the documentation for the
1682 * <b>--unix-data</b> option to <b>wimcapture</b> for more information. */
1683 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1685 /** Do not capture security descriptors. Only has an effect in NTFS-3G capture
1686 * mode, or in Windows native builds. */
1687 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1689 /** Fail immediately if the full security descriptor of any file or directory
1690 * cannot be accessed. Only has an effect in Windows native builds. The
1691 * default behavior without this flag is to first try omitting the SACL from the
1692 * security descriptor, then to try omitting the security descriptor entirely.
1694 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1696 /** Call the progress function with the message
1697 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1698 * capture. This is a subset of the messages provided by
1699 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1700 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1702 /** Reparse-point fixups: Modify absolute symbolic links (and junctions, in the
1703 * case of Windows) that point inside the directory being captured to instead be
1704 * absolute relative to the directory being captured.
1706 * Without this flag, the default is to do reparse-point fixups if
1707 * <c>WIM_HDR_FLAG_RP_FIX</c> is set in the WIM header or if this is the first
1708 * image being added. */
1709 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1711 /** Don't do reparse point fixups. See ::WIMLIB_ADD_FLAG_RPFIX. */
1712 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1714 /** Do not automatically exclude unsupported files or directories from capture,
1715 * such as encrypted files in NTFS-3G capture mode, or device files and FIFOs on
1716 * UNIX-like systems when not also using ::WIMLIB_ADD_FLAG_UNIX_DATA. Instead,
1717 * fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when such a file is encountered. */
1718 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1721 * Automatically select a capture configuration appropriate for capturing
1722 * filesystems containing Windows operating systems. For example,
1723 * <c>/pagefile.sys</c> and <c>"/System Volume Information"</c> will be
1726 * When this flag is specified, the corresponding @p config parameter (for
1727 * wimlib_add_image()) or member (for wimlib_update_image()) must be @c NULL.
1728 * Otherwise, ::WIMLIB_ERR_INVALID_PARAM will be returned.
1730 * Note that the default behavior--- that is, when neither
1731 * ::WIMLIB_ADD_FLAG_WINCONFIG nor ::WIMLIB_ADD_FLAG_WIMBOOT is specified and @p
1732 * config is @c NULL--- is to use no capture configuration, meaning that no
1733 * files are excluded from capture.
1735 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1738 * Capture image as "WIMBoot compatible". In addition, if no capture
1739 * configuration file is explicitly specified use the capture configuration file
1740 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1741 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1742 * configuration file is explicitly specified, use it and also place it at
1743 * <c>/Windows/System32/WimBootCompress.ini</c> in the WIM image.
1745 * This flag does not, by itself, change the compression type or chunk size.
1746 * Before writing the WIM file, you may wish to set the compression format to
1747 * be the same as that used by WIMGAPI and DISM:
1750 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1751 * wimlib_set_output_chunk_size(wim, 4096);
1754 * However, "WIMBoot" also works with other XPRESS chunk sizes as well as LZX
1755 * with 32768 byte chunks.
1757 * Note: ::WIMLIB_ADD_FLAG_WIMBOOT does something different from, and
1758 * independent from, ::WIMLIB_ADD_FLAG_BOOT.
1760 * Since wimlib v1.8.3, ::WIMLIB_ADD_FLAG_WIMBOOT also causes offline WIM-backed
1761 * files to be added as the "real" files rather than as their reparse points,
1762 * provided that their data is already present in the WIM. This feature can be
1763 * useful when updating a backing WIM file in an "offline" state.
1765 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1768 * If the add command involves adding a non-directory file to a location at
1769 * which there already exists a nondirectory file in the image, issue
1770 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This was the
1771 * default behavior before wimlib v1.7.0.
1773 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1776 * Send ::WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION messages to the progress
1779 * Note: This method for file exclusions is independent from the capture
1780 * configuration file mechanism.
1782 #define WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION 0x00004000
1785 * Since wimlib v1.9.0: create a temporary filesystem snapshot of the source
1786 * directory and add the files from it. Currently, this option is only
1787 * supported on Windows, where it uses the Volume Shadow Copy Service (VSS).
1788 * Using this option, you can create a consistent backup of the system volume of
1789 * a running Windows system without running into problems with locked files.
1790 * For the VSS snapshot to be successfully created, your application must be run
1791 * as an Administrator, and it cannot be run in WoW64 mode (i.e. if Windows is
1792 * 64-bit, then your application must be 64-bit as well).
1794 #define WIMLIB_ADD_FLAG_SNAPSHOT 0x00008000
1797 * Since wimlib v1.9.0: permit the library to discard file paths after the
1798 * initial scan. If the application won't use
1799 * ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES while writing the WIM
1800 * archive, this flag can be used to allow the library to enable optimizations
1801 * such as opening files by inode number rather than by path. Currently this
1802 * only makes a difference on Windows.
1804 #define WIMLIB_ADD_FLAG_FILE_PATHS_UNNEEDED 0x00010000
1807 /** @addtogroup G_modifying_wims
1810 /** Do not issue an error if the path to delete does not exist. */
1811 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1813 /** Delete the file or directory tree recursively; if not specified, an error is
1814 * issued if the path to delete is a directory. */
1815 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1818 /** @addtogroup G_modifying_wims
1822 * If a single image is being exported, mark it bootable in the destination WIM.
1823 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1824 * the image in the source WIM (if any) that is marked as bootable is also
1825 * marked as bootable in the destination WIM.
1827 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1829 /** Give the exported image(s) no names. Avoids problems with image name
1832 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1834 /** Give the exported image(s) no descriptions. */
1835 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1837 /** This advises the library that the program is finished with the source
1838 * WIMStruct and will not attempt to access it after the call to
1839 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1840 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1843 * Mark each exported image as WIMBoot-compatible.
1845 * Note: by itself, this does change the destination WIM's compression type, nor
1846 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1847 * image. Before writing the destination WIM, it's recommended to do something
1851 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1852 * wimlib_set_output_chunk_size(wim, 4096);
1853 * wimlib_add_tree(wim, image, L"myconfig.ini",
1854 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1857 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1860 /** @addtogroup G_extracting_wims
1863 /** Extract the image directly to an NTFS volume rather than a generic directory.
1864 * This mode is only available if wimlib was compiled with libntfs-3g support;
1865 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1866 * extraction target will be interpreted as the path to an NTFS volume image (as
1867 * a regular file or block device) rather than a directory. It will be opened
1868 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1869 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1870 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1871 * wimlib_extract_paths() when passed multiple paths. */
1872 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1874 /** UNIX-like systems only: Extract special UNIX data captured with
1875 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1876 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1877 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1879 /** Do not extract security descriptors. This flag cannot be combined with
1880 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1881 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1884 * Fail immediately if the full security descriptor of any file or directory
1885 * cannot be set exactly as specified in the WIM image. On Windows, the default
1886 * behavior without this flag when wimlib does not have permission to set the
1887 * correct security descriptor is to fall back to setting the security
1888 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1889 * owner omitted, then not at all. This flag cannot be combined with
1890 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS.
1892 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1895 * This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1896 * reparse-point fixups on, so absolute symbolic links or junction points will
1897 * be fixed to be absolute relative to the actual extraction root. Reparse-
1898 * point fixups are done by default for wimlib_extract_image() and
1899 * wimlib_extract_image_from_pipe() if <c>WIM_HDR_FLAG_RP_FIX</c> is set in the
1900 * WIM header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX.
1902 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1904 /** Force reparse-point fixups on extraction off, regardless of the state of the
1905 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1906 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1907 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1909 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1910 * paths, each of which must name a regular file, to standard output. */
1911 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1914 * Instead of ignoring files and directories with names that cannot be
1915 * represented on the current platform (note: Windows has more restrictions on
1916 * filenames than POSIX-compliant systems), try to replace characters or append
1917 * junk to the names so that they can be extracted in some form.
1919 * Note: this flag is unlikely to have any effect when extracting a WIM image
1920 * that was captured on Windows.
1922 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1925 * On Windows, when there exist two or more files with the same case insensitive
1926 * name but different case sensitive names, try to extract them all by appending
1927 * junk to the end of them, rather than arbitrarily extracting only one.
1929 * Note: this flag is unlikely to have any effect when extracting a WIM image
1930 * that was captured on Windows.
1932 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1934 /** Do not ignore failure to set timestamps on extracted files. This flag
1935 * currently only has an effect when extracting to a directory on UNIX-like
1937 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1939 /** Do not ignore failure to set short names on extracted files. This flag
1940 * currently only has an effect on Windows. */
1941 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1943 /** Do not ignore failure to extract symbolic links and junctions due to
1944 * permissions problems. This flag currently only has an effect on Windows. By
1945 * default, such failures are ignored since the default configuration of Windows
1946 * only allows the Administrator to create symbolic links. */
1947 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1950 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1951 * paths to extract as wildcard patterns ("globs") which may contain the
1952 * wildcard characters @c ? and @c *. The @c ? character matches any
1953 * non-path-separator character, whereas the @c * character matches zero or more
1954 * non-path-separator characters. Consequently, each glob may match zero or
1955 * more actual paths in the WIM image.
1957 * By default, if a glob does not match any files, a warning but not an error
1958 * will be issued. This is the case even if the glob did not actually contain
1959 * wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error
1962 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1964 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1965 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1966 * one of the provided globs did not match a file. */
1967 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1970 * Do not extract Windows file attributes such as readonly, hidden, etc.
1972 * This flag has an effect on Windows as well as in the NTFS-3G extraction mode.
1974 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1977 * For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1978 * preserve the directory structure of the archive when extracting --- that is,
1979 * place each extracted file or directory tree directly in the target directory.
1980 * The target directory will still be created if it does not already exist.
1982 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1985 * Windows only: Extract files as "pointers" back to the WIM archive.
1987 * The effects of this option are fairly complex. See the documentation for the
1988 * <b>--wimboot</b> option of <b>wimapply</b> for more information.
1990 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1993 * Since wimlib v1.8.2 and Windows-only: compress the extracted files using
1994 * System Compression, when possible. This only works on either Windows 10 or
1995 * later, or on an older Windows to which Microsoft's wofadk.sys driver has been
1996 * added. Several different compression formats may be used with System
1997 * Compression; this particular flag selects the XPRESS compression format with
2000 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K 0x01000000
2002 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2003 * 8192 byte chunks. */
2004 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K 0x02000000
2006 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use XPRESS compression with
2007 * 16384 byte chunks. */
2008 #define WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K 0x04000000
2010 /** Like ::WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K, but use LZX compression with
2011 * 32768 byte chunks. */
2012 #define WIMLIB_EXTRACT_FLAG_COMPACT_LZX 0x08000000
2015 /** @addtogroup G_mounting_wim_images
2018 /** Mount the WIM image read-write rather than the default of read-only. */
2019 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
2021 /** Enable FUSE debugging by passing the @c -d option to @c fuse_main(). */
2022 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
2024 /** Do not allow accessing named data streams in the mounted WIM image. */
2025 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
2027 /** Access named data streams in the mounted WIM image through extended file
2028 * attributes named "user.X", where X is the name of a data stream. This is the
2030 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
2032 /** Access named data streams in the mounted WIM image by specifying the file
2033 * name, a colon, then the name of the data stream. */
2034 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
2036 /** Use UNIX metadata if available in the WIM image. See
2037 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
2038 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
2040 /** Allow other users to see the mounted filesystem. This passes the @c
2041 * allow_other option to fuse_main(). */
2042 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
2045 /** @addtogroup G_creating_and_opening_wims
2048 /** Verify the WIM contents against the WIM's integrity table, if present. The
2049 * integrity table stores checksums for the raw data of the WIM file, divided
2050 * into fixed size chunks. Verification will compute checksums and compare them
2051 * with the stored values. If there are any mismatches, then
2052 * ::WIMLIB_ERR_INTEGRITY will be issued. If the WIM file does not contain an
2053 * integrity table, then this flag has no effect. */
2054 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
2056 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
2057 * WIM. Software can provide this flag for convenience if it explicitly does
2058 * not want to support split WIMs. */
2059 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
2061 /** Check if the WIM is writable and issue an error
2062 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
2063 * only if it is writable at the filesystem level, does not have the
2064 * <c>WIM_HDR_FLAG_READONLY</c> flag set in its header, and is not part of a
2065 * spanned set. It is not required to provide this flag before attempting to
2066 * make changes to the WIM, but with this flag you get an error immediately
2067 * rather than potentially much later, when wimlib_overwrite() is finally
2069 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
2072 /** @addtogroup G_mounting_wim_images
2075 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
2076 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2077 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
2079 /** Commit changes to the read-write mounted WIM image.
2080 * If this flag is not specified, changes will be discarded. */
2081 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
2083 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
2084 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2085 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
2087 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
2088 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
2089 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
2092 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
2093 * image, forces all file descriptors to the open WIM image to be closed before
2096 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
2097 * this flag has no effect.
2099 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
2101 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
2102 * WIM image, causes the modified image to be committed to the WIM file as a
2103 * new, unnamed image appended to the archive. The original image in the WIM
2104 * file will be unmodified. */
2105 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
2108 /** @addtogroup G_modifying_wims
2111 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
2112 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
2113 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
2116 /** @addtogroup G_writing_and_overwriting_wims
2120 * Include an integrity table in the resulting WIM file.
2122 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2123 * include an integrity table if and only if one was present before. For
2124 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2125 * to not include an integrity table.
2127 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
2130 * Do not include an integrity table in the resulting WIM file. This is the
2131 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
2134 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
2137 * Write the WIM as "pipable". After writing a WIM with this flag specified,
2138 * images from it can be applied directly from a pipe using
2139 * wimlib_extract_image_from_pipe(). See the documentation for the
2140 * <b>--pipable</b> option of <b>wimcapture</b> for more information. Beware:
2141 * WIMs written with this flag will not be compatible with Microsoft's software.
2143 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
2144 * write the WIM as pipable if and only if it was pipable before. For
2145 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
2146 * to write the WIM as non-pipable.
2148 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
2151 * Do not write the WIM as "pipable". This is the default behavior, unless the
2152 * ::WIMStruct was created by opening a pipable WIM.
2154 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
2157 * When writing data to the WIM file, recompress it, even if the data is already
2158 * available in the desired compressed form (for example, in a WIM file from
2159 * which an image has been exported using wimlib_export_image()).
2161 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
2162 * compression ratio for the same compression type and chunk size. Simply using
2163 * the default compression settings may suffice for this, especially if the WIM
2164 * file was created using another program/library that may not use as
2165 * sophisticated compression algorithms. Or,
2166 * wimlib_set_default_compression_level() can be called beforehand to set an
2167 * even higher compression level than the default.
2169 * If the WIM contains solid resources, then ::WIMLIB_WRITE_FLAG_RECOMPRESS can
2170 * be used in combination with ::WIMLIB_WRITE_FLAG_SOLID to prevent any solid
2171 * resources from being re-used. Otherwise, solid resources are re-used
2172 * somewhat more liberally than normal compressed resources.
2174 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of data
2175 * that would not otherwise be written. For example, a call to
2176 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
2177 * cause already-existing data in the WIM file to be recompressed. To force the
2178 * WIM file to be fully rebuilt and recompressed, combine
2179 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
2181 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
2184 * Immediately before closing the WIM file, sync its data to disk.
2186 * This flag forces the function to wait until the data is safely on disk before
2187 * returning success. Otherwise, modern operating systems tend to cache data
2188 * for some time (in some cases, 30+ seconds) before actually writing it to
2189 * disk, even after reporting to the application that the writes have succeeded.
2191 * wimlib_overwrite() will set this flag automatically if it decides to
2192 * overwrite the WIM file via a temporary file instead of in-place. This is
2193 * necessary on POSIX systems; it will, for example, avoid problems with delayed
2194 * allocation on ext4.
2196 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
2199 * For wimlib_overwrite(): rebuild the entire WIM file, even if it otherwise
2200 * could be updated in-place by appending to it. Any data that existed in the
2201 * original WIM file but is not actually needed by any of the remaining images
2202 * will not be included. This can free up space left over after previous
2203 * in-place modifications to the WIM file.
2205 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
2206 * data to be recompressed. Otherwise, compressed data is re-used if possible.
2208 * wimlib_write() ignores this flag.
2210 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
2213 * For wimlib_overwrite(): override the default behavior after one or more calls
2214 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
2215 * flag, only minimal changes to correctly remove the image from the WIM file
2216 * will be taken. This can be much faster, but it will result in the WIM file
2217 * getting larger rather than smaller.
2219 * wimlib_write() ignores this flag.
2221 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
2224 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
2225 * flag (<c>WIM_HDR_FLAG_READONLY</c>) is set in the WIM header. This can be
2226 * used following a call to wimlib_set_wim_info() with the
2227 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
2230 * wimlib_write() ignores this flag.
2232 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
2235 * Do not include file data already present in other WIMs. This flag can be
2236 * used to write a "delta" WIM after the WIM files on which the delta is to be
2237 * based were referenced with wimlib_reference_resource_files() or
2238 * wimlib_reference_resources().
2240 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
2242 /** Deprecated; this flag should not be used outside of the library itself. */
2243 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
2246 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
2248 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
2251 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
2254 * Concatenate files and compress them together, rather than compress each file
2255 * independently. This is also known as creating a "solid archive". This tends
2256 * to produce a better compression ratio at the cost of much slower random
2259 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
2260 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
2261 * created with this flag use a different version number in their header (3584
2262 * instead of 68864) and are also called "ESD files".
2264 * Note that providing this flag does not affect the "append by default"
2265 * behavior of wimlib_overwrite(). In other words, wimlib_overwrite() with just
2266 * ::WIMLIB_WRITE_FLAG_SOLID can be used to append solid-compressed data to a
2267 * WIM file that originally did not contain any solid-compressed data. But if
2268 * you instead want to rebuild and recompress an entire WIM file in solid mode,
2269 * then also provide ::WIMLIB_WRITE_FLAG_REBUILD and
2270 * ::WIMLIB_WRITE_FLAG_RECOMPRESS.
2272 * Currently, new solid resources will, by default, be written using LZMS
2273 * compression with 64 MiB (67108864 byte) chunks. Use
2274 * wimlib_set_output_pack_compression_type() and/or
2275 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
2276 * the WIM's main compression type and chunk size; you can have a WIM that
2277 * nominally uses LZX compression and 32768 byte chunks but actually contains
2278 * LZMS-compressed solid resources, for example. However, if including solid
2279 * resources, I suggest that you set the WIM's main compression type to LZMS as
2280 * well, either by creating the WIM with
2281 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
2282 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
2284 * This flag will be set by default when writing or overwriting a WIM file that
2285 * either already contains solid resources, or has had solid resources exported
2286 * into it and the WIM's main compression type is LZMS.
2288 #define WIMLIB_WRITE_FLAG_SOLID 0x00001000
2291 * Send ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE messages while writing the WIM
2292 * file. This is only needed in the unusual case that the library user needs to
2293 * know exactly when wimlib has read each file for the last time.
2295 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
2298 * Do not consider content similarity when arranging file data for solid
2299 * compression. Providing this flag will typically worsen the compression
2300 * ratio, so only provide this flag if you know what you are doing.
2302 #define WIMLIB_WRITE_FLAG_NO_SOLID_SORT 0x00004000
2305 * Since wimlib v1.8.3 and for wimlib_overwrite() only: <b>unsafely</b> compact
2306 * the WIM file in-place, without appending. Existing resources are shifted
2307 * down to fill holes and new resources are appended as needed. The WIM file is
2308 * truncated to its final size, which may shrink the on-disk file. <b>This
2309 * operation cannot be safely interrupted. If the operation is interrupted,
2310 * then the WIM file will be corrupted, and it may be impossible (or at least
2311 * very difficult) to recover any data from it. Users of this flag are expected
2312 * to know what they are doing and assume responsibility for any data corruption
2313 * that may result.</b>
2315 * If the WIM file cannot be compacted in-place because of its structure, its
2316 * layout, or other requested write parameters, then wimlib_overwrite() fails
2317 * with ::WIMLIB_ERR_COMPACTION_NOT_POSSIBLE, and the caller may wish to retry
2318 * the operation without this flag.
2320 #define WIMLIB_WRITE_FLAG_UNSAFE_COMPACT 0x00008000
2323 /** @addtogroup G_general
2326 /** Assume that strings are represented in UTF-8, even if this is not the
2327 * locale's character encoding. This flag is ignored on Windows, where wimlib
2328 * always uses UTF-16LE. */
2329 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
2331 /** Windows-only: do not attempt to acquire additional privileges (currently
2332 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege,
2333 * SeTakeOwnershipPrivilege, and SeManageVolumePrivilege) when initializing the
2334 * library. This flag is intended for the case where the calling program
2335 * manages these privileges itself. Note: by default, no error is issued if
2336 * privileges cannot be acquired, although related errors may be reported later,
2337 * depending on if the operations performed actually require additional
2338 * privileges or not. */
2339 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
2341 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2342 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2343 * to read all possible data and metadata for a capture operation could not be
2344 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
2346 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
2348 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2349 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2350 * to restore all possible data and metadata for an apply operation could not be
2351 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
2353 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
2355 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
2357 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
2359 /** Default to interpreting WIM paths case insensitively (default on Windows).
2360 * This does not apply to mounted images. */
2361 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
2364 /** @addtogroup G_nonstandalone_wims
2367 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
2368 * Ignored by wimlib_reference_resources(). */
2369 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
2371 /** For wimlib_reference_resource_files(), issue an error
2372 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
2373 * default behavior without this flag is to issue no error at that point, but
2374 * then attempt to open the glob as a literal path, which of course will fail
2375 * anyway if no file exists at that path. No effect if
2376 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
2377 * wimlib_reference_resources(). */
2378 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
2381 /** @addtogroup G_modifying_wims
2384 /** The specific type of update to perform. */
2385 enum wimlib_update_op {
2386 /** Add a new file or directory tree to the image. */
2387 WIMLIB_UPDATE_OP_ADD = 0,
2389 /** Delete a file or directory tree from the image. */
2390 WIMLIB_UPDATE_OP_DELETE = 1,
2392 /** Rename a file or directory tree in the image. */
2393 WIMLIB_UPDATE_OP_RENAME = 2,
2396 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2397 struct wimlib_add_command {
2398 /** Filesystem path to the file or directory tree to add. */
2399 wimlib_tchar *fs_source_path;
2401 /** Destination path in the image. To specify the root directory of the
2402 * image, use ::WIMLIB_WIM_ROOT_PATH. */
2403 wimlib_tchar *wim_target_path;
2405 /** Path to capture configuration file to use, or @c NULL if not
2407 wimlib_tchar *config_file;
2409 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2413 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2414 struct wimlib_delete_command {
2416 /** The path to the file or directory within the image to delete. */
2417 wimlib_tchar *wim_path;
2419 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2423 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2424 struct wimlib_rename_command {
2426 /** The path to the source file or directory within the image. */
2427 wimlib_tchar *wim_source_path;
2429 /** The path to the destination file or directory within the image. */
2430 wimlib_tchar *wim_target_path;
2432 /** Reserved; set to 0. */
2436 /** Specification of an update to perform on a WIM image. */
2437 struct wimlib_update_command {
2439 enum wimlib_update_op op;
2442 struct wimlib_add_command add;
2443 struct wimlib_delete_command delete_; /* Underscore is for C++
2445 struct wimlib_rename_command rename;
2450 /** @addtogroup G_general
2454 * Possible values of the error code returned by many functions in wimlib.
2456 * See the documentation for each wimlib function to see specifically what error
2457 * codes can be returned by a given function, and what they mean.
2459 enum wimlib_error_code {
2460 WIMLIB_ERR_SUCCESS = 0,
2461 WIMLIB_ERR_ALREADY_LOCKED = 1,
2462 WIMLIB_ERR_DECOMPRESSION = 2,
2463 WIMLIB_ERR_FUSE = 6,
2464 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2465 WIMLIB_ERR_ICONV_NOT_AVAILABLE = 9,
2466 WIMLIB_ERR_IMAGE_COUNT = 10,
2467 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2468 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2469 WIMLIB_ERR_INTEGRITY = 13,
2470 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2471 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2472 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2473 WIMLIB_ERR_INVALID_HEADER = 17,
2474 WIMLIB_ERR_INVALID_IMAGE = 18,
2475 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2476 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2477 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2478 WIMLIB_ERR_INVALID_MULTIBYTE_STRING = 22,
2479 WIMLIB_ERR_INVALID_OVERLAY = 23,
2480 WIMLIB_ERR_INVALID_PARAM = 24,
2481 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2482 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2483 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2484 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2485 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2486 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2487 WIMLIB_ERR_IS_DIRECTORY = 32,
2488 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2489 WIMLIB_ERR_LINK = 35,
2490 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2491 WIMLIB_ERR_MKDIR = 37,
2492 WIMLIB_ERR_MQUEUE = 38,
2493 WIMLIB_ERR_NOMEM = 39,
2494 WIMLIB_ERR_NOTDIR = 40,
2495 WIMLIB_ERR_NOTEMPTY = 41,
2496 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2497 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2498 WIMLIB_ERR_NOT_PIPABLE = 44,
2499 WIMLIB_ERR_NO_FILENAME = 45,
2500 WIMLIB_ERR_NTFS_3G = 46,
2501 WIMLIB_ERR_OPEN = 47,
2502 WIMLIB_ERR_OPENDIR = 48,
2503 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2504 WIMLIB_ERR_READ = 50,
2505 WIMLIB_ERR_READLINK = 51,
2506 WIMLIB_ERR_RENAME = 52,
2507 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2508 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2509 WIMLIB_ERR_RESOURCE_ORDER = 56,
2510 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2511 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2512 WIMLIB_ERR_SET_SECURITY = 59,
2513 WIMLIB_ERR_SET_SHORT_NAME = 60,
2514 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2515 WIMLIB_ERR_SPLIT_INVALID = 62,
2516 WIMLIB_ERR_STAT = 63,
2517 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2518 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2519 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2520 WIMLIB_ERR_UNSUPPORTED = 68,
2521 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2522 WIMLIB_ERR_WIM_IS_READONLY = 71,
2523 WIMLIB_ERR_WRITE = 72,
2524 WIMLIB_ERR_XML = 73,
2525 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2526 WIMLIB_ERR_WIMBOOT = 75,
2527 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2528 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2529 WIMLIB_ERR_MKNOD = 78,
2530 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2531 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2532 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2533 WIMLIB_ERR_FVE_LOCKED_VOLUME = 82,
2534 WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG = 83,
2535 WIMLIB_ERR_WIM_IS_INCOMPLETE = 84,
2536 WIMLIB_ERR_COMPACTION_NOT_POSSIBLE = 85,
2537 WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES = 86,
2538 WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE = 87,
2539 WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED = 88,
2540 WIMLIB_ERR_SNAPSHOT_FAILURE = 89,
2544 /** Used to indicate no image or an invalid image. */
2545 #define WIMLIB_NO_IMAGE 0
2547 /** Used to specify all images in the WIM. */
2548 #define WIMLIB_ALL_IMAGES (-1)
2553 * @ingroup G_modifying_wims
2555 * Append an empty image to a ::WIMStruct.
2557 * The new image will initially contain no files or directories, although if
2558 * written without further modifications, then a root directory will be created
2559 * automatically for it.
2561 * After calling this function, you can use wimlib_update_image() to add files
2562 * to the new image. This gives you more control over making the new image
2563 * compared to calling wimlib_add_image() or wimlib_add_image_multisource().
2566 * Pointer to the ::WIMStruct to which to add the image.
2568 * Name to give the new image. If @c NULL or empty, the new image is given
2569 * no name. If nonempty, it must specify a name that does not already
2571 * @param new_idx_ret
2572 * If non-<c>NULL</c>, the index of the newly added image is returned in
2575 * @return 0 on success; a ::wimlib_error_code value on failure.
2577 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2578 * The WIM already contains an image with the requested name.
2581 wimlib_add_empty_image(WIMStruct *wim,
2582 const wimlib_tchar *name,
2586 * @ingroup G_modifying_wims
2588 * Add an image to a ::WIMStruct from an on-disk directory tree or NTFS volume.
2590 * The directory tree or NTFS volume is scanned immediately to load the dentry
2591 * tree into memory, and file metadata is read. However, actual file data may
2592 * not be read until the ::WIMStruct is persisted to disk using wimlib_write()
2593 * or wimlib_overwrite().
2595 * See the documentation for the @b wimlib-imagex program for more information
2596 * about the "normal" capture mode versus the NTFS capture mode (entered by
2597 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2599 * Note that no changes are committed to disk until wimlib_write() or
2600 * wimlib_overwrite() is called.
2603 * Pointer to the ::WIMStruct to which to add the image.
2605 * A path to a directory or unmounted NTFS volume that will be captured as
2608 * Name to give the new image. If @c NULL or empty, the new image is given
2609 * no name. If nonempty, it must specify a name that does not already
2611 * @param config_file
2612 * Path to capture configuration file, or @c NULL. This file may specify,
2613 * among other things, which files to exclude from capture. See the
2614 * documentation for <b>wimcapture</b> (<b>--config</b> option) for details
2615 * of the file format. If @c NULL, the default capture configuration will
2616 * be used. Ordinarily, the default capture configuration will result in
2617 * no files being excluded from capture purely based on name; however, the
2618 * ::WIMLIB_ADD_FLAG_WINCONFIG and ::WIMLIB_ADD_FLAG_WIMBOOT flags modify
2621 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2623 * @return 0 on success; a ::wimlib_error_code value on failure.
2625 * This function is implemented by calling wimlib_add_empty_image(), then
2626 * calling wimlib_update_image() with a single "add" command, so any error code
2627 * returned by wimlib_add_empty_image() may be returned, as well as any error
2628 * codes returned by wimlib_update_image() other than ones documented as only
2629 * being returned specifically by an update involving delete or rename commands.
2631 * If a progress function is registered with @p wim, then it will receive the
2632 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2633 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2634 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2637 wimlib_add_image(WIMStruct *wim,
2638 const wimlib_tchar *source,
2639 const wimlib_tchar *name,
2640 const wimlib_tchar *config_file,
2644 * @ingroup G_modifying_wims
2646 * This function is equivalent to wimlib_add_image() except it allows for
2647 * multiple sources to be combined into a single WIM image. This is done by
2648 * specifying the @p sources and @p num_sources parameters instead of the @p
2649 * source parameter of wimlib_add_image(). The rest of the parameters are the
2650 * same as wimlib_add_image(). See the documentation for <b>wimcapture</b> for
2651 * full details on how this mode works.
2654 wimlib_add_image_multisource(WIMStruct *wim,
2655 const struct wimlib_capture_source *sources,
2657 const wimlib_tchar *name,
2658 const wimlib_tchar *config_file,
2662 * @ingroup G_modifying_wims
2664 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2665 * location @p wim_target_path within the specified @p image of the @p wim.
2667 * This just builds an appropriate ::wimlib_add_command and passes it to
2668 * wimlib_update_image().
2671 wimlib_add_tree(WIMStruct *wim, int image,
2672 const wimlib_tchar *fs_source_path,
2673 const wimlib_tchar *wim_target_path, int add_flags);
2676 * @ingroup G_creating_and_opening_wims
2678 * Create a ::WIMStruct which initially contains no images and is not backed by
2682 * The "output compression type" to assign to the ::WIMStruct. This is the
2683 * compression type that will be used if the ::WIMStruct is later persisted
2684 * to an on-disk file using wimlib_write().
2686 * This choice is not necessarily final. If desired, it can still be
2687 * changed at any time before wimlib_write() is called, using
2688 * wimlib_set_output_compression_type(). In addition, if you wish to use a
2689 * non-default compression chunk size, then you will need to call
2690 * wimlib_set_output_chunk_size().
2692 * On success, a pointer to the new ::WIMStruct is written to the memory
2693 * location pointed to by this parameter. This ::WIMStruct must be freed
2694 * using using wimlib_free() when finished with it.
2696 * @return 0 on success; a ::wimlib_error_code value on failure.
2698 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2699 * @p ctype was not a supported compression type.
2700 * @retval ::WIMLIB_ERR_NOMEM
2701 * Insufficient memory to allocate a new ::WIMStruct.
2704 wimlib_create_new_wim(enum wimlib_compression_type ctype, WIMStruct **wim_ret);
2707 * @ingroup G_modifying_wims
2709 * Delete an image, or all images, from a ::WIMStruct.
2711 * Note that no changes are committed to disk until wimlib_write() or
2712 * wimlib_overwrite() is called.
2715 * Pointer to the ::WIMStruct from which to delete the image.
2717 * The 1-based index of the image to delete, or ::WIMLIB_ALL_IMAGES to
2718 * delete all images.
2720 * @return 0 on success; a ::wimlib_error_code value on failure.
2722 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2723 * @p image does not exist in the WIM.
2725 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2726 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2727 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2728 * indicate failure (for different reasons) to read the metadata resource for an
2729 * image that needed to be deleted.
2731 * If this function fails when @p image was ::WIMLIB_ALL_IMAGES, then it's
2732 * possible that some but not all of the images were deleted.
2735 wimlib_delete_image(WIMStruct *wim, int image);
2738 * @ingroup G_modifying_wims
2740 * Delete the @p path from the specified @p image of the @p wim.
2742 * This just builds an appropriate ::wimlib_delete_command and passes it to
2743 * wimlib_update_image().
2746 wimlib_delete_path(WIMStruct *wim, int image,
2747 const wimlib_tchar *path, int delete_flags);
2750 * @ingroup G_modifying_wims
2752 * Export an image, or all images, from a ::WIMStruct into another ::WIMStruct.
2754 * Specifically, if the destination ::WIMStruct contains <tt>n</tt> images, then
2755 * the source image(s) will be appended, in order, starting at destination index
2756 * <tt>n + 1</tt>. By default, all image metadata will be exported verbatim,
2757 * but certain changes can be made by passing appropriate parameters.
2759 * wimlib_export_image() is only an in-memory operation; no changes are
2760 * committed to disk until wimlib_write() or wimlib_overwrite() is called.
2762 * A limitation of the current implementation of wimlib_export_image() is that
2763 * the directory tree of a source or destination image cannot be updated
2764 * following an export until one of the two images has been freed from memory.
2767 * The WIM from which to export the images, specified as a pointer to the
2768 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2769 * split WIM. In the case of a WIM file that is not standalone, this
2770 * ::WIMStruct must have had any needed external resources previously
2771 * referenced using wimlib_reference_resources() or
2772 * wimlib_reference_resource_files().
2774 * The 1-based index of the image from @p src_wim to export, or
2775 * ::WIMLIB_ALL_IMAGES.
2777 * The ::WIMStruct to which to export the images.
2779 * For single-image exports, the name to give the exported image in @p
2780 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2781 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2782 * that case, the names are all taken from @p src_wim. This parameter is
2783 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2784 * @param dest_description
2785 * For single-image exports, the description to give the exported image in
2786 * the new WIM file. If left @c NULL, the description from @p src_wim is
2787 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2788 * NULL; in that case, the description are all taken from @p src_wim. This
2789 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2790 * @param export_flags
2791 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2793 * @return 0 on success; a ::wimlib_error_code value on failure.
2795 * @retval ::WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE
2796 * One or more of the source images had already been exported into the
2798 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2799 * One or more of the names being given to an exported image was already in
2800 * use in the destination WIM.
2801 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2802 * @p src_image does not exist in @p src_wim.
2803 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2804 * At least one of @p src_wim and @p dest_wim does not contain image
2805 * metadata; for example, one of them represents a non-first part of a
2807 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2808 * A file data blob that needed to be exported could not be found in the
2809 * blob lookup table of @p src_wim. See @ref G_nonstandalone_wims.
2811 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2812 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2813 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2814 * indicate failure (for different reasons) to read the metadata resource for an
2815 * image in @p src_wim that needed to be exported.
2818 wimlib_export_image(WIMStruct *src_wim, int src_image,
2819 WIMStruct *dest_wim,
2820 const wimlib_tchar *dest_name,
2821 const wimlib_tchar *dest_description,
2825 * @ingroup G_extracting_wims
2827 * Extract an image, or all images, from a ::WIMStruct.
2829 * The exact behavior of how wimlib extracts files from a WIM image is
2830 * controllable by the @p extract_flags parameter, but there also are
2831 * differences depending on the platform (UNIX-like vs Windows). See the
2832 * documentation for <b>wimapply</b> for more information, including about the
2833 * NTFS-3G extraction mode.
2836 * The WIM from which to extract the image(s), specified as a pointer to the
2837 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2838 * split WIM. In the case of a WIM file that is not standalone, this
2839 * ::WIMStruct must have had any needed external resources previously
2840 * referenced using wimlib_reference_resources() or
2841 * wimlib_reference_resource_files().
2843 * The 1-based index of the image to extract, or ::WIMLIB_ALL_IMAGES to
2844 * extract all images. Note: ::WIMLIB_ALL_IMAGES is unsupported in NTFS-3G
2847 * A null-terminated string which names the location to which the image(s)
2848 * will be extracted. By default, this is interpreted as a path to a
2849 * directory. Alternatively, if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in
2850 * @p extract_flags, then this is interpreted as a path to an unmounted
2852 * @param extract_flags
2853 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2855 * @return 0 on success; a ::wimlib_error_code value on failure.
2857 * @retval ::WIMLIB_ERR_DECOMPRESSION
2858 * The WIM file contains invalid compressed data.
2859 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2860 * @p image does not exist in @p wim.
2861 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2862 * The metadata for an image to extract was invalid.
2863 * @retval ::WIMLIB_ERR_INVALID_PARAM
2864 * The extraction flags were invalid; more details may be found in the
2865 * documentation for the specific extraction flags that were specified. Or
2866 * @p target was @c NULL or an empty string, or @p wim was @c NULL.
2867 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2868 * The data of a file that needed to be extracted was corrupt.
2869 * @retval ::WIMLIB_ERR_LINK
2870 * Failed to create a symbolic link or a hard link.
2871 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2872 * @p wim does not contain image metadata; for example, it represents a
2873 * non-first part of a split WIM.
2874 * @retval ::WIMLIB_ERR_MKDIR
2875 * Failed create a directory.
2876 * @retval ::WIMLIB_ERR_NTFS_3G
2877 * libntfs-3g reported that a problem occurred while writing to the NTFS
2879 * @retval ::WIMLIB_ERR_OPEN
2880 * Could not create a file, or failed to open an already-extracted file.
2881 * @retval ::WIMLIB_ERR_READ
2882 * Failed to read data from the WIM.
2883 * @retval ::WIMLIB_ERR_READLINK
2884 * Failed to determine the target of a symbolic link in the WIM.
2885 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2886 * Failed to fix the target of an absolute symbolic link (e.g. if the
2887 * target would have exceeded the maximum allowed length). (Only if
2888 * reparse data was supported by the extraction mode and
2889 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2891 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2892 * A file data blob that needed to be extracted could not be found in the
2893 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
2894 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2895 * Failed to set attributes on a file.
2896 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2897 * Failed to set reparse data on a file (only if reparse data was supported
2898 * by the extraction mode).
2899 * @retval ::WIMLIB_ERR_SET_SECURITY
2900 * Failed to set security descriptor on a file.
2901 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2902 * Failed to set the short name of a file.
2903 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2904 * Failed to set timestamps on a file.
2905 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2906 * Unexpected end-of-file occurred when reading data from the WIM.
2907 * @retval ::WIMLIB_ERR_UNSUPPORTED
2908 * A requested extraction flag, or the data or metadata that must be
2909 * extracted to support it, is unsupported in the build and configuration
2910 * of wimlib, or on the current platform or extraction mode or target
2911 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2912 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2913 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2914 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2915 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2916 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2917 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2918 * image contains one or more files with short names, but extracting short
2919 * names is not supported --- on Windows, this occurs if the target volume
2920 * does not support short names, while on non-Windows, this occurs if
2921 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2922 * @retval ::WIMLIB_ERR_WIMBOOT
2923 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2924 * there was a problem creating WIMBoot pointer files or registering a
2925 * source WIM file with the Windows Overlay Filesystem (WOF) driver.
2926 * @retval ::WIMLIB_ERR_WRITE
2927 * Failed to write data to a file being extracted.
2929 * If a progress function is registered with @p wim, then as each image is
2930 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2931 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE messages, then zero
2932 * or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then zero or more
2933 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, then
2934 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2937 wimlib_extract_image(WIMStruct *wim, int image,
2938 const wimlib_tchar *target, int extract_flags);
2941 * @ingroup G_extracting_wims
2943 * Extract one image from a pipe on which a pipable WIM is being sent.
2945 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE, and @ref
2946 * subsec_pipable_wims, for more information about pipable WIMs.
2948 * This function operates in a special way to read the WIM fully sequentially.
2949 * As a result, there is no ::WIMStruct is made visible to library users, and
2950 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2951 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2952 * seekable file, not a pipe.)
2955 * File descriptor, which may be a pipe, opened for reading and positioned
2956 * at the start of the pipable WIM.
2957 * @param image_num_or_name
2958 * String that specifies the 1-based index or name of the image to extract.
2959 * It is translated to an image index using the same rules that
2960 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2961 * only a single image (not all images) can be specified. Alternatively,
2962 * specify @p NULL here to use the first image in the WIM if it contains
2963 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2965 * Same as the corresponding parameter to wimlib_extract_image().
2966 * @param extract_flags
2967 * Same as the corresponding parameter to wimlib_extract_image().
2969 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
2970 * error codes include those returned by wimlib_extract_image() and
2971 * wimlib_open_wim() as well as the following:
2973 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2974 * Data read from the pipable WIM was invalid.
2975 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2976 * The WIM being piped over @p pipe_fd is a normal WIM, not a pipable WIM.
2979 wimlib_extract_image_from_pipe(int pipe_fd,
2980 const wimlib_tchar *image_num_or_name,
2981 const wimlib_tchar *target, int extract_flags);
2984 * @ingroup G_extracting_wims
2986 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2987 * function. The progress function will be used while extracting the image and
2988 * will receive the normal extraction progress messages, such as
2989 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2990 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2993 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2994 const wimlib_tchar *image_num_or_name,
2995 const wimlib_tchar *target,
2997 wimlib_progress_func_t progfunc,
3001 * @ingroup G_extracting_wims
3003 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
3004 * image are specified in the ASCII, UTF-8, or UTF-16LE text file named by @p
3005 * path_list_file which itself contains the list of paths to use, one per line.
3006 * Leading and trailing whitespace is ignored. Empty lines and lines beginning
3007 * with the ';' or '#' characters are ignored. No quotes are needed, as paths
3008 * are otherwise delimited by the newline character. However, quotes will be
3009 * stripped if present.
3011 * The error codes are the same as those returned by wimlib_extract_paths(),
3012 * except that wimlib_extract_pathlist() returns an appropriate error code if it
3013 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
3014 * ::WIMLIB_ERR_READ).
3017 wimlib_extract_pathlist(WIMStruct *wim, int image,
3018 const wimlib_tchar *target,
3019 const wimlib_tchar *path_list_file,
3023 * @ingroup G_extracting_wims
3025 * Extract zero or more paths (files or directory trees) from the specified WIM
3028 * By default, each path will be extracted to a corresponding subdirectory of
3029 * the target based on its location in the image. For example, if one of the
3030 * paths to extract is <c>/Windows/explorer.exe</c> and the target is
3031 * <c>outdir</c>, the file will be extracted to
3032 * <c>outdir/Windows/explorer.exe</c>. This behavior can be changed by
3033 * providing the flag ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which
3034 * will cause each file or directory tree to be placed directly in the target
3035 * directory --- so the same example would extract <c>/Windows/explorer.exe</c>
3036 * to <c>outdir/explorer.exe</c>.
3038 * With globbing turned off (the default), paths are always checked for
3039 * existence strictly; that is, if any path to extract does not exist in the
3040 * image, then nothing is extracted and the function fails with
3041 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST. But with globbing turned on
3042 * (::WIMLIB_EXTRACT_FLAG_GLOB_PATHS specified), globs are by default permitted
3043 * to match no files, and there is a flag (::WIMLIB_EXTRACT_FLAG_STRICT_GLOB) to
3044 * enable the strict behavior if desired.
3046 * Symbolic links are not dereferenced when paths in the image are interpreted.
3049 * WIM from which to extract the paths, specified as a pointer to the
3050 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
3051 * split WIM. In the case of a WIM file that is not standalone, this
3052 * ::WIMStruct must have had any needed external resources previously
3053 * referenced using wimlib_reference_resources() or
3054 * wimlib_reference_resource_files().
3056 * The 1-based index of the WIM image from which to extract the paths.
3058 * Array of paths to extract. Each element must be the absolute path to a
3059 * file or directory within the image. Path separators may be either
3060 * forwards or backwards slashes, and leading path separators are optional.
3061 * The paths will be interpreted either case-sensitively (UNIX default) or
3062 * case-insensitively (Windows default); however, the case sensitivity can
3063 * be configured explicitly at library initialization time by passing an
3064 * appropriate flag to wimlib_global_init().
3066 * By default, "globbing" is disabled, so the characters @c * and @c ? are
3067 * interpreted literally. This can be changed by specifying
3068 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p extract_flags.
3070 * Number of paths specified in @p paths.
3072 * Directory to which to extract the paths.
3073 * @param extract_flags
3074 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
3076 * @return 0 on success; a ::wimlib_error_code value on failure. Most of the
3077 * error codes are the same as those returned by wimlib_extract_image(). Below,
3078 * some of the error codes returned in situations specific to path-mode
3079 * extraction are documented:
3081 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
3082 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
3083 * one of the paths to extract did not name a regular file.
3084 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3085 * One of the paths to extract does not exist in the image; see discussion
3086 * above about strict vs. non-strict behavior.
3088 * If a progress function is registered with @p wim, then it will receive
3089 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS.
3092 wimlib_extract_paths(WIMStruct *wim,
3094 const wimlib_tchar *target,
3095 const wimlib_tchar * const *paths,
3100 * @ingroup G_wim_information
3102 * Similar to wimlib_get_xml_data(), but the XML document will be written to the
3103 * specified standard C <c>FILE*</c> instead of retrieved in an in-memory
3106 * @return 0 on success; a ::wimlib_error_code value on failure. This may
3107 * return any error code which can be returned by wimlib_get_xml_data() as well
3108 * as the following error codes:
3110 * @retval ::WIMLIB_ERR_WRITE
3111 * Failed to write the data to the requested file.
3114 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
3117 * @ingroup G_general
3119 * Release a reference to a ::WIMStruct. If the ::WIMStruct is still referenced
3120 * by other ::WIMStruct's (e.g. following calls to wimlib_export_image() or
3121 * wimlib_reference_resources()), then the library will free it later, when the
3122 * last reference is released; otherwise it is freed immediately and any
3123 * associated file descriptors are closed.
3126 * Pointer to the ::WIMStruct to release. If @c NULL, no action is taken.
3129 wimlib_free(WIMStruct *wim);
3132 * @ingroup G_general
3134 * Convert a ::wimlib_compression_type value into a string.
3137 * The compression type value to convert.
3140 * A statically allocated string naming the compression type, such as
3141 * "None", "LZX", or "XPRESS". If the value was unrecognized, then
3142 * the resulting string will be "Invalid".
3144 extern const wimlib_tchar *
3145 wimlib_get_compression_type_string(enum wimlib_compression_type ctype);
3148 * @ingroup G_general
3150 * Convert a wimlib error code into a string describing it.
3153 * An error code returned by one of wimlib's functions.
3156 * Pointer to a statically allocated string describing the error code. If
3157 * the value was unrecognized, then the resulting string will be "Unknown
3160 extern const wimlib_tchar *
3161 wimlib_get_error_string(enum wimlib_error_code code);
3164 * @ingroup G_wim_information
3166 * Get the description of the specified image. Equivalent to
3167 * <tt>wimlib_get_image_property(wim, image, "DESCRIPTION")</tt>.
3169 extern const wimlib_tchar *
3170 wimlib_get_image_description(const WIMStruct *wim, int image);
3173 * @ingroup G_wim_information
3175 * Get the name of the specified image. Equivalent to
3176 * <tt>wimlib_get_image_property(wim, image, "NAME")</tt>, except that
3177 * wimlib_get_image_name() will return an empty string if the image is unnamed
3178 * whereas wimlib_get_image_property() may return @c NULL in that case.
3180 extern const wimlib_tchar *
3181 wimlib_get_image_name(const WIMStruct *wim, int image);
3184 * @ingroup G_wim_information
3186 * Since wimlib v1.8.3: get a per-image property from the WIM's XML document.
3187 * This is an alternative to wimlib_get_image_name() and
3188 * wimlib_get_image_description() which allows getting any simple string
3192 * Pointer to the ::WIMStruct for the WIM.
3194 * The 1-based index of the image for which to get the property.
3195 * @param property_name
3196 * The name of the image property, for example "NAME", "DESCRIPTION", or
3197 * "TOTALBYTES". The name can contain forward slashes to indicate a nested
3198 * XML element; for example, "WINDOWS/VERSION/BUILD" indicates the BUILD
3199 * element nested within the VERSION element nested within the WINDOWS
3200 * element. Since wimlib v1.9.0, a bracketed number can be used to
3201 * indicate one of several identically-named elements; for example,
3202 * "WINDOWS/LANGUAGES/LANGUAGE[2]" indicates the second "LANGUAGE" element
3203 * nested within the "WINDOWS/LANGUAGES" element. Note that element names
3204 * are case sensitive.
3207 * The property's value as a ::wimlib_tchar string, or @c NULL if there is
3208 * no such property. The string may not remain valid after later library
3209 * calls, so the caller should duplicate it if needed.
3211 extern const wimlib_tchar *
3212 wimlib_get_image_property(const WIMStruct *wim, int image,
3213 const wimlib_tchar *property_name);
3216 * @ingroup G_general
3218 * Return the version of wimlib as a 32-bit number whose top 12 bits contain the
3219 * major version, the next 10 bits contain the minor version, and the low 10
3220 * bits contain the patch version.
3222 * In other words, the returned value is equal to <c>((WIMLIB_MAJOR_VERSION <<
3223 * 20) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</c> for the
3224 * corresponding header file.
3227 wimlib_get_version(void);
3230 * @ingroup G_wim_information
3232 * Get basic information about a WIM file.
3235 * Pointer to the ::WIMStruct to query. This need not represent a
3236 * standalone WIM (e.g. it could represent part of a split WIM).
3238 * A ::wimlib_wim_info structure that will be filled in with information
3239 * about the WIM file.
3244 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
3247 * @ingroup G_wim_information
3249 * Read a WIM file's XML document into an in-memory buffer.
3251 * The XML document contains metadata about the WIM file and the images stored
3255 * Pointer to the ::WIMStruct to query. This need not represent a
3256 * standalone WIM (e.g. it could represent part of a split WIM).
3258 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
3259 * XML document is written to this location.
3260 * @param bufsize_ret
3261 * The size of the XML document in bytes is written to this location.
3263 * @return 0 on success; a ::wimlib_error_code value on failure.
3265 * @retval ::WIMLIB_ERR_NO_FILENAME
3266 * @p wim is not backed by a file and therefore does not have an XML
3268 * @retval ::WIMLIB_ERR_READ
3269 * Failed to read the XML document from the WIM file.
3270 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3271 * Failed to read the XML document from the WIM file.
3274 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
3277 * @ingroup G_general
3279 * Initialization function for wimlib. Call before using any other wimlib
3280 * function (except possibly wimlib_set_print_errors()). If not done manually,
3281 * this function will be called automatically with @p init_flags set to
3282 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
3283 * after it has already successfully run.
3286 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
3288 * @return 0 on success; a ::wimlib_error_code value on failure.
3290 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
3291 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
3292 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
3293 * init_flags, but the corresponding privileges could not be acquired.
3296 wimlib_global_init(int init_flags);
3299 * @ingroup G_general
3301 * Cleanup function for wimlib. You are not required to call this function, but
3302 * it will release any global resources allocated by the library.
3305 wimlib_global_cleanup(void);
3308 * @ingroup G_wim_information
3310 * Determine if an image name is already used by some image in the WIM.
3313 * Pointer to the ::WIMStruct to query. This need not represent a
3314 * standalone WIM (e.g. it could represent part of a split WIM).
3316 * The name to check.
3319 * @c true if there is already an image in @p wim named @p name; @c false
3320 * if there is no image named @p name in @p wim. If @p name is @c NULL or
3321 * the empty string, then @c false is returned.
3324 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
3327 * @ingroup G_wim_information
3329 * Iterate through a file or directory tree in a WIM image. By specifying
3330 * appropriate flags and a callback function, you can get the attributes of a
3331 * file in the image, get a directory listing, or even get a listing of the
3335 * The ::WIMStruct containing the image(s) over which to iterate. This
3336 * ::WIMStruct must contain image metadata, so it cannot be the non-first
3337 * part of a split WIM (for example).
3339 * The 1-based index of the image that contains the files or directories to
3340 * iterate over, or ::WIMLIB_ALL_IMAGES to iterate over all images.
3342 * Path in the image at which to do the iteration.
3344 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3346 * A callback function that will receive each directory entry.
3348 * An extra parameter that will always be passed to the callback function
3351 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3352 * first nonzero value that was returned from @p cb. However, additional
3353 * ::wimlib_error_code values may be returned, including the following:
3355 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3356 * @p image does not exist in @p wim.
3357 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3358 * @p path does not exist in the image.
3359 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3360 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED was specified, but the
3361 * data for some files could not be found in the blob lookup table of @p
3364 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3365 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3366 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3367 * indicate failure (for different reasons) to read the metadata resource for an
3368 * image over which iteration needed to be done.
3371 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3373 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3376 * @ingroup G_wim_information
3378 * Iterate through the blob lookup table of a ::WIMStruct. This can be used to
3379 * directly get a listing of the unique "blobs" contained in a WIM file, which
3380 * are deduplicated over all images.
3382 * Specifically, each listed blob may be from any of the following sources:
3384 * - Metadata blobs, if the ::WIMStruct contains image metadata
3385 * - File blobs from the on-disk WIM file (if any) backing the ::WIMStruct
3386 * - File blobs from files that have been added to the in-memory ::WIMStruct,
3387 * e.g. by using wimlib_add_image()
3388 * - File blobs from external WIMs referenced by
3389 * wimlib_reference_resource_files() or wimlib_reference_resources()
3392 * Pointer to the ::WIMStruct for which to get the blob listing.
3394 * Reserved; set to 0.
3396 * A callback function that will receive each blob.
3398 * An extra parameter that will always be passed to the callback function
3401 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3402 * that was returned from @p cb.
3405 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3406 wimlib_iterate_lookup_table_callback_t cb,
3410 * @ingroup G_nonstandalone_wims
3412 * Join a split WIM into a stand-alone (one-part) WIM.
3415 * An array of strings that gives the filenames of all parts of the split
3416 * WIM. No specific order is required, but all parts must be included with
3419 * Number of filenames in @p swms.
3420 * @param swm_open_flags
3421 * Open flags for the split WIM parts (e.g.
3422 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3423 * @param wim_write_flags
3424 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3425 * be used to write the joined WIM.
3426 * @param output_path
3427 * The path to write the joined WIM file to.
3429 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3430 * may return most error codes that can be returned by wimlib_open_wim() and
3431 * wimlib_write(), as well as the following error codes:
3433 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3434 * The split WIMs do not form a valid WIM because they do not include all
3435 * the parts of the original WIM, there are duplicate parts, or not all the
3436 * parts have the same GUID and compression type.
3438 * Note: wimlib is generalized enough that this function is not actually needed
3439 * to join a split WIM; instead, you could open the first part of the split WIM,
3440 * then reference the other parts with wimlib_reference_resource_files(), then
3441 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3442 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3446 wimlib_join(const wimlib_tchar * const *swms,
3448 const wimlib_tchar *output_path,
3450 int wim_write_flags);
3453 * @ingroup G_nonstandalone_wims
3455 * Same as wimlib_join(), but allows specifying a progress function. The
3456 * progress function will receive the write progress messages, such as
3457 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3458 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3459 * swm_open_flags, the progress function will receive a series of
3460 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3464 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3466 const wimlib_tchar *output_path,
3468 int wim_write_flags,
3469 wimlib_progress_func_t progfunc,
3474 * @ingroup G_mounting_wim_images
3476 * Mount an image from a WIM file on a directory read-only or read-write.
3479 * Pointer to the ::WIMStruct containing the image to be mounted. This
3480 * ::WIMStruct must have a backing file.
3482 * The 1-based index of the image to mount. This image cannot have been
3483 * previously modified in memory.
3485 * The path to an existing empty directory on which to mount the image.
3486 * @param mount_flags
3487 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3488 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3490 * @param staging_dir
3491 * If non-NULL, the name of a directory in which a temporary directory for
3492 * storing modified or added files will be created. Ignored if
3493 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3494 * left @c NULL, the staging directory is created in the same directory as
3495 * the backing WIM file. The staging directory is automatically deleted
3496 * when the image is unmounted.
3498 * @return 0 on success; a ::wimlib_error_code value on failure.
3500 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3501 * Another process is currently modifying the WIM file.
3502 * @retval ::WIMLIB_ERR_FUSE
3503 * A non-zero status code was returned by @c fuse_main().
3504 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
3505 * There are currently multiple references to the image as a result of a
3506 * call to wimlib_export_image(). Free one before attempting the
3508 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3509 * @p image does not exist in @p wim.
3510 * @retval ::WIMLIB_ERR_INVALID_PARAM
3511 * @p wim was @c NULL; or @p dir was NULL or an empty string; or an
3512 * unrecognized flag was specified in @p mount_flags; or the image has
3513 * already been modified in memory (e.g. by wimlib_update_image()).
3514 * @retval ::WIMLIB_ERR_MKDIR
3515 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3516 * staging directory could not be created.
3517 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3518 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3519 * WIM file is considered read-only because of any of the reasons mentioned
3520 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3521 * @retval ::WIMLIB_ERR_UNSUPPORTED
3522 * Mounting is not supported in this build of the library.
3524 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3525 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3526 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3527 * indicate failure (for different reasons) to read the metadata resource for
3528 * the image to mount.
3530 * The ability to mount WIM images is implemented using FUSE (Filesystem in
3531 * UserSpacE). Depending on how FUSE is set up on your system, this function
3532 * may work as normal users in addition to the root user.
3534 * Mounting WIM images is not supported if wimlib was configured
3535 * <c>--without-fuse</c>. This includes Windows builds of wimlib;
3536 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3538 * Calling this function daemonizes the process, unless
3539 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3541 * It is safe to mount multiple images from the same WIM file read-only at the
3542 * same time, but only if different ::WIMStruct's are used. It is @b not safe
3543 * to mount multiple images from the same WIM file read-write at the same time.
3545 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3546 * different process.
3549 wimlib_mount_image(WIMStruct *wim,
3551 const wimlib_tchar *dir,
3553 const wimlib_tchar *staging_dir);
3556 * @ingroup G_creating_and_opening_wims
3558 * Open a WIM file and create a ::WIMStruct for it.
3561 * The path to the WIM file to open.
3563 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3565 * On success, a pointer to a new ::WIMStruct backed by the specified
3566 * on-disk WIM file is written to the memory location pointed to by this
3567 * parameter. This ::WIMStruct must be freed using using wimlib_free()
3568 * when finished with it.
3570 * @return 0 on success; a ::wimlib_error_code value on failure.
3572 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3573 * The number of metadata resources found in the WIM did not match the
3574 * image count specified in the WIM header, or the number of <IMAGE>
3575 * elements in the XML data of the WIM did not match the image count
3576 * specified in the WIM header.
3577 * @retval ::WIMLIB_ERR_INTEGRITY
3578 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags, and
3579 * the WIM file failed the integrity check.
3580 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3581 * The library did not recognize the compression chunk size of the WIM as
3582 * valid for its compression type.
3583 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3584 * The library did not recognize the compression type of the WIM.
3585 * @retval ::WIMLIB_ERR_INVALID_HEADER
3586 * The header of the WIM was otherwise invalid.
3587 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3588 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3589 * the WIM contained an integrity table, but the integrity table was
3591 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3592 * The lookup table of the WIM was invalid.
3593 * @retval ::WIMLIB_ERR_INVALID_PARAM
3594 * @p wim_ret was @c NULL; or, @p wim_file was not a nonempty string.
3595 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3596 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3597 * specified in @p open_flags.
3598 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3599 * The file did not begin with the magic characters that identify a WIM
3601 * @retval ::WIMLIB_ERR_OPEN
3602 * Failed to open the WIM file for reading. Some possible reasons: the WIM
3603 * file does not exist, or the calling process does not have permission to
3605 * @retval ::WIMLIB_ERR_READ
3606 * Failed to read data from the WIM file.
3607 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3608 * Unexpected end-of-file while reading data from the WIM file.
3609 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3610 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3611 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3612 * The WIM cannot be opened because it contains encrypted segments. (It
3613 * may be a Windows 8 "ESD" file.)
3614 * @retval ::WIMLIB_ERR_WIM_IS_INCOMPLETE
3615 * The WIM file is not complete (e.g. the program which wrote it was
3616 * terminated before it finished)
3617 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3618 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3619 * considered read-only because of any of the reasons mentioned in the
3620 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3621 * @retval ::WIMLIB_ERR_XML
3622 * The XML data of the WIM was invalid.
3625 wimlib_open_wim(const wimlib_tchar *wim_file,
3627 WIMStruct **wim_ret);
3630 * @ingroup G_creating_and_opening_wims
3632 * Same as wimlib_open_wim(), but allows specifying a progress function and
3633 * progress context. If successful, the progress function will be registered in
3634 * the newly open ::WIMStruct, as if by an automatic call to
3635 * wimlib_register_progress_function(). In addition, if
3636 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, then the
3637 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3638 * messages while checking the WIM file's integrity.
3641 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3643 WIMStruct **wim_ret,
3644 wimlib_progress_func_t progfunc,
3648 * @ingroup G_writing_and_overwriting_wims
3650 * Commit a ::WIMStruct to disk, updating its backing file.
3652 * There are several alternative ways in which changes may be committed:
3654 * 1. Full rebuild: write the updated WIM to a temporary file, then rename the
3655 * temporary file to the original.
3656 * 2. Appending: append updates to the new original WIM file, then overwrite
3657 * its header such that those changes become visible to new readers.
3658 * 3. Compaction: normally should not be used; see
3659 * ::WIMLIB_WRITE_FLAG_UNSAFE_COMPACT for details.
3661 * Append mode is often much faster than a full rebuild, but it wastes some
3662 * amount of space due to leaving "holes" in the WIM file. Because of the
3663 * greater efficiency, wimlib_overwrite() normally defaults to append mode.
3664 * However, ::WIMLIB_WRITE_FLAG_REBUILD can be used to explicitly request a full
3665 * rebuild. In addition, if wimlib_delete_image() has been used on the
3666 * ::WIMStruct, then the default mode switches to rebuild mode, and
3667 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE can be used to explicitly request append
3670 * If this function completes successfully, then no more functions can be called
3671 * on the ::WIMStruct other than wimlib_free(). If you need to continue using
3672 * the WIM file, you must use wimlib_open_wim() to open a new ::WIMStruct for
3676 * Pointer to a ::WIMStruct to commit to its backing file.
3677 * @param write_flags
3678 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3679 * @param num_threads
3680 * The number of threads to use for compressing data, or 0 to have the
3681 * library automatically choose an appropriate number.
3683 * @return 0 on success; a ::wimlib_error_code value on failure. This function
3684 * may return most error codes returned by wimlib_write() as well as the
3685 * following error codes:
3687 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3688 * Another process is currently modifying the WIM file.
3689 * @retval ::WIMLIB_ERR_NO_FILENAME
3690 * @p wim is not backed by an on-disk file. In other words, it is a
3691 * ::WIMStruct created by wimlib_create_new_wim() rather than
3692 * wimlib_open_wim().
3693 * @retval ::WIMLIB_ERR_RENAME
3694 * The temporary file to which the WIM was written could not be renamed to
3695 * the original file.
3696 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3697 * The WIM file is considered read-only because of any of the reasons
3698 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3701 * If a progress function is registered with @p wim, then it will receive the
3702 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3703 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3704 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3707 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3710 * @ingroup G_wim_information
3712 * (Deprecated) Print information about one image, or all images, contained in a
3716 * Pointer to the ::WIMStruct to query. This need not represent a
3717 * standalone WIM (e.g. it could represent part of a split WIM).
3719 * The 1-based index of the image for which to print information, or
3720 * ::WIMLIB_ALL_IMAGES to print information about all images.
3722 * @return This function has no return value. No error checking is done when
3723 * printing the information. If @p image is invalid, an error message is
3726 * This function is deprecated; use wimlib_get_xml_data() or
3727 * wimlib_get_image_property() to query image information instead.
3730 wimlib_print_available_images(const WIMStruct *wim, int image);
3733 * @ingroup G_wim_information
3735 * Print the header of the WIM file (intended for debugging only).
3738 wimlib_print_header(const WIMStruct *wim);
3741 * @ingroup G_nonstandalone_wims
3743 * Reference file data from other WIM files or split WIM parts. This function
3744 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3745 * to load additional file data before calling a function such as
3746 * wimlib_extract_image() that requires the file data to be present.
3749 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3750 * necessarily "standalone". In the case of split WIMs, this should be the
3751 * first part, since only the first part contains the metadata resources.
3752 * In the case of delta WIMs, this should be the delta WIM rather than the
3753 * WIM on which it is based.
3754 * @param resource_wimfiles_or_globs
3755 * Array of paths to WIM files and/or split WIM parts to reference.
3756 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3757 * ref_flags, these are treated as globs rather than literal paths. That
3758 * is, using this function you can specify zero or more globs, each of
3759 * which expands to one or more literal paths.
3761 * Number of entries in @p resource_wimfiles_or_globs.
3763 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3764 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3766 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3767 * pass to internal calls to wimlib_open_wim() on the reference files.
3769 * @return 0 on success; a ::wimlib_error_code value on failure.
3771 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3772 * One of the specified globs did not match any paths (only with both
3773 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3774 * specified in @p ref_flags).
3775 * @retval ::WIMLIB_ERR_READ
3776 * I/O or permissions error while processing a file glob.
3778 * This function can additionally return most values that can be returned by
3779 * wimlib_open_wim().
3782 wimlib_reference_resource_files(WIMStruct *wim,
3783 const wimlib_tchar * const *resource_wimfiles_or_globs,
3789 * @ingroup G_nonstandalone_wims
3791 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3792 * where the caller must open the ::WIMStruct for each referenced file itself.
3795 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3796 * necessarily "standalone". In the case of split WIMs, this should be the
3797 * first part, since only the first part contains the metadata resources.
3798 * @param resource_wims
3799 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3800 * split WIM parts to reference.
3801 * @param num_resource_wims
3802 * Number of entries in @p resource_wims.
3804 * Reserved; must be 0.
3806 * @return 0 on success; a ::wimlib_error_code value on failure.
3809 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3810 unsigned num_resource_wims, int ref_flags);
3813 * @ingroup G_modifying_wims
3815 * Declare that a newly added image is mostly the same as a prior image, but
3816 * captured at a later point in time, possibly with some modifications in the
3817 * intervening time. This is designed to be used in incremental backups of the
3818 * same filesystem or directory tree.
3820 * This function compares the metadata of the directory tree of the newly added
3821 * image against that of the old image. Any files that are present in both the
3822 * newly added image and the old image and have timestamps that indicate they
3823 * haven't been modified are deemed not to have been modified and have their
3824 * checksums copied from the old image. Because of this and because WIM uses
3825 * single-instance streams, such files need not be read from the filesystem when
3826 * the WIM is being written or overwritten. Note that these unchanged files
3827 * will still be "archived" and will be logically present in the new image; the
3828 * optimization is that they don't need to actually be read from the filesystem
3829 * because the WIM already contains them.
3831 * This function is provided to optimize incremental backups. The resulting WIM
3832 * file will still be the same regardless of whether this function is called.
3833 * (This is, however, assuming that timestamps have not been manipulated or
3834 * unmaintained as to trick this function into thinking a file has not been
3835 * modified when really it has. To partly guard against such cases, other
3836 * metadata such as file sizes will be checked as well.)
3838 * This function must be called after adding the new image (e.g. with
3839 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3840 * wimlib_overwrite()).
3843 * Pointer to the ::WIMStruct containing the newly added image.
3845 * The 1-based index in @p wim of the newly added image.
3846 * @param template_wim
3847 * Pointer to the ::WIMStruct containing the template image. This can be,
3848 * but does not have to be, the same ::WIMStruct as @p wim.
3849 * @param template_image
3850 * The 1-based index in @p template_wim of the template image.
3852 * Reserved; must be 0.
3854 * @return 0 on success; a ::wimlib_error_code value on failure.
3856 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3857 * @p new_image does not exist in @p wim or @p template_image does not
3858 * exist in @p template_wim.
3859 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3860 * At least one of @p wim and @p template_wim does not contain image
3861 * metadata; for example, one of them represents a non-first part of a
3863 * @retval ::WIMLIB_ERR_INVALID_PARAM
3864 * Identical values were provided for the template and new image; or @p
3865 * new_image specified an image that had not been modified since opening
3868 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3869 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3870 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
3871 * indicate failure (for different reasons) to read the metadata resource for
3872 * the template image.
3875 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3876 WIMStruct *template_wim, int template_image,
3880 * @ingroup G_general
3882 * Register a progress function with a ::WIMStruct.
3885 * The ::WIMStruct for which to register the progress function.
3887 * Pointer to the progress function to register. If the WIM already has a
3888 * progress function registered, it will be replaced with this one. If @p
3889 * NULL, the current progress function (if any) will be unregistered.
3891 * The value which will be passed as the third argument to calls to @p
3895 wimlib_register_progress_function(WIMStruct *wim,
3896 wimlib_progress_func_t progfunc,
3900 * @ingroup G_modifying_wims
3902 * Rename the @p source_path to the @p dest_path in the specified @p image of
3905 * This just builds an appropriate ::wimlib_rename_command and passes it to
3906 * wimlib_update_image().
3909 wimlib_rename_path(WIMStruct *wim, int image,
3910 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3913 * @ingroup G_wim_information
3915 * Translate a string specifying the name or number of an image in the WIM into
3916 * the number of the image. The images are numbered starting at 1.
3919 * Pointer to the ::WIMStruct for a WIM.
3920 * @param image_name_or_num
3921 * A string specifying the name or number of an image in the WIM. If it
3922 * parses to a positive integer, this integer is taken to specify the
3923 * number of the image, indexed starting at 1. Otherwise, it is taken to
3924 * be the name of an image, as given in the XML data for the WIM file. It
3925 * also may be the keyword "all" or the string "*", both of which will
3926 * resolve to ::WIMLIB_ALL_IMAGES.
3928 * There is no way to search for an image actually named "all", "*", or an
3929 * integer number, or an image that has no name. However, you can use
3930 * wimlib_get_image_name() to get the name of any image.
3933 * If the string resolved to a single existing image, the number of that
3934 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3935 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3936 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3937 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3938 * images in @p wim has no name. (Since a WIM may have multiple unnamed
3939 * images, an unnamed image must be specified by index to eliminate the
3943 wimlib_resolve_image(WIMStruct *wim,
3944 const wimlib_tchar *image_name_or_num);
3947 * @ingroup G_general
3949 * Set the file to which the library will print error and warning messages.
3951 * This version of the function takes a C library <c>FILE*</c> opened for
3952 * writing (or appending). Use wimlib_set_error_file_by_name() to specify the
3953 * file by name instead.
3955 * This also enables error messages, as if by a call to
3956 * wimlib_set_print_errors(true).
3958 * @return 0 on success; a ::wimlib_error_code value on failure.
3960 * @retval ::WIMLIB_ERR_UNSUPPORTED
3961 * wimlib was compiled using the <c>--without-error-messages</c> option.
3964 wimlib_set_error_file(FILE *fp);
3967 * @ingroup G_general
3969 * Set the path to the file to which the library will print error and warning
3970 * messages. The library will open this file for appending.
3972 * This also enables error messages, as if by a call to
3973 * wimlib_set_print_errors(true).
3975 * @return 0 on success; a ::wimlib_error_code value on failure.
3977 * @retval ::WIMLIB_ERR_OPEN
3978 * The file named by @p path could not be opened for appending.
3979 * @retval ::WIMLIB_ERR_UNSUPPORTED
3980 * wimlib was compiled using the <c>--without-error-messages</c> option.
3983 wimlib_set_error_file_by_name(const wimlib_tchar *path);
3986 * @ingroup G_modifying_wims
3988 * Change the description of a WIM image. Equivalent to
3989 * <tt>wimlib_set_image_property(wim, image, "DESCRIPTION", description)</tt>.
3991 * Note that "description" is misspelled in the name of this function.
3994 wimlib_set_image_descripton(WIMStruct *wim, int image,
3995 const wimlib_tchar *description);
3998 * @ingroup G_modifying_wims
4000 * Change what is stored in the \<FLAGS\> element in the WIM XML document
4001 * (usually something like "Core" or "Ultimate"). Equivalent to
4002 * <tt>wimlib_set_image_property(wim, image, "FLAGS", flags)</tt>.
4005 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
4008 * @ingroup G_modifying_wims
4010 * Change the name of a WIM image. Equivalent to
4011 * <tt>wimlib_set_image_property(wim, image, "NAME", name)</tt>.
4014 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
4017 * @ingroup G_modifying_wims
4019 * Since wimlib v1.8.3: add, modify, or remove a per-image property from the
4020 * WIM's XML document. This is an alternative to wimlib_set_image_name(),
4021 * wimlib_set_image_descripton(), and wimlib_set_image_flags() which allows
4022 * manipulating any simple string property.
4025 * Pointer to the ::WIMStruct for the WIM.
4027 * The 1-based index of the image for which to set the property.
4028 * @param property_name
4029 * The name of the image property in the same format documented for
4030 * wimlib_get_image_property().
4032 * Note: if creating a new element using a bracketed index such as
4033 * "WINDOWS/LANGUAGES/LANGUAGE[2]", the highest index that can be specified
4034 * is one greater than the number of existing elements with that same name,
4035 * excluding the index. That means that if you are adding a list of new
4036 * elements, they must be added sequentially from the first index (1) to
4037 * the last index (n).
4038 * @param property_value
4039 * If not NULL and not empty, the property is set to this value.
4040 * Otherwise, the property is removed from the XML document.
4042 * @return 0 on success; a ::wimlib_error_code value on failure.
4044 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
4045 * The user requested to set the image name (the <tt>NAME</tt> property),
4046 * but another image in the WIM already had the requested name.
4047 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4048 * @p image does not exist in @p wim.
4049 * @retval ::WIMLIB_ERR_INVALID_PARAM
4050 * @p property_name has an unsupported format, or @p property_name included
4051 * a bracketed index that was too high.
4054 wimlib_set_image_property(WIMStruct *wim, int image,
4055 const wimlib_tchar *property_name,
4056 const wimlib_tchar *property_value);
4059 * @ingroup G_general
4061 * Set the functions that wimlib uses to allocate and free memory.
4063 * These settings are global and not per-WIM.
4065 * The default is to use the default @c malloc(), @c free(), and @c realloc()
4066 * from the standard C library.
4068 * Note: some external functions, such as those in @c libntfs-3g, may use the
4069 * standard memory allocation functions regardless of this setting.
4071 * @param malloc_func
4072 * A function equivalent to @c malloc() that wimlib will use to allocate
4073 * memory. If @c NULL, the allocator function is set back to the default
4074 * @c malloc() from the C library.
4076 * A function equivalent to @c free() that wimlib will use to free memory.
4077 * If @c NULL, the free function is set back to the default @c free() from
4079 * @param realloc_func
4080 * A function equivalent to @c realloc() that wimlib will use to reallocate
4081 * memory. If @c NULL, the free function is set back to the default @c
4082 * realloc() from the C library.
4087 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
4088 void (*free_func)(void *),
4089 void *(*realloc_func)(void *, size_t));
4092 * @ingroup G_writing_and_overwriting_wims
4094 * Set a ::WIMStruct's output compression chunk size. This is the compression
4095 * chunk size that will be used for writing non-solid resources in subsequent
4096 * calls to wimlib_write() or wimlib_overwrite(). A larger compression chunk
4097 * size often results in a better compression ratio, but compression may be
4098 * slower and the speed of random access to data may be reduced. In addition,
4099 * some chunk sizes are not compatible with Microsoft software.
4102 * The ::WIMStruct for which to set the output chunk size.
4104 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
4105 * on the compression type. See the documentation for each
4106 * ::wimlib_compression_type constant for more information. As a special
4107 * case, if @p chunk_size is specified as 0, then the chunk size will be
4108 * reset to the default for the currently selected output compression type.
4110 * @return 0 on success; a ::wimlib_error_code value on failure.
4112 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
4113 * @p chunk_size was not 0 or a supported chunk size for the currently
4114 * selected output compression type.
4117 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4120 * @ingroup G_writing_and_overwriting_wims
4122 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
4126 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
4129 * @ingroup G_writing_and_overwriting_wims
4131 * Set a ::WIMStruct's output compression type. This is the compression type
4132 * that will be used for writing non-solid resources in subsequent calls to
4133 * wimlib_write() or wimlib_overwrite().
4136 * The ::WIMStruct for which to set the output compression type.
4138 * The compression type to set. If this compression type is incompatible
4139 * with the current output chunk size, then the output chunk size will be
4140 * reset to the default for the new compression type.
4142 * @return 0 on success; a ::wimlib_error_code value on failure.
4144 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4145 * @p ctype did not specify a valid compression type.
4148 wimlib_set_output_compression_type(WIMStruct *wim,
4149 enum wimlib_compression_type ctype);
4152 * @ingroup G_writing_and_overwriting_wims
4154 * Similar to wimlib_set_output_compression_type(), but set the compression type
4155 * for writing solid resources. This cannot be ::WIMLIB_COMPRESSION_TYPE_NONE.
4158 wimlib_set_output_pack_compression_type(WIMStruct *wim,
4159 enum wimlib_compression_type ctype);
4162 * @ingroup G_general
4164 * Set whether wimlib can print error and warning messages to the error file,
4165 * which defaults to standard error. Error and warning messages may provide
4166 * information that cannot be determined only from returned error codes.
4168 * By default, error messages are not printed.
4170 * This setting applies globally (it is not per-WIM).
4172 * This can be called before wimlib_global_init().
4174 * @param show_messages
4175 * @c true if messages are to be printed; @c false if messages are not to
4178 * @return 0 on success; a ::wimlib_error_code value on failure.
4180 * @retval ::WIMLIB_ERR_UNSUPPORTED
4181 * wimlib was compiled using the <c>--without-error-messages</c> option.
4184 wimlib_set_print_errors(bool show_messages);
4187 * @ingroup G_modifying_wims
4189 * Set basic information about a WIM.
4192 * Pointer to the ::WIMStruct for a WIM.
4194 * Pointer to a ::wimlib_wim_info structure that contains the information
4195 * to set. Only the information explicitly specified in the @p which flags
4198 * Flags that specify which information to set. This is a bitwise OR of
4199 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
4200 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
4202 * @return 0 on success; a ::wimlib_error_code value on failure.
4204 * @retval ::WIMLIB_ERR_IMAGE_COUNT
4205 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
4206 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
4210 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
4214 * @ingroup G_nonstandalone_wims
4216 * Split a WIM into multiple parts.
4219 * The ::WIMStruct for the WIM to split.
4221 * Name of the split WIM (SWM) file to create. This will be the name of
4222 * the first part. The other parts will, by default, have the same name
4223 * with 2, 3, 4, ..., etc. appended before the suffix. However, the exact
4224 * names can be customized using the progress function.
4226 * The maximum size per part, in bytes. Unfortunately, it is not
4227 * guaranteed that this will really be the maximum size per part, because
4228 * some file resources in the WIM may be larger than this size, and the WIM
4229 * file format provides no way to split up file resources among multiple
4231 * @param write_flags
4232 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
4233 * flags will be used to write each split WIM part. Specify 0 here to get
4234 * the default behavior.
4236 * @return 0 on success; a ::wimlib_error_code value on failure. This function
4237 * may return most error codes that can be returned by wimlib_write() as well as
4238 * the following error codes:
4240 * @retval ::WIMLIB_ERR_INVALID_PARAM
4241 * @p swm_name was not a nonempty string, or @p part_size was 0.
4242 * @retval ::WIMLIB_ERR_UNSUPPORTED
4243 * The WIM contains solid resources. Splitting a WIM containing solid
4244 * resources is not supported.
4246 * If a progress function is registered with @p wim, then for each split WIM
4247 * part that is written it will receive the messages
4248 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
4249 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
4252 wimlib_split(WIMStruct *wim,
4253 const wimlib_tchar *swm_name,
4258 * @ingroup G_general
4260 * Perform verification checks on a WIM file.
4262 * This function is intended for safety checking and/or debugging. If used on a
4263 * well-formed WIM file, it should always succeed.
4266 * The ::WIMStruct for the WIM file to verify. Note: for an extra layer of
4267 * verification, it is a good idea to have used
4268 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
4270 * If verifying a split WIM, specify the first part of the split WIM here,
4271 * and reference the other parts using wimlib_reference_resource_files()
4272 * before calling this function.
4273 * @param verify_flags
4274 * Reserved; must be 0.
4276 * @return 0 if the WIM file was successfully verified; a ::wimlib_error_code
4277 * value if it failed verification or another error occurred.
4279 * @retval ::WIMLIB_ERR_DECOMPRESSION
4280 * The WIM file contains invalid compressed data.
4281 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
4282 * The metadata resource for an image is invalid.
4283 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4284 * File data stored in the WIM file is corrupt.
4285 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4286 * The data for a file in an image could not be found. See @ref
4287 * G_nonstandalone_wims.
4289 * If a progress function is registered with @p wim, then it will receive the
4290 * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
4291 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
4292 * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
4295 wimlib_verify_wim(WIMStruct *wim, int verify_flags);
4298 * @ingroup G_mounting_wim_images
4300 * Unmount a WIM image that was mounted using wimlib_mount_image().
4302 * When unmounting a read-write mounted image, the default behavior is to
4303 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
4304 * image to be committed.
4307 * The directory on which the WIM image is mounted.
4308 * @param unmount_flags
4309 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
4311 * @return 0 on success; a ::wimlib_error_code value on failure.
4313 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
4314 * There is no WIM image mounted on the specified directory.
4315 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
4316 * The read-write mounted image cannot be committed because there are file
4317 * descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
4319 * @retval ::WIMLIB_ERR_MQUEUE
4320 * Could not create a POSIX message queue.
4321 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
4322 * The image was mounted by a different user.
4323 * @retval ::WIMLIB_ERR_UNSUPPORTED
4324 * Mounting is not supported in this build of the library.
4326 * Note: you can also unmount the image by using the @c umount() system call, or
4327 * by using the @c umount or @c fusermount programs. However, you need to call
4328 * this function if you want changes to be committed.
4331 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
4334 * @ingroup G_mounting_wim_images
4336 * Same as wimlib_unmount_image(), but allows specifying a progress function.
4337 * The progress function will receive a ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN
4338 * message. In addition, if changes are committed from a read-write mount, the
4339 * progress function will receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
4342 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
4344 wimlib_progress_func_t progfunc,
4348 * @ingroup G_modifying_wims
4350 * Update a WIM image by adding, deleting, and/or renaming files or directories.
4353 * Pointer to the ::WIMStruct containing the image to update.
4355 * The 1-based index of the image to update.
4357 * An array of ::wimlib_update_command's that specify the update operations
4360 * Number of commands in @p cmds.
4361 * @param update_flags
4362 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
4364 * @return 0 on success; a ::wimlib_error_code value on failure. On failure,
4365 * all update commands will be rolled back, and no visible changes will have
4366 * been made to @p wim.
4368 * @retval ::WIMLIB_ERR_FVE_LOCKED_VOLUME
4369 * Windows-only: One of the "add" commands attempted to add files from an
4370 * encrypted BitLocker volume that hasn't yet been unlocked.
4371 * @retval ::WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES
4372 * There are currently multiple references to the image as a result of a
4373 * call to wimlib_export_image(). Free one before attempting the update.
4374 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
4375 * The contents of a capture configuration file were invalid.
4376 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4377 * @p image did not exist in @p wim.
4378 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
4379 * An add command with ::WIMLIB_ADD_FLAG_NO_REPLACE specified attempted to
4380 * replace an existing nondirectory file.
4381 * @retval ::WIMLIB_ERR_INVALID_PARAM
4382 * An unknown operation type was provided in the update commands; or
4383 * unknown or incompatible flags were provided in a flags parameter; or
4384 * there was another problem with the provided parameters.
4385 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4386 * While executing an add command, a reparse point had invalid data.
4387 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4388 * An add command attempted to replace a directory with a non-directory; or
4389 * a delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE attempted to
4390 * delete a directory; or a rename command attempted to rename a directory
4391 * to a non-directory.
4392 * @retval ::WIMLIB_ERR_NOTDIR
4393 * An add command attempted to replace a non-directory with a directory; or
4394 * an add command attempted to set the root of the image to a
4395 * non-directory; or a rename command attempted to rename a directory to a
4396 * non-directory; or a component of an image path that was used as a
4397 * directory was not, in fact, a directory.
4398 * @retval ::WIMLIB_ERR_NOTEMPTY
4399 * A rename command attempted to rename a directory to a non-empty
4400 * directory; or a rename command would have created a loop.
4401 * @retval ::WIMLIB_ERR_NTFS_3G
4402 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4403 * error occurred while reading data from the NTFS volume using libntfs-3g.
4404 * @retval ::WIMLIB_ERR_OPEN
4405 * Failed to open a file to be captured while executing an add command.
4406 * @retval ::WIMLIB_ERR_OPENDIR
4407 * Failed to open a directory to be captured while executing an add
4409 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4410 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4411 * WIM path that did not exist; or a rename command attempted to rename a
4412 * file that does not exist.
4413 * @retval ::WIMLIB_ERR_READ
4414 * While executing an add command, failed to read data from a file or
4415 * directory to be captured.
4416 * @retval ::WIMLIB_ERR_READLINK
4417 * While executing an add command, failed to read the target of a symbolic
4418 * link, junction, or other reparse point.
4419 * @retval ::WIMLIB_ERR_STAT
4420 * While executing an add command, failed to read metadata for a file or
4422 * @retval ::WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG
4423 * A capture configuration file could not be read.
4424 * @retval ::WIMLIB_ERR_UNSUPPORTED
4425 * A command had flags provided that are not supported on this platform or
4426 * in this build of the library.
4427 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4428 * An add command with ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified
4429 * discovered a file that was not of a supported type.
4431 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4432 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4433 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4434 * indicate failure (for different reasons) to read the metadata resource for an
4435 * image that needed to be updated.
4438 wimlib_update_image(WIMStruct *wim,
4440 const struct wimlib_update_command *cmds,
4445 * @ingroup G_writing_and_overwriting_wims
4447 * Persist a ::WIMStruct to a new on-disk WIM file.
4449 * This brings in file data from any external locations, such as directory trees
4450 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4451 * wimlib_export_image(), and incorporates it into a new on-disk WIM file.
4453 * By default, the new WIM file is written as stand-alone. Using the
4454 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4455 * instead. However, this function cannot directly write a "split" WIM; use
4456 * wimlib_split() for that.
4459 * Pointer to the ::WIMStruct being persisted.
4461 * The path to the on-disk file to write.
4463 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4464 * images are to be included in the new on-disk WIM file. If for some
4465 * reason you only want to include a single image, specify the 1-based
4466 * index of that image instead.
4467 * @param write_flags
4468 * Bitwise OR of flags prefixed with @c WIMLIB_WRITE_FLAG.
4469 * @param num_threads
4470 * The number of threads to use for compressing data, or 0 to have the
4471 * library automatically choose an appropriate number.
4473 * @return 0 on success; a ::wimlib_error_code value on failure.
4475 * @retval ::WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED
4476 * A file that had previously been scanned for inclusion in the WIM was
4477 * concurrently modified.
4478 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4479 * @p image did not exist in @p wim.
4480 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4481 * A file, stored in another WIM, which needed to be written was corrupt.
4482 * @retval ::WIMLIB_ERR_INVALID_PARAM
4483 * @p path was not a nonempty string, or invalid flags were passed.
4484 * @retval ::WIMLIB_ERR_OPEN
4485 * Failed to open the output WIM file for writing, or failed to open a file
4486 * whose data needed to be included in the WIM.
4487 * @retval ::WIMLIB_ERR_READ
4488 * Failed to read data that needed to be included in the WIM.
4489 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4490 * A file data blob that needed to be written could not be found in the
4491 * blob lookup table of @p wim. See @ref G_nonstandalone_wims.
4492 * @retval ::WIMLIB_ERR_WRITE
4493 * An error occurred when trying to write data to the new WIM file.
4495 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4496 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4497 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
4498 * indicate failure (for different reasons) to read the data from a WIM file.
4500 * If a progress function is registered with @p wim, then it will receive the
4501 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4502 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4503 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4506 wimlib_write(WIMStruct *wim,
4507 const wimlib_tchar *path,
4510 unsigned num_threads);
4513 * @ingroup G_writing_and_overwriting_wims
4515 * Same as wimlib_write(), but write the WIM directly to a file descriptor,
4516 * which need not be seekable if the write is done in a special pipable WIM
4517 * format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p write_flags. This can,
4518 * for example, allow capturing a WIM image and streaming it over the network.
4519 * See @ref subsec_pipable_wims for more information about pipable WIMs.
4521 * The file descriptor @p fd will @b not be closed when the write is complete;
4522 * the calling code is responsible for this.
4524 * @return 0 on success; a ::wimlib_error_code value on failure. The possible
4525 * error codes include those that can be returned by wimlib_write() as well as
4528 * @retval ::WIMLIB_ERR_INVALID_PARAM
4529 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4530 * specified in @p write_flags.
4533 wimlib_write_to_fd(WIMStruct *wim,
4537 unsigned num_threads);
4540 * @defgroup G_compression Compression and decompression functions
4542 * @brief Functions for XPRESS, LZX, and LZMS compression and decompression.
4544 * These functions are already used by wimlib internally when appropriate for
4545 * reading and writing WIM archives. But they are exported and documented so
4546 * that they can be used in other applications or libraries for general-purpose
4547 * lossless data compression. They are implemented in highly optimized C code,
4548 * using state-of-the-art compression techniques. The main limitation is the
4549 * lack of sliding window support; this has, however, allowed the algorithms to
4550 * be optimized for block-based compression.
4555 /** Opaque compressor handle. */
4556 struct wimlib_compressor;
4558 /** Opaque decompressor handle. */
4559 struct wimlib_decompressor;
4562 * Set the default compression level for the specified compression type. This
4563 * is the compression level that wimlib_create_compressor() assumes if it is
4564 * called with @p compression_level specified as 0.
4566 * wimlib's WIM writing code (e.g. wimlib_write()) will pass 0 to
4567 * wimlib_create_compressor() internally. Therefore, calling this function will
4568 * affect the compression level of any data later written to WIM files using the
4569 * specified compression type.
4571 * The initial state, before this function is called, is that all compression
4572 * types have a default compression level of 50.
4575 * Compression type for which to set the default compression level, as one
4576 * of the ::wimlib_compression_type constants. Or, if this is the special
4577 * value -1, the default compression levels for all compression types will
4579 * @param compression_level
4580 * The default compression level to set. If 0, the "default default" level
4581 * of 50 is restored. Otherwise, a higher value indicates higher
4582 * compression, whereas a lower value indicates lower compression. See
4583 * wimlib_create_compressor() for more information.
4585 * @return 0 on success; a ::wimlib_error_code value on failure.
4587 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4588 * @p ctype was neither a supported compression type nor -1.
4591 wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
4594 * Return the approximate number of bytes needed to allocate a compressor with
4595 * wimlib_create_compressor() for the specified compression type, maximum block
4596 * size, and compression level. @p compression_level may be 0, in which case
4597 * the current default compression level for @p ctype is used. Returns 0 if the
4598 * compression type is invalid, or the @p max_block_size for that compression
4602 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4603 size_t max_block_size,
4604 unsigned int compression_level);
4606 #define WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE 0x80000000
4609 * Allocate a compressor for the specified compression type using the specified
4610 * parameters. This function is part of wimlib's compression API; it is not
4611 * necessary to call this to process a WIM file.
4614 * Compression type for which to create the compressor, as one of the
4615 * ::wimlib_compression_type constants.
4616 * @param max_block_size
4617 * The maximum compression block size to support. This specifies the
4618 * maximum allowed value for the @p uncompressed_size parameter of
4619 * wimlib_compress() when called using this compressor.
4621 * Usually, the amount of memory used by the compressor will scale in
4622 * proportion to the @p max_block_size parameter.
4623 * wimlib_get_compressor_needed_memory() can be used to query the specific
4624 * amount of memory that will be required.
4626 * This parameter must be at least 1 and must be less than or equal to a
4627 * compression-type-specific limit.
4629 * In general, the same value of @p max_block_size must be passed to
4630 * wimlib_create_decompressor() when the data is later decompressed.
4631 * However, some compression types have looser requirements regarding this.
4632 * @param compression_level
4633 * The compression level to use. If 0, the default compression level (50,
4634 * or another value as set through wimlib_set_default_compression_level())
4635 * is used. Otherwise, a higher value indicates higher compression. The
4636 * values are scaled so that 10 is low compression, 50 is medium
4637 * compression, and 100 is high compression. This is not a percentage;
4638 * values above 100 are also valid.
4640 * Using a higher-than-default compression level can result in a better
4641 * compression ratio, but can significantly reduce performance. Similarly,
4642 * using a lower-than-default compression level can result in better
4643 * performance, but can significantly worsen the compression ratio. The
4644 * exact results will depend heavily on the compression type and what
4645 * algorithms are implemented for it. If you are considering using a
4646 * non-default compression level, you should run benchmarks to see if it is
4647 * worthwhile for your application.
4649 * The compression level does not affect the format of the compressed data.
4650 * Therefore, it is a compressor-only parameter and does not need to be
4651 * passed to the decompressor.
4653 * Since wimlib v1.8.0, this parameter can be OR-ed with the flag
4654 * ::WIMLIB_COMPRESSOR_FLAG_DESTRUCTIVE. This creates the compressor in a
4655 * mode where it is allowed to modify the input buffer. Specifically, in
4656 * this mode, if compression succeeds, the input buffer may have been
4657 * modified, whereas if compression does not succeed the input buffer still
4658 * may have been written to but will have been restored exactly to its
4659 * original state. This mode is designed to save some memory when using
4660 * large buffer sizes.
4661 * @param compressor_ret
4662 * A location into which to return the pointer to the allocated compressor.
4663 * The allocated compressor can be used for any number of calls to
4664 * wimlib_compress() before being freed with wimlib_free_compressor().
4666 * @return 0 on success; a ::wimlib_error_code value on failure.
4668 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4669 * @p ctype was not a supported compression type.
4670 * @retval ::WIMLIB_ERR_INVALID_PARAM
4671 * @p max_block_size was invalid for the compression type, or @p
4672 * compressor_ret was @c NULL.
4673 * @retval ::WIMLIB_ERR_NOMEM
4674 * Insufficient memory to allocate the compressor.
4677 wimlib_create_compressor(enum wimlib_compression_type ctype,
4678 size_t max_block_size,
4679 unsigned int compression_level,
4680 struct wimlib_compressor **compressor_ret);
4683 * Compress a buffer of data.
4685 * @param uncompressed_data
4686 * Buffer containing the data to compress.
4687 * @param uncompressed_size
4688 * Size, in bytes, of the data to compress. This cannot be greater than
4689 * the @p max_block_size with which wimlib_create_compressor() was called.
4690 * (If it is, the data will not be compressed and 0 will be returned.)
4691 * @param compressed_data
4692 * Buffer into which to write the compressed data.
4693 * @param compressed_size_avail
4694 * Number of bytes available in @p compressed_data.
4696 * A compressor previously allocated with wimlib_create_compressor().
4699 * The size of the compressed data, in bytes, or 0 if the data could not be
4700 * compressed to @p compressed_size_avail or fewer bytes.
4703 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4704 void *compressed_data, size_t compressed_size_avail,
4705 struct wimlib_compressor *compressor);
4708 * Free a compressor previously allocated with wimlib_create_compressor().
4711 * The compressor to free. If @c NULL, no action is taken.
4714 wimlib_free_compressor(struct wimlib_compressor *compressor);
4717 * Allocate a decompressor for the specified compression type. This function is
4718 * part of wimlib's compression API; it is not necessary to call this to process
4722 * Compression type for which to create the decompressor, as one of the
4723 * ::wimlib_compression_type constants.
4724 * @param max_block_size
4725 * The maximum compression block size to support. This specifies the
4726 * maximum allowed value for the @p uncompressed_size parameter of
4727 * wimlib_decompress().
4729 * In general, this parameter must be the same as the @p max_block_size
4730 * that was passed to wimlib_create_compressor() when the data was
4731 * compressed. However, some compression types have looser requirements
4733 * @param decompressor_ret
4734 * A location into which to return the pointer to the allocated
4735 * decompressor. The allocated decompressor can be used for any number of
4736 * calls to wimlib_decompress() before being freed with
4737 * wimlib_free_decompressor().
4739 * @return 0 on success; a ::wimlib_error_code value on failure.
4741 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4742 * @p ctype was not a supported compression type.
4743 * @retval ::WIMLIB_ERR_INVALID_PARAM
4744 * @p max_block_size was invalid for the compression type, or @p
4745 * decompressor_ret was @c NULL.
4746 * @retval ::WIMLIB_ERR_NOMEM
4747 * Insufficient memory to allocate the decompressor.
4750 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4751 size_t max_block_size,
4752 struct wimlib_decompressor **decompressor_ret);
4755 * Decompress a buffer of data.
4757 * @param compressed_data
4758 * Buffer containing the data to decompress.
4759 * @param compressed_size
4760 * Size, in bytes, of the data to decompress.
4761 * @param uncompressed_data
4762 * Buffer into which to write the uncompressed data.
4763 * @param uncompressed_size
4764 * Size, in bytes, of the data when uncompressed. This cannot exceed the
4765 * @p max_block_size with which wimlib_create_decompressor() was called.
4766 * (If it does, the data will not be decompressed and a nonzero value will
4768 * @param decompressor
4769 * A decompressor previously allocated with wimlib_create_decompressor().
4771 * @return 0 on success; nonzero on failure.
4773 * No specific error codes are defined; any nonzero value indicates that the
4774 * decompression failed. This can only occur if the data is truly invalid;
4775 * there will never be transient errors like "out of memory", for example.
4777 * This function requires that the exact uncompressed size of the data be passed
4778 * as the @p uncompressed_size parameter. If this is not done correctly,
4779 * decompression may fail or the data may be decompressed incorrectly.
4782 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4783 void *uncompressed_data, size_t uncompressed_size,
4784 struct wimlib_decompressor *decompressor);
4787 * Free a decompressor previously allocated with wimlib_create_decompressor().
4789 * @param decompressor
4790 * The decompressor to free. If @c NULL, no action is taken.
4793 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4805 #endif /* _WIMLIB_H */