3 * @brief External header for wimlib.
5 * This file contains extensive comments for generating documentation with
6 * Doxygen. The built HTML documentation can be viewed at
7 * http://wimlib.sourceforge.net. Make sure to see the <a
8 * href="modules.html">Modules page</a> to make more sense of the declarations
13 * Copyright (C) 2012, 2013, 2014 Eric Biggers
15 * This file is part of wimlib, a library for working with WIM files.
17 * wimlib is free software; you can redistribute it and/or modify it under the
18 * terms of the GNU General Public License as published by the Free
19 * Software Foundation; either version 3 of the License, or (at your option)
22 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
23 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
24 * A PARTICULAR PURPOSE. See the GNU General Public License for more
27 * You should have received a copy of the GNU General Public License
28 * along with wimlib; if not, see http://www.gnu.org/licenses/.
34 * This is the documentation for the library interface of wimlib 1.7.1, a C
35 * library for creating, modifying, extracting, and mounting files in the
36 * Windows Imaging Format. This documentation is intended for developers only.
37 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
38 * program, please see the manual pages and also the <a
39 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/README">README
42 * @section sec_installing Installing
46 * Download the source code from <a
47 * href="http://sourceforge.net/projects/wimlib/files">http://sourceforge.net/projects/wimlib/files</a>.
48 * Install the library by running <c>configure && make && sudo make install</c>.
49 * See the README for information about configuration options. To use wimlib in
50 * your program after installing it, include wimlib.h and link your program with
55 * Download the Windows binary distribution with the appropriate architecture
56 * (i686 or x86_64 --- also called "x86" and "amd64" respectively) from <a
57 * href="http://sourceforge.net/projects/wimlib/files">http://sourceforge.net/projects/wimlib/files</a>.
58 * Link your program with the libwim-15.dll file. Make sure to also download
59 * the source code so you can get wimlib.h, as it is not included in the binary
60 * distribution. If you need to access the DLL from other programming
61 * languages, note that the calling convention is "cdecl".
63 * @section sec_examples Examples
65 * Several examples are located in the <a
66 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/examples">examples</a>
67 * directory of the source distribution.
69 * There is also the <a
70 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/programs/imagex.c">
71 * source code of <b>wimlib-imagex</b></a>, which is complicated but uses most
72 * capabilities of wimlib.
74 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
76 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
77 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
78 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
79 * which creates a new ::WIMStruct that initially contains no images and does
80 * not yet have a backing on-disk file. See @ref G_creating_and_opening_wims
83 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
84 * Images can be extracted (or "applied") using wimlib_extract_image(), added
85 * (or "captured" or "appended") using wimlib_add_image(), deleted using
86 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
87 * modified using wimlib_update_image(). However, changes made to a WIM
88 * represented by a ::WIMStruct have no persistent effect until the WIM is
89 * actually written to an on-disk file. This can be done using wimlib_write(),
90 * but if the WIM was originally opened using wimlib_open_wim(), then
91 * wimlib_overwrite() can be used instead. See @ref G_extracting_wims, @ref
92 * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
94 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
95 * files is a multi-step process. For example, to add, or "append" an image to
96 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
97 * append</b>, you must call the following functions:
99 * 1. wimlib_open_wim()
100 * 2. wimlib_add_image()
101 * 3. wimlib_overwrite()
103 * This design is very much on purpose as it makes the library more useful in
104 * general by allowing functions to be composed in different ways. For example,
105 * you can make multiple changes to a WIM and commit them all to the underlying
106 * file in only one overwrite operation, which is more efficient.
108 * Note: before calling any other function declared in wimlib.h,
109 * wimlib_global_init() can (and in some cases, must) be called. See its
110 * documentation for more details.
112 * @section sec_cleaning_up Cleaning up
114 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
115 * all resources associated with it. Also, when you are completely done with
116 * using wimlib in your program, you can call wimlib_global_cleanup() to free
117 * any other resources allocated by the library.
119 * @section sec_error_handling Error Handling
121 * Most functions in wimlib return 0 on success and a positive error code on
122 * failure. Use wimlib_get_error_string() to get a string that describes an
123 * error code. wimlib also can print error messages to standard error itself
124 * when an error happens, and these may be more informative than the error code;
125 * to enable this, call wimlib_set_print_errors(). Please note that this is for
126 * convenience only, and some errors can occur without a message being printed.
127 * Currently, error messages and strings (as well as all documentation, for that
128 * matter) are only available in English.
130 * @section sec_encodings Locales and character encodings
132 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
133 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
136 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
137 * and the encoding is UTF-16LE.
139 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
140 * and the encoding is the locale-dependent multibyte encoding. I recommend you
141 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
142 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
143 * call wimlib_global_init() after having set your desired locale.
145 * @section sec_advanced Additional information and features
148 * @subsection subsec_mounting_wim_images Mounting WIM images
150 * See @ref G_mounting_wim_images.
152 * @subsection subsec_progress_functions Progress Messages
154 * See @ref G_progress.
156 * @subsection subsec_non_standalone_wims Non-standalone WIMs
158 * See @ref G_nonstandalone_wims.
160 * @subsection subsec_pipable_wims Pipable WIMs
162 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
163 * compatible with Microsoft's software. To create a pipable WIM, call
164 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
165 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
166 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
167 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
168 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
169 * s using a seekable file descriptor using the regular function calls (e.g.
170 * wimlib_open_wim(), wimlib_extract_image()).
172 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
173 * capture</b> for more information about pipable WIMs.
175 * @subsection subsec_thread_safety Thread Safety
177 * wimlib is thread-safe, with the following exceptions:
178 * - Different threads cannot operate on the same ::WIMStruct at the same time;
179 * they must use different ::WIMStruct's.
180 * - You must call wimlib_global_init() in one thread before calling any other
182 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
183 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
184 * concurrently in the same process, will daemonize the entire process when it
185 * does so for the first time. This includes changing the working directory
186 * to the root directory.
188 * @subsection subsec_limitations Limitations
190 * This section documents some technical limitations of wimlib not already
191 * documented in the man page for @b wimlib-imagex.
193 * - The old WIM format from Vista pre-releases is not supported.
194 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
195 * functionality other than that already present in @b ImageX, that allows you
196 * to make certain Windows-specific modifications to a Windows PE image, such
197 * as adding a driver or Windows component. Such a tool could be implemented
200 * @subsection more_info More information
202 * You are advised to read the README as well as the manual pages for
203 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
204 * the API documentation.
207 /** @defgroup G_general General
209 * @brief Declarations and structures shared across the library.
212 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
214 * @brief Create new WIMs and open existing WIMs.
217 /** @defgroup G_wim_information Retrieving WIM information and directory listings
219 * @brief Retrieve information about a WIM or WIM image.
222 /** @defgroup G_modifying_wims Modifying WIMs
224 * @brief Make changes to a WIM.
226 * @section sec_adding_images Capturing and adding WIM images
228 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
229 * appending an image to an existing WIM is a multi-step process, but at its
230 * core is wimlib_add_image() or an equivalent function. Normally,
231 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
232 * ::WIMStruct as a new image. However, when supported by the build of the
233 * library, there is also a special NTFS volume capture mode (entered when
234 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
235 * from an unmounted NTFS volume.
237 * Another function, wimlib_add_image_multisource() is also provided. It
238 * generalizes wimlib_add_image() to allow combining multiple files or directory
239 * trees into a single WIM image in a configurable way.
241 * For maximum customization of WIM image creation, it is also possible to add a
242 * completely empty WIM image with wimlib_add_empty_image(), then update it with
243 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
244 * wimlib_add_image_multisource() do internally.)
246 * Note that some details of how image addition/capture works are documented
247 * more fully in the manual page for <b>wimlib-imagex capture</b>.
249 * @section sec_deleting_images Deleting WIM images
251 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
252 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
253 * be made persistent in an on-disk WIM file.
255 * @section sec_exporting_images Exporting WIM images
257 * wimlib_export_image() can copy, or "export", an image from one WIM to
260 * @section sec_other_modifications Other modifications
262 * wimlib_update_image() can add, delete, and rename files in a WIM image.
264 * wimlib_set_image_name(), wimlib_set_image_descripton(), and
265 * wimlib_set_image_flags() can change other image metadata.
267 * wimlib_set_wim_info() can change information about the WIM file itself, such
271 /** @defgroup G_extracting_wims Extracting WIMs
273 * @brief Extract files, directories, and images from a WIM.
275 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
276 * represented by a ::WIMStruct. This normally extracts the image to a
277 * directory, but when supported by the build of the library there is also a
278 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
279 * is specified) that allows extracting a WIM image directly to an unmounted
280 * NTFS volume. Various other flags allow further customization of image
283 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
284 * of (possibly wildcard) paths from a WIM image.
286 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
287 * over a pipe; see @ref subsec_pipable_wims.
289 * Some details of how WIM extraction works are documented more fully in the
290 * manual pages for <b>wimlib-imagex apply</b> and <b>wimlib-imagex extract</b>.
293 /** @defgroup G_mounting_wim_images Mounting WIM images
295 * @brief Mount and unmount WIM images.
297 * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
298 * mounting images from WIM files either read-only or read-write. To mount an
299 * image, call wimlib_mount_image(). To unmount an image, call
300 * wimlib_unmount_image(). Mounting can be done without root privileges because
301 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
302 * compiled with the <code>--without-fuse</code> flag, these functions will be
303 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED. Note that mounting an
304 * image read-write is an alternative to calling wimlib_update_image().
308 * @defgroup G_progress Progress Messages
310 * @brief Track the progress of long WIM operations.
312 * Library users can provide a progress function which will be called
313 * periodically during operations such as extracting a WIM image or writing a
314 * WIM image. A ::WIMStruct can have a progress function of type
315 * ::wimlib_progress_func_t associated with it by calling
316 * wimlib_register_progress_function() or by opening the ::WIMStruct using
317 * wimlib_open_wim_with_progress(). Once this is done, the progress function
318 * will be called automatically during many operations, such as
319 * wimlib_extract_image() and wimlib_write().
321 * Some functions that do not operate directly on a user-provided ::WIMStruct,
322 * such as wimlib_join(), also take the progress function directly using an
323 * extended version of the function, such as wimlib_join_with_progress().
325 * In wimlib v1.7.0 and later, progress functions are no longer just
326 * unidirectional. You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause
327 * the current operation to be aborted. wimlib v1.7.0 also added the third
328 * argument to ::wimlib_progress_func_t, which is a user-supplied context.
331 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
333 * @brief Write and overwrite on-disk WIM files.
335 * As described in @ref sec_basic_wim_handling_concepts, these functions are
336 * fundamental to the design of the library as they allow new or modified
337 * ::WIMStruct's to actually be written to on-disk files. Call wimlib_write()
338 * to write a new WIM file, or wimlib_overwrite() to persistently update an
342 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
344 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
346 * Normally, a ::WIMStruct represents a WIM file, but there's a bit more to it
347 * than that. Normally, WIM files are "standalone". However, WIM files can
348 * also be arranged in non-standalone ways, such as a set of on-disk files that
349 * together form a single "split WIM" or "delta WIM". Such arrangements are
350 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
351 * created from one of these on-disk files initially only partially represents
352 * the full WIM and needs to, in effect, be logically combined with other
353 * ::WIMStruct's before performing certain operations, such as extracting files
354 * with wimlib_extract_image() or wimlib_extract_paths(). This is done by
355 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
357 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
358 * specialized function (wimlib_split()) is needed to create a split WIM.
367 #include <inttypes.h>
371 # define _wimlib_deprecated __attribute__((deprecated))
373 # define _wimlib_deprecated
376 /** @addtogroup G_general
379 /** Major version of the library (for example, the 1 in 1.2.5). */
380 #define WIMLIB_MAJOR_VERSION 1
382 /** Minor version of the library (for example, the 2 in 1.2.5). */
383 #define WIMLIB_MINOR_VERSION 7
385 /** Patch version of the library (for example, the 5 in 1.2.5). */
386 #define WIMLIB_PATCH_VERSION 1
393 * Opaque structure that represents a WIM file. This is an in-memory structure
394 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
395 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
396 * continuing to exist so that data can be read from it as needed.
398 * Most functions in this library will work the same way regardless of whether a
399 * given ::WIMStruct was obtained through wimlib_open_wim() or
400 * wimlib_create_new_wim(). Exceptions are documented.
402 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
403 * file from a ::WIMStruct.
405 * See @ref sec_basic_wim_handling_concepts for more information.
407 #ifndef WIMLIB_WIMSTRUCT_DECLARED
408 typedef struct WIMStruct WIMStruct;
409 #define WIMLIB_WIMSTRUCT_DECLARED
413 typedef wchar_t wimlib_tchar;
415 /** See @ref sec_encodings */
416 typedef char wimlib_tchar;
420 /** Path separator for WIM paths passed back to progress callbacks.
421 * This is forward slash on UNIX and backslash on Windows. */
422 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
423 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
425 /** Path separator for WIM paths passed back to progress callbacks.
426 * This is forward slash on UNIX and backslash on Windows. */
427 # define WIMLIB_WIM_PATH_SEPARATOR '/'
428 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
431 /** Use this to specify the root directory of the WIM image. */
432 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
434 /** Use this to test if the specified path refers to the root directory of the
436 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
437 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
440 /** Length of a Globally Unique Identifier (GUID) */
441 #define WIMLIB_GUID_LEN 16
444 * Specifies a compression format. Pass one of these values to
445 * wimlib_create_new_wim(), wimlib_set_output_compression_type(),
446 * wimlib_create_compressor(), or wimlib_create_decompressor().
448 * A WIM file has one default compression type and chunk size. Normally, each
449 * resource in the WIM file is compressed with this compression type. However,
450 * resources may be stored as uncompressed; for example, wimlib will do so if a
451 * resource does not compress to less than its original size. In addition, a
452 * WIM with the new version number of 3584, or "ESD file", might contain solid
453 * blocks with different compression types.
455 enum wimlib_compression_type {
459 * This is a valid argument to wimlib_create_new_wim() and
460 * wimlib_set_output_compression_type(), but not to the functions in the
461 * compression API such as wimlib_create_compressor().
463 WIMLIB_COMPRESSION_TYPE_NONE = 0,
466 * The XPRESS compression format. This format combines Lempel-Ziv
467 * factorization with Huffman encoding. Compression and decompression
468 * are both fast. This format supports chunk sizes that are powers of 2
469 * between <c>2^12</c> and <c>2^16</c>, inclusively.
471 * wimlib's XPRESS compressor will, with the default settings, usually
472 * produce a better compression ratio, and work more quickly, than the
473 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
474 * Non-default compression levels are also supported. For example,
475 * level 80 will enable two-pass optimal parsing, which is significantly
476 * slower but usually improves compression by several percent over the
477 * default level of 50.
479 * If using wimlib_create_compressor() to create an XPRESS compressor
480 * directly, the @p max_block_size parameter may be any positive value
483 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
486 * The LZX compression format. This format combines Lempel-Ziv
487 * factorization with Huffman encoding, but with more features and
488 * complexity than XPRESS. Compression is slow to somewhat fast,
489 * depending on the settings. Decompression is fast but slower than
490 * XPRESS. This format supports chunk sizes that are powers of 2
491 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
492 * other than <c>2^15</c> are not compatible with the Microsoft
495 * wimlib's LZX compressor will, with the default settings, usually
496 * produce a better compression ratio, and work more quickly, than the
497 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
498 * Non-default compression levels are also supported. For example,
499 * level 20 will provide fast compression, almost as fast as XPRESS.
501 * If using wimlib_create_compressor() to create an LZX compressor
502 * directly, the @p max_block_size parameter may be any positive value
505 WIMLIB_COMPRESSION_TYPE_LZX = 2,
508 * The LZMS compression format. This format combines Lempel-Ziv
509 * factorization with adaptive Huffman encoding and range coding.
510 * Compression and decompression are both fairly slow. This format
511 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
512 * <c>2^30</c>, inclusively. This format is best used for large chunk
513 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
514 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
515 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
516 * with the Microsoft implementation.
518 * wimlib's LZMS compressor is currently faster but will usually not
519 * compress as much as the implementation in Microsoft's WIMGAPI
522 * If using wimlib_create_compressor() to create an LZMS compressor
523 * directly, the @p max_block_size parameter may be any positive value
524 * up to <c>2^31 - 2</c>.
526 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
530 /** @addtogroup G_progress
533 /** Possible values of the first parameter to the user-supplied
534 * ::wimlib_progress_func_t progress function */
535 enum wimlib_progress_msg {
537 /** A WIM image is about to be extracted. @p info will point to
538 * ::wimlib_progress_info.extract. This message is received once per
539 * image for calls to wimlib_extract_image() and
540 * wimlib_extract_image_from_pipe(). */
541 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
543 /** One or more file or directory trees within a WIM image is about to
544 * be extracted. @p info will point to ::wimlib_progress_info.extract.
545 * This message is received only once per wimlib_extract_paths() and
546 * wimlib_extract_pathlist(), since wimlib combines all paths into a
547 * single extraction operation for optimization purposes. */
548 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
550 /** This message may be sent periodically (not for every file) while
551 * files or directories are being created, prior to data stream
552 * extraction. @p info will point to ::wimlib_progress_info.extract.
554 WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE = 3,
556 /** File data is currently being extracted. @p info will point to
557 * ::wimlib_progress_info.extract. This is the main message to track
558 * the progress of an extraction operation. */
559 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
561 /** Starting to read a new part of a split pipable WIM over the pipe.
562 * @p info will point to ::wimlib_progress_info.extract. */
563 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
565 /** This message may be sent periodically (not for every file) while
566 * file and directory metadata is being applied, following data stream
567 * extraction. @p info will point to ::wimlib_progress_info.extract.
569 WIMLIB_PROGRESS_MSG_EXTRACT_METADATA = 6,
571 /** Confirms that the image has been successfully extracted. @p info
572 * will point to ::wimlib_progress_info.extract. This is paired with
573 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
574 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
576 /** Confirms that the files or directory trees have been successfully
577 * extracted. @p info will point to ::wimlib_progress_info.extract.
578 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
579 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
581 /** The directory or NTFS volume is about to be scanned for metadata.
582 * @p info will point to ::wimlib_progress_info.scan. This message is
583 * received once per call to wimlib_add_image(), or once per capture
584 * source passed to wimlib_add_image_multisource(), or once per add
585 * command passed to wimlib_update_image(). */
586 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
588 /** A directory or file has been scanned. @p info will point to
589 * ::wimlib_progress_info.scan, and its @p cur_path member will be
590 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
592 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
594 /** Confirms that the directory or NTFS volume has been successfully
595 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
596 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
597 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
599 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
601 /** File resources ("streams") are currently being written to the WIM.
602 * @p info will point to ::wimlib_progress_info.write_streams. This
603 * message may be received many times while the WIM file is being
604 * written or appended to with wimlib_write(), wimlib_overwrite(), or
605 * wimlib_write_to_fd(). */
606 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
608 /** Per-image metadata is about to be written to the WIM file. @p info
609 * will not be valid. */
610 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
612 /** Confirms that per-image metadata has been successfully been written
613 * to the WIM file. @p info will not be valid. This message is paired
614 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
616 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
618 /** wimlib_overwrite() has successfully renamed the temporary file to
619 * the original WIM file, thereby committing the update. @p info will
620 * point to ::wimlib_progress_info.rename. Note: this message is not
621 * received if wimlib_overwrite() chose to append to the WIM file
623 WIMLIB_PROGRESS_MSG_RENAME = 15,
625 /** The contents of the WIM file are being checked against the integrity
626 * table. @p info will point to ::wimlib_progress_info.integrity. This
627 * message is only received (and may be received many times) when
628 * wimlib_open_wim_with_progress() is called with the
629 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
630 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
632 /** An integrity table is being calculated for the WIM being written.
633 * @p info will point to ::wimlib_progress_info.integrity. This message
634 * is only received (and may be received many times) when a WIM file is
635 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
636 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
638 /** A wimlib_split() operation is in progress, and a new split part is
639 * about to be started. @p info will point to
640 * ::wimlib_progress_info.split. */
641 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
643 /** A wimlib_split() operation is in progress, and a split part has been
644 * finished. @p info will point to ::wimlib_progress_info.split. */
645 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
647 /** A WIM update command is just about to be executed. @p info will
648 * point to ::wimlib_progress_info.update. This message is received
649 * once per update command when wimlib_update_image() is called with the
650 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
651 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
653 /** A WIM update command has just been executed. @p info will point to
654 * ::wimlib_progress_info.update. This message is received once per
655 * update command when wimlib_update_image() is called with the flag
656 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
657 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
659 /** A file in the WIM image is being replaced as a result of a
660 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
661 * @p info will point to ::wimlib_progress_info.replace. This is only
662 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
664 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
666 /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
667 * a file is being extracted normally (not as a WIMBoot "pointer file")
668 * due to it matching a pattern in the [PrepopulateList] section of the
669 * configuration file @c \\Windows\\System32\\WimBootCompress.ini in the
670 * WIM image. @p info will point to
671 * ::wimlib_progress_info.wimboot_exclude.
673 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
675 /** Starting to unmount a WIM image. @p info will point to
676 * ::wimlib_progress_info.unmount. */
677 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
679 /** wimlib has used a file's data for the last time (including all data
680 * streams, if it has multiple). @p info will point to
681 * ::wimlib_progress_info.done_with_file. This message is only received
682 * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided. */
683 WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
685 /** wimlib_verify_wim() is starting to verify the metadata for an image.
686 * @p info will point to ::wimlib_progress_info.verify_image. */
687 WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
689 /** wimlib_verify_wim() has finished verifying the metadata for an
690 * image. @p info will point to ::wimlib_progress_info.verify_image.
692 WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
694 /** wimlib_verify_wim() is verifying stream integrity. @p info will
695 * point to ::wimlib_progress_info.verify_streams. */
696 WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
699 /** Valid return values from user-provided progress functions
700 * (::wimlib_progress_func_t).
702 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
705 enum wimlib_progress_status {
707 /** The operation should be continued. This is the normal return value.
709 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
711 /** The operation should be aborted. This will cause the current
712 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
713 WIMLIB_PROGRESS_STATUS_ABORT = 1,
717 * A pointer to this union is passed to the user-supplied
718 * ::wimlib_progress_func_t progress function. One (or none) of the structures
719 * contained in this union will be applicable for the operation
720 * (::wimlib_progress_msg) indicated in the first argument to the progress
722 union wimlib_progress_info {
724 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
725 * document them if they aren't given a name... */
727 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
728 * the primary message for tracking the progress of writing a WIM file.
730 struct wimlib_progress_info_write_streams {
731 /** Total number of uncompressed bytes of stream data being
732 * written. This can be thought of as the total uncompressed
733 * size of the files being archived, with some caveats. WIM
734 * files use single-instance streams, so the size provided here
735 * only counts distinct streams, except for the following
736 * exception: the size provided here may include the sizes of
737 * all newly added (e.g. with wimlib_add_image() streams,
738 * pending automatic de-duplication during the write operation
739 * itself. When each such stream de-duplication occurs, this
740 * number will be decreased by the size of the duplicate stream
741 * that need not be written.
743 * In the case of a wimlib_overwrite() that the library opted to
744 * perform in-place, both @p total_streams and @p total_bytes
745 * will only count the streams actually being written and not
746 * pre-existing streams in the WIM file. */
747 uint64_t total_bytes;
749 /** Total number of streams being written. This can be thought
750 * of as the total number of files being archived, with some
751 * caveats. In general, a single file or directory may contain
752 * multiple data streams, each of which will be represented
753 * separately in this number. Furthermore, WIM files use
754 * single-instance streams, so the stream count provided here
755 * only counts distinct streams, except for the following
756 * exception: the stream count provided here may include newly
757 * added (e.g. with wimlib_add_image() streams, pending
758 * automatic de-duplication during the write operation itself.
759 * When each such stream de-duplication occurs, this number will
760 * be decreased by 1 to account for the duplicate stream that
761 * need not be written. */
762 uint64_t total_streams;
764 /** Number of uncompressed bytes of stream data that have been
765 * written so far. This number be 0 initially, and will be
766 * equal to @p total_bytes at the end of the write operation.
767 * Note that @p total_bytes (but not @p completed_bytes) may
768 * decrease throughout the write operation due to the discovery
769 * of stream duplications. */
770 uint64_t completed_bytes;
772 /** Number of streams that have been written so far. This
773 * number will be 0 initially, and will be equal to @p
774 * total_streams at the end of the write operation. Note that
775 * @p total_streams (but not @p completed_streams) may decrease
776 * throughout the write operation due to the discovery of stream
779 * For applications that wish to calculate a simple "percent
780 * complete" for the write operation, it will likely be more
781 * accurate to calculate the percentage from @p completed_bytes
782 * and @p total_bytes rather than @p completed_streams and
783 * @p total_streams because the time for the operation to
784 * complete is mainly determined by the number of bytes that
785 * need to be read, compressed, and written, not just the number
786 * of files being archived. */
787 uint64_t completed_streams;
789 /** Number of threads that are being used to compress streams,
790 * or 1 if streams are being written uncompressed. */
791 uint32_t num_threads;
793 /** The compression type being used to write the streams, as one
794 * of the ::wimlib_compression_type constants. */
795 int32_t compression_type;
797 /** Number of split WIM parts from which streams are being
798 * written (may be 0 if irrelevant). */
799 uint32_t total_parts;
801 /** This is currently broken and will always be 0. */
802 uint32_t completed_parts;
805 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
806 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
807 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
808 struct wimlib_progress_info_scan {
809 /** Top-level directory being scanned; or, when capturing an NTFS
810 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
811 * to the file or block device that contains the NTFS volume
813 const wimlib_tchar *source;
815 /** Path to the file (or directory) that has been scanned, valid
816 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
817 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
818 * relative to the root of the NTFS volume. */
819 const wimlib_tchar *cur_path;
821 /** Dentry scan status, valid on
822 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
824 /** The file looks okay and will be captured. */
825 WIMLIB_SCAN_DENTRY_OK = 0,
827 /** File is being excluded from capture due to the
828 * capture configuration. */
829 WIMLIB_SCAN_DENTRY_EXCLUDED,
831 /** File is being excluded from capture due to being
832 * unsupported (e.g. an encrypted or device file). */
833 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
835 /** The file is an absolute symbolic link or junction
836 * that points into the capture directory, and
837 * reparse-point fixups are enabled, so its target is
838 * being adjusted. (Reparse point fixups can be
839 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
841 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
843 /** Reparse-point fixups are enabled, but the file is an
844 * absolute symbolic link or junction that does
845 * <b>not</b> point into the capture directory, so its
846 * target is <b>not</b> being adjusted. */
847 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK,
851 /** Target path in the WIM image. Only valid on
852 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
853 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
854 const wimlib_tchar *wim_target_path;
856 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
857 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
858 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
859 * target of the absolute symbolic link or junction. */
860 const wimlib_tchar *symlink_target;
863 /** Number of directories scanned so far, including the root
864 * directory but excluding any unsupported/excluded directories.
866 * Details: On Windows and in NTFS capture mode, a reparse point
867 * counts as a directory if and only if it has
868 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
869 * counts as a directory if and only if when fully dereferenced
870 * it points to an accessible directory. If a file has multiple
871 * names (hard links), it is only counted one time. */
872 uint64_t num_dirs_scanned;
874 /** Number of non-directories scanned so far, excluding any
875 * unsupported/excluded files.
877 * Details: On Windows and in NTFS capture mode, a reparse point
878 * counts as a non-directory if and only if it does not have
879 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
880 * counts as a non-directory if and only if when fully
881 * dereferenced it points to a non-directory or its target is
882 * inaccessible. If a file has multiple names (hard links), it
883 * is only counted one time. */
884 uint64_t num_nondirs_scanned;
886 /** Number of bytes of file data that have been detected so far.
888 * Details: This data may not actually have been read yet, and
889 * it will not actually be written to the WIM file until
890 * wimlib_write() or wimlib_overwrite() has been called. Data
891 * from excluded files is not counted. This number includes
892 * default file contents as well as named data streams and
893 * reparse point data. The size of reparse point data is
894 * tallied after any reparse-point fixups, and in the case of
895 * capturing a symbolic link on a UNIX-like system, the creation
896 * of the reparse point data itself. If a file has multiple
897 * names (hard links), its size(s) are only counted one time.
898 * On Windows, encrypted files have their encrypted size
899 * counted, not their unencrypted size; however, compressed
900 * files have their uncompressed size counted. */
901 uint64_t num_bytes_scanned;
904 /** Valid on messages
905 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
906 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
907 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
908 * ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE,
909 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
910 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA,
911 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
912 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
914 * Note: most of the time of an extraction operation will be spent
915 * extracting streams, and the application will receive
916 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
917 * completed_bytes and @p total_bytes, the application can calculate a
918 * percentage complete. However, note that this message does not, in
919 * general, actually provide information about which "file" is currently
920 * being extracted. This is because wimlib, by default, extracts the
921 * individual data streams in whichever order it determines to be the
924 struct wimlib_progress_info_extract {
925 /** Number of the image from which files are being extracted
929 /** Extraction flags being used. */
930 uint32_t extract_flags;
932 /** Full path to the WIM file from which files are being
933 * extracted, or @c NULL if the WIMStruct has no associated
935 const wimlib_tchar *wimfile_name;
937 /** Name of the image from which files are being extracted, or
938 * the empty string if the image is unnamed. */
939 const wimlib_tchar *image_name;
941 /** Path to the directory or NTFS volume to which the files are
942 * being extracted. */
943 const wimlib_tchar *target;
946 const wimlib_tchar *reserved;
948 /** Number of bytes of uncompressed data that will be extracted.
949 * If a file has multiple names (hard links), its size (or
950 * sizes, in the case of named data streams) is only counted one
951 * time. For "reparse points" and symbolic links, the size to
952 * be extracted is the size of the reparse data buffer.
954 * This number will stay constant throughout the extraction. */
955 uint64_t total_bytes;
957 /** Number of bytes of uncompressed data that have been
958 * extracted so far. This initially be 0 and will equal to @p
959 * total_bytes at the end of the extraction. */
960 uint64_t completed_bytes;
962 /** Number of (not necessarily unique) streams that will be
963 * extracted. This may be more or less than the number of
964 * "files" to be extracted due to hard links as well as
965 * potentially multiple streams per file (named data streams).
966 * A "stream" may be the default contents of a file, a named
967 * data stream, or a reparse data buffer. */
968 uint64_t total_streams;
970 /** Number of (not necessarily unique) streams that have been
971 * extracted so far. */
972 uint64_t completed_streams;
974 /** Currently only used for
975 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
976 uint32_t part_number;
978 /** Currently only used for
979 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
980 uint32_t total_parts;
982 /** Currently only used for
983 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
984 uint8_t guid[WIMLIB_GUID_LEN];
987 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
988 struct wimlib_progress_info_rename {
989 /** Name of the temporary file that the WIM was written to. */
990 const wimlib_tchar *from;
992 /** Name of the original WIM file to which the temporary file is
994 const wimlib_tchar *to;
997 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
998 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
999 struct wimlib_progress_info_update {
1000 /** Pointer to the update command that will be executed or has
1001 * just been executed. */
1002 const struct wimlib_update_command *command;
1004 /** Number of update commands that have been completed so far.
1006 size_t completed_commands;
1008 /** Number of update commands that are being executed as part of
1009 * this call to wimlib_update_image(). */
1010 size_t total_commands;
1013 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
1014 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
1015 struct wimlib_progress_info_integrity {
1016 /** Number of bytes from the end of the WIM header to the end of
1017 * the lookup table (the area that is covered by the SHA1
1018 * integrity checks.) */
1019 uint64_t total_bytes;
1021 /** Number of bytes that have been SHA1-summed so far. Will be
1022 * 0 initially, and equal @p total_bytes at the end. */
1023 uint64_t completed_bytes;
1025 /** Number of chunks that the checksummed region is divided
1027 uint32_t total_chunks;
1029 /** Number of chunks that have been SHA1-summed so far. Will
1030 * be 0 initially, and equal to @p total_chunks at the end. */
1031 uint32_t completed_chunks;
1033 /** Size of the chunks used for the integrity calculation. */
1034 uint32_t chunk_size;
1036 /** Filename of the WIM (only valid if the message is
1037 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
1038 const wimlib_tchar *filename;
1041 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
1042 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
1043 struct wimlib_progress_info_split {
1044 /** Total size of the original WIM's file and metadata resources
1046 uint64_t total_bytes;
1048 /** Number of bytes of file and metadata resources that have
1049 * been copied out of the original WIM so far. Will be 0
1050 * initially, and equal to @p total_bytes at the end. */
1051 uint64_t completed_bytes;
1053 /** Number of the split WIM part that is about to be started
1054 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1055 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
1056 unsigned cur_part_number;
1058 /** Total number of split WIM parts that are being written. */
1059 unsigned total_parts;
1061 /** Name of the split WIM part that is about to be started
1062 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1063 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
1064 * As of wimlib v1.7.0, the library user may change this when
1065 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
1066 * cause the next split WIM part to be written to a different
1068 wimlib_tchar *part_name;
1071 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
1072 struct wimlib_progress_info_replace {
1073 /** Path to the file in the WIM image that is being replaced */
1074 const wimlib_tchar *path_in_wim;
1077 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1078 struct wimlib_progress_info_wimboot_exclude {
1079 /** Path to the file in the WIM image */
1080 const wimlib_tchar *path_in_wim;
1082 /** Path to which the file is being extracted */
1083 const wimlib_tchar *extraction_path;
1086 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1087 struct wimlib_progress_info_unmount {
1088 /** Path to directory being unmounted */
1089 const wimlib_tchar *mountpoint;
1091 /** Path to WIM file being unmounted */
1092 const wimlib_tchar *mounted_wim;
1094 /** 1-based index of image being unmounted. */
1095 uint32_t mounted_image;
1097 /** Flags that were passed to wimlib_mount_image() when the
1098 * mountpoint was set up. */
1099 uint32_t mount_flags;
1101 /** Flags passed to wimlib_unmount_image(). */
1102 uint32_t unmount_flags;
1105 /** Valid on messages ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE. */
1106 struct wimlib_progress_info_done_with_file {
1107 /* Path to the file whose data has been written to the WIM file,
1108 * or is currently being asynchronously compressed in memory,
1109 * and therefore is no longer needed by wimlib.
1111 * WARNING: The file data will not actually be accessible in the
1112 * WIM file until the WIM file has been completely written.
1113 * Ordinarily you should <b>not</b> treat this message as a
1114 * green light to go ahead and delete the specified file, since
1115 * that would result in data loss if the WIM file cannot be
1116 * successfully created for any reason.
1118 * If a file has multiple names (hard links),
1119 * ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE will only be received
1120 * for one name. Also, this message will not be received for
1121 * empty files or reparse points (or symbolic links), unless
1122 * they have nonempty named data streams.
1124 const wimlib_tchar *path_to_file;
1127 /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
1128 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE. */
1129 struct wimlib_progress_info_verify_image {
1130 const wimlib_tchar *wimfile;
1131 uint32_t total_images;
1132 uint32_t current_image;
1135 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS. */
1136 struct wimlib_progress_info_verify_streams {
1137 const wimlib_tchar *wimfile;
1138 uint64_t total_streams;
1139 uint64_t total_bytes;
1140 uint64_t completed_streams;
1141 uint64_t completed_bytes;
1146 * A user-supplied function that will be called periodically during certain WIM
1149 * The first argument will be the type of operation that is being performed or
1150 * is about to be started or has been completed.
1152 * The second argument will be a pointer to one of a number of structures
1153 * depending on the first argument. It may be @c NULL for some message types.
1154 * Note that although this argument is not @c const, users should not modify it
1155 * except in explicitly documented cases.
1157 * The third argument will be a user-supplied value that was provided when
1158 * registering or specifying the progress function.
1160 * This function must return one of the ::wimlib_progress_status values. By
1161 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1163 typedef enum wimlib_progress_status
1164 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1165 union wimlib_progress_info *info,
1169 /** @addtogroup G_modifying_wims
1172 /** An array of these structures is passed to wimlib_add_image_multisource() to
1173 * specify the sources from which to create a WIM image. */
1174 struct wimlib_capture_source {
1175 /** Absolute or relative path to a file or directory on the external
1176 * filesystem to be included in the WIM image. */
1177 wimlib_tchar *fs_source_path;
1179 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1180 * specify the root directory of the WIM image. */
1181 wimlib_tchar *wim_target_path;
1183 /** Reserved; set to 0. */
1187 /** Set or unset the WIM header flag that marks it read-only
1188 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
1189 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
1190 * is distinct from basic file permissions; this flag can be set on a WIM file
1191 * that is physically writable. If this flag is set, all further operations to
1192 * modify the WIM will fail, except calling wimlib_overwrite() with
1193 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
1194 * allows you to set this flag persistently on the underlying WIM file.
1196 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1198 /** Set the GUID (globally unique identifier) of the WIM file to the value
1199 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1200 #define WIMLIB_CHANGE_GUID 0x00000002
1202 /** Change the bootable image of the WIM to the value specified in
1203 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1204 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1206 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1207 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
1208 * indicates whether an image in the WIM has been captured with reparse-point
1209 * fixups enabled. wimlib also treats this flag as specifying whether to do
1210 * reparse-point fixups by default when capturing or applying WIM images. */
1211 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1215 /** @addtogroup G_wim_information
1220 /** General information about a WIM file. */
1221 struct wimlib_wim_info {
1223 /** Globally unique identifier for the WIM file. Note: all parts of a
1224 * split WIM should have an identical value in this field. */
1225 uint8_t guid[WIMLIB_GUID_LEN];
1227 /** Number of images in the WIM. */
1228 uint32_t image_count;
1230 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1232 uint32_t boot_index;
1234 /** Version of the WIM file. */
1235 uint32_t wim_version;
1237 /** Chunk size used for compression. */
1238 uint32_t chunk_size;
1240 /** For split WIMs, the 1-based index of this part within the split WIM;
1242 uint16_t part_number;
1244 /** For split WIMs, the total number of parts in the split WIM;
1246 uint16_t total_parts;
1248 /** One of the ::wimlib_compression_type values that specifies the
1249 * method used to compress resources in the WIM. */
1250 int32_t compression_type;
1252 /** Size of the WIM file in bytes, excluding the XML data and integrity
1254 uint64_t total_bytes;
1256 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1257 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1258 * this will always be 0, even if the ::WIMStruct was written to
1259 * somewhere by calling wimlib_write() with the
1260 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1261 uint32_t has_integrity_table : 1;
1263 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1264 * wimlib_create_new_wim(). */
1265 uint32_t opened_from_file : 1;
1267 /** 1 if the WIM is considered readonly for any reason. */
1268 uint32_t is_readonly : 1;
1270 /** 1 if reparse-point fixups are supposedly enabled for one or more
1271 * images in the WIM. */
1272 uint32_t has_rpfix : 1;
1274 /** 1 if the WIM is marked as read-only. */
1275 uint32_t is_marked_readonly : 1;
1277 /** 1 if the WIM is part of a spanned set. */
1278 uint32_t spanned : 1;
1280 uint32_t write_in_progress : 1;
1281 uint32_t metadata_only : 1;
1282 uint32_t resource_only : 1;
1284 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1285 uint32_t pipable : 1;
1286 uint32_t reserved_flags : 22;
1287 uint32_t reserved[9];
1290 /** Information about a unique stream in the WIM file. (A stream is the same
1291 * thing as a "resource", except in the case of packed resources.) */
1292 struct wimlib_resource_entry {
1293 /** Uncompressed size of the stream in bytes. */
1294 uint64_t uncompressed_size;
1296 /** Compressed size of the stream in bytes. This will be the same as @p
1297 * uncompressed_size if the stream is uncompressed. Or, if @p
1298 * is_packed_streams is 1, this will be 0. */
1299 uint64_t compressed_size;
1301 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1302 * if @p packed is 1, then this is actually the offset at which this
1303 * stream begins in the uncompressed contents of the packed resource.
1307 /** SHA1 message digest of the stream's uncompressed contents. */
1308 uint8_t sha1_hash[20];
1310 /** Which part number of the split WIM this stream is in. This should
1311 * be the same as the part number provided by wimlib_get_wim_info(). */
1312 uint32_t part_number;
1314 /** Number of times this stream is referenced over all WIM images. */
1315 uint32_t reference_count;
1317 /** 1 if this stream is compressed. */
1318 uint32_t is_compressed : 1;
1320 /** 1 if this stream is a metadata resource rather than a file resource.
1322 uint32_t is_metadata : 1;
1324 uint32_t is_free : 1;
1325 uint32_t is_spanned : 1;
1327 /** 1 if this stream was not found in the lookup table of the
1328 * ::WIMStruct. This normally implies a missing call to
1329 * wimlib_reference_resource_files() or wimlib_reference_resources().
1331 uint32_t is_missing : 1;
1333 /** 1 if this stream is located in a packed resource which may contain
1334 * other streams (all compressed together) as well. */
1335 uint32_t packed : 1;
1337 uint32_t reserved_flags : 26;
1339 /** If @p packed is 1, then this will specify the offset of the packed
1340 * resource in the WIM. */
1341 uint64_t raw_resource_offset_in_wim;
1343 /** If @p is_packed_streams is 1, then this will specify the compressed
1344 * size of the packed resource in the WIM. */
1345 uint64_t raw_resource_compressed_size;
1347 uint64_t reserved[2];
1350 /** Information about a stream of a particular file in the WIM. */
1351 struct wimlib_stream_entry {
1352 /** Name of the stream, or NULL if the stream is unnamed. */
1353 const wimlib_tchar *stream_name;
1354 /** Location, size, etc. of the stream within the WIM file. */
1355 struct wimlib_resource_entry resource;
1356 uint64_t reserved[4];
1359 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1360 * Roughly, the information about a "file" in the WIM--- but really a directory
1361 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1362 * field can be used to distinguish actual file inodes. */
1363 struct wimlib_dir_entry {
1364 /** Name of the file, or NULL if this file is unnamed (only possible for
1365 * the root directory) */
1366 const wimlib_tchar *filename;
1368 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1370 const wimlib_tchar *dos_name;
1372 /** Full path to this file within the WIM image. */
1373 const wimlib_tchar *full_path;
1375 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1376 * children, ..., etc. */
1379 /** Pointer to the security descriptor for this file, in Windows
1380 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1381 * security descriptor. */
1382 const char *security_descriptor;
1384 /** Length of the above security descriptor. */
1385 size_t security_descriptor_size;
1387 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1388 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1389 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1390 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1391 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1392 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1393 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1394 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1395 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1396 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1397 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1398 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1399 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1400 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1401 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1402 /** File attributes, such as whether the file is a directory or not.
1403 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1404 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1405 * on other platforms. */
1406 uint32_t attributes;
1408 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1409 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1410 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1411 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1412 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1413 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1414 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1415 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1416 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1417 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1418 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1419 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1420 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1421 * attributes), this will give the reparse tag. This tells you whether
1422 * the reparse point is a symbolic link, junction point, or some other,
1423 * more unusual kind of reparse point. */
1424 uint32_t reparse_tag;
1426 /* Number of (hard) links to this file. */
1429 /** Number of named data streams that this file has. Normally 0. */
1430 uint32_t num_named_streams;
1432 /** Roughly, the inode number of this file. However, it may be 0 if
1433 * @p num_links == 1. */
1434 uint64_t hard_link_group_id;
1436 /** Time this file was created. */
1437 struct timespec creation_time;
1439 /** Time this file was last written to. */
1440 struct timespec last_write_time;
1442 /** Time this file was last accessed. */
1443 struct timespec last_access_time;
1445 /* UNIX data (wimlib extension), only valid if unix_mode != 0 */
1451 uint64_t reserved[14];
1453 /** Array of streams that make up this file. The first entry will
1454 * always exist and will correspond to the unnamed data stream (default
1455 * file contents), so it will have @p stream_name == @c NULL. There
1456 * will then be @p num_named_streams additional entries that specify the
1457 * named data streams, if any, each of which will have @p stream_name !=
1459 struct wimlib_stream_entry streams[];
1463 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1466 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1470 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1473 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1476 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1477 * just on the specified path. */
1478 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1480 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1481 * itself; only its children (in the case of a non-empty directory) */
1482 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1484 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1485 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1486 * table of the ::WIMStruct. The default behavior without this flag is to fill
1487 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1488 * wimlib_resource_entry::is_missing "is_missing" flag. */
1489 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1493 /** @addtogroup G_modifying_wims
1496 /** UNIX-like systems only: Directly capture an NTFS volume rather than a
1497 * generic directory. This requires that wimlib was compiled with support for
1500 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1501 * ::WIMLIB_ADD_FLAG_UNIX_DATA.
1503 * Do not use this flag on Windows, where wimlib already supports all
1504 * Windows-native filesystems, including NTFS, through the Windows APIs. */
1505 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1507 /** Follow symbolic links when scanning the directory tree. Currently only
1508 * supported on UNIX-like systems. */
1509 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1511 /** Call the progress function with the message
1512 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1514 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1516 /** Mark the image being added as the bootable image of the WIM. This flag is
1517 * valid only for wimlib_add_image() and wimlib_add_image_multisource().
1519 * Note that you can also change the bootable image of a WIM using
1520 * wimlib_set_wim_info().
1522 * Note: ::WIMLIB_ADD_FLAG_BOOT does something different from, and independent
1523 * from, ::WIMLIB_ADD_FLAG_WIMBOOT. */
1524 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1526 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1527 * (major and minor number) of each file. Also allows capturing special files
1528 * such as device nodes and FIFOs. See the documentation for the
1529 * <b>--unix-data</b> option to <b>wimlib-imagex capture</b> for more
1531 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1533 /** Do not capture security descriptors. Only has an effect in NTFS capture
1534 * mode, or in Windows native builds. */
1535 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1537 /** Fail immediately if the full security descriptor of any file or directory
1538 * cannot be accessed. Only has an effect in Windows native builds. The
1539 * default behavior without this flag is to first try omitting the SACL from the
1540 * security descriptor, then to try omitting the security descriptor entirely.
1542 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1544 /** Call the progress function with the message
1545 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1546 * capture. This is a subset of the messages provided by
1547 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1548 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1550 /** Reparse-point fixups: Modify absolute symbolic links (and junctions, in the
1551 * case of Windows) that point inside the directory being captured to instead be
1552 * absolute relative to the directory being captured.
1554 * Without this flag, the default is to do reparse-point fixups if
1555 * WIM_HDR_FLAG_RP_FIX is set in the WIM header or if this is the first image
1556 * being added. WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is
1557 * captured with reparse point fixups enabled and currently cannot be unset. */
1558 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1560 /** Don't do reparse point fixups. See ::WIMLIB_ADD_FLAG_RPFIX. */
1561 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1563 /** Do not automatically exclude unsupported files or directories from capture;
1564 * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1565 * UNIX-like systems when not also using ::WIMLIB_ADD_FLAG_UNIX_DATA. Instead,
1566 * fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when such a file is encountered. */
1567 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1570 * Automatically select a capture configuration appropriate for capturing
1571 * filesystems containing Windows operating systems. For example,
1572 * "/pagefile.sys" and "System Volume Information" will be excluded.
1574 * When this flag is specified, the corresponding @p config parameter (for
1575 * wimlib_add_image()) or member (for wimlib_update_image()) must be @c NULL.
1576 * Otherwise, ::WIMLIB_ERR_INVALID_PARAM will be returned.
1578 * Note that the default behavior--- that is, when neither
1579 * ::WIMLIB_ADD_FLAG_WINCONFIG nor ::WIMLIB_ADD_FLAG_WIMBOOT is specified and @p
1580 * config is @c NULL--- is to use no capture configuration, meaning that no
1581 * files are excluded from capture.
1583 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1586 * Capture image as WIMBoot compatible. In addition, if no capture
1587 * configuration file is explicitly specified use the capture configuration file
1588 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1589 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1590 * configuration file is explicitly specified, use it and also place it at
1591 * /Windows/System32/WimBootCompress.ini in the WIM image.
1593 * Note: this will not by itself change the compression type. Before writing
1594 * the WIM file, it's recommended to also do:
1597 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1598 * wimlib_set_output_chunk_size(wim, 4096);
1601 * since that makes access to the data faster (at the cost of a worse
1602 * compression ratio compared to the 32768-byte LZX chunks usually used).
1604 * Note: ::WIMLIB_ADD_FLAG_WIMBOOT does something different from, and
1605 * independent from, ::WIMLIB_ADD_FLAG_BOOT.
1607 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1610 * If the add command involves adding a non-directory file to a location at
1611 * which there already exists a nondirectory file in the WIM image, issue
1612 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This only has an
1613 * effect when updating an existing image with wimlib_update_image().
1614 * This was the default behavior in wimlib v1.6.2 and earlier.
1616 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1618 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1619 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1620 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1621 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1622 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1623 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1624 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1625 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1626 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1627 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1628 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1629 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1630 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1631 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT WIMLIB_ADD_FLAG_WIMBOOT
1635 /** @addtogroup G_modifying_wims
1638 /** Do not issue an error if the path to delete does not exist. */
1639 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1641 /** Delete the file or directory tree recursively; if not specified, an error is
1642 * issued if the path to delete is a directory. */
1643 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1646 /** @addtogroup G_modifying_wims
1650 * If a single image is being exported, mark it bootable in the destination WIM.
1651 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1652 * the image in the source WIM (if any) that is marked as bootable is also
1653 * marked as bootable in the destination WIM.
1655 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1657 /** Give the exported image(s) no names. Avoids problems with image name
1660 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1662 /** Give the exported image(s) no descriptions. */
1663 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1665 /** This advises the library that the program is finished with the source
1666 * WIMStruct and will not attempt to access it after the call to
1667 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1668 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1671 * Mark each exported image as WIMBoot-compatible.
1673 * Note: by itself, this does change the destination WIM's compression type, nor
1674 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1675 * image. Before writing the destination WIM, it's recommended to do something
1679 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1680 * wimlib_set_output_chunk_size(wim, 4096);
1681 * wimlib_add_tree(wim, image, L"myconfig.ini",
1682 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1685 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1688 /** @addtogroup G_extracting_wims
1691 /** Extract the image directly to an NTFS volume rather than a generic directory.
1692 * This mode is only available if wimlib was compiled with libntfs-3g support;
1693 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1694 * extraction target will be interpreted as the path to an NTFS volume image (as
1695 * a regular file or block device) rather than a directory. It will be opened
1696 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1697 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1698 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1699 * wimlib_extract_paths() when passed multiple paths. */
1700 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1702 /** UNIX-like systems only: Extract special UNIX data captured with
1703 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1704 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1705 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1707 /** Do not extract security descriptors. This flag cannot be combined with
1708 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1709 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1711 /** Fail immediately if the full security descriptor of any file or directory
1712 * cannot be set exactly as specified in the WIM file. On Windows, the default
1713 * behavior without this flag when wimlib does not have permission to set the
1714 * correct security descriptor is to fall back to setting the security
1715 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1716 * owner omitted, then not at all. This flag cannot be combined with
1717 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1718 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1720 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1721 * reparse-point fixups on, so absolute symbolic links or junction points will
1722 * be fixed to be absolute relative to the actual extraction root. Reparse-
1723 * point fixups are done by default for wimlib_extract_image() and
1724 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1725 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1726 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1728 /** Force reparse-point fixups on extraction off, regardless of the state of the
1729 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1730 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1731 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1733 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1734 * paths, each of which must name a regular file, to standard output. */
1735 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1737 /** Instead of ignoring files and directories with names that cannot be
1738 * represented on the current platform (note: Windows has more restrictions on
1739 * filenames than POSIX-compliant systems), try to replace characters or append
1740 * junk to the names so that they can be extracted in some form. */
1741 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1743 /** On Windows, when there exist two or more files with the same case
1744 * insensitive name but different case sensitive names, try to extract them all
1745 * by appending junk to the end of them, rather than arbitrarily extracting only
1747 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1749 /** Do not ignore failure to set timestamps on extracted files. */
1750 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1752 /** Do not ignore failure to set short names on extracted files. */
1753 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1755 /** On Windows, do not ignore failure to extract symbolic links and junctions
1756 * due to permissions problems. By default, such failures are ignored since the
1757 * default configuration of Windows only allows the Administrator to create
1758 * symbolic links. */
1759 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1761 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1762 * behavior is currently less than satisfactory. Do not use (yet). */
1763 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1765 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1766 * paths to extract as wildcard patterns ("globs") which may contain the
1767 * wildcard characters @c ? and @c *. The @c ? character matches any
1768 * non-path-separator character, whereas the @c * character matches zero or more
1769 * non-path-separator characters. Consequently, each glob may match zero or
1770 * more actual paths in the WIM image. By default, if a glob does not match any
1771 * files, a warning but not an error will be issued, even if the glob did not
1772 * actually contain wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
1773 * to get an error instead. */
1774 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1776 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1777 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1778 * one of the provided globs did not match a file. */
1779 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1781 /** Do not extract Windows file attributes such as readonly, hidden, etc. */
1782 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1784 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1785 * preserve the directory structure of the archive when extracting --- that is,
1786 * place each extracted file or directory tree directly in the target directory.
1788 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1790 /** Windows only: Extract files as "pointers" back to the WIM archive. See the
1791 * documentation for the <b>--wimboot</b> option of <b>wimlib-imagex apply</b>
1792 * for more information. */
1793 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1796 /** @addtogroup G_mounting_wim_images
1799 /** Mount the WIM image read-write rather than the default of read-only. */
1800 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1802 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1803 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1805 /** Do not allow accessing named data streams in the mounted WIM image. */
1806 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1808 /** Access named data streams in the mounted WIM image through extended file
1809 * attributes named "user.X", where X is the name of a data stream. This is the
1811 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1813 /** Access named data streams in the mounted WIM image by specifying the file
1814 * name, a colon, then the name of the data stream. */
1815 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1817 /** Use UNIX metadata if available in the WIM image. See
1818 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1819 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1821 /** Allow other users to see the mounted filesystem. This passes the @c
1822 * allow_other option to the FUSE mount. */
1823 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1826 /** @addtogroup G_creating_and_opening_wims
1829 /** Verify the WIM contents against the WIM's integrity table, if present. This
1830 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1831 * checksummed and checked against the SHA1 message digests specified in the
1832 * integrity table. If there are any mismatches, ::WIMLIB_ERR_INTEGRITY is
1833 * issued. If the WIM file does not contain an integrity table, this flag has
1835 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1837 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
1838 * WIM. Software can provide this flag for convenience if it explicitly does
1839 * not want to support split WIMs. */
1840 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1842 /** Check if the WIM is writable and issue an error
1843 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
1844 * only if it is writable at the filesystem level, does not have the
1845 * WIM_HDR_FLAG_READONLY flag set in its header, and is not part of a spanned
1846 * set. It is not required to provide this flag before attempting to make
1847 * changes to the WIM, but with this flag you get an error sooner rather than
1849 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1852 /** @addtogroup G_mounting_wim_images
1855 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
1856 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1857 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1859 /** Commit changes to the read-write mounted WIM image.
1860 * If this flag is not specified, changes will be discarded. */
1861 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1863 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
1864 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1865 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1867 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
1868 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1869 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1872 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
1873 * image, forces all file descriptors to the open WIM image to be closed before
1876 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
1877 * this flag has no effect.
1879 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
1881 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1882 * WIM image, causes the modified image to be committed to the WIM file as a
1883 * new, unnamed image appended to the archive. The original image in the WIM
1884 * file will be unmodified. */
1885 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
1888 /** @addtogroup G_modifying_wims
1891 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1892 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1893 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1896 /** @addtogroup G_writing_and_overwriting_wims
1900 * Include an integrity table in the resulting WIM file.
1902 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1903 * include an integrity table if and only if one was present before. For
1904 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1905 * to not include an integrity table.
1907 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1910 * Do not include an integrity table in the resulting WIM file. This is the
1911 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
1914 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1917 * Write the WIM as "pipable". After writing a WIM with this flag specified,
1918 * images from it can be applied directly from a pipe using
1919 * wimlib_extract_image_from_pipe(). See the documentation for the
1920 * <b>--pipable</b> option of <b>wimlib-imagex capture</b> for more information.
1921 * Beware: WIMs written with this flag will not be compatible with Microsoft's
1924 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1925 * write the WIM as pipable if and only if it was pipable before. For
1926 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1927 * to write the WIM as non-pipable.
1929 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1932 * Do not write the WIM as "pipable". This is the default behavior, unless the
1933 * ::WIMStruct was created by opening a pipable WIM.
1935 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1938 * When writing streams to the WIM file, recompress them, even if their data is
1939 * already available in the desired compressed form (for example, in a WIM file
1940 * from which an image has been exported using wimlib_export_image()).
1942 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
1943 * compression ratio for the same compression type and chunk size. wimlib's LZX
1944 * compressor currently can be given different parameters in order to achieve
1945 * different balances between compression ratio and time. In its default mode
1946 * as of v1.7.0, it usually compresses slightly better than the competing
1947 * Microsoft implementation and is almost as fast.
1949 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can also be used in combination with
1950 * ::WIMLIB_WRITE_FLAG_PACK_STREAMS to prevent any solid blocks from being
1951 * re-used. (Otherwise, solid blocks are re-used somewhat more liberally than
1952 * normal compressed blocks.)
1954 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
1955 * that would not otherwise be written. For example, a call to
1956 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
1957 * cause already-existing streams in the WIM file to be recompressed. To force
1958 * the WIM file to be fully rebuilt and recompressed, combine
1959 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
1961 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1964 * Immediately before closing the WIM file, sync its data to disk.
1966 * wimlib_overwrite() will set this flag automatically if it decides to
1967 * overwrite the WIM file via a temporary file instead of in-place.
1969 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1972 * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
1973 * could be updated merely by appending to it.
1975 * When rebuilding the WIM file, stream reference counts will be recomputed, and
1976 * any streams with 0 reference count (e.g. from deleted files or images) will
1977 * not be included in the resulting WIM file.
1979 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
1980 * data to be recompressed. Otherwise, compressed data is re-used if possible.
1982 * wimlib_write() ignores this flag.
1984 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1987 * For wimlib_overwrite(), override the default behavior after one or more calls
1988 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
1989 * flag, only minimal changes to correctly remove the image from the WIM file
1990 * will be taken. In particular, all streams will be retained, even if they are
1991 * no longer referenced. This may not be what you want, because no space will
1992 * be saved by deleting an image in this way.
1994 * wimlib_write() ignores this flag.
1996 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1999 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
2000 * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header. This can be used
2001 * following a call to wimlib_set_wim_info() with the
2002 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
2005 * wimlib_write() ignores this flag.
2007 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
2010 * Do not include streams already present in other WIMs. This flag can be used
2011 * to write a "delta" WIM after resources from the WIM on which the delta is to
2012 * be based were referenced with wimlib_reference_resource_files() or
2013 * wimlib_reference_resources().
2015 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
2018 * Advises the library that for writes of all WIM images, all streams needed for
2019 * the WIM are already present (not in external resource WIMs) and their
2020 * reference counts are correct, so the code does not need to recalculate which
2021 * streams are referenced. This is for optimization purposes only, since with
2022 * this flag specified, the metadata resources may not need to be decompressed
2025 * wimlib_overwrite() will set this flag automatically.
2027 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
2030 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
2032 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
2035 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
2038 * When writing streams in the resulting WIM file, pack multiple streams into a
2039 * single compressed resource instead of compressing them independently. This
2040 * is also known as creating a "solid archive". This tends to produce a better
2041 * compression ratio at the cost of much slower random access.
2043 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
2044 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
2045 * created with this flag use a different version number in their header (3584
2046 * instead of 68864) and are also called "ESD files".
2048 * If this flag is passed to wimlib_overwrite(), any new data streams will be
2049 * written in solid mode. Use both ::WIMLIB_WRITE_FLAG_REBUILD and
2050 * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
2051 * all streams recompressed in solid mode.
2053 * Currently, new solid blocks will, by default, be written using LZMS
2054 * compression with 32 MiB (33554432 byte) chunks. Use
2055 * wimlib_set_output_pack_compression_type() and/or
2056 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
2057 * the WIM's main compression type and chunk size; you can have a WIM that
2058 * nominally uses LZX compression and 32768 byte chunks but actually contains
2059 * LZMS-compressed solid blocks, for example. However, if including solid
2060 * blocks, I suggest that you set the WIM's main compression type to LZMS as
2061 * well, either by creating the WIM with
2062 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
2063 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
2065 * This flag will be set by default when writing or overwriting a WIM file that
2066 * either already contains packed streams, or has had packed streams exported
2067 * into it and the WIM's main compression type is LZMS.
2069 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
2072 * Send ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE messages while writing the WIM
2073 * file. This is only needed in the unusual case that the library user needs to
2074 * know exactly when wimlib has read each file for the last time.
2076 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
2079 /** @addtogroup G_general
2082 /** Assume that strings are represented in UTF-8, even if this is not the
2083 * locale's character encoding. This flag is ignored on Windows, where wimlib
2084 * always uses UTF-16LE. */
2085 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
2087 /** Windows-only: do not attempt to acquire additional privileges (currently
2088 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
2089 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
2090 * for the case where the calling program manages these privileges itself.
2091 * Note: no error is issued if privileges cannot be acquired, although related
2092 * errors may be reported later, depending on if the operations performed
2093 * actually require additional privileges or not. */
2094 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
2096 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2097 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2098 * to read all possible data and metadata for a capture operation could not be
2099 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
2101 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
2103 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2104 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2105 * to restore all possible data and metadata for an apply operation could not be
2106 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
2108 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
2110 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
2112 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
2114 /** Default to interpreting WIM paths case insensitively (default on Windows).
2115 * This does not apply to mounted images. */
2116 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
2119 /** @addtogroup G_nonstandalone_wims
2122 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
2123 * Ignored by wimlib_reference_resources(). */
2124 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
2126 /** For wimlib_reference_resource_files(), issue an error
2127 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
2128 * default behavior without this flag is to issue no error at that point, but
2129 * then attempt to open the glob as a literal path, which of course will fail
2130 * anyway if no file exists at that path. No effect if
2131 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
2132 * wimlib_reference_resources(). */
2133 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
2136 /** @addtogroup G_modifying_wims
2139 /** The specific type of update to perform. */
2140 enum wimlib_update_op {
2141 /** Add a new file or directory tree to the WIM image in a
2142 * certain location. */
2143 WIMLIB_UPDATE_OP_ADD = 0,
2145 /** Delete a file or directory tree from the WIM image. */
2146 WIMLIB_UPDATE_OP_DELETE,
2148 /** Rename a file or directory tree in the WIM image. */
2149 WIMLIB_UPDATE_OP_RENAME,
2152 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2153 struct wimlib_add_command {
2154 /** Filesystem path to the file or directory tree to add. */
2155 wimlib_tchar *fs_source_path;
2157 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
2158 * specify the root directory of the WIM image. */
2159 wimlib_tchar *wim_target_path;
2161 /** Path to capture configuration file to use, or @c NULL for default.
2163 wimlib_tchar *config_file;
2165 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2169 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2170 struct wimlib_delete_command {
2172 /** Path, specified from the root of the WIM image, for the file or
2173 * directory tree within the WIM image to be deleted. */
2174 wimlib_tchar *wim_path;
2176 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2180 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2181 struct wimlib_rename_command {
2183 /** Path, specified from the root of the WIM image, for the source file
2184 * or directory tree within the WIM image. */
2185 wimlib_tchar *wim_source_path;
2187 /** Path, specified from the root of the WIM image, for the destination
2188 * file or directory tree within the WIM image. */
2189 wimlib_tchar *wim_target_path;
2191 /** Reserved; set to 0. */
2195 /** Specification of an update to perform on a WIM image. */
2196 struct wimlib_update_command {
2198 enum wimlib_update_op op;
2201 struct wimlib_add_command add;
2202 struct wimlib_delete_command delete_; /* Underscore is for C++
2204 struct wimlib_rename_command rename;
2209 /** @addtogroup G_general
2213 * Possible values of the error code returned by many functions in wimlib.
2215 * See the documentation for each wimlib function to see specifically what error
2216 * codes can be returned by a given function, and what they mean.
2218 enum wimlib_error_code {
2219 WIMLIB_ERR_SUCCESS = 0,
2220 WIMLIB_ERR_ALREADY_LOCKED = 1,
2221 WIMLIB_ERR_DECOMPRESSION = 2,
2222 WIMLIB_ERR_FUSE = 6,
2223 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2224 WIMLIB_ERR_ICONV_NOT_AVAILABLE = 9,
2225 WIMLIB_ERR_IMAGE_COUNT = 10,
2226 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2227 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2228 WIMLIB_ERR_INTEGRITY = 13,
2229 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2230 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2231 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2232 WIMLIB_ERR_INVALID_HEADER = 17,
2233 WIMLIB_ERR_INVALID_IMAGE = 18,
2234 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2235 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2236 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2237 WIMLIB_ERR_INVALID_MULTIBYTE_STRING = 22,
2238 WIMLIB_ERR_INVALID_OVERLAY = 23,
2239 WIMLIB_ERR_INVALID_PARAM = 24,
2240 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2241 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2242 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2243 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2244 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2245 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2246 WIMLIB_ERR_IS_DIRECTORY = 32,
2247 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2248 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE = 34,
2249 WIMLIB_ERR_LINK = 35,
2250 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2251 WIMLIB_ERR_MKDIR = 37,
2252 WIMLIB_ERR_MQUEUE = 38,
2253 WIMLIB_ERR_NOMEM = 39,
2254 WIMLIB_ERR_NOTDIR = 40,
2255 WIMLIB_ERR_NOTEMPTY = 41,
2256 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2257 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2258 WIMLIB_ERR_NOT_PIPABLE = 44,
2259 WIMLIB_ERR_NO_FILENAME = 45,
2260 WIMLIB_ERR_NTFS_3G = 46,
2261 WIMLIB_ERR_OPEN = 47,
2262 WIMLIB_ERR_OPENDIR = 48,
2263 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2264 WIMLIB_ERR_READ = 50,
2265 WIMLIB_ERR_READLINK = 51,
2266 WIMLIB_ERR_RENAME = 52,
2267 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2268 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2269 WIMLIB_ERR_RESOURCE_ORDER = 56,
2270 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2271 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2272 WIMLIB_ERR_SET_SECURITY = 59,
2273 WIMLIB_ERR_SET_SHORT_NAME = 60,
2274 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2275 WIMLIB_ERR_SPLIT_INVALID = 62,
2276 WIMLIB_ERR_STAT = 63,
2277 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2278 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2279 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2280 WIMLIB_ERR_UNSUPPORTED = 68,
2281 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2282 WIMLIB_ERR_WIM_IS_READONLY = 71,
2283 WIMLIB_ERR_WRITE = 72,
2284 WIMLIB_ERR_XML = 73,
2285 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2286 WIMLIB_ERR_WIMBOOT = 75,
2287 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2288 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2289 WIMLIB_ERR_MKNOD = 78,
2290 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2291 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2292 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2296 /** Used to indicate no WIM image or an invalid WIM image. */
2297 #define WIMLIB_NO_IMAGE 0
2299 /** Used to specify all images in the WIM. */
2300 #define WIMLIB_ALL_IMAGES (-1)
2305 * @ingroup G_modifying_wims
2307 * Appends an empty image to a WIM file. This empty image will initially
2308 * contain no files or directories, although if written without further
2309 * modifications, a root directory will be created automatically for it. After
2310 * calling this function, you can use wimlib_update_image() to add files to the
2311 * new WIM image. This gives you slightly more control over making the new
2312 * image compared to calling wimlib_add_image() or
2313 * wimlib_add_image_multisource() directly.
2316 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2319 * Name to give the new image. If @c NULL or empty, the new image is given
2320 * no name. If nonempty, it must specify a name that does not already
2322 * @param new_idx_ret
2323 * If non-<code>NULL</code>, the index of the newly added image is returned
2326 * @return 0 on success; nonzero on failure. The possible error codes are:
2328 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2329 * There is already an image in @p wim named @p name.
2330 * @retval ::WIMLIB_ERR_NOMEM
2331 * Failed to allocate the memory needed to add the new image.
2332 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2333 * The WIM file is considered read-only because of any of the reasons
2334 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2338 wimlib_add_empty_image(WIMStruct *wim,
2339 const wimlib_tchar *name,
2343 * @ingroup G_modifying_wims
2345 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2347 * The directory tree or NTFS volume is scanned immediately to load the dentry
2348 * tree into memory, and file attributes and symbolic links are read. However,
2349 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2352 * See the manual page for the @b wimlib-imagex program for more information
2353 * about the "normal" capture mode versus the NTFS capture mode (entered by
2354 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2356 * Note that @b no changes are committed to the underlying WIM file (if
2357 * any) until wimlib_write() or wimlib_overwrite() is called.
2360 * Pointer to the ::WIMStruct to which to add the image.
2362 * A path to a directory or unmounted NTFS volume that will be captured as
2365 * Name to give the new image. If @c NULL or empty, the new image is given
2366 * no name. If nonempty, it must specify a name that does not already
2368 * @param config_file
2369 * Path to capture configuration file, or @c NULL. This file may specify,
2370 * among other things, which files to exclude from capture. See the man
2371 * page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2372 * details of the file format. If @c NULL, the default capture
2373 * configuration shall be used. Ordinarily, the default capture
2374 * configuration will result in no files being excluded from capture purely
2375 * based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2376 * ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2378 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2380 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2381 * discarded so that it appears to be in the same state as when this function
2384 * This function is implemented by calling wimlib_add_empty_image(), then
2385 * calling wimlib_update_image() with a single "add" command, so any error code
2386 * returned by wimlib_add_empty_image() may be returned, as well as any error
2387 * codes returned by wimlib_update_image() other than ones documented as only
2388 * being returned specifically by an update involving delete or rename commands.
2390 * If a progress function is registered with @p wim, it will receive the
2391 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2392 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2393 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2396 wimlib_add_image(WIMStruct *wim,
2397 const wimlib_tchar *source,
2398 const wimlib_tchar *name,
2399 const wimlib_tchar *config_file,
2403 * @ingroup G_modifying_wims
2405 * This function is equivalent to wimlib_add_image() except it allows for
2406 * multiple sources to be combined into a single WIM image. This is done by
2407 * specifying the @p sources and @p num_sources parameters instead of the @p
2408 * source parameter of wimlib_add_image(). The rest of the parameters are the
2409 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2410 * capture</b> for full details on how this mode works.
2412 * In addition to the error codes that wimlib_add_image() can return,
2413 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2414 * when trying to overlay a non-directory on a directory or when otherwise
2415 * trying to overlay multiple conflicting files to the same location in the WIM
2416 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2417 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2418 * was not exactly one capture source with the target being the root directory.
2419 * (In this respect, there is no advantage to using
2420 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2423 wimlib_add_image_multisource(WIMStruct *wim,
2424 const struct wimlib_capture_source *sources,
2426 const wimlib_tchar *name,
2427 const wimlib_tchar *config_file,
2431 * @ingroup G_modifying_wims
2433 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2434 * location @p wim_target_path within the specified @p image of the @p wim.
2436 * This just builds an appropriate ::wimlib_add_command and passes it to
2437 * wimlib_update_image().
2440 wimlib_add_tree(WIMStruct *wim, int image,
2441 const wimlib_tchar *fs_source_path,
2442 const wimlib_tchar *wim_target_path, int add_flags);
2445 * @ingroup G_creating_and_opening_wims
2447 * Creates a ::WIMStruct for a new WIM file.
2449 * This only creates an in-memory structure for a WIM that initially contains no
2450 * images. No on-disk file is created until wimlib_write() is called.
2453 * The type of compression to be used in the new WIM file, as one of the
2454 * ::wimlib_compression_type constants.
2456 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2457 * written to the memory location pointed to by this parameter. The
2458 * ::WIMStruct must be freed using using wimlib_free() when finished with
2460 * @return 0 on success; nonzero on error.
2461 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2462 * @p ctype was not a supported compression type.
2463 * @retval ::WIMLIB_ERR_NOMEM
2464 * Failed to allocate needed memory.
2467 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2470 * @ingroup G_modifying_wims
2472 * Deletes an image, or all images, from a WIM file.
2474 * All streams referenced by the image(s) being deleted are removed from the
2475 * lookup table of the WIM if they are not referenced by any other images in the
2478 * Please note that @b no changes are committed to the underlying WIM file (if
2479 * any) until wimlib_write() or wimlib_overwrite() is called.
2482 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2485 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2487 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2488 * to be left unmodified only if @p image specified a single image. If instead
2489 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2490 * possible for some but not all of the images to have been deleted when a
2491 * failure status is returned.
2493 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2494 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2495 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2496 * The WIM file is considered read-only because of any of the reasons
2497 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2500 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2501 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2502 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2503 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2504 * different reasons) to read the metadata resource for an image that needed to
2508 wimlib_delete_image(WIMStruct *wim, int image);
2511 * @ingroup G_modifying_wims
2513 * Delete the @p path from the specified @p image of the @p wim.
2515 * This just builds an appropriate ::wimlib_delete_command and passes it to
2516 * wimlib_update_image().
2519 wimlib_delete_path(WIMStruct *wim, int image,
2520 const wimlib_tchar *path, int delete_flags);
2523 * @ingroup G_modifying_wims
2525 * Exports an image, or all the images, from a WIM file, into another WIM file.
2527 * The destination image is made to share the same dentry tree and security data
2528 * structure as the source image. This places some restrictions on additional
2529 * functions that may be called. For example, you may not call wimlib_free() on
2530 * @p src_wim before calling wimlib_write() or wimlib_overwrite() on @p dest_wim
2531 * because @p dest_wim will have references back to @p src_wim.
2533 * If this function fails, all changes to @p dest_wim are rolled back.
2535 * Please note that no changes are committed to the underlying WIM file of @p
2536 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2539 * The WIM from which to export the images, specified as a pointer to the
2540 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2541 * split WIM. In the case of a WIM file that is not standalone, this
2542 * ::WIMStruct must have had any needed external resources previously
2543 * referenced using wimlib_reference_resources() or
2544 * wimlib_reference_resource_files().
2546 * The image to export from @p src_wim, as either a 1-based image index to
2547 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2549 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2552 * For single-image exports, the name to give the exported image in @p
2553 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2554 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2555 * that case, the names are all taken from @p src_wim. This parameter is
2556 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2557 * @param dest_description
2558 * For single-image exports, the description to give the exported image in
2559 * the new WIM file. If left @c NULL, the description from @p src_wim is
2560 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2561 * NULL; in that case, the description are all taken from @p src_wim. This
2562 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2563 * @param export_flags
2564 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2566 * @return 0 on success; nonzero on error.
2567 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2568 * One or more of the names being given to an exported image was already in
2569 * use in the destination WIM.
2570 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2571 * @p src_image does not exist in @p src_wim and was not
2572 * ::WIMLIB_ALL_IMAGES.
2573 * @retval ::WIMLIB_ERR_INVALID_PARAM
2574 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2575 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2577 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2578 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2579 * example, one of them was a non-first part of a split WIM.
2580 * @retval ::WIMLIB_ERR_NOMEM
2581 * Failed to allocate needed memory.
2582 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2583 * A resource that needed to be exported could not be found in either the
2584 * source or destination WIMs. This error can occur if, for example, @p
2585 * src_wim is part of a split WIM but needed resources from the other split
2586 * WIM parts were not referenced with wimlib_reference_resources() or
2587 * wimlib_reference_resource_files() before the call to
2588 * wimlib_export_image().
2589 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2590 * @p dest_wim is considered read-only because of any of the reasons
2591 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2594 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2595 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2596 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2597 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2598 * different reasons) to read the metadata resource for an image in @p src_wim
2599 * that needed to be exported.
2602 wimlib_export_image(WIMStruct *src_wim, int src_image,
2603 WIMStruct *dest_wim,
2604 const wimlib_tchar *dest_name,
2605 const wimlib_tchar *dest_description,
2609 * @ingroup G_extracting_wims
2611 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2614 * The exact behavior of how wimlib extracts files from a WIM image is
2615 * controllable by the @p extract_flags parameter, but there also are
2616 * differences depending on the platform (UNIX-like vs Windows). See the manual
2617 * page for <b>wimlib-imagex apply</b> for more information, including about the
2618 * special "NTFS volume extraction mode" entered by providing
2619 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2622 * The WIM from which to extract the image(s), specified as a pointer to
2623 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2624 * of a split WIM. In the case of a WIM file that is not standalone, this
2625 * ::WIMStruct must have had any needed external resources previously
2626 * referenced using wimlib_reference_resources() or
2627 * wimlib_reference_resource_files().
2629 * The image to extract, specified as either the 1-based index of a single
2630 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2631 * to be extracted. ::WIMLIB_ALL_IMAGES cannot be used if
2632 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2634 * Directory to extract the WIM image(s) to; or, with
2635 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2636 * the unmounted NTFS volume to which to extract the image.
2637 * @param extract_flags
2638 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2640 * @return 0 on success; nonzero on error.
2641 * @retval ::WIMLIB_ERR_DECOMPRESSION
2642 * Failed to decompress data contained in the WIM.
2643 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2644 * The metadata for one of the images to extract was invalid.
2645 * @retval ::WIMLIB_ERR_INVALID_PARAM
2646 * The extraction flags were invalid; more details may be found in the
2647 * documentation for the specific extraction flags that were specified. Or
2648 * @p target was @c NULL or the empty string, or @p wim was @c NULL.
2649 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2650 * The SHA1 message digest of an extracted stream did not match the SHA1
2651 * message digest given in the WIM.
2652 * @retval ::WIMLIB_ERR_LINK
2653 * Failed to create a symbolic link or a hard link.
2654 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2655 * The metadata resource for one of the images to extract was not found.
2656 * This can happen if @p wim represents a non-first part of a split WIM.
2657 * @retval ::WIMLIB_ERR_MKDIR
2658 * Failed create a directory.
2659 * @retval ::WIMLIB_ERR_NOMEM
2660 * Failed to allocate needed memory.
2661 * @retval ::WIMLIB_ERR_OPEN
2662 * Could not create a file, or failed to open an already-extracted file.
2663 * @retval ::WIMLIB_ERR_READ
2664 * Failed to read data from the WIM.
2665 * @retval ::WIMLIB_ERR_READLINK
2666 * Failed to determine the target of a symbolic link in the WIM.
2667 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2668 * Failed to fix the target of an absolute symbolic link (e.g. if the
2669 * target would have exceeded the maximum allowed length). (Only if
2670 * reparse data was supported by the extraction mode and
2671 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2673 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2674 * One of the files or directories that needed to be extracted referenced a
2675 * stream not present in the WIM's lookup table (or in any of the lookup
2676 * tables of the split WIM parts).
2677 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2678 * Failed to set attributes on a file.
2679 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2680 * Failed to set reparse data on a file (only if reparse data was supported
2681 * by the extraction mode).
2682 * @retval ::WIMLIB_ERR_SET_SECURITY
2683 * Failed to set security descriptor on a file
2684 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2686 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2687 * Failed to set the short name of a file (only if
2688 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2689 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2690 * Failed to set timestamps on a file (only if
2691 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2692 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2693 * Unexpected end-of-file occurred when reading data from the WIM.
2694 * @retval ::WIMLIB_ERR_UNSUPPORTED
2695 * A requested extraction flag, or the data or metadata that must be
2696 * extracted to support it, is unsupported in the build and configuration
2697 * of wimlib, or on the current platform or extraction mode or target
2698 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2699 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2700 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2701 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2702 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2703 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2704 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2705 * image contains one or more files with short names, but extracting short
2706 * names is not supported --- on Windows, this occurs if the target volume
2707 * does not support short names, while on non-Windows, this occurs if
2708 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2709 * @retval ::WIMLIB_ERR_WIMBOOT
2710 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2711 * there was a problem creating WIMBoot pointer files.
2712 * @retval ::WIMLIB_ERR_WRITE
2713 * Failed to write data to a file being extracted.
2715 * If a progress function is registered with @p wim, then as each image is
2716 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2717 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE messages, then zero
2718 * or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then zero or more
2719 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, then
2720 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2723 wimlib_extract_image(WIMStruct *wim, int image,
2724 const wimlib_tchar *target, int extract_flags);
2727 * @ingroup G_extracting_wims
2729 * Since wimlib v1.5.0: Extract one image from a pipe on which a pipable WIM is
2732 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2733 * about pipable WIMs.
2735 * This function operates in a special way to read the WIM fully sequentially.
2736 * As a result, there is no ::WIMStruct is made visible to library users, and
2737 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2738 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2739 * seekable file, not a pipe.)
2742 * File descriptor, which may be a pipe, opened for reading and positioned
2743 * at the start of the pipable WIM.
2744 * @param image_num_or_name
2745 * String that specifies the 1-based index or name of the image to extract.
2746 * It is translated to an image index using the same rules that
2747 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2748 * only a single image (not all images) can be specified. Alternatively,
2749 * specify @p NULL here to use the first image in the WIM if it contains
2750 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2752 * Same as the corresponding parameter to wimlib_extract_image().
2753 * @param extract_flags
2754 * Same as the corresponding parameter to wimlib_extract_image().
2756 * @return 0 on success; nonzero on error. The possible error codes include
2757 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2760 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2761 * Data read from the pipable WIM was invalid.
2762 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2763 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2766 wimlib_extract_image_from_pipe(int pipe_fd,
2767 const wimlib_tchar *image_num_or_name,
2768 const wimlib_tchar *target, int extract_flags);
2771 * @ingroup G_extracting_wims
2773 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2774 * function. The progress function will be used while extracting the WIM image
2775 * and will receive the normal extraction progress messages, such as
2776 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2777 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2780 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2781 const wimlib_tchar *image_num_or_name,
2782 const wimlib_tchar *target,
2784 wimlib_progress_func_t progfunc,
2788 * @ingroup G_extracting_wims
2790 * Since wimlib v1.6.0: Similar to wimlib_extract_paths(), but the paths to
2791 * extract from the WIM image are specified in the ASCII, UTF-8, or UTF-16LE
2792 * text file named by @p path_list_file which itself contains the list of paths
2793 * to use, one per line. Leading and trailing whitespace, and otherwise empty
2794 * lines and lines beginning with the ';' character are ignored. No quotes are
2795 * needed as paths are otherwise delimited by the newline character.
2797 * The error codes are the same as those returned by wimlib_extract_paths(),
2798 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2799 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2800 * ::WIMLIB_ERR_READ).
2803 wimlib_extract_pathlist(WIMStruct *wim, int image,
2804 const wimlib_tchar *target,
2805 const wimlib_tchar *path_list_file,
2809 * @ingroup G_extracting_wims
2811 * Since wimlib v1.6.0: Extract zero or more paths (files or directory trees)
2812 * from the specified WIM image.
2814 * By default, each path will be extracted to a corresponding subdirectory of
2815 * the target based on its location in the WIM image. For example, if one of
2816 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2817 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
2818 * can be changed by providing the flag
2819 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2820 * or directory tree to be placed directly in the target directory --- so the
2821 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2823 * Symbolic links will not be dereferenced when paths in the WIM image are
2827 * WIM from which to extract the paths, specified as a pointer to the
2828 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2829 * split WIM. In the case of a WIM file that is not standalone, this
2830 * ::WIMStruct must have had any needed external resources previously
2831 * referenced using wimlib_reference_resources() or
2832 * wimlib_reference_resource_files().
2834 * 1-based index of the WIM image from which to extract the paths.
2836 * Array of paths to extract. Each element must be the absolute path to a
2837 * file or directory within the WIM image. Separators may be either
2838 * forwards or backwards slashes, and leading path separators are optional.
2839 * The paths will be interpreted either case-sensitively (UNIX default) or
2840 * case-insensitively (Windows default); this can be changed by
2841 * wimlib_global_init().
2843 * By default, the characters @c * and @c ? are interpreted literally.
2844 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2847 * By default, if any paths to extract do not exist, the error code
2848 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
2849 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2851 * Number of paths specified in @p paths.
2853 * Directory to which to extract the paths; or with
2854 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2855 * unmounted NTFS volume to which to extract the paths. Unlike the @p
2856 * paths being extracted, the @p target must be native path. On UNIX-like
2857 * systems it may not contain backslashes, for example.
2858 * @param extract_flags
2859 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2861 * @return 0 on success; nonzero on error. Most of the error codes are the same
2862 * as those returned by wimlib_extract_image(). Below, some of the error codes
2863 * returned in situations specific to path-mode extraction are documented:
2865 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2866 * @p image was ::WIMLIB_ALL_IMAGES or was otherwise not a valid single
2868 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2869 * One of the paths to extract did not exist in the WIM image. This error
2870 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2871 * specified in @p extract_flags, or if both
2872 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2873 * were specified in @p extract_flags.
2874 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2875 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2876 * one of the paths to extract did not name a regular file.
2878 * If a progress function is registered with @p wim, it will receive
2879 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. Note that because the extraction code
2880 * is stream-based and not file-based, there is no way to get information about
2881 * which path is currently being extracted, but based on byte count you can
2882 * still calculate an approximate percentage complete for the extraction overall
2883 * which may be all you really need anyway.
2886 wimlib_extract_paths(WIMStruct *wim,
2888 const wimlib_tchar *target,
2889 const wimlib_tchar * const *paths,
2894 * @ingroup G_wim_information
2896 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2897 * includes a string of XML that describes the images contained in the WIM.
2899 * See wimlib_get_xml_data() to read the XML data into memory instead.
2902 * Pointer to the ::WIMStruct to query. This need not represent a
2903 * standalone WIM (e.g. it could represent part of a split WIM).
2905 * @c stdout, or a FILE* opened for writing, to extract the data to.
2907 * @return 0 on success; nonzero on error.
2908 * @retval ::WIMLIB_ERR_INVALID_PARAM
2909 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2910 * @retval ::WIMLIB_ERR_NOMEM
2911 * Failed to allocate needed memory.
2912 * @retval ::WIMLIB_ERR_READ
2913 * Error reading the XML data from the WIM file.
2914 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2915 * Error reading the XML data from the WIM file.
2916 * @retval ::WIMLIB_ERR_WRITE
2917 * Failed to completely write the XML data to @p fp.
2920 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2923 * @ingroup G_general
2925 * Frees all memory allocated for a WIMStruct and closes all files associated
2929 * Pointer to the ::WIMStruct to free.
2931 * @return This function has no return value.
2934 wimlib_free(WIMStruct *wim);
2937 * @ingroup G_general
2939 * Converts a ::wimlib_compression_type value into a string.
2942 * The ::wimlib_compression_type value to convert.
2945 * A statically allocated string naming the compression algorithm,
2946 * such as "None", "LZX", "XPRESS", or "Invalid".
2948 extern const wimlib_tchar *
2949 wimlib_get_compression_type_string(int ctype);
2952 * @ingroup G_general
2954 * Converts an error code into a string describing it.
2957 * The error code returned by one of wimlib's functions.
2960 * Pointer to a statically allocated string describing the error code. If
2961 * the error code is for some reason not recognized by the library, the
2962 * string will be "Unknown error".
2964 extern const wimlib_tchar *
2965 wimlib_get_error_string(enum wimlib_error_code code);
2968 * @ingroup G_wim_information
2970 * Returns the description of the specified image.
2973 * Pointer to the ::WIMStruct to query. This need not represent a
2974 * standalone WIM (e.g. it could represent part of a split WIM).
2976 * The number of the image, numbered starting at 1.
2979 * The description of the image, or @c NULL if there is no such image, or
2980 * @c NULL if the specified image has no description. The description
2981 * string is in library-internal memory and may not be modified or freed;
2982 * in addition, the string will become invalid if the description of the
2983 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2985 extern const wimlib_tchar *
2986 wimlib_get_image_description(const WIMStruct *wim, int image);
2989 * @ingroup G_wim_information
2991 * Returns the name of the specified image.
2994 * Pointer to the ::WIMStruct to query. This need not represent a
2995 * standalone WIM (e.g. it could represent part of a split WIM).
2997 * The number of the image, numbered starting at 1.
3000 * The name of the image, or @c NULL if there is no such image, or an empty
3001 * string if the image is unnamed. The name string is in
3002 * library-internal memory and may not be modified or freed; in addition,
3003 * the string will become invalid if the name of the image is changed, the
3004 * image is deleted, or the ::WIMStruct is destroyed.
3006 extern const wimlib_tchar *
3007 wimlib_get_image_name(const WIMStruct *wim, int image);
3010 * @ingroup G_general
3012 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
3013 * the major version, the next 10 bits contain the minor version, and the low 10
3014 * bits contain the patch version.
3016 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
3017 * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
3018 * corresponding header file.
3021 wimlib_get_version(void);
3024 * @ingroup G_wim_information
3026 * Get basic information about a WIM file.
3029 * Pointer to the ::WIMStruct to query. This need not represent a
3030 * standalone WIM (e.g. it could represent part of a split WIM).
3032 * A ::wimlib_wim_info structure that will be filled in with information
3033 * about the WIM file.
3038 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
3041 * @ingroup G_wim_information
3043 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
3044 * includes a string of XML that describes the images contained in the WIM.
3046 * See wimlib_extract_xml_data() to extract the XML data to a file stream
3050 * Pointer to the ::WIMStruct to query. This need not represent a
3051 * standalone WIM (e.g. it could represent part of a split WIM).
3053 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
3054 * XML data is written to this location.
3055 * @param bufsize_ret
3056 * The size of the XML data in bytes is written to this location.
3058 * @return 0 on success; nonzero on error.
3059 * @retval ::WIMLIB_ERR_INVALID_PARAM
3060 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
3061 * @p buf_ret or @p bufsize_ret was @c NULL.
3062 * @retval ::WIMLIB_ERR_NOMEM
3063 * @retval ::WIMLIB_ERR_READ
3064 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3065 * Failed to read the XML data from the WIM.
3068 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
3071 * @ingroup G_general
3073 * Initialization function for wimlib. Call before using any other wimlib
3074 * function except wimlib_set_print_errors(). If not done manually, this
3075 * function will be called automatically with @p init_flags set to
3076 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
3077 * after it has already successfully run.
3080 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
3082 * @return 0 on success; nonzero on failure. Currently, only the following
3083 * error code is defined:
3085 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
3086 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
3087 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
3088 * init_flags, but the corresponding privileges could not be acquired.
3091 wimlib_global_init(int init_flags);
3094 * @ingroup G_general
3096 * Cleanup function for wimlib. You are not required to call this function, but
3097 * it will release any global resources allocated by the library.
3100 wimlib_global_cleanup(void);
3103 * @ingroup G_wim_information
3105 * Determines if an image name is already used by some image in the WIM.
3108 * Pointer to the ::WIMStruct to query. This need not represent a
3109 * standalone WIM (e.g. it could represent part of a split WIM).
3111 * The name to check.
3114 * @c true if there is already an image in @p wim named @p name; @c false
3115 * if there is no image named @p name in @p wim. If @p name is @c NULL or
3116 * the empty string, @c false is returned.
3119 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
3122 * @ingroup G_wim_information
3124 * Iterate through a file or directory tree in the WIM image. By specifying
3125 * appropriate flags and a callback function, you can get the attributes of a
3126 * file in the WIM, get a directory listing, or even get a listing of the entire
3130 * The WIM containing the image(s) over which to iterate, specified as a
3131 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
3132 * or part 1 of a split WIM. In the case of a WIM file that is not
3133 * standalone, this ::WIMStruct should have had any needed external
3134 * resources previously referenced using wimlib_reference_resources() or
3135 * wimlib_reference_resource_files(). If not, see
3136 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
3137 * the behavior when resources are missing.
3140 * The 1-based number of the image in @p wim that contains the files or
3141 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
3142 * iteration on all images in the WIM.
3145 * Path in the WIM image at which to do the iteration.
3148 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3151 * A callback function that will receive each directory entry.
3154 * An extra parameter that will always be passed to the callback function
3157 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3158 * first nonzero value that was returned from @p cb. However, additional error
3159 * codes may be returned, including the following:
3161 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3162 * @p path did not exist in the WIM image.
3163 * @retval ::WIMLIB_ERR_NOMEM
3164 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
3166 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3167 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3168 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3169 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3170 * different reasons) to read the metadata resource for an image over which
3171 * iteration needed to be done.
3174 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3176 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3179 * @ingroup G_wim_information
3181 * Iterate through the lookup table of a WIM file. This can be used to directly
3182 * get a listing of the unique resources contained in a WIM file over all
3183 * images. Both file resources and metadata resources are included. However,
3184 * only resources actually included in the file represented by @a wim, plus
3185 * explicitly referenced external resources (via wimlib_reference_resources() or
3186 * wimlib_reference_resource_files()) are included in the iteration. For
3187 * example, if @p wim represents just one part of a split WIM, then only
3188 * resources in that part will be included, unless other resources were
3189 * explicitly referenced.
3192 * Pointer to the ::WIMStruct to query. This need not represent a
3193 * standalone WIM (e.g. it could represent part of a split WIM).
3196 * Reserved; set to 0.
3199 * A callback function that will receive each resource.
3202 * An extra parameter that will always be passed to the callback function
3205 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3206 * that was returned from @p cb.
3209 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3210 wimlib_iterate_lookup_table_callback_t cb,
3214 * @ingroup G_nonstandalone_wims
3216 * Joins a split WIM into a stand-alone one-part WIM.
3219 * An array of strings that gives the filenames of all parts of the split
3220 * WIM. No specific order is required, but all parts must be included with
3223 * Number of filenames in @p swms.
3224 * @param swm_open_flags
3225 * Open flags for the split WIM parts (e.g.
3226 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3227 * @param wim_write_flags
3228 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3229 * be used to write the joined WIM.
3230 * @param output_path
3231 * The path to write the joined WIM file to.
3233 * @return 0 on success; nonzero on error. This function may return most error
3234 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
3235 * as the following error code:
3237 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3238 * The split WIMs do not form a valid WIM because they do not include all
3239 * the parts of the original WIM, there are duplicate parts, or not all the
3240 * parts have the same GUID and compression type.
3242 * Note: wimlib is generalized enough that this function is not actually needed
3243 * to join a split WIM; instead, you could open the first part of the split WIM,
3244 * then reference the other parts with wimlib_reference_resource_files(), then
3245 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3246 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3250 wimlib_join(const wimlib_tchar * const *swms,
3252 const wimlib_tchar *output_path,
3254 int wim_write_flags);
3257 * @ingroup G_nonstandalone_wims
3259 * Same as wimlib_join(), but allows specifying a progress function. The
3260 * progress function will receive the write progress messages, such as
3261 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3262 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3263 * swm_open_flags, the progress function will receive a series of
3264 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3268 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3270 const wimlib_tchar *output_path,
3272 int wim_write_flags,
3273 wimlib_progress_func_t progfunc,
3278 * @ingroup G_mounting_wim_images
3280 * Mounts an image from a WIM file on a directory read-only or read-write.
3283 * Pointer to the ::WIMStruct containing the image to be mounted.
3285 * The 1-based index of the image to mount.
3287 * The path to an existing empty directory on which to mount the WIM image.
3288 * @param mount_flags
3289 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3290 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3292 * @param staging_dir
3293 * If non-NULL, the name of a directory in which a temporary directory for
3294 * storing modified or added files will be created. Ignored if
3295 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3296 * left @c NULL, the staging directory is created in the same directory as
3297 * the WIM file that @p wim was originally read from. The staging
3298 * directory is deleted when the image is unmounted.
3300 * @return 0 on success; nonzero on error. The possible error codes include:
3302 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3303 * An image from the WIM file is already mounted read-write, or another
3304 * process is currently appending data to the WIM file.
3305 * @retval ::WIMLIB_ERR_FUSE
3306 * A non-zero status code was returned by @c fuse_main().
3307 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3308 * @p image does not specify an existing, single image in @p wim.
3309 * @retval ::WIMLIB_ERR_INVALID_PARAM
3310 * @p wim was @c NULL; or @p dir was NULL or the empty string; or an
3311 * unrecognized flag was specified in @p mount_flags; or the WIM image has
3312 * already been modified in memory (e.g. by wimlib_update_image()).
3313 * @retval ::WIMLIB_ERR_MKDIR
3314 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3315 * staging directory could not be created.
3316 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3317 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3318 * WIM file is considered read-only because of any of the reasons mentioned
3319 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3320 * @retval ::WIMLIB_ERR_UNSUPPORTED
3321 * Mounting is not supported, either because the platform is Windows, or
3322 * because the platform is UNIX-like and wimlib was compiled using
3323 * <code>--without-fuse</code>.
3325 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3326 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3327 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3328 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3329 * different reasons) to read the metadata resource for the image to mount.
3331 * The ability to mount WIM image is implemented using FUSE (Filesystem in
3332 * UserSpacE). Depending on how FUSE is set up on your system, this function
3333 * may work as normal users in addition to the root user.
3335 * Mounting WIM images is not supported if wimlib was configured
3336 * <code>--without-fuse</code>. This includes Windows builds of wimlib;
3337 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3339 * Calling this function daemonizes the process, unless
3340 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3342 * It is safe to mount multiple images from the same underlying WIM file
3343 * read-only at the same time, but only if different ::WIMStruct's are used. It
3344 * is @b not safe to mount multiple images from the same WIM file read-write at
3347 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3348 * different process.
3351 wimlib_mount_image(WIMStruct *wim,
3353 const wimlib_tchar *dir,
3355 const wimlib_tchar *staging_dir);
3358 * @ingroup G_creating_and_opening_wims
3360 * Opens a WIM file and creates a ::WIMStruct for it.
3363 * The path to the WIM file to open.
3366 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3369 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3370 * is written to the memory location pointed to by this parameter. The
3371 * ::WIMStruct must be freed using using wimlib_free() when finished with
3374 * @return 0 on success; nonzero on error.
3375 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3376 * The number of metadata resources found in the WIM did not match the
3377 * image count specified in the WIM header, or the number of <IMAGE>
3378 * elements in the XML data of the WIM did not match the image count
3379 * specified in the WIM header.
3380 * @retval ::WIMLIB_ERR_INTEGRITY
3381 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3382 * the WIM contained an integrity table, but the SHA1 message digest for a
3383 * chunk of the WIM did not match the corresponding value in the integrity
3385 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3386 * The library did not recognize the compression chunk size of the WIM as
3387 * valid for its compression type.
3388 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3389 * The library did not recognize the compression type of the WIM.
3390 * @retval ::WIMLIB_ERR_INVALID_HEADER
3391 * The header of the WIM was otherwise invalid.
3392 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3393 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3394 * the WIM contained an integrity table, but the integrity table was
3396 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3397 * The lookup table of the WIM was invalid.
3398 * @retval ::WIMLIB_ERR_INVALID_PARAM
3399 * @p wim_ret was @c NULL.
3400 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3401 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3402 * specified in @p open_flags.
3403 * @retval ::WIMLIB_ERR_NOMEM
3404 * Failed to allocated needed memory.
3405 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3406 * The file did not begin with the magic characters that identify a WIM
3408 * @retval ::WIMLIB_ERR_OPEN
3409 * Failed to open the file for reading.
3410 * @retval ::WIMLIB_ERR_READ
3411 * Failed to read data from the file.
3412 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3413 * Unexpected end-of-file while reading data from the file.
3414 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3415 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3416 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3417 * The WIM cannot be opened because it contains encrypted segments. (It
3418 * may be a Windows 8 "ESD" file.)
3419 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3420 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3421 * considered read-only because of any of the reasons mentioned in the
3422 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3423 * @retval ::WIMLIB_ERR_XML
3424 * The XML data of the WIM was invalid.
3427 wimlib_open_wim(const wimlib_tchar *wim_file,
3429 WIMStruct **wim_ret);
3432 * @ingroup G_creating_and_opening_wims
3434 * Same as wimlib_open_wim(), but allows specifying a progress function and
3435 * progress context. If successful, the progress function will be registered in
3436 * the newly open ::WIMStruct, as if by an automatic call to
3437 * wimlib_register_progress_function(). In addition, if
3438 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, the
3439 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3440 * messages while checking the WIM's integrity.
3443 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3445 WIMStruct **wim_ret,
3446 wimlib_progress_func_t progfunc,
3450 * @ingroup G_writing_and_overwriting_wims
3452 * Overwrites the file that the WIM was originally read from, with changes made.
3453 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3454 * rather than wimlib_create_new_wim().
3456 * There are two ways that a WIM may be overwritten. The first is to do a full
3457 * rebuild. In this mode, the new WIM is written to a temporary file and then
3458 * renamed to the original file after it is has been completely written. The
3459 * temporary file is made in the same directory as the original WIM file. A
3460 * full rebuild may take a while, but it will save space by producing a WIM with
3463 * The second way to overwrite a WIM is by appending to the end of it and
3464 * overwriting the header. This can be much faster than a full rebuild, but the
3465 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3466 * begins with writing any new file resources *after* everything in the old WIM,
3467 * even though this will leave a hole where the old lookup table, XML data, and
3468 * integrity were. This is done so that the WIM remains valid even if the
3469 * operation is aborted mid-write. The WIM header is only overwritten at the
3470 * very last moment, and up until that point the WIM will be seen as the old
3473 * By default, wimlib_overwrite() does the append-style overwrite described
3474 * above, unless resources in the WIM are arranged in an unusual way or if
3475 * images have been deleted from the WIM. Use the flag
3476 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3477 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3478 * images have been deleted from the WIM.
3480 * If this function completes successfully, no more functions should be called
3481 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
3482 * the WIM file anew.
3485 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3486 * been in-memory changes made to it, which are then reflected in the
3488 * @param write_flags
3489 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3490 * @param num_threads
3491 * Number of threads to use for compression (see wimlib_write()).
3493 * @return 0 on success; nonzero on error. This function may return most error
3494 * codes returned by wimlib_write() as well as the following error codes:
3496 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3497 * The WIM was going to be modified in-place (with no temporary file), but
3498 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3499 * because another thread or process has mounted an image from the WIM
3500 * read-write or is currently modifying the WIM in-place.
3501 * @retval ::WIMLIB_ERR_NO_FILENAME
3502 * @p wim corresponds to a ::WIMStruct created with wimlib_create_new_wim()
3503 * rather than a WIM read with wimlib_open_wim().
3504 * @retval ::WIMLIB_ERR_RENAME
3505 * The temporary file that the WIM was written to could not be renamed to
3506 * the original filename of @p wim.
3507 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3508 * The WIM file is considered read-only because of any of the reasons
3509 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3512 * If a progress function is registered with @p wim, it will receive the
3513 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3514 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3515 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3518 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3521 * @ingroup G_wim_information
3523 * Prints information about one image, or all images, contained in a WIM.
3526 * Pointer to the ::WIMStruct to query. This need not represent a
3527 * standalone WIM (e.g. it could represent part of a split WIM).
3529 * The image about which to print information. Can be the number of an
3530 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3533 * @return This function has no return value. No error checking is done when
3534 * printing the information. If @p image is invalid, an error message is
3538 wimlib_print_available_images(const WIMStruct *wim, int image);
3541 * @ingroup G_wim_information
3543 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3544 * in a way that can be accessed programatically.
3547 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3550 * @ingroup G_nonstandalone_wims
3552 * Reference resources from other WIM files or split WIM parts. This function
3553 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3554 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3555 * from other files, before calling a function such as wimlib_extract_image()
3556 * that requires the resources to be present.
3559 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3560 * necessarily "standalone". In the case of split WIMs, this should be the
3561 * first part, since only the first part contains the metadata resources.
3562 * In the case of delta WIMs, this should be the delta WIM rather than the
3563 * WIM on which it is based.
3564 * @param resource_wimfiles_or_globs
3565 * Array of paths to WIM files and/or split WIM parts to reference.
3566 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3567 * ref_flags, these are treated as globs rather than literal paths. That
3568 * is, using this function you can specify zero or more globs, each of
3569 * which expands to one or more literal paths.
3571 * Number of entries in @p resource_wimfiles_or_globs.
3573 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3574 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3576 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3577 * pass to internal calls to wimlib_open_wim() on the reference files.
3579 * @return 0 on success; nonzero on error.
3581 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3582 * One of the specified globs did not match any paths (only with both
3583 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3584 * specified in @p ref_flags).
3585 * @retval ::WIMLIB_ERR_NOMEM
3586 * Failed to allocate memory.
3587 * @retval ::WIMLIB_ERR_READ
3588 * I/O or permissions error while processing a file glob.
3590 * This function can additionally return most values that can be returned by
3591 * wimlib_open_wim().
3594 wimlib_reference_resource_files(WIMStruct *wim,
3595 const wimlib_tchar * const *resource_wimfiles_or_globs,
3601 * @ingroup G_nonstandalone_wims
3603 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3604 * where the caller must open the ::WIMStruct for each referenced file itself.
3607 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3608 * necessarily "standalone". In the case of split WIMs, this should be the
3609 * first part, since only the first part contains the metadata resources.
3610 * @param resource_wims
3611 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3612 * split WIM parts to reference.
3613 * @param num_resource_wims
3614 * Number of entries in @p resource_wims.
3616 * Currently ignored (set to 0).
3618 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3619 * @p resource_wims are referenced internally by @p wim and must not be freed
3620 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3621 * been freed with wimlib_free(), or immediately before freeing @p wim with
3624 * @retval ::WIMLIB_ERR_INVALID_PARAM
3625 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3626 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3627 * @retval ::WIMLIB_ERR_NOMEM
3628 * Failed to allocate memory.
3631 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3632 unsigned num_resource_wims, int ref_flags);
3635 * @ingroup G_modifying_wims
3637 * Declares that a newly added image is mostly the same as a prior image, but
3638 * captured at a later point in time, possibly with some modifications in the
3639 * intervening time. This is designed to be used in incremental backups of the
3640 * same filesystem or directory tree.
3642 * This function compares the metadata of the directory tree of the newly added
3643 * image against that of the old image. Any files that are present in both the
3644 * newly added image and the old image and have timestamps that indicate they
3645 * haven't been modified are deemed not to have been modified and have their
3646 * SHA1 message digest copied from the old image. Because of this and because
3647 * WIM uses single-instance streams, such files need not be read from the
3648 * filesystem when the WIM is being written or overwritten. Note that these
3649 * unchanged files will still be "archived" and will be logically present in the
3650 * new image; the optimization is that they don't need to actually be read from
3651 * the filesystem because the WIM already contains them.
3653 * This function is provided to optimize incremental backups. The resulting WIM
3654 * file will still be the same regardless of whether this function is called.
3655 * (This is, however, assuming that timestamps have not been manipulated or
3656 * unmaintained as to trick this function into thinking a file has not been
3657 * modified when really it has. To partly guard against such cases, other
3658 * metadata such as file sizes will be checked as well.)
3660 * This function must be called after adding the new image (e.g. with
3661 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3662 * wimlib_overwrite()).
3665 * Pointer to the ::WIMStruct for a WIM.
3667 * 1-based index in the WIM of the newly added image. This image can have
3668 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3669 * wimlib_add_empty_image() followed by wimlib_update_image().
3670 * @param template_wim
3671 * The ::WIMStruct for the WIM containing the template image. This can be
3672 * the same as @p wim, or it can be a different ::WIMStruct.
3673 * @param template_image
3674 * 1-based index in the WIM of a template image that reflects a prior state
3675 * of the directory tree being captured.
3677 * Reserved; must be 0.
3679 * @return 0 on success; nonzero on error.
3681 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3682 * @p new_image and/or @p template_image were not a valid image indices in
3684 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3685 * The specified ::WIMStruct did not actually contain the metadata resource
3686 * for the new or template image; for example, it was a non-first part of a
3688 * @retval ::WIMLIB_ERR_NOMEM
3689 * Failed to allocate needed memory.
3690 * @retval ::WIMLIB_ERR_INVALID_PARAM
3691 * @p new_image was equal to @p template_image, or @p new_image specified
3692 * an image that had not been modified since opening the WIM.
3694 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3695 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3696 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3697 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3698 * different reasons) to read the metadata resource for the template image.
3701 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3702 WIMStruct *template_wim, int template_image,
3706 * @ingroup G_general
3708 * Registers a progress function with a ::WIMStruct.
3711 * The ::WIMStruct for which to register the progress function.
3713 * Pointer to the progress function to register. If the WIM already has a
3714 * progress function registered, it will be replaced with this one. If @p
3715 * NULL, the current progress function (if any) will be unregistered.
3717 * The value which will be passed as the third argument to calls to @p
3721 wimlib_register_progress_function(WIMStruct *wim,
3722 wimlib_progress_func_t progfunc,
3726 * @ingroup G_modifying_wims
3728 * Rename the @p source_path to the @p dest_path in the specified @p image of
3731 * This just builds an appropriate ::wimlib_rename_command and passes it to
3732 * wimlib_update_image().
3735 wimlib_rename_path(WIMStruct *wim, int image,
3736 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3739 * @ingroup G_wim_information
3741 * Translates a string specifying the name or number of an image in the WIM into
3742 * the number of the image. The images are numbered starting at 1.
3745 * Pointer to the ::WIMStruct for a WIM.
3746 * @param image_name_or_num
3747 * A string specifying the name or number of an image in the WIM. If it
3748 * parses to a positive integer, this integer is taken to specify the
3749 * number of the image, indexed starting at 1. Otherwise, it is taken to
3750 * be the name of an image, as given in the XML data for the WIM file. It
3751 * also may be the keyword "all" or the string "*", both of which will
3752 * resolve to ::WIMLIB_ALL_IMAGES.
3754 * There is no way to search for an image actually named "all", "*", or an
3755 * integer number, or an image that has no name. However, you can use
3756 * wimlib_get_image_name() to get the name of any image.
3759 * If the string resolved to a single existing image, the number of that
3760 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3761 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3762 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3763 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3764 * images in @p wim has no name.
3767 wimlib_resolve_image(WIMStruct *wim,
3768 const wimlib_tchar *image_name_or_num);
3771 * @ingroup G_general
3773 * Sets the file to which the library will print error and warning messages.
3775 * This version of the function takes a C library <c>FILE *</c> opened for
3776 * writing (or appending). Use wimlib_set_error_file_by_name() to specify the
3777 * file by name instead.
3779 * This also enables error messages, as if by a call to
3780 * wimlib_set_print_errors(true).
3782 * @return 0 on success; nonzero on error.
3783 * @retval ::WIMLIB_ERR_UNSUPPORTED
3784 * wimlib was compiled using the <c>--without-error-messages</c> option.
3787 wimlib_set_error_file(FILE *fp);
3790 * @ingroup G_general
3792 * Sets the path to the file to which the library will print error and warning
3793 * messages. The library will open this file for appending.
3795 * This also enables error messages, as if by a call to
3796 * wimlib_set_print_errors(true).
3798 * @return 0 on success; nonzero on error.
3799 * @retval ::WIMLIB_ERR_OPEN
3800 * The file named by @p path could not be opened for appending.
3801 * @retval ::WIMLIB_ERR_UNSUPPORTED
3802 * wimlib was compiled using the <c>--without-error-messages</c> option.
3805 wimlib_set_error_file_by_name(const wimlib_tchar *path);
3808 * @ingroup G_modifying_wims
3810 * Changes the description of an image in the WIM.
3813 * Pointer to the ::WIMStruct for a WIM.
3815 * The number of the image for which to change the description.
3816 * @param description
3817 * The new description to give the image. It may be @c NULL, which
3818 * indicates that the image is to be given no description.
3820 * @return 0 on success; nonzero on error.
3821 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3822 * @p image does not specify a single existing image in @p wim.
3823 * @retval ::WIMLIB_ERR_NOMEM
3824 * Failed to allocate the memory needed to duplicate the @p description
3826 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3827 * @p wim is considered read-only because of any of the reasons mentioned
3828 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3831 wimlib_set_image_descripton(WIMStruct *wim, int image,
3832 const wimlib_tchar *description);
3835 * @ingroup G_writing_and_overwriting_wims
3837 * Set the compression chunk size of a WIM to use in subsequent calls to
3838 * wimlib_write() or wimlib_overwrite().
3840 * A larger compression chunk size will likely result in a better compression
3841 * ratio, but the speed of random access to the WIM will be reduced.
3842 * Furthermore, the effect of a larger compression chunk size is limited by the
3843 * size of each stream ("file") being compressed.
3846 * ::WIMStruct for a WIM.
3848 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3849 * on the compression format. See the documentation for each
3850 * ::wimlib_compression_type constant for more information. As a special
3851 * case, if @p chunk_size is specified as 0, the chunk size is set to the
3852 * default for the currently selected output compression type.
3854 * @return 0 on success; nonzero on error.
3856 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3857 * @p chunk_size is not a supported chunk size for the currently selected
3858 * output compression type.
3861 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3864 * @ingroup G_writing_and_overwriting_wims
3866 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3867 * packed streams (solid blocks).
3870 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3873 * @ingroup G_writing_and_overwriting_wims
3875 * Set the compression type of a WIM to use in subsequent calls to
3876 * wimlib_write() or wimlib_overwrite().
3879 * ::WIMStruct for a WIM.
3881 * The compression type to set (one of ::wimlib_compression_type). If this
3882 * compression type is incompatible with the current output chunk size
3883 * (either the default or as set with wimlib_set_output_chunk_size()), the
3884 * output chunk size is reset to the default for that compression type.
3886 * @return 0 on success; nonzero on error.
3888 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3889 * @p ctype did not specify a valid compression type.
3892 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3895 * @ingroup G_writing_and_overwriting_wims
3897 * Similar to wimlib_set_output_compression_type(), but set the compression type
3898 * for writing packed streams (solid blocks).
3901 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3904 * @ingroup G_modifying_wims
3906 * Set basic information about a WIM.
3909 * Pointer to the ::WIMStruct for a WIM.
3911 * A struct ::wimlib_wim_info that contains the information to set. Only
3912 * the information explicitly specified in the @p which flags need be
3915 * Flags that specify which information to set. This is a bitwise OR of
3916 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3917 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3919 * @return 0 on success; nonzero on failure.
3920 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3921 * The WIM file is considered read-only because of any of the reasons
3922 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3923 * flag. However, as a special case, if you are using
3924 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3925 * function will not fail due to the readonly flag being previously set.
3926 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3927 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3928 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3932 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3936 * @ingroup G_modifying_wims
3938 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3939 * (something like "Core" or "Ultimate")
3942 * Pointer to the ::WIMStruct for a WIM.
3944 * The number of the image for which to change the description.
3946 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3947 * indicates that the image is to be given no \<FLAGS\> element.
3949 * @return 0 on success; nonzero on error.
3950 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3951 * @p image does not specify a single existing image in @p wim.
3952 * @retval ::WIMLIB_ERR_NOMEM
3953 * Failed to allocate the memory needed to duplicate the @p flags string.
3954 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3955 * @p wim is considered read-only because of any of the reasons mentioned
3956 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3959 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3962 * @ingroup G_modifying_wims
3964 * Changes the name of an image in the WIM.
3967 * Pointer to the ::WIMStruct for a WIM.
3969 * The number of the image for which to change the name.
3971 * New name to give the new image. If @c NULL or empty, the new image is
3972 * given no name. If nonempty, it must specify a name that does not
3973 * already exist in @p wim.
3975 * @return 0 on success; nonzero on error.
3976 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3977 * There is already an image named @p name in @p wim.
3978 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3979 * @p image does not specify a single existing image in @p wim.
3980 * @retval ::WIMLIB_ERR_NOMEM
3981 * Failed to allocate the memory needed to duplicate the @p name string.
3982 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3983 * @p wim is considered read-only because of any of the reasons mentioned
3984 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3987 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3990 * @ingroup G_general
3992 * Set the functions that wimlib uses to allocate and free memory.
3994 * These settings are global and not per-WIM.
3996 * The default is to use the default @c malloc() and @c free() from the C
3999 * Please note that some external functions, such as those in @c libntfs-3g, may
4000 * use the standard memory allocation functions regardless of this setting.
4002 * @param malloc_func
4003 * A function equivalent to @c malloc() that wimlib will use to allocate
4004 * memory. If @c NULL, the allocator function is set back to the default
4005 * @c malloc() from the C library.
4007 * A function equivalent to @c free() that wimlib will use to free memory.
4008 * If @c NULL, the free function is set back to the default @c free() from
4010 * @param realloc_func
4011 * A function equivalent to @c realloc() that wimlib will use to reallocate
4012 * memory. If @c NULL, the free function is set back to the default @c
4013 * realloc() from the C library.
4017 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
4018 void (*free_func)(void *),
4019 void *(*realloc_func)(void *, size_t));
4022 * @ingroup G_general
4024 * Sets whether wimlib is to print error messages to @c stderr when a function
4025 * fails. These error messages may provide information that cannot be
4026 * determined only from the error code that is returned. Not every error will
4027 * result in an error message being printed.
4029 * This setting is global and not per-WIM.
4031 * By default, error messages are not printed.
4033 * This can be called before wimlib_global_init().
4035 * @param show_messages
4036 * @c true if error messages are to be printed; @c false if error messages
4037 * are not to be printed.
4039 * @return 0 on success; nonzero on error.
4040 * @retval ::WIMLIB_ERR_UNSUPPORTED
4041 * @p show_messages was @c true, but wimlib was compiled with the @c
4042 * --without-error-messages option. Therefore, error messages cannot be
4046 wimlib_set_print_errors(bool show_messages);
4049 * @ingroup G_nonstandalone_wims
4051 * Splits a WIM into multiple parts.
4054 * The ::WIMStruct for the WIM to split.
4056 * Name of the SWM file to create. This will be the name of the first
4057 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
4058 * appended before the suffix.
4060 * The maximum size per part, in bytes. Unfortunately, it is not
4061 * guaranteed that this will really be the maximum size per part, because
4062 * some file resources in the WIM may be larger than this size, and the WIM
4063 * file format provides no way to split up file resources among multiple
4065 * @param write_flags
4066 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
4067 * flags will be used to write each split WIM part. Specify 0 here to get
4068 * the default behavior.
4070 * @return 0 on success; nonzero on error. This function may return most error
4071 * codes that can be returned by wimlib_write() as well as the following error
4074 * @retval ::WIMLIB_ERR_INVALID_PARAM
4075 * @p swm_name was not a nonempty string, or @p part_size was 0.
4077 * If a progress function is registered with @p wim, for each split WIM part
4078 * that is written it will receive the messages
4079 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
4080 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
4083 wimlib_split(WIMStruct *wim,
4084 const wimlib_tchar *swm_name,
4089 * @ingroup G_general
4091 * Perform verification checks on a WIM file.
4094 * The ::WIMStruct for the WIM file to verify. Note: for an extra layer of
4095 * verification, it is a good idea to have used
4096 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
4098 * If verifying a split WIM, specify the first part of the split WIM here,
4099 * and reference the other parts using wimlib_reference_resource_files()
4100 * before calling this function.
4102 * @param verify_flags
4103 * Reserved; must be 0.
4105 * @retval 0 if the WIM file was successfully verified; nonzero if it failed
4106 * verification or another error occurred. Some of the possible error codes
4109 * @retval ::WIMLIB_ERR_DECOMPRESSION
4110 * A compressed resource could not be decompressed.
4111 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
4112 * The metadata resource for an image is invalid.
4113 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4114 * One of the files did not decompress to its original data, as given by a
4115 * cryptographic checksum.
4116 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4117 * One of the files referenced by an image could not be located.
4119 * If a progress function is registered with @p wim, it will receive the
4120 * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
4121 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
4122 * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
4125 wimlib_verify_wim(WIMStruct *wim, int verify_flags);
4128 * @ingroup G_mounting_wim_images
4130 * Unmounts a WIM image that was mounted using wimlib_mount_image().
4132 * When unmounting a read-write mounted image, the default behavior is to
4133 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
4134 * WIM image to be committed.
4137 * The directory the WIM image was mounted on.
4138 * @param unmount_flags
4139 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
4141 * @return 0 on success; nonzero on error. The possible error codes include:
4143 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
4144 * There is no WIM image mounted on the specified directory.
4145 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
4146 * The read-write mounted WIM image cannot be committed because there are
4147 * file descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
4149 * @retval ::WIMLIB_ERR_MQUEUE
4150 * Could not create a POSIX message queue.
4151 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
4152 * The WIM image was mounted by a different user.
4153 * @retval ::WIMLIB_ERR_UNSUPPORTED
4154 * Mounting is not supported, either because the platform is Windows, or
4155 * because the platform is UNIX-like and wimlib was compiled using @c
4158 * Note: you can also unmount the image by using the @c umount() system call, or
4159 * by using the @c umount or @c fusermount programs. However, you need to call
4160 * this function if you want changes to be committed.
4163 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
4166 * @ingroup G_mounting_wim_images
4168 * Same as wimlib_unmount_image(), but allows specifying a progress function.
4169 * If changes are committed from a read-write mount, the progress function will
4170 * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
4173 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
4175 wimlib_progress_func_t progfunc,
4179 * @ingroup G_modifying_wims
4181 * Update a WIM image by adding, deleting, and/or renaming files or directories.
4184 * Pointer to the ::WIMStruct for the WIM file to update.
4186 * The 1-based index of the image in the WIM to update. It cannot be
4187 * ::WIMLIB_ALL_IMAGES.
4189 * An array of ::wimlib_update_command's that specify the update operations
4192 * Number of commands in @p cmds.
4193 * @param update_flags
4194 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
4196 * @return 0 on success; nonzero on error. On failure, all update commands will
4197 * be rolled back, and no visible changes shall have been made to @p wim.
4198 * Possible error codes include:
4200 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
4201 * The capture configuration structure specified for an add command was
4203 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4204 * @p image did not specify a single, existing image in @p wim.
4205 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
4206 * Attempted to perform an add command that conflicted with previously
4207 * existing files in the WIM when an overlay was attempted.
4208 * @retval ::WIMLIB_ERR_INVALID_PARAM
4209 * An unknown operation type was specified in the update commands; or,
4210 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
4211 * in the @p add_flags, but the same image had previously already been
4212 * added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
4213 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
4214 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
4215 * specified in the @p add_flags for an add command in which @p
4216 * wim_target_path was not the root directory of the WIM image.
4217 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4218 * (Windows only): While executing an add command, tried to capture a
4219 * reparse point with invalid data.
4220 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4221 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
4222 * for a WIM path that corresponded to a directory; or, a rename command
4223 * attempted to rename a directory to a non-directory.
4224 * @retval ::WIMLIB_ERR_NOMEM
4225 * Failed to allocate needed memory.
4226 * @retval ::WIMLIB_ERR_NOTDIR
4227 * A rename command attempted to rename a directory to a non-directory; or,
4228 * an add command was executed that attempted to set the root of the WIM
4229 * image as a non-directory; or, a path component used as a directory in a
4230 * rename command was not, in fact, a directory.
4231 * @retval ::WIMLIB_ERR_NOTEMPTY
4232 * A rename command attempted to rename a directory to a non-empty
4234 * @retval ::WIMLIB_ERR_NTFS_3G
4235 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4236 * error occurred while reading data from the NTFS volume using libntfs-3g.
4237 * @retval ::WIMLIB_ERR_OPEN
4238 * Failed to open a file to be captured while executing an add command.
4239 * @retval ::WIMLIB_ERR_OPENDIR
4240 * Failed to open a directory to be captured while executing an add command.
4241 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4242 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4243 * WIM path that did not exist; or, a rename command attempted to rename a
4244 * file that does not exist.
4245 * @retval ::WIMLIB_ERR_READ
4246 * While executing an add command, failed to read data from a file or
4247 * directory to be captured.
4248 * @retval ::WIMLIB_ERR_READLINK
4249 * While executing an add command, failed to read the target of a symbolic
4250 * link or junction point.
4251 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
4252 * (Windows only) Failed to perform a reparse point fixup because of
4253 * problems with the data of a reparse point.
4254 * @retval ::WIMLIB_ERR_STAT
4255 * While executing an add command, failed to get attributes for a file or
4257 * @retval ::WIMLIB_ERR_UNSUPPORTED
4258 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
4259 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
4260 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
4261 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
4262 * add_flags for an update command.
4263 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4264 * While executing an add command, attempted to capture a file that was not
4265 * a supported file type (e.g. a device file). Only if
4266 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
4267 * for an update command.
4268 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4269 * The WIM file is considered read-only because of any of the reasons
4270 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
4273 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4274 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4275 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4276 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4277 * different reasons) to read the metadata resource for an image that needed to
4281 wimlib_update_image(WIMStruct *wim,
4283 const struct wimlib_update_command *cmds,
4288 * @ingroup G_writing_and_overwriting_wims
4290 * Writes a WIM to a file.
4292 * This brings in resources from any external locations, such as directory trees
4293 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4294 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
4296 * By default, the new WIM file is written as stand-alone. Using the
4297 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4298 * instead. However, this function cannot directly write a "split" WIM; use
4299 * wimlib_split() for that.
4302 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
4303 * changes made to it, which are then reflected in the output file.
4305 * The path to the file to write the WIM to.
4307 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4308 * images are to be included in the new on-disk WIM file. If for some
4309 * reason you only want to include a single image, specify the index of
4310 * that image instead.
4311 * @param write_flags
4312 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
4313 * @param num_threads
4314 * Number of threads to use for compressing data. If 0, the number of
4315 * threads is taken to be the number of online processors. Note: if no
4316 * data compression needs to be done, no additional threads will be created
4317 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
4318 * exporting an image from a compressed WIM to another WIM of the same
4319 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
4322 * @return 0 on success; nonzero on error.
4324 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4325 * @p image does not specify a single existing image in @p wim, and is not
4326 * ::WIMLIB_ALL_IMAGES.
4327 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4328 * A file that had previously been scanned for inclusion in the WIM by
4329 * wimlib_add_image() was concurrently modified, so it failed the SHA1
4330 * message digest check.
4331 * @retval ::WIMLIB_ERR_INVALID_PARAM
4332 * @p path was @c NULL.
4333 * @retval ::WIMLIB_ERR_NOMEM
4334 * Failed to allocate needed memory.
4335 * @retval ::WIMLIB_ERR_OPEN
4336 * Failed to open @p path for writing, or some file resources in @p wim
4337 * refer to files in the outside filesystem, and one of these files could
4338 * not be opened for reading.
4339 * @retval ::WIMLIB_ERR_READ
4340 * An error occurred when trying to read data from the WIM file associated
4341 * with @p wim, or some file resources in @p wim refer to files in the
4342 * outside filesystem, and a read error occurred when reading one of these
4344 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4345 * A stream that needed to be written could not be found in the stream
4346 * lookup table of @p wim. This error can occur if, for example, @p wim is
4347 * part of a split WIM but needed resources from the other split WIM parts
4348 * were not referenced with wimlib_reference_resources() or
4349 * wimlib_reference_resource_files() before the call to wimlib_write().
4350 * @retval ::WIMLIB_ERR_WRITE
4351 * An error occurred when trying to write data to the new WIM file.
4353 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4354 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4355 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4356 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4357 * different reasons) to read the metadata resource for an image that needed to
4360 * If a progress function is registered with @p wim, it will receive the
4361 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4362 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4363 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4366 wimlib_write(WIMStruct *wim,
4367 const wimlib_tchar *path,
4370 unsigned num_threads);
4373 * @ingroup G_writing_and_overwriting_wims
4375 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
4376 * file descriptor, which need not be seekable if the write is done in a special
4377 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
4378 * write_flags. This can, for example, allow capturing a WIM image and
4379 * streaming it over the network. See the documentation for
4380 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
4382 * The file descriptor @p fd will @b not be closed when the write is complete;
4383 * the calling code is responsible for this.
4385 * Returns 0 on success; nonzero on failure. The possible error codes include
4386 * those that can be returned by wimlib_write() as well as the following:
4388 * @retval ::WIMLIB_ERR_INVALID_PARAM
4389 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4390 * specified in @p write_flags.
4393 wimlib_write_to_fd(WIMStruct *wim,
4397 unsigned num_threads);
4400 * @defgroup G_compression Compression and decompression functions
4402 * @brief Functions for XPRESS, LZX, and LZMS compression and decompression.
4404 * These functions are already used by wimlib internally when appropriate for
4405 * reading and writing WIM archives. But they are exported and documented so
4406 * that they can be used in other applications or libraries for general-purpose
4407 * lossless data compression. They are implemented in highly optimized C code,
4408 * using state-of-the-art compression techniques. The main limitation is the
4409 * lack of sliding window support; this has, however, allowed the algorithms to
4410 * be optimized for block-based compression.
4415 /** Opaque compressor handle. */
4416 struct wimlib_compressor;
4418 /** Opaque decompressor handle. */
4419 struct wimlib_decompressor;
4422 * Set the default compression level for the specified compression type. This
4423 * is the compression level that wimlib_create_compressor() assumes if it is
4424 * called with @p compression_level specified as 0.
4426 * wimlib's WIM writing code (e.g. wimlib_write()) will pass 0 to
4427 * wimlib_create_compressor() internally. Therefore, calling this function will
4428 * affect the compression level of any data later written to WIM files using the
4429 * specified compression type.
4431 * The initial state, before this function is called, is that all compression
4432 * types have a default compression level of 50.
4435 * Compression type for which to set the default compression level, as one
4436 * of the ::wimlib_compression_type constants. Or, if this is the special
4437 * value -1, the default compression levels for all compression types will
4439 * @param compression_level
4440 * The default compression level to set. If 0, the "default default" level
4441 * of 50 is restored. Otherwise, a higher value indicates higher
4442 * compression, whereas a lower value indicates lower compression. See
4443 * wimlib_create_compressor() for more information.
4445 * @return 0 on success; nonzero on error.
4447 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4448 * @p ctype was neither a supported compression type nor -1.
4451 wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
4454 * Returns the approximate number of bytes needed to allocate a compressor with
4455 * wimlib_create_compressor() for the specified compression type, maximum block
4456 * size, and compression level. @p compression_level may be 0, in which case
4457 * the current default compression level for @p ctype is used. Returns 0 if the
4458 * compression type is invalid, or the @p max_block_size for that compression
4462 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4463 size_t max_block_size,
4464 unsigned int compression_level);
4467 * Allocate a compressor for the specified compression type using the specified
4468 * parameters. This function is part of wimlib's compression API; it is not
4469 * necessary to call this to process a WIM file.
4472 * Compression type for which to create the compressor, as one of the
4473 * ::wimlib_compression_type constants.
4474 * @param max_block_size
4475 * The maximum compression block size to support. This specifies the
4476 * maximum allowed value for the @p uncompressed_size parameter of
4477 * wimlib_compress() when called using this compressor.
4479 * Usually, the amount of memory used by the compressor will scale in
4480 * proportion to the @p max_block_size parameter.
4481 * wimlib_get_compressor_needed_memory() can be used to query the specific
4482 * amount of memory that will be required.
4484 * This parameter must be at least 1 and must be less than or equal to a
4485 * compression-type-specific limit.
4487 * In general, the same value of @p max_block_size must be passed to
4488 * wimlib_create_decompressor() when the data is later decompressed.
4489 * However, some compression types have looser requirements regarding this.
4490 * @param compression_level
4491 * The compression level to use. If 0, the default compression level (50,
4492 * or another value as set through wimlib_set_default_compression_level())
4493 * is used. Otherwise, a higher value indicates higher compression. The
4494 * values are scaled so that 10 is low compression, 50 is medium
4495 * compression, and 100 is high compression. This is not a percentage;
4496 * values above 100 are also valid.
4498 * Using a higher-than-default compression level can result in a better
4499 * compression ratio, but can significantly reduce performance. Similarly,
4500 * using a lower-than-default compression level can result in better
4501 * performance, but can significantly worsen the compression ratio. The
4502 * exact results will depend heavily on the compression type and what
4503 * algorithms are implemented for it. If you are considering using a
4504 * non-default compression level, you should run benchmarks to see if it is
4505 * worthwhile for your application.
4507 * The compression level does not affect the format of the compressed data.
4508 * Therefore, it is a compressor-only parameter and does not need to be
4509 * passed to the decompressor.
4510 * @param compressor_ret
4511 * A location into which to return the pointer to the allocated compressor.
4512 * The allocated compressor can be used for any number of calls to
4513 * wimlib_compress() before being freed with wimlib_free_compressor().
4515 * @return 0 on success; nonzero on error.
4517 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4518 * @p ctype was not a supported compression type.
4519 * @retval ::WIMLIB_ERR_INVALID_PARAM
4520 * @p max_block_size was invalid for the compression type, or @p
4521 * compressor_ret was @c NULL.
4522 * @retval ::WIMLIB_ERR_NOMEM
4523 * Insufficient memory to allocate the compressor.
4526 wimlib_create_compressor(enum wimlib_compression_type ctype,
4527 size_t max_block_size,
4528 unsigned int compression_level,
4529 struct wimlib_compressor **compressor_ret);
4532 * Compress a buffer of data.
4534 * @param uncompressed_data
4535 * Buffer containing the data to compress.
4536 * @param uncompressed_size
4537 * Size, in bytes, of the data to compress. This cannot be greater than
4538 * the @p max_block_size with which wimlib_create_compressor() was called.
4539 * (If it is, the data will not be compressed and 0 will be returned.)
4540 * @param compressed_data
4541 * Buffer into which to write the compressed data.
4542 * @param compressed_size_avail
4543 * Number of bytes available in @p compressed_data.
4545 * A compressor previously allocated with wimlib_create_compressor().
4548 * The size of the compressed data, in bytes, or 0 if the data could not be
4549 * compressed to @p compressed_size_avail or fewer bytes.
4552 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4553 void *compressed_data, size_t compressed_size_avail,
4554 struct wimlib_compressor *compressor);
4557 * Free a compressor previously allocated with wimlib_create_compressor().
4560 * The compressor to free. If @c NULL, no action is taken.
4563 wimlib_free_compressor(struct wimlib_compressor *compressor);
4566 * Allocate a decompressor for the specified compression type. This function is
4567 * part of wimlib's compression API; it is not necessary to call this to process
4571 * Compression type for which to create the decompressor, as one of the
4572 * ::wimlib_compression_type constants.
4573 * @param max_block_size
4574 * The maximum compression block size to support. This specifies the
4575 * maximum allowed value for the @p uncompressed_size parameter of
4576 * wimlib_decompress().
4578 * In general, this parameter must be the same as the @p max_block_size
4579 * that was passed to wimlib_create_compressor() when the data was
4580 * compressed. However, some compression types have looser requirements
4582 * @param decompressor_ret
4583 * A location into which to return the pointer to the allocated
4584 * decompressor. The allocated decompressor can be used for any number of
4585 * calls to wimlib_decompress() before being freed with
4586 * wimlib_free_decompressor().
4588 * @return 0 on success; nonzero on error.
4590 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4591 * @p ctype was not a supported compression type.
4592 * @retval ::WIMLIB_ERR_INVALID_PARAM
4593 * @p max_block_size was invalid for the compression type, or @p
4594 * decompressor_ret was @c NULL.
4595 * @retval ::WIMLIB_ERR_NOMEM
4596 * Insufficient memory to allocate the decompressor.
4599 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4600 size_t max_block_size,
4601 struct wimlib_decompressor **decompressor_ret);
4604 * Decompress a buffer of data.
4606 * @param compressed_data
4607 * Buffer containing the data to decompress.
4608 * @param compressed_size
4609 * Size, in bytes, of the data to decompress.
4610 * @param uncompressed_data
4611 * Buffer into which to write the uncompressed data.
4612 * @param uncompressed_size
4613 * Size, in bytes, of the data when uncompressed. This cannot exceed the
4614 * @p max_block_size with which wimlib_create_decompressor() was called.
4615 * (If it does, the data will not be decompressed and a nonzero value will
4617 * @param decompressor
4618 * A decompressor previously allocated with wimlib_create_decompressor().
4620 * @return 0 on success; nonzero on error.
4622 * No specific error codes are defined; any nonzero value indicates that the
4623 * decompression failed. This can only occur if the data is truly invalid;
4624 * there will never be transient errors like "out of memory", for example.
4626 * This function requires that the exact uncompressed size of the data be passed
4627 * as the @p uncompressed_size parameter. If this is not done correctly,
4628 * decompression may fail or the data may be decompressed incorrectly.
4631 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4632 void *uncompressed_data, size_t uncompressed_size,
4633 struct wimlib_decompressor *decompressor);
4636 * Free a decompressor previously allocated with wimlib_create_decompressor().
4638 * @param decompressor
4639 * The decompressor to free. If @c NULL, no action is taken.
4642 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4654 #endif /* _WIMLIB_H */