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.0, 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 0
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_create_compressor(), or
446 * wimlib_create_decompressor().
448 * A WIM file has one default compression type and chunk size. Normally, each
449 * resource is compressed with this compression type. However, resources may be
450 * stored as uncompressed. In addition, a WIM with the new version number of
451 * 3584, or "ESD file", might contain solid blocks with different compression
454 enum wimlib_compression_type {
455 /** No compression. */
456 WIMLIB_COMPRESSION_TYPE_NONE = 0,
458 /** The XPRESS compression format. This format combines Lempel-Ziv
459 * factorization with Huffman encoding. Compression and decompression
460 * are both fast. This format supports chunk sizes that are powers of 2
461 * between <c>2^12</c> and <c>2^26</c>, inclusively. */
462 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
464 /** The LZX compression format. This format combines Lempel-Ziv
465 * factorization with Huffman encoding, but with more features and
466 * complexity than XPRESS. Compression is slow to somewhat fast,
467 * depending on the settings. Decompression is fast but slower than
468 * XPRESS. This format supports chunk sizes that are powers of 2
469 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
470 * other than <c>2^15</c> are not compatible with the Microsoft
472 WIMLIB_COMPRESSION_TYPE_LZX = 2,
474 /** The LZMS compression format. This format combines Lempel-Ziv
475 * factorization with adaptive Huffman encoding and range coding.
476 * Compression and decompression are both fairly slow. This format
477 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
478 * <c>2^30</c>, inclusively. This format is best used for large chunk
479 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
480 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
481 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
482 * with the Microsoft implementation. */
483 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
487 /** @addtogroup G_progress
490 /** Possible values of the first parameter to the user-supplied
491 * ::wimlib_progress_func_t progress function */
492 enum wimlib_progress_msg {
494 /** A WIM image is about to be extracted. @p info will point to
495 * ::wimlib_progress_info.extract. This message is received once per
496 * image for calls to wimlib_extract_image() and
497 * wimlib_extract_image_from_pipe(). */
498 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
500 /** One or more file or directory trees within a WIM image is about to
501 * be extracted. @p info will point to ::wimlib_progress_info.extract.
502 * This message is received only once per wimlib_extract_paths() and
503 * wimlib_extract_pathlist(), since wimlib combines all paths into a
504 * single extraction operation for optimization purposes. */
505 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
507 /** File data is currently being extracted. @p info will point to
508 * ::wimlib_progress_info.extract. This is the main message to track
509 * the progress of an extraction operation. */
510 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
512 /** Starting to read a new part of a split pipable WIM over the pipe.
513 * @p info will point to ::wimlib_progress_info.extract. */
514 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
516 /** Confirms that the image has been successfully extracted. @p info
517 * will point to ::wimlib_progress_info.extract. This is paired with
518 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
519 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
521 /** Confirms that the files or directory trees have been successfully
522 * extracted. @p info will point to ::wimlib_progress_info.extract.
523 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
524 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
526 /** The directory or NTFS volume is about to be scanned for metadata.
527 * @p info will point to ::wimlib_progress_info.scan. This message is
528 * received once per call to wimlib_add_image(), or once per capture
529 * source passed to wimlib_add_image_multisource(), or once per add
530 * command passed to wimlib_update_image(). */
531 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
533 /** A directory or file has been scanned. @p info will point to
534 * ::wimlib_progress_info.scan, and its @p cur_path member will be
535 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
537 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
539 /** Confirms that the directory or NTFS volume has been successfully
540 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
541 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
542 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
544 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
546 /** File resources ("streams") are currently being written to the WIM.
547 * @p info will point to ::wimlib_progress_info.write_streams. This
548 * message may be received many times while the WIM file is being
549 * written or appended to with wimlib_write(), wimlib_overwrite(), or
550 * wimlib_write_to_fd(). */
551 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
553 /** Per-image metadata is about to be written to the WIM file. @p info
554 * will not be valid. */
555 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
557 /** Confirms that per-image metadata has been successfully been written
558 * to the WIM file. @p info will not be valid. This message is paired
559 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
561 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
563 /** wimlib_overwrite() has successfully renamed the temporary file to
564 * the original WIM file, thereby committing the update. @p info will
565 * point to ::wimlib_progress_info.rename. Note: this message is not
566 * received if wimlib_overwrite() chose to append to the WIM file
568 WIMLIB_PROGRESS_MSG_RENAME = 15,
570 /** The contents of the WIM file are being checked against the integrity
571 * table. @p info will point to ::wimlib_progress_info.integrity. This
572 * message is only received (and may be received many times) when
573 * wimlib_open_wim_with_progress() is called with the
574 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
575 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
577 /** An integrity table is being calculated for the WIM being written.
578 * @p info will point to ::wimlib_progress_info.integrity. This message
579 * is only received (and may be received many times) when a WIM file is
580 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
581 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
583 /** A wimlib_split() operation is in progress, and a new split part is
584 * about to be started. @p info will point to
585 * ::wimlib_progress_info.split. */
586 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
588 /** A wimlib_split() operation is in progress, and a split part has been
589 * finished. @p info will point to ::wimlib_progress_info.split. */
590 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
592 /** A WIM update command is just about to be executed. @p info will
593 * point to ::wimlib_progress_info.update. This message is received
594 * once per update command when wimlib_update_image() is called with the
595 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
596 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
598 /** A WIM update command has just been executed. @p info will point to
599 * ::wimlib_progress_info.update. This message is received once per
600 * update command when wimlib_update_image() is called with the flag
601 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
602 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
604 /** A file in the WIM image is being replaced as a result of a
605 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
606 * @p info will point to ::wimlib_progress_info.replace. This is only
607 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
609 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
611 /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
612 * a file is being extracted normally (not as a WIMBoot "pointer file")
613 * due to it matching a pattern in the [PrepopulateList] section of the
614 * configuration file @c \\Windows\\System32\\WimBootCompress.ini in the
615 * WIM image. @p info will point to
616 * ::wimlib_progress_info.wimboot_exclude.
618 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
620 /** Starting to unmount a WIM image. @p info will point to
621 * ::wimlib_progress_info.unmount. */
622 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
625 /** Valid return values from user-provided progress functions
626 * (::wimlib_progress_func_t).
628 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
631 enum wimlib_progress_status {
633 /** The operation should be continued. This is the normal return value.
635 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
637 /** The operation should be aborted. This will cause the current
638 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
639 WIMLIB_PROGRESS_STATUS_ABORT = 1,
643 * A pointer to this union is passed to the user-supplied
644 * ::wimlib_progress_func_t progress function. One (or none) of the structures
645 * contained in this union will be applicable for the operation
646 * (::wimlib_progress_msg) indicated in the first argument to the progress
648 union wimlib_progress_info {
650 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
651 * document them if they aren't given a name... */
653 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
654 * the primary message for tracking the progress of writing a WIM file.
656 struct wimlib_progress_info_write_streams {
657 /** Total number of uncompressed bytes of stream data being
658 * written. This can be thought of as the total uncompressed
659 * size of the files being archived, with some caveats. WIM
660 * files use single-instance streams, so the size provided here
661 * only counts distinct streams, except for the following
662 * exception: the size provided here may include the sizes of
663 * all newly added (e.g. with wimlib_add_image() streams,
664 * pending automatic de-duplication during the write operation
665 * itself. When each such stream de-duplication occurs, this
666 * number will be decreased by the size of the duplicate stream
667 * that need not be written.
669 * In the case of a wimlib_overwrite() that the library opted to
670 * perform in-place, both @p total_streams and @p total_bytes
671 * will only count the streams actually being written and not
672 * pre-existing streams in the WIM file. */
673 uint64_t total_bytes;
675 /** Total number of streams being written. This can be thought
676 * of as the total number of files being archived, with some
677 * caveats. In general, a single file or directory may contain
678 * multiple data streams, each of which will be represented
679 * separately in this number. Furthermore, WIM files use
680 * single-instance streams, so the stream count provided here
681 * only counts distinct streams, except for the following
682 * exception: the stream count provided here may include newly
683 * added (e.g. with wimlib_add_image() streams, pending
684 * automatic de-duplication during the write operation itself.
685 * When each such stream de-duplication occurs, this number will
686 * be decreased by 1 to account for the duplicate stream that
687 * need not be written. */
688 uint64_t total_streams;
690 /** Number of uncompressed bytes of stream data that have been
691 * written so far. This number be 0 initially, and will be
692 * equal to @p total_bytes at the end of the write operation.
693 * Note that @p total_bytes (but not @p completed_bytes) may
694 * decrease throughout the write operation due to the discovery
695 * of stream duplications. */
696 uint64_t completed_bytes;
698 /** Number of streams that have been written so far. This
699 * number will be 0 initially, and will be equal to @p
700 * total_streams at the end of the write operation. Note that
701 * @p total_streams (but not @p completed_streams) may decrease
702 * throughout the write operation due to the discovery of stream
705 * For applications that wish to calculate a simple "percent
706 * complete" for the write operation, it will likely be more
707 * accurate to calculate the percentage from @p completed_bytes
708 * and @p total_bytes rather than @p completed_streams and
709 * @p total_streams because the time for the operation to
710 * complete is mainly determined by the number of bytes that
711 * need to be read, compressed, and written, not just the number
712 * of files being archived. */
713 uint64_t completed_streams;
715 /** Number of threads that are being used to compress streams,
716 * or 1 if streams are being written uncompressed. */
717 uint32_t num_threads;
719 /** The compression type being used to write the streams, as one
720 * of the ::wimlib_compression_type constants. */
721 int32_t compression_type;
723 /** Number of split WIM parts from which streams are being
724 * written (may be 0 if irrelevant). */
725 uint32_t total_parts;
727 /** This is currently broken and will always be 0. */
728 uint32_t completed_parts;
731 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
732 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
733 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
734 struct wimlib_progress_info_scan {
735 /** Top-level directory being scanned; or, when capturing an NTFS
736 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
737 * to the file or block device that contains the NTFS volume
739 const wimlib_tchar *source;
741 /** Path to the file (or directory) that has been scanned, valid
742 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
743 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
744 * relative to the root of the NTFS volume. */
745 const wimlib_tchar *cur_path;
747 /** Dentry scan status, valid on
748 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
750 /** The file looks okay and will be captured. */
751 WIMLIB_SCAN_DENTRY_OK = 0,
753 /** File is being excluded from capture due to the
754 * capture configuration. */
755 WIMLIB_SCAN_DENTRY_EXCLUDED,
757 /** File is being excluded from capture due to being
758 * unsupported (e.g. an encrypted or device file). */
759 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
761 /** The file is an absolute symbolic link or junction
762 * that points into the capture directory, and
763 * reparse-point fixups are enabled, so its target is
764 * being adjusted. (Reparse point fixups can be
765 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
767 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
769 /** Reparse-point fixups are enabled, but the file is an
770 * absolute symbolic link or junction that does
771 * <b>not</b> point into the capture directory, so its
772 * target is <b>not</b> being adjusted. */
773 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK,
777 /** Target path in the WIM image. Only valid on
778 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
779 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
780 const wimlib_tchar *wim_target_path;
782 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
783 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
784 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
785 * target of the absolute symbolic link or junction. */
786 const wimlib_tchar *symlink_target;
789 /** Number of directories scanned so far, including the root
790 * directory but excluding any unsupported/excluded directories.
792 * Details: On Windows and in NTFS capture mode, a reparse point
793 * counts as a directory if and only if it has
794 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
795 * counts as a directory if and only if when fully dereferenced
796 * it points to an accessible directory. If a file has multiple
797 * names (hard links), it is only counted one time. */
798 uint64_t num_dirs_scanned;
800 /** Number of non-directories scanned so far, excluding any
801 * unsupported/excluded files.
803 * Details: On Windows and in NTFS capture mode, a reparse point
804 * counts as a non-directory if and only if it does not have
805 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
806 * counts as a non-directory if and only if when fully
807 * dereferenced it points to a non-directory or its target is
808 * inaccessible. If a file has multiple names (hard links), it
809 * is only counted one time. */
810 uint64_t num_nondirs_scanned;
812 /** Number of bytes of file data that have been detected so far.
814 * Details: This data may not actually have been read yet, and
815 * it will not actually be written to the WIM file until
816 * wimlib_write() or wimlib_overwrite() has been called. Data
817 * from excluded files is not counted. This number includes
818 * default file contents as well as named data streams and
819 * reparse point data. The size of reparse point data is
820 * tallied after any reparse-point fixups, and in the case of
821 * capturing a symbolic link on a UNIX-like system, the creation
822 * of the reparse point data itself. If a file has multiple
823 * names (hard links), its size(s) are only counted one time.
824 * On Windows, encrypted files have their encrypted size
825 * counted, not their unencrypted size; however, compressed
826 * files have their uncompressed size counted. */
827 uint64_t num_bytes_scanned;
830 /** Valid on messages
831 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
832 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
833 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
834 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
835 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
836 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
838 * Note: most of the time of an extraction operation will be spent
839 * extracting streams, and the application will receive
840 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
841 * completed_bytes and @p total_bytes, the application can calculate a
842 * percentage complete. However, note that this message does not, in
843 * general, actually provide information about which "file" is currently
844 * being extracted. This is because wimlib, by default, extracts the
845 * individual data streams in whichever order it determines to be the
848 struct wimlib_progress_info_extract {
849 /** Number of the image from which files are being extracted
853 /** Extraction flags being used. */
854 uint32_t extract_flags;
856 /** Full path to the WIM file from which files are being
857 * extracted, or @c NULL if the WIMStruct has no associated
859 const wimlib_tchar *wimfile_name;
861 /** Name of the image from which files are being extracted, or
862 * the empty string if the image is unnamed. */
863 const wimlib_tchar *image_name;
865 /** Path to the directory or NTFS volume to which the files are
866 * being extracted. */
867 const wimlib_tchar *target;
870 const wimlib_tchar *reserved;
872 /** Number of bytes of uncompressed data that will be extracted.
873 * If a file has multiple names (hard links), its size (or
874 * sizes, in the case of named data streams) is only counted one
875 * time. For "reparse points" and symbolic links, the size to
876 * be extracted is the size of the reparse data buffer.
878 * This number will stay constant throughout the extraction. */
879 uint64_t total_bytes;
881 /** Number of bytes of uncompressed data that have been
882 * extracted so far. This initially be 0 and will equal to @p
883 * total_bytes at the end of the extraction. */
884 uint64_t completed_bytes;
886 /** Number of (not necessarily unique) streams that will be
887 * extracted. This may be more or less than the number of
888 * "files" to be extracted due to hard links as well as
889 * potentially multiple streams per file (named data streams).
890 * A "stream" may be the default contents of a file, a named
891 * data stream, or a reparse data buffer. */
892 uint64_t num_streams;
895 const wimlib_tchar *reserved_2;
897 /** Currently only used for
898 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
899 uint32_t part_number;
901 /** Currently only used for
902 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
903 uint32_t total_parts;
905 /** Currently only used for
906 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
907 uint8_t guid[WIMLIB_GUID_LEN];
910 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
911 struct wimlib_progress_info_rename {
912 /** Name of the temporary file that the WIM was written to. */
913 const wimlib_tchar *from;
915 /** Name of the original WIM file to which the temporary file is
917 const wimlib_tchar *to;
920 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
921 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
922 struct wimlib_progress_info_update {
923 /** Pointer to the update command that will be executed or has
924 * just been executed. */
925 const struct wimlib_update_command *command;
927 /** Number of update commands that have been completed so far.
929 size_t completed_commands;
931 /** Number of update commands that are being executed as part of
932 * this call to wimlib_update_image(). */
933 size_t total_commands;
936 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
937 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
938 struct wimlib_progress_info_integrity {
939 /** Number of bytes from the end of the WIM header to the end of
940 * the lookup table (the area that is covered by the SHA1
941 * integrity checks.) */
942 uint64_t total_bytes;
944 /** Number of bytes that have been SHA1-summed so far. Will be
945 * 0 initially, and equal @p total_bytes at the end. */
946 uint64_t completed_bytes;
948 /** Number of chunks that the checksummed region is divided
950 uint32_t total_chunks;
952 /** Number of chunks that have been SHA1-summed so far. Will
953 * be 0 initially, and equal to @p total_chunks at the end. */
954 uint32_t completed_chunks;
956 /** Size of the chunks used for the integrity calculation. */
959 /** Filename of the WIM (only valid if the message is
960 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
961 const wimlib_tchar *filename;
964 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
965 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
966 struct wimlib_progress_info_split {
967 /** Total size of the original WIM's file and metadata resources
969 uint64_t total_bytes;
971 /** Number of bytes of file and metadata resources that have
972 * been copied out of the original WIM so far. Will be 0
973 * initially, and equal to @p total_bytes at the end. */
974 uint64_t completed_bytes;
976 /** Number of the split WIM part that is about to be started
977 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
978 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
979 unsigned cur_part_number;
981 /** Total number of split WIM parts that are being written. */
982 unsigned total_parts;
984 /** Name of the split WIM part that is about to be started
985 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
986 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
987 * As of wimlib v1.7.0, the library user may change this when
988 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
989 * cause the next split WIM part to be written to a different
991 wimlib_tchar *part_name;
994 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
995 struct wimlib_progress_info_replace {
996 /** Path to the file in the WIM image that is being replaced */
997 const wimlib_tchar *path_in_wim;
1000 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1001 struct wimlib_progress_info_wimboot_exclude {
1002 /** Path to the file in the WIM image */
1003 const wimlib_tchar *path_in_wim;
1005 /** Path to which the file is being extracted */
1006 const wimlib_tchar *extraction_path;
1009 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1010 struct wimlib_progress_info_unmount {
1011 /** Path to directory being unmounted */
1012 const wimlib_tchar *mountpoint;
1014 /** Path to WIM file being unmounted */
1015 const wimlib_tchar *mounted_wim;
1017 /** 1-based index of image being unmounted. */
1018 uint32_t mounted_image;
1020 /** Flags that were passed to wimlib_mount_image() when the
1021 * mountpoint was set up. */
1022 uint32_t mount_flags;
1024 /** Flags passed to wimlib_unmount_image(). */
1025 uint32_t unmount_flags;
1030 * A user-supplied function that will be called periodically during certain WIM
1033 * The first argument will be the type of operation that is being performed or
1034 * is about to be started or has been completed.
1036 * The second argument will be a pointer to one of a number of structures
1037 * depending on the first argument. It may be @c NULL for some message types.
1038 * Note that although this argument is not @c const, users should not modify it
1039 * except in explicitly documented cases.
1041 * The third argument will be a user-supplied value that was provided when
1042 * registering or specifying the progress function.
1044 * This function must return one of the ::wimlib_progress_status values. By
1045 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1047 typedef enum wimlib_progress_status
1048 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1049 union wimlib_progress_info *info,
1053 /** @addtogroup G_modifying_wims
1056 /** An array of these structures is passed to wimlib_add_image_multisource() to
1057 * specify the sources from which to create a WIM image. */
1058 struct wimlib_capture_source {
1059 /** Absolute or relative path to a file or directory on the external
1060 * filesystem to be included in the WIM image. */
1061 wimlib_tchar *fs_source_path;
1063 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1064 * specify the root directory of the WIM image. */
1065 wimlib_tchar *wim_target_path;
1067 /** Reserved; set to 0. */
1071 /** Set or unset the WIM header flag that marks it read-only
1072 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
1073 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
1074 * is distinct from basic file permissions; this flag can be set on a WIM file
1075 * that is physically writable. If this flag is set, all further operations to
1076 * modify the WIM will fail, except calling wimlib_overwrite() with
1077 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
1078 * allows you to set this flag persistently on the underlying WIM file.
1080 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1082 /** Set the GUID (globally unique identifier) of the WIM file to the value
1083 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1084 #define WIMLIB_CHANGE_GUID 0x00000002
1086 /** Change the bootable image of the WIM to the value specified in
1087 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1088 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1090 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1091 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
1092 * indicates whether an image in the WIM has been captured with reparse-point
1093 * fixups enabled. wimlib also treats this flag as specifying whether to do
1094 * reparse-point fixups by default when capturing or applying WIM images. */
1095 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1099 /** @addtogroup G_wim_information
1104 /** General information about a WIM file. */
1105 struct wimlib_wim_info {
1107 /** Globally unique identifier for the WIM file. Note: all parts of a
1108 * split WIM should have an identical value in this field. */
1109 uint8_t guid[WIMLIB_GUID_LEN];
1111 /** Number of images in the WIM. */
1112 uint32_t image_count;
1114 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1116 uint32_t boot_index;
1118 /** Version of the WIM file. */
1119 uint32_t wim_version;
1121 /** Chunk size used for compression. */
1122 uint32_t chunk_size;
1124 /** For split WIMs, the 1-based index of this part within the split WIM;
1126 uint16_t part_number;
1128 /** For split WIMs, the total number of parts in the split WIM;
1130 uint16_t total_parts;
1132 /** One of the ::wimlib_compression_type values that specifies the
1133 * method used to compress resources in the WIM. */
1134 int32_t compression_type;
1136 /** Size of the WIM file in bytes, excluding the XML data and integrity
1138 uint64_t total_bytes;
1140 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1141 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1142 * this will always be 0, even if the ::WIMStruct was written to
1143 * somewhere by calling wimlib_write() with the
1144 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1145 uint32_t has_integrity_table : 1;
1147 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1148 * wimlib_create_new_wim(). */
1149 uint32_t opened_from_file : 1;
1151 /** 1 if the WIM is considered readonly for any reason. */
1152 uint32_t is_readonly : 1;
1154 /** 1 if reparse-point fixups are supposedly enabled for one or more
1155 * images in the WIM. */
1156 uint32_t has_rpfix : 1;
1158 /** 1 if the WIM is marked as read-only. */
1159 uint32_t is_marked_readonly : 1;
1161 /** 1 if the WIM is part of a spanned set. */
1162 uint32_t spanned : 1;
1164 uint32_t write_in_progress : 1;
1165 uint32_t metadata_only : 1;
1166 uint32_t resource_only : 1;
1168 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1169 uint32_t pipable : 1;
1170 uint32_t reserved_flags : 22;
1171 uint32_t reserved[9];
1174 /** Information about a unique stream in the WIM file. (A stream is the same
1175 * thing as a "resource", except in the case of packed resources.) */
1176 struct wimlib_resource_entry {
1177 /** Uncompressed size of the stream in bytes. */
1178 uint64_t uncompressed_size;
1180 /** Compressed size of the stream in bytes. This will be the same as @p
1181 * uncompressed_size if the stream is uncompressed. Or, if @p
1182 * is_packed_streams is 1, this will be 0. */
1183 uint64_t compressed_size;
1185 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1186 * if @p packed is 1, then this is actually the offset at which this
1187 * stream begins in the uncompressed contents of the packed resource.
1191 /** SHA1 message digest of the stream's uncompressed contents. */
1192 uint8_t sha1_hash[20];
1194 /** Which part number of the split WIM this stream is in. This should
1195 * be the same as the part number provided by wimlib_get_wim_info(). */
1196 uint32_t part_number;
1198 /** Number of times this stream is referenced over all WIM images. */
1199 uint32_t reference_count;
1201 /** 1 if this stream is compressed. */
1202 uint32_t is_compressed : 1;
1204 /** 1 if this stream is a metadata resource rather than a file resource.
1206 uint32_t is_metadata : 1;
1208 uint32_t is_free : 1;
1209 uint32_t is_spanned : 1;
1211 /** 1 if this stream was not found in the lookup table of the
1212 * ::WIMStruct. This normally implies a missing call to
1213 * wimlib_reference_resource_files() or wimlib_reference_resources().
1215 uint32_t is_missing : 1;
1217 /** 1 if this stream is located in a packed resource which may contain
1218 * other streams (all compressed together) as well. */
1219 uint32_t packed : 1;
1221 uint32_t reserved_flags : 26;
1223 /** If @p packed is 1, then this will specify the offset of the packed
1224 * resource in the WIM. */
1225 uint64_t raw_resource_offset_in_wim;
1227 /** If @p is_packed_streams is 1, then this will specify the compressed
1228 * size of the packed resource in the WIM. */
1229 uint64_t raw_resource_compressed_size;
1231 uint64_t reserved[2];
1234 /** Information about a stream of a particular file in the WIM. */
1235 struct wimlib_stream_entry {
1236 /** Name of the stream, or NULL if the stream is unnamed. */
1237 const wimlib_tchar *stream_name;
1238 /** Location, size, etc. of the stream within the WIM file. */
1239 struct wimlib_resource_entry resource;
1240 uint64_t reserved[4];
1243 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1244 * Roughly, the information about a "file" in the WIM--- but really a directory
1245 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1246 * field can be used to distinguish actual file inodes. */
1247 struct wimlib_dir_entry {
1248 /** Name of the file, or NULL if this file is unnamed (only possible for
1249 * the root directory) */
1250 const wimlib_tchar *filename;
1252 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1254 const wimlib_tchar *dos_name;
1256 /** Full path to this file within the WIM image. */
1257 const wimlib_tchar *full_path;
1259 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1260 * children, ..., etc. */
1263 /** Pointer to the security descriptor for this file, in Windows
1264 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1265 * security descriptor. */
1266 const char *security_descriptor;
1268 /** Length of the above security descriptor. */
1269 size_t security_descriptor_size;
1271 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1272 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1273 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1274 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1275 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1276 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1277 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1278 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1279 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1280 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1281 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1282 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1283 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1284 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1285 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1286 /** File attributes, such as whether the file is a directory or not.
1287 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1288 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1289 * on other platforms. */
1290 uint32_t attributes;
1292 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1293 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1294 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1295 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1296 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1297 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1298 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1299 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1300 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1301 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1302 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1303 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1304 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1305 * attributes), this will give the reparse tag. This tells you whether
1306 * the reparse point is a symbolic link, junction point, or some other,
1307 * more unusual kind of reparse point. */
1308 uint32_t reparse_tag;
1310 /* Number of (hard) links to this file. */
1313 /** Number of named data streams that this file has. Normally 0. */
1314 uint32_t num_named_streams;
1316 /** Roughly, the inode number of this file. However, it may be 0 if
1317 * @p num_links == 1. */
1318 uint64_t hard_link_group_id;
1320 /** Time this file was created. */
1321 struct timespec creation_time;
1323 /** Time this file was last written to. */
1324 struct timespec last_write_time;
1326 /** Time this file was last accessed. */
1327 struct timespec last_access_time;
1329 /* UNIX data (wimlib extension), only valid if unix_mode != 0 */
1335 uint64_t reserved[14];
1337 /** Array of streams that make up this file. The first entry will
1338 * always exist and will correspond to the unnamed data stream (default
1339 * file contents), so it will have @p stream_name == @c NULL. There
1340 * will then be @p num_named_streams additional entries that specify the
1341 * named data streams, if any, each of which will have @p stream_name !=
1343 struct wimlib_stream_entry streams[];
1347 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1350 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1354 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1357 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1360 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1361 * just on the specified path. */
1362 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1364 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1365 * itself; only its children (in the case of a non-empty directory) */
1366 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1368 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1369 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1370 * table of the ::WIMStruct. The default behavior without this flag is to fill
1371 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1372 * wimlib_resource_entry::is_missing "is_missing" flag. */
1373 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1377 /** @addtogroup G_modifying_wims
1380 /** Directly capture an NTFS volume rather than a generic directory. This flag
1381 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1382 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1383 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1385 /** Follow symlinks; archive and dump the files they point to. Currently only
1386 * supported on UNIX-like systems. */
1387 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1389 /** Call the progress function with the message
1390 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1392 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1394 /** Mark the image being added as the bootable image of the WIM. Not valid for
1395 * wimlib_update_image(). */
1396 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1398 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1399 * (major and minor number) of each file. See the documentation for the
1400 * <b>--unix-data</b> option to <b>wimlib-imagex capture</b> for more
1402 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1404 /** Do not capture security descriptors. Only has an effect in NTFS capture
1405 * mode, or in Windows native builds. */
1406 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1408 /** Fail immediately if the full security descriptor of any file or directory
1409 * cannot be accessed. Only has an effect in Windows native builds. The
1410 * default behavior without this flag is to first try omitting the SACL from the
1411 * security descriptor, then to try omitting the security descriptor entirely.
1413 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1415 /** Call the progress function with the message
1416 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1417 * capture. This is a subset of the messages provided by
1418 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1419 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1421 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1422 * in the case of Windows) that point inside the directory being captured to
1423 * instead be absolute relative to the directory being captured, rather than the
1426 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1427 * the WIM header or if this is the first image being added.
1428 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1429 * reparse point fixups enabled and currently cannot be unset. */
1430 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1432 /** Don't do reparse point fixups. The default behavior is described in the
1433 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1434 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1436 /** Do not automatically exclude unsupported files or directories from capture;
1437 * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1438 * UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1439 * such a file is encountered. */
1440 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1443 * Automatically select a capture configuration appropriate for capturing
1444 * filesystems containing Windows operating systems. For example,
1445 * "pagefile.sys" and "System Volume Information" will be excluded.
1447 * When this flag is specified, the corresponding @p config parameter or member
1450 * Note that the default behavior--- that is, when this flag is not specified
1451 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1452 * no files are excluded from capture.
1454 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1457 * Capture image as WIMBoot compatible. In addition, if no capture
1458 * configuration file is explicitly specified use the capture configuration file
1459 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1460 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1461 * configuration file is explicitly specified, use it and also place it at
1462 * /Windows/System32/WimBootCompress.ini in the WIM image.
1464 * Note: this will not by itself change the compression type. Before writing
1465 * the WIM file, it's recommended to also do:
1468 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1469 * wimlib_set_output_chunk_size(wim, 4096);
1472 * since that makes access to the data faster (at the cost of a worse
1473 * compression ratio compared to the 32768-byte LZX chunks usually used).
1475 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1478 * If the add command involves adding a non-directory file to a location at
1479 * which there already exists a nondirectory file in the WIM image, issue
1480 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This only has an
1481 * effect when updating an existing image with wimlib_update_image().
1482 * This was the default behavior in wimlib v1.6.2 and earlier.
1484 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1486 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1487 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1488 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1489 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1490 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1491 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1492 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1493 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1494 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1495 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1496 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1497 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1498 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1499 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT WIMLIB_ADD_FLAG_WIMBOOT
1503 /** @addtogroup G_modifying_wims
1506 /** Do not issue an error if the path to delete does not exist. */
1507 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1509 /** Delete the file or directory tree recursively; if not specified, an error is
1510 * issued if the path to delete is a directory. */
1511 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1514 /** @addtogroup G_modifying_wims
1518 * If a single image is being exported, mark it bootable in the destination WIM.
1519 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1520 * the image in the source WIM (if any) that is marked as bootable is also
1521 * marked as bootable in the destination WIM.
1523 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1525 /** Give the exported image(s) no names. Avoids problems with image name
1528 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1530 /** Give the exported image(s) no descriptions. */
1531 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1533 /** This advises the library that the program is finished with the source
1534 * WIMStruct and will not attempt to access it after the call to
1535 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1536 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1539 * Mark each exported image as WIMBoot-compatible.
1541 * Note: by itself, this does change the destination WIM's compression type, nor
1542 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1543 * image. Before writing the destination WIM, it's recommended to do something
1547 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1548 * wimlib_set_output_chunk_size(wim, 4096);
1549 * wimlib_add_tree(wim, image, L"myconfig.ini",
1550 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1553 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1556 /** @addtogroup G_extracting_wims
1559 /** Extract the image directly to an NTFS volume rather than a generic directory.
1560 * This mode is only available if wimlib was compiled with libntfs-3g support;
1561 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1562 * extraction target will be interpreted as the path to an NTFS volume image (as
1563 * a regular file or block device) rather than a directory. It will be opened
1564 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1565 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1566 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1567 * wimlib_extract_paths() when passed multiple paths. */
1568 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1570 /** UNIX-like systems only: Extract special UNIX data captured with
1571 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1572 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1573 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1575 /** Do not extract security descriptors. This flag cannot be combined with
1576 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1577 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1579 /** Fail immediately if the full security descriptor of any file or directory
1580 * cannot be set exactly as specified in the WIM file. On Windows, the default
1581 * behavior without this flag when wimlib does not have permission to set the
1582 * correct security descriptor is to fall back to setting the security
1583 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1584 * owner omitted, then not at all. This flag cannot be combined with
1585 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1586 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1588 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1589 * reparse-point fixups on, so absolute symbolic links or junction points will
1590 * be fixed to be absolute relative to the actual extraction root. Reparse-
1591 * point fixups are done by default for wimlib_extract_image() and
1592 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1593 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1594 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1596 /** Force reparse-point fixups on extraction off, regardless of the state of the
1597 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1598 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1599 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1601 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1602 * paths, each of which must name a regular file, to standard output. */
1603 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1605 /** Instead of ignoring files and directories with names that cannot be
1606 * represented on the current platform (note: Windows has more restrictions on
1607 * filenames than POSIX-compliant systems), try to replace characters or append
1608 * junk to the names so that they can be extracted in some form. */
1609 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1611 /** On Windows, when there exist two or more files with the same case
1612 * insensitive name but different case sensitive names, try to extract them all
1613 * by appending junk to the end of them, rather than arbitrarily extracting only
1615 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1617 /** Do not ignore failure to set timestamps on extracted files. */
1618 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1620 /** Do not ignore failure to set short names on extracted files. */
1621 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1623 /** On Windows, do not ignore failure to extract symbolic links and junctions
1624 * due to permissions problems. By default, such failures are ignored since the
1625 * default configuration of Windows only allows the Administrator to create
1626 * symbolic links. */
1627 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1629 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1630 * behavior is currently less than satisfactory. Do not use (yet). */
1631 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1633 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1634 * paths to extract as wildcard patterns ("globs") which may contain the
1635 * wildcard characters @c ? and @c *. The @c ? character matches any
1636 * non-path-separator character, whereas the @c * character matches zero or more
1637 * non-path-separator characters. Consequently, each glob may match zero or
1638 * more actual paths in the WIM image. By default, if a glob does not match any
1639 * files, a warning but not an error will be issued, even if the glob did not
1640 * actually contain wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
1641 * to get an error instead. */
1642 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1644 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1645 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1646 * one of the provided globs did not match a file. */
1647 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1649 /** Do not extract Windows file attributes such as readonly, hidden, etc. */
1650 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1652 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1653 * preserve the directory structure of the archive when extracting --- that is,
1654 * place each extracted file or directory tree directly in the target directory.
1656 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1658 /** Windows only: Extract files as "pointers" back to the WIM archive. See the
1659 * documentation for the <b>--wimboot</b> option of <b>wimlib-imagex apply</b>
1660 * for more information. */
1661 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1664 /** @addtogroup G_mounting_wim_images
1667 /** Mount the WIM image read-write rather than the default of read-only. */
1668 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1670 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1671 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1673 /** Do not allow accessing named data streams in the mounted WIM image. */
1674 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1676 /** Access named data streams in the mounted WIM image through extended file
1677 * attributes named "user.X", where X is the name of a data stream. This is the
1679 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1681 /** Access named data streams in the mounted WIM image by specifying the file
1682 * name, a colon, then the name of the data stream. */
1683 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1685 /** Use UNIX metadata if available in the WIM image. See
1686 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1687 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1689 /** Allow other users to see the mounted filesystem. This passes the @c
1690 * allow_other option to the FUSE mount. */
1691 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1694 /** @addtogroup G_creating_and_opening_wims
1697 /** Verify the WIM contents against the WIM's integrity table, if present. This
1698 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1699 * checksummed and checked against the SHA1 message digests specified in the
1700 * integrity table. If there are any mismatches, ::WIMLIB_ERR_INTEGRITY is
1701 * issued. If the WIM file does not contain an integrity table, this flag has
1703 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1705 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
1706 * WIM. Software can provide this flag for convenience if it explicitly does
1707 * not want to support split WIMs. */
1708 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1710 /** Check if the WIM is writable and issue an error
1711 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
1712 * only if it is writable at the filesystem level, does not have the
1713 * WIM_HDR_FLAG_READONLY flag set in its header, and is not part of a spanned
1714 * set. It is not required to provide this flag before attempting to make
1715 * changes to the WIM, but with this flag you get an error sooner rather than
1717 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1720 /** @addtogroup G_mounting_wim_images
1723 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
1724 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1725 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1727 /** Commit changes to the read-write mounted WIM image.
1728 * If this flag is not specified, changes will be discarded. */
1729 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1731 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
1732 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1733 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1735 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
1736 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1737 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1740 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
1741 * image, forces all file descriptors to the open WIM image to be closed before
1744 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
1745 * this flag has no effect.
1747 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
1749 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1750 * WIM image, causes the modified image to be committed to the WIM file as a
1751 * new, unnamed image appended to the archive. The original image in the WIM
1752 * file will be unmodified. */
1753 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
1756 /** @addtogroup G_modifying_wims
1759 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1760 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1761 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1764 /** @addtogroup G_writing_and_overwriting_wims
1768 * Include an integrity table in the resulting WIM file.
1770 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1771 * include an integrity table if and only if one was present before. For
1772 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1773 * to not include an integrity table.
1775 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1778 * Do not include an integrity table in the resulting WIM file. This is the
1779 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
1782 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1785 * Write the WIM as "pipable". After writing a WIM with this flag specified,
1786 * images from it can be applied directly from a pipe using
1787 * wimlib_extract_image_from_pipe(). See the documentation for the
1788 * <b>--pipable</b> option of <b>wimlib-imagex capture</b> for more information.
1789 * Beware: WIMs written with this flag will not be compatible with Microsoft's
1792 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1793 * write the WIM as pipable if and only if it was pipable before. For
1794 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1795 * to write the WIM as non-pipable.
1797 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1800 * Do not write the WIM as "pipable". This is the default behavior, unless the
1801 * ::WIMStruct was created by opening a pipable WIM.
1803 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1806 * When writing streams to the WIM file, recompress them, even if their data is
1807 * already available in the desired compressed form (for example, in a WIM file
1808 * from which an image has been exported using wimlib_export_image()).
1810 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
1811 * compression ratio for the same compression type and chunk size. wimlib's LZX
1812 * compressor currently can be given different parameters in order to achieve
1813 * different balances between compression ratio and time. In its default mode
1814 * as of v1.7.0, it usually compresses slightly better than the competing
1815 * Microsoft implementation and is almost as fast.
1817 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can also be used in combination with
1818 * ::WIMLIB_WRITE_FLAG_PACK_STREAMS to prevent any solid blocks from being
1819 * re-used. (Otherwise, solid blocks are re-used somewhat more liberally than
1820 * normal compressed blocks.)
1822 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
1823 * that would not otherwise be written. For example, a call to
1824 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
1825 * cause already-existing streams in the WIM file to be recompressed. To force
1826 * the WIM file to be fully rebuilt and recompressed, combine
1827 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
1829 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1832 * Immediately before closing the WIM file, sync its data to disk.
1834 * wimlib_overwrite() will set this flag automatically if it decides to
1835 * overwrite the WIM file via a temporary file instead of in-place.
1837 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1840 * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
1841 * could be updated merely by appending to it.
1843 * When rebuilding the WIM file, stream reference counts will be recomputed, and
1844 * any streams with 0 reference count (e.g. from deleted files or images) will
1845 * not be included in the resulting WIM file.
1847 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
1848 * data to be recompressed. Otherwise, compressed data is re-used if possible.
1850 * wimlib_write() ignores this flag.
1852 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1855 * For wimlib_overwrite(), override the default behavior after one or more calls
1856 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
1857 * flag, only minimal changes to correctly remove the image from the WIM file
1858 * will be taken. In particular, all streams will be retained, even if they are
1859 * no longer referenced. This may not be what you want, because no space will
1860 * be saved by deleting an image in this way.
1862 * wimlib_write() ignores this flag.
1864 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1867 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
1868 * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header. This can be used
1869 * following a call to wimlib_set_wim_info() with the
1870 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
1873 * wimlib_write() ignores this flag.
1875 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1878 * Do not include streams already present in other WIMs. This flag can be used
1879 * to write a "delta" WIM after resources from the WIM on which the delta is to
1880 * be based were referenced with wimlib_reference_resource_files() or
1881 * wimlib_reference_resources().
1883 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1886 * Advises the library that for writes of all WIM images, all streams needed for
1887 * the WIM are already present (not in external resource WIMs) and their
1888 * reference counts are correct, so the code does not need to recalculate which
1889 * streams are referenced. This is for optimization purposes only, since with
1890 * this flag specified, the metadata resources may not need to be decompressed
1893 * wimlib_overwrite() will set this flag automatically.
1895 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1898 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
1900 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
1903 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
1906 * When writing streams in the resulting WIM file, pack multiple streams into a
1907 * single compressed resource instead of compressing them independently. This
1908 * is also known as creating a "solid archive". This tends to produce a better
1909 * compression ratio at the cost of much slower random access.
1911 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
1912 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
1913 * created with this flag use a different version number in their header (3584
1914 * instead of 68864) and are also called "ESD files".
1916 * If this flag is passed to wimlib_overwrite(), any new data streams will be
1917 * written in solid mode. Use both ::WIMLIB_WRITE_FLAG_REBUILD and
1918 * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
1919 * all streams recompressed in solid mode.
1921 * Currently, new solid blocks will, by default, be written using LZMS
1922 * compression with 64 MiB (67108864 byte) chunks. Use
1923 * wimlib_set_output_pack_compression_type() and/or
1924 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
1925 * the WIM's main compression type and chunk size; you can have a WIM that
1926 * nominally uses LZX compression and 32768 byte chunks but actually contains
1927 * LZMS-compressed solid blocks, for example. However, if including solid
1928 * blocks, I suggest that you set the WIM's main compression type to LZMS as
1929 * well, either by creating the WIM with
1930 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
1931 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
1933 * This flag will be set by default when writing or overwriting a WIM file that
1934 * either already contains packed streams, or has had packed streams exported
1935 * into it and the WIM's main compression type is LZMS.
1937 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
1940 /** @addtogroup G_general
1943 /** Assume that strings are represented in UTF-8, even if this is not the
1944 * locale's character encoding. This flag is ignored on Windows, where wimlib
1945 * always uses UTF-16LE. */
1946 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1948 /** Windows-only: do not attempt to acquire additional privileges (currently
1949 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1950 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1951 * for the case where the calling program manages these privileges itself.
1952 * Note: no error is issued if privileges cannot be acquired, although related
1953 * errors may be reported later, depending on if the operations performed
1954 * actually require additional privileges or not. */
1955 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1957 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1958 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1959 * to read all possible data and metadata for a capture operation could not be
1960 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1962 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1964 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1965 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1966 * to restore all possible data and metadata for an apply operation could not be
1967 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1969 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1971 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1973 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
1975 /** Default to interpreting WIM paths case insensitively (default on Windows).
1976 * This does not apply to mounted images. */
1977 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
1980 /** @addtogroup G_nonstandalone_wims
1983 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
1984 * Ignored by wimlib_reference_resources(). */
1985 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1987 /** For wimlib_reference_resource_files(), issue an error
1988 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1989 * default behavior without this flag is to issue no error at that point, but
1990 * then attempt to open the glob as a literal path, which of course will fail
1991 * anyway if no file exists at that path. No effect if
1992 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
1993 * wimlib_reference_resources(). */
1994 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1997 /** @addtogroup G_modifying_wims
2000 /** The specific type of update to perform. */
2001 enum wimlib_update_op {
2002 /** Add a new file or directory tree to the WIM image in a
2003 * certain location. */
2004 WIMLIB_UPDATE_OP_ADD = 0,
2006 /** Delete a file or directory tree from the WIM image. */
2007 WIMLIB_UPDATE_OP_DELETE,
2009 /** Rename a file or directory tree in the WIM image. */
2010 WIMLIB_UPDATE_OP_RENAME,
2013 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2014 struct wimlib_add_command {
2015 /** Filesystem path to the file or directory tree to add. */
2016 wimlib_tchar *fs_source_path;
2018 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
2019 * specify the root directory of the WIM image. */
2020 wimlib_tchar *wim_target_path;
2022 /** Path to capture configuration file to use, or @c NULL for default.
2024 wimlib_tchar *config_file;
2026 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2030 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2031 struct wimlib_delete_command {
2033 /** Path, specified from the root of the WIM image, for the file or
2034 * directory tree within the WIM image to be deleted. */
2035 wimlib_tchar *wim_path;
2037 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2041 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2042 struct wimlib_rename_command {
2044 /** Path, specified from the root of the WIM image, for the source file
2045 * or directory tree within the WIM image. */
2046 wimlib_tchar *wim_source_path;
2048 /** Path, specified from the root of the WIM image, for the destination
2049 * file or directory tree within the WIM image. */
2050 wimlib_tchar *wim_target_path;
2052 /** Reserved; set to 0. */
2056 /** Specification of an update to perform on a WIM image. */
2057 struct wimlib_update_command {
2059 enum wimlib_update_op op;
2062 struct wimlib_add_command add;
2063 struct wimlib_delete_command delete_; /* Underscore is for C++
2065 struct wimlib_rename_command rename;
2070 /** @addtogroup G_general
2074 * Possible values of the error code returned by many functions in wimlib.
2076 * See the documentation for each wimlib function to see specifically what error
2077 * codes can be returned by a given function, and what they mean.
2079 enum wimlib_error_code {
2080 WIMLIB_ERR_SUCCESS = 0,
2081 WIMLIB_ERR_ALREADY_LOCKED = 1,
2082 WIMLIB_ERR_DECOMPRESSION = 2,
2083 WIMLIB_ERR_FUSE = 6,
2084 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2085 WIMLIB_ERR_ICONV_NOT_AVAILABLE = 9,
2086 WIMLIB_ERR_IMAGE_COUNT = 10,
2087 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2088 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2089 WIMLIB_ERR_INTEGRITY = 13,
2090 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2091 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2092 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2093 WIMLIB_ERR_INVALID_HEADER = 17,
2094 WIMLIB_ERR_INVALID_IMAGE = 18,
2095 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2096 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2097 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2098 WIMLIB_ERR_INVALID_MULTIBYTE_STRING = 22,
2099 WIMLIB_ERR_INVALID_OVERLAY = 23,
2100 WIMLIB_ERR_INVALID_PARAM = 24,
2101 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2102 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2103 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2104 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2105 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2106 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2107 WIMLIB_ERR_IS_DIRECTORY = 32,
2108 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2109 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE = 34,
2110 WIMLIB_ERR_LINK = 35,
2111 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2112 WIMLIB_ERR_MKDIR = 37,
2113 WIMLIB_ERR_MQUEUE = 38,
2114 WIMLIB_ERR_NOMEM = 39,
2115 WIMLIB_ERR_NOTDIR = 40,
2116 WIMLIB_ERR_NOTEMPTY = 41,
2117 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2118 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2119 WIMLIB_ERR_NOT_PIPABLE = 44,
2120 WIMLIB_ERR_NO_FILENAME = 45,
2121 WIMLIB_ERR_NTFS_3G = 46,
2122 WIMLIB_ERR_OPEN = 47,
2123 WIMLIB_ERR_OPENDIR = 48,
2124 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2125 WIMLIB_ERR_READ = 50,
2126 WIMLIB_ERR_READLINK = 51,
2127 WIMLIB_ERR_RENAME = 52,
2128 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2129 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2130 WIMLIB_ERR_RESOURCE_ORDER = 56,
2131 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2132 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2133 WIMLIB_ERR_SET_SECURITY = 59,
2134 WIMLIB_ERR_SET_SHORT_NAME = 60,
2135 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2136 WIMLIB_ERR_SPLIT_INVALID = 62,
2137 WIMLIB_ERR_STAT = 63,
2138 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2139 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2140 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2141 WIMLIB_ERR_UNSUPPORTED = 68,
2142 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2143 WIMLIB_ERR_WIM_IS_READONLY = 71,
2144 WIMLIB_ERR_WRITE = 72,
2145 WIMLIB_ERR_XML = 73,
2146 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2147 WIMLIB_ERR_WIMBOOT = 75,
2148 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2149 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2150 WIMLIB_ERR_MKNOD = 78,
2151 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2152 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2153 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2157 /** Used to indicate no WIM image or an invalid WIM image. */
2158 #define WIMLIB_NO_IMAGE 0
2160 /** Used to specify all images in the WIM. */
2161 #define WIMLIB_ALL_IMAGES (-1)
2166 * @ingroup G_modifying_wims
2168 * Appends an empty image to a WIM file. This empty image will initially
2169 * contain no files or directories, although if written without further
2170 * modifications, a root directory will be created automatically for it. After
2171 * calling this function, you can use wimlib_update_image() to add files to the
2172 * new WIM image. This gives you slightly more control over making the new
2173 * image compared to calling wimlib_add_image() or
2174 * wimlib_add_image_multisource() directly.
2177 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2180 * Name to give the new image. If @c NULL or empty, the new image is given
2181 * no name. If nonempty, it must specify a name that does not already
2183 * @param new_idx_ret
2184 * If non-<code>NULL</code>, the index of the newly added image is returned
2187 * @return 0 on success; nonzero on failure. The possible error codes are:
2189 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2190 * There is already an image in @p wim named @p name.
2191 * @retval ::WIMLIB_ERR_NOMEM
2192 * Failed to allocate the memory needed to add the new image.
2193 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2194 * The WIM file is considered read-only because of any of the reasons
2195 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2199 wimlib_add_empty_image(WIMStruct *wim,
2200 const wimlib_tchar *name,
2204 * @ingroup G_modifying_wims
2206 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2208 * The directory tree or NTFS volume is scanned immediately to load the dentry
2209 * tree into memory, and file attributes and symbolic links are read. However,
2210 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2213 * See the manual page for the @b wimlib-imagex program for more information
2214 * about the "normal" capture mode versus the NTFS capture mode (entered by
2215 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2217 * Note that @b no changes are committed to the underlying WIM file (if
2218 * any) until wimlib_write() or wimlib_overwrite() is called.
2221 * Pointer to the ::WIMStruct to which to add the image.
2223 * A path to a directory or unmounted NTFS volume that will be captured as
2226 * Name to give the new image. If @c NULL or empty, the new image is given
2227 * no name. If nonempty, it must specify a name that does not already
2229 * @param config_file
2230 * Path to capture configuration file, or @c NULL. This file may specify,
2231 * among other things, which files to exclude from capture. See the man
2232 * page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2233 * details of the file format. If @c NULL, the default capture
2234 * configuration shall be used. Ordinarily, the default capture
2235 * configuration will result in no files being excluded from capture purely
2236 * based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2237 * ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2239 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2241 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2242 * discarded so that it appears to be in the same state as when this function
2245 * This function is implemented by calling wimlib_add_empty_image(), then
2246 * calling wimlib_update_image() with a single "add" command, so any error code
2247 * returned by wimlib_add_empty_image() may be returned, as well as any error
2248 * codes returned by wimlib_update_image() other than ones documented as only
2249 * being returned specifically by an update involving delete or rename commands.
2251 * If a progress function is registered with @p wim, it will receive the
2252 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2253 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2254 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2257 wimlib_add_image(WIMStruct *wim,
2258 const wimlib_tchar *source,
2259 const wimlib_tchar *name,
2260 const wimlib_tchar *config_file,
2264 * @ingroup G_modifying_wims
2266 * This function is equivalent to wimlib_add_image() except it allows for
2267 * multiple sources to be combined into a single WIM image. This is done by
2268 * specifying the @p sources and @p num_sources parameters instead of the @p
2269 * source parameter of wimlib_add_image(). The rest of the parameters are the
2270 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2271 * capture</b> for full details on how this mode works.
2273 * In addition to the error codes that wimlib_add_image() can return,
2274 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2275 * when trying to overlay a non-directory on a directory or when otherwise
2276 * trying to overlay multiple conflicting files to the same location in the WIM
2277 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2278 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2279 * was not exactly one capture source with the target being the root directory.
2280 * (In this respect, there is no advantage to using
2281 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2284 wimlib_add_image_multisource(WIMStruct *wim,
2285 const struct wimlib_capture_source *sources,
2287 const wimlib_tchar *name,
2288 const wimlib_tchar *config_file,
2292 * @ingroup G_modifying_wims
2294 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2295 * location @p wim_target_path within the specified @p image of the @p wim.
2297 * This just builds an appropriate ::wimlib_add_command and passes it to
2298 * wimlib_update_image().
2301 wimlib_add_tree(WIMStruct *wim, int image,
2302 const wimlib_tchar *fs_source_path,
2303 const wimlib_tchar *wim_target_path, int add_flags);
2306 * @ingroup G_creating_and_opening_wims
2308 * Creates a ::WIMStruct for a new WIM file.
2310 * This only creates an in-memory structure for a WIM that initially contains no
2311 * images. No on-disk file is created until wimlib_write() is called.
2314 * The type of compression to be used in the new WIM file, as one of the
2315 * ::wimlib_compression_type constants.
2317 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2318 * written to the memory location pointed to by this parameter. The
2319 * ::WIMStruct must be freed using using wimlib_free() when finished with
2321 * @return 0 on success; nonzero on error.
2322 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2323 * @p ctype was not a supported compression type.
2324 * @retval ::WIMLIB_ERR_NOMEM
2325 * Failed to allocate needed memory.
2328 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2331 * @ingroup G_modifying_wims
2333 * Deletes an image, or all images, from a WIM file.
2335 * All streams referenced by the image(s) being deleted are removed from the
2336 * lookup table of the WIM if they are not referenced by any other images in the
2339 * Please note that @b no changes are committed to the underlying WIM file (if
2340 * any) until wimlib_write() or wimlib_overwrite() is called.
2343 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2346 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2348 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2349 * to be left unmodified only if @p image specified a single image. If instead
2350 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2351 * possible for some but not all of the images to have been deleted when a
2352 * failure status is returned.
2354 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2355 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2356 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2357 * The WIM file is considered read-only because of any of the reasons
2358 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2361 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2362 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2363 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2364 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2365 * different reasons) to read the metadata resource for an image that needed to
2369 wimlib_delete_image(WIMStruct *wim, int image);
2372 * @ingroup G_modifying_wims
2374 * Delete the @p path from the specified @p image of the @p wim.
2376 * This just builds an appropriate ::wimlib_delete_command and passes it to
2377 * wimlib_update_image().
2380 wimlib_delete_path(WIMStruct *wim, int image,
2381 const wimlib_tchar *path, int delete_flags);
2384 * @ingroup G_modifying_wims
2386 * Exports an image, or all the images, from a WIM file, into another WIM file.
2388 * The destination image is made to share the same dentry tree and security data
2389 * structure as the source image. This places some restrictions on additional
2390 * functions that may be called. For example, you may not call wimlib_free() on
2391 * @p src_wim before calling wimlib_write() or wimlib_overwrite() on @p dest_wim
2392 * because @p dest_wim will have references back to @p src_wim.
2394 * If this function fails, all changes to @p dest_wim are rolled back.
2396 * Please note that no changes are committed to the underlying WIM file of @p
2397 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2400 * The WIM from which to export the images, specified as a pointer to the
2401 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2402 * split WIM. In the case of a WIM file that is not standalone, this
2403 * ::WIMStruct must have had any needed external resources previously
2404 * referenced using wimlib_reference_resources() or
2405 * wimlib_reference_resource_files().
2407 * The image to export from @p src_wim, as either a 1-based image index to
2408 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2410 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2413 * For single-image exports, the name to give the exported image in @p
2414 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2415 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2416 * that case, the names are all taken from @p src_wim. This parameter is
2417 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2418 * @param dest_description
2419 * For single-image exports, the description to give the exported image in
2420 * the new WIM file. If left @c NULL, the description from @p src_wim is
2421 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2422 * NULL; in that case, the description are all taken from @p src_wim. This
2423 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2424 * @param export_flags
2425 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2427 * @return 0 on success; nonzero on error.
2428 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2429 * One or more of the names being given to an exported image was already in
2430 * use in the destination WIM.
2431 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2432 * @p src_image does not exist in @p src_wim and was not
2433 * ::WIMLIB_ALL_IMAGES.
2434 * @retval ::WIMLIB_ERR_INVALID_PARAM
2435 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2436 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2438 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2439 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2440 * example, one of them was a non-first part of a split WIM.
2441 * @retval ::WIMLIB_ERR_NOMEM
2442 * Failed to allocate needed memory.
2443 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2444 * A resource that needed to be exported could not be found in either the
2445 * source or destination WIMs. This error can occur if, for example, @p
2446 * src_wim is part of a split WIM but needed resources from the other split
2447 * WIM parts were not referenced with wimlib_reference_resources() or
2448 * wimlib_reference_resource_files() before the call to
2449 * wimlib_export_image().
2450 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2451 * @p dest_wim is considered read-only because of any of the reasons
2452 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2455 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2456 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2457 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2458 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2459 * different reasons) to read the metadata resource for an image in @p src_wim
2460 * that needed to be exported.
2463 wimlib_export_image(WIMStruct *src_wim, int src_image,
2464 WIMStruct *dest_wim,
2465 const wimlib_tchar *dest_name,
2466 const wimlib_tchar *dest_description,
2470 * @ingroup G_extracting_wims
2472 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2475 * The exact behavior of how wimlib extracts files from a WIM image is
2476 * controllable by the @p extract_flags parameter, but there also are
2477 * differences depending on the platform (UNIX-like vs Windows). See the manual
2478 * page for <b>wimlib-imagex apply</b> for more information, including about the
2479 * special "NTFS volume extraction mode" entered by providing
2480 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2483 * The WIM from which to extract the image(s), specified as a pointer to
2484 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2485 * of a split WIM. In the case of a WIM file that is not standalone, this
2486 * ::WIMStruct must have had any needed external resources previously
2487 * referenced using wimlib_reference_resources() or
2488 * wimlib_reference_resource_files().
2490 * The image to extract, specified as either the 1-based index of a single
2491 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2492 * to be extracted. ::WIMLIB_ALL_IMAGES cannot be used if
2493 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2495 * Directory to extract the WIM image(s) to; or, with
2496 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2497 * the unmounted NTFS volume to which to extract the image.
2498 * @param extract_flags
2499 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2501 * @return 0 on success; nonzero on error.
2502 * @retval ::WIMLIB_ERR_DECOMPRESSION
2503 * Failed to decompress data contained in the WIM.
2504 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2505 * The metadata for one of the images to extract was invalid.
2506 * @retval ::WIMLIB_ERR_INVALID_PARAM
2507 * The extraction flags were invalid; more details may be found in the
2508 * documentation for the specific extraction flags that were specified. Or
2509 * @p target was @c NULL or the empty string, or @p wim was @c NULL.
2510 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2511 * The SHA1 message digest of an extracted stream did not match the SHA1
2512 * message digest given in the WIM.
2513 * @retval ::WIMLIB_ERR_LINK
2514 * Failed to create a symbolic link or a hard link.
2515 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2516 * The metadata resource for one of the images to extract was not found.
2517 * This can happen if @p wim represents a non-first part of a split WIM.
2518 * @retval ::WIMLIB_ERR_MKDIR
2519 * Failed create a directory.
2520 * @retval ::WIMLIB_ERR_NOMEM
2521 * Failed to allocate needed memory.
2522 * @retval ::WIMLIB_ERR_OPEN
2523 * Could not create a file, or failed to open an already-extracted file.
2524 * @retval ::WIMLIB_ERR_READ
2525 * Failed to read data from the WIM.
2526 * @retval ::WIMLIB_ERR_READLINK
2527 * Failed to determine the target of a symbolic link in the WIM.
2528 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2529 * Failed to fix the target of an absolute symbolic link (e.g. if the
2530 * target would have exceeded the maximum allowed length). (Only if
2531 * reparse data was supported by the extraction mode and
2532 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2534 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2535 * One of the files or directories that needed to be extracted referenced a
2536 * stream not present in the WIM's lookup table (or in any of the lookup
2537 * tables of the split WIM parts).
2538 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2539 * Failed to set attributes on a file.
2540 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2541 * Failed to set reparse data on a file (only if reparse data was supported
2542 * by the extraction mode).
2543 * @retval ::WIMLIB_ERR_SET_SECURITY
2544 * Failed to set security descriptor on a file
2545 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2547 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2548 * Failed to set the short name of a file (only if
2549 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2550 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2551 * Failed to set timestamps on a file (only if
2552 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2553 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2554 * Unexpected end-of-file occurred when reading data from the WIM.
2555 * @retval ::WIMLIB_ERR_UNSUPPORTED
2556 * A requested extraction flag, or the data or metadata that must be
2557 * extracted to support it, is unsupported in the build and configuration
2558 * of wimlib, or on the current platform or extraction mode or target
2559 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2560 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2561 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2562 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2563 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2564 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2565 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2566 * image contains one or more files with short names, but extracting short
2567 * names is not supported --- on Windows, this occurs if the target volume
2568 * does not support short names, while on non-Windows, this occurs if
2569 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2570 * @retval ::WIMLIB_ERR_WIMBOOT
2571 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2572 * there was a problem creating WIMBoot pointer files.
2573 * @retval ::WIMLIB_ERR_WRITE
2574 * Failed to write data to a file being extracted.
2576 * If a progress function is registered with @p wim, then as each image is
2577 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2578 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then
2579 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2582 wimlib_extract_image(WIMStruct *wim, int image,
2583 const wimlib_tchar *target, int extract_flags);
2586 * @ingroup G_extracting_wims
2588 * Since wimlib v1.5.0: Extract one image from a pipe on which a pipable WIM is
2591 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2592 * about pipable WIMs.
2594 * This function operates in a special way to read the WIM fully sequentially.
2595 * As a result, there is no ::WIMStruct is made visible to library users, and
2596 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2597 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2598 * seekable file, not a pipe.)
2601 * File descriptor, which may be a pipe, opened for reading and positioned
2602 * at the start of the pipable WIM.
2603 * @param image_num_or_name
2604 * String that specifies the 1-based index or name of the image to extract.
2605 * It is translated to an image index using the same rules that
2606 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2607 * only a single image (not all images) can be specified. Alternatively,
2608 * specify @p NULL here to use the first image in the WIM if it contains
2609 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2611 * Same as the corresponding parameter to wimlib_extract_image().
2612 * @param extract_flags
2613 * Same as the corresponding parameter to wimlib_extract_image().
2615 * @return 0 on success; nonzero on error. The possible error codes include
2616 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2619 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2620 * Data read from the pipable WIM was invalid.
2621 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2622 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2625 wimlib_extract_image_from_pipe(int pipe_fd,
2626 const wimlib_tchar *image_num_or_name,
2627 const wimlib_tchar *target, int extract_flags);
2630 * @ingroup G_extracting_wims
2632 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2633 * function. The progress function will be used while extracting the WIM image
2634 * and will receive the normal extraction progress messages, such as
2635 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2636 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2639 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2640 const wimlib_tchar *image_num_or_name,
2641 const wimlib_tchar *target,
2643 wimlib_progress_func_t progfunc,
2647 * @ingroup G_extracting_wims
2649 * Since wimlib v1.6.0: Similar to wimlib_extract_paths(), but the paths to
2650 * extract from the WIM image are specified in the ASCII, UTF-8, or UTF-16LE
2651 * text file named by @p path_list_file which itself contains the list of paths
2652 * to use, one per line. Leading and trailing whitespace, and otherwise empty
2653 * lines and lines beginning with the ';' character are ignored. No quotes are
2654 * needed as paths are otherwise delimited by the newline character.
2656 * The error codes are the same as those returned by wimlib_extract_paths(),
2657 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2658 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2659 * ::WIMLIB_ERR_READ).
2662 wimlib_extract_pathlist(WIMStruct *wim, int image,
2663 const wimlib_tchar *target,
2664 const wimlib_tchar *path_list_file,
2668 * @ingroup G_extracting_wims
2670 * Since wimlib v1.6.0: Extract zero or more paths (files or directory trees)
2671 * from the specified WIM image.
2673 * By default, each path will be extracted to a corresponding subdirectory of
2674 * the target based on its location in the WIM image. For example, if one of
2675 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2676 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
2677 * can be changed by providing the flag
2678 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2679 * or directory tree to be placed directly in the target directory --- so the
2680 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2682 * Symbolic links will not be dereferenced when paths in the WIM image are
2686 * WIM from which to extract the paths, specified as a pointer to the
2687 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2688 * split WIM. In the case of a WIM file that is not standalone, this
2689 * ::WIMStruct must have had any needed external resources previously
2690 * referenced using wimlib_reference_resources() or
2691 * wimlib_reference_resource_files().
2693 * 1-based index of the WIM image from which to extract the paths.
2695 * Array of paths to extract. Each element must be the absolute path to a
2696 * file or directory within the WIM image. Separators may be either
2697 * forwards or backwards slashes, and leading path separators are optional.
2698 * The paths will be interpreted either case-sensitively (UNIX default) or
2699 * case-insensitively (Windows default); this can be changed by
2700 * wimlib_global_init().
2702 * By default, the characters @c * and @c ? are interpreted literally.
2703 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2706 * By default, if any paths to extract do not exist, the error code
2707 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
2708 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2710 * Number of paths specified in @p paths.
2712 * Directory to which to extract the paths; or with
2713 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2714 * unmounted NTFS volume to which to extract the paths. Unlike the @p
2715 * paths being extracted, the @p target must be native path. On UNIX-like
2716 * systems it may not contain backslashes, for example.
2717 * @param extract_flags
2718 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2720 * @return 0 on success; nonzero on error. Most of the error codes are the same
2721 * as those returned by wimlib_extract_image(). Below, some of the error codes
2722 * returned in situations specific to path-mode extraction are documented:
2724 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2725 * @p image was ::WIMLIB_ALL_IMAGES or was otherwise not a valid single
2727 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2728 * One of the paths to extract did not exist in the WIM image. This error
2729 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2730 * specified in @p extract_flags, or if both
2731 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2732 * were specified in @p extract_flags.
2733 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2734 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2735 * one of the paths to extract did not name a regular file.
2737 * If a progress function is registered with @p wim, it will receive
2738 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. Note that because the extraction code
2739 * is stream-based and not file-based, there is no way to get information about
2740 * which path is currently being extracted, but based on byte count you can
2741 * still calculate an approximate percentage complete for the extraction overall
2742 * which may be all you really need anyway.
2745 wimlib_extract_paths(WIMStruct *wim,
2747 const wimlib_tchar *target,
2748 const wimlib_tchar * const *paths,
2753 * @ingroup G_wim_information
2755 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2756 * includes a string of XML that describes the images contained in the WIM.
2758 * See wimlib_get_xml_data() to read the XML data into memory instead.
2761 * Pointer to the ::WIMStruct to query. This need not represent a
2762 * standalone WIM (e.g. it could represent part of a split WIM).
2764 * @c stdout, or a FILE* opened for writing, to extract the data to.
2766 * @return 0 on success; nonzero on error.
2767 * @retval ::WIMLIB_ERR_INVALID_PARAM
2768 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2769 * @retval ::WIMLIB_ERR_NOMEM
2770 * Failed to allocate needed memory.
2771 * @retval ::WIMLIB_ERR_READ
2772 * Error reading the XML data from the WIM file.
2773 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2774 * Error reading the XML data from the WIM file.
2775 * @retval ::WIMLIB_ERR_WRITE
2776 * Failed to completely write the XML data to @p fp.
2779 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2782 * @ingroup G_general
2784 * Frees all memory allocated for a WIMStruct and closes all files associated
2788 * Pointer to the ::WIMStruct to free.
2790 * @return This function has no return value.
2793 wimlib_free(WIMStruct *wim);
2796 * @ingroup G_general
2798 * Converts a ::wimlib_compression_type value into a string.
2801 * The ::wimlib_compression_type value to convert.
2804 * A statically allocated string naming the compression algorithm,
2805 * such as "None", "LZX", "XPRESS", or "Invalid".
2807 extern const wimlib_tchar *
2808 wimlib_get_compression_type_string(int ctype);
2811 * @ingroup G_general
2813 * Converts an error code into a string describing it.
2816 * The error code returned by one of wimlib's functions.
2819 * Pointer to a statically allocated string describing the error code,
2820 * or @c NULL if the error code is not valid.
2822 extern const wimlib_tchar *
2823 wimlib_get_error_string(enum wimlib_error_code code);
2826 * @ingroup G_wim_information
2828 * Returns the description of the specified image.
2831 * Pointer to the ::WIMStruct to query. This need not represent a
2832 * standalone WIM (e.g. it could represent part of a split WIM).
2834 * The number of the image, numbered starting at 1.
2837 * The description of the image, or @c NULL if there is no such image, or
2838 * @c NULL if the specified image has no description. The description
2839 * string is in library-internal memory and may not be modified or freed;
2840 * in addition, the string will become invalid if the description of the
2841 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2843 extern const wimlib_tchar *
2844 wimlib_get_image_description(const WIMStruct *wim, int image);
2847 * @ingroup G_wim_information
2849 * Returns the name of the specified image.
2852 * Pointer to the ::WIMStruct to query. This need not represent a
2853 * standalone WIM (e.g. it could represent part of a split WIM).
2855 * The number of the image, numbered starting at 1.
2858 * The name of the image, or @c NULL if there is no such image, or an empty
2859 * string if the image is unnamed. The name string is in
2860 * library-internal memory and may not be modified or freed; in addition,
2861 * the string will become invalid if the name of the image is changed, the
2862 * image is deleted, or the ::WIMStruct is destroyed.
2864 extern const wimlib_tchar *
2865 wimlib_get_image_name(const WIMStruct *wim, int image);
2868 * @ingroup G_general
2870 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
2871 * the major version, the next 10 bits contain the minor version, and the low 10
2872 * bits contain the patch version.
2874 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
2875 * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
2876 * corresponding header file.
2879 wimlib_get_version(void);
2882 * @ingroup G_wim_information
2884 * Get basic information about a WIM file.
2887 * Pointer to the ::WIMStruct to query. This need not represent a
2888 * standalone WIM (e.g. it could represent part of a split WIM).
2890 * A ::wimlib_wim_info structure that will be filled in with information
2891 * about the WIM file.
2896 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2899 * @ingroup G_wim_information
2901 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
2902 * includes a string of XML that describes the images contained in the WIM.
2904 * See wimlib_extract_xml_data() to extract the XML data to a file stream
2908 * Pointer to the ::WIMStruct to query. This need not represent a
2909 * standalone WIM (e.g. it could represent part of a split WIM).
2911 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
2912 * XML data is written to this location.
2913 * @param bufsize_ret
2914 * The size of the XML data in bytes is written to this location.
2916 * @return 0 on success; nonzero on error.
2917 * @retval ::WIMLIB_ERR_INVALID_PARAM
2918 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2919 * @p buf_ret or @p bufsize_ret was @c NULL.
2920 * @retval ::WIMLIB_ERR_NOMEM
2921 * @retval ::WIMLIB_ERR_READ
2922 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2923 * Failed to read the XML data from the WIM.
2926 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2929 * @ingroup G_general
2931 * Initialization function for wimlib. Call before using any other wimlib
2932 * function except wimlib_set_print_errors(). If not done manually, this
2933 * function will be called automatically with @p init_flags set to
2934 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
2935 * after it has already successfully run.
2938 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2940 * @return 0 on success; nonzero on failure. Currently, only the following
2941 * error code is defined:
2943 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2944 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2945 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2946 * init_flags, but the corresponding privileges could not be acquired.
2949 wimlib_global_init(int init_flags);
2952 * @ingroup G_general
2954 * Cleanup function for wimlib. You are not required to call this function, but
2955 * it will release any global resources allocated by the library.
2958 wimlib_global_cleanup(void);
2961 * @ingroup G_wim_information
2963 * Determines if an image name is already used by some image in the WIM.
2966 * Pointer to the ::WIMStruct to query. This need not represent a
2967 * standalone WIM (e.g. it could represent part of a split WIM).
2969 * The name to check.
2972 * @c true if there is already an image in @p wim named @p name; @c false
2973 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2974 * the empty string, @c false is returned.
2977 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2980 * @ingroup G_wim_information
2982 * Iterate through a file or directory tree in the WIM image. By specifying
2983 * appropriate flags and a callback function, you can get the attributes of a
2984 * file in the WIM, get a directory listing, or even get a listing of the entire
2988 * The WIM containing the image(s) over which to iterate, specified as a
2989 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2990 * or part 1 of a split WIM. In the case of a WIM file that is not
2991 * standalone, this ::WIMStruct should have had any needed external
2992 * resources previously referenced using wimlib_reference_resources() or
2993 * wimlib_reference_resource_files(). If not, see
2994 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2995 * the behavior when resources are missing.
2998 * The 1-based number of the image in @p wim that contains the files or
2999 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
3000 * iteration on all images in the WIM.
3003 * Path in the WIM image at which to do the iteration.
3006 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3009 * A callback function that will receive each directory entry.
3012 * An extra parameter that will always be passed to the callback function
3015 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3016 * first nonzero value that was returned from @p cb. However, additional error
3017 * codes may be returned, including the following:
3019 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3020 * @p path did not exist in the WIM image.
3021 * @retval ::WIMLIB_ERR_NOMEM
3022 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
3024 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3025 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3026 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3027 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3028 * different reasons) to read the metadata resource for an image over which
3029 * iteration needed to be done.
3032 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3034 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3037 * @ingroup G_wim_information
3039 * Iterate through the lookup table of a WIM file. This can be used to directly
3040 * get a listing of the unique resources contained in a WIM file over all
3041 * images. Both file resources and metadata resources are included. However,
3042 * only resources actually included in the file represented by @a wim, plus
3043 * explicitly referenced external resources (via wimlib_reference_resources() or
3044 * wimlib_reference_resource_files()) are included in the iteration. For
3045 * example, if @p wim represents just one part of a split WIM, then only
3046 * resources in that part will be included, unless other resources were
3047 * explicitly referenced.
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).
3054 * Reserved; set to 0.
3057 * A callback function that will receive each resource.
3060 * An extra parameter that will always be passed to the callback function
3063 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3064 * that was returned from @p cb.
3067 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3068 wimlib_iterate_lookup_table_callback_t cb,
3072 * @ingroup G_nonstandalone_wims
3074 * Joins a split WIM into a stand-alone one-part WIM.
3077 * An array of strings that gives the filenames of all parts of the split
3078 * WIM. No specific order is required, but all parts must be included with
3081 * Number of filenames in @p swms.
3082 * @param swm_open_flags
3083 * Open flags for the split WIM parts (e.g.
3084 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3085 * @param wim_write_flags
3086 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3087 * be used to write the joined WIM.
3088 * @param output_path
3089 * The path to write the joined WIM file to.
3091 * @return 0 on success; nonzero on error. This function may return most error
3092 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
3093 * as the following error code:
3095 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3096 * The split WIMs do not form a valid WIM because they do not include all
3097 * the parts of the original WIM, there are duplicate parts, or not all the
3098 * parts have the same GUID and compression type.
3100 * Note: wimlib is generalized enough that this function is not actually needed
3101 * to join a split WIM; instead, you could open the first part of the split WIM,
3102 * then reference the other parts with wimlib_reference_resource_files(), then
3103 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3104 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3108 wimlib_join(const wimlib_tchar * const *swms,
3110 const wimlib_tchar *output_path,
3112 int wim_write_flags);
3115 * @ingroup G_nonstandalone_wims
3117 * Same as wimlib_join(), but allows specifying a progress function. The
3118 * progress function will receive the write progress messages, such as
3119 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3120 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3121 * swm_open_flags, the progress function will receive a series of
3122 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3126 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3128 const wimlib_tchar *output_path,
3130 int wim_write_flags,
3131 wimlib_progress_func_t progfunc,
3136 * @ingroup G_mounting_wim_images
3138 * Mounts an image from a WIM file on a directory read-only or read-write.
3141 * Pointer to the ::WIMStruct containing the image to be mounted.
3143 * The 1-based index of the image to mount.
3145 * The path to an existing empty directory on which to mount the WIM image.
3146 * @param mount_flags
3147 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3148 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3150 * @param staging_dir
3151 * If non-NULL, the name of a directory in which a temporary directory for
3152 * storing modified or added files will be created. Ignored if
3153 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3154 * left @c NULL, the staging directory is created in the same directory as
3155 * the WIM file that @p wim was originally read from. The staging
3156 * directory is deleted when the image is unmounted.
3158 * @return 0 on success; nonzero on error. The possible error codes include:
3160 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3161 * An image from the WIM file is already mounted read-write, or another
3162 * process is currently appending data to the WIM file.
3163 * @retval ::WIMLIB_ERR_FUSE
3164 * A non-zero status code was returned by @c fuse_main().
3165 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3166 * @p image does not specify an existing, single image in @p wim.
3167 * @retval ::WIMLIB_ERR_INVALID_PARAM
3168 * @p wim was @c NULL; or @p dir was NULL or the empty string; or an
3169 * unrecognized flag was specified in @p mount_flags; or the WIM image has
3170 * already been modified in memory (e.g. by wimlib_update_image()).
3171 * @retval ::WIMLIB_ERR_MKDIR
3172 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3173 * staging directory could not be created.
3174 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3175 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3176 * WIM file is considered read-only because of any of the reasons mentioned
3177 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3178 * @retval ::WIMLIB_ERR_UNSUPPORTED
3179 * Mounting is not supported, either because the platform is Windows, or
3180 * because the platform is UNIX-like and wimlib was compiled using
3181 * <code>--without-fuse</code>.
3183 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3184 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3185 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3186 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3187 * different reasons) to read the metadata resource for the image to mount.
3189 * The ability to mount WIM image is implemented using FUSE (Filesystem in
3190 * UserSpacE). Depending on how FUSE is set up on your system, this function
3191 * may work as normal users in addition to the root user.
3193 * Mounting WIM images is not supported if wimlib was configured
3194 * <code>--without-fuse</code>. This includes Windows builds of wimlib;
3195 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3197 * Calling this function daemonizes the process, unless
3198 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3200 * It is safe to mount multiple images from the same underlying WIM file
3201 * read-only at the same time, but only if different ::WIMStruct's are used. It
3202 * is @b not safe to mount multiple images from the same WIM file read-write at
3205 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3206 * different process.
3209 wimlib_mount_image(WIMStruct *wim,
3211 const wimlib_tchar *dir,
3213 const wimlib_tchar *staging_dir);
3216 * @ingroup G_creating_and_opening_wims
3218 * Opens a WIM file and creates a ::WIMStruct for it.
3221 * The path to the WIM file to open.
3224 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3227 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3228 * is written to the memory location pointed to by this parameter. The
3229 * ::WIMStruct must be freed using using wimlib_free() when finished with
3232 * @return 0 on success; nonzero on error.
3233 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3234 * The number of metadata resources found in the WIM did not match the
3235 * image count specified in the WIM header, or the number of <IMAGE>
3236 * elements in the XML data of the WIM did not match the image count
3237 * specified in the WIM header.
3238 * @retval ::WIMLIB_ERR_INTEGRITY
3239 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3240 * the WIM contained an integrity table, but the SHA1 message digest for a
3241 * chunk of the WIM did not match the corresponding value in the integrity
3243 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3244 * The library did not recognize the compression chunk size of the WIM as
3245 * valid for its compression type.
3246 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3247 * The library did not recognize the compression type of the WIM.
3248 * @retval ::WIMLIB_ERR_INVALID_HEADER
3249 * The header of the WIM was otherwise invalid.
3250 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3251 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3252 * the WIM contained an integrity table, but the integrity table was
3254 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3255 * The lookup table of the WIM was invalid.
3256 * @retval ::WIMLIB_ERR_INVALID_PARAM
3257 * @p wim_ret was @c NULL.
3258 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3259 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3260 * specified in @p open_flags.
3261 * @retval ::WIMLIB_ERR_NOMEM
3262 * Failed to allocated needed memory.
3263 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3264 * The file did not begin with the magic characters that identify a WIM
3266 * @retval ::WIMLIB_ERR_OPEN
3267 * Failed to open the file for reading.
3268 * @retval ::WIMLIB_ERR_READ
3269 * Failed to read data from the file.
3270 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3271 * Unexpected end-of-file while reading data from the file.
3272 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3273 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3274 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3275 * The WIM cannot be opened because it contains encrypted segments. (It
3276 * may be a Windows 8 "ESD" file.)
3277 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3278 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3279 * considered read-only because of any of the reasons mentioned in the
3280 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3281 * @retval ::WIMLIB_ERR_XML
3282 * The XML data of the WIM was invalid.
3285 wimlib_open_wim(const wimlib_tchar *wim_file,
3287 WIMStruct **wim_ret);
3290 * @ingroup G_creating_and_opening_wims
3292 * Same as wimlib_open_wim(), but allows specifying a progress function and
3293 * progress context. If successful, the progress function will be registered in
3294 * the newly open ::WIMStruct, as if by an automatic call to
3295 * wimlib_register_progress_function(). In addition, if
3296 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, the
3297 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3298 * messages while checking the WIM's integrity.
3301 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3303 WIMStruct **wim_ret,
3304 wimlib_progress_func_t progfunc,
3308 * @ingroup G_writing_and_overwriting_wims
3310 * Overwrites the file that the WIM was originally read from, with changes made.
3311 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3312 * rather than wimlib_create_new_wim().
3314 * There are two ways that a WIM may be overwritten. The first is to do a full
3315 * rebuild. In this mode, the new WIM is written to a temporary file and then
3316 * renamed to the original file after it is has been completely written. The
3317 * temporary file is made in the same directory as the original WIM file. A
3318 * full rebuild may take a while, but it will save space by producing a WIM with
3321 * The second way to overwrite a WIM is by appending to the end of it and
3322 * overwriting the header. This can be much faster than a full rebuild, but the
3323 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3324 * begins with writing any new file resources *after* everything in the old WIM,
3325 * even though this will leave a hole where the old lookup table, XML data, and
3326 * integrity were. This is done so that the WIM remains valid even if the
3327 * operation is aborted mid-write. The WIM header is only overwritten at the
3328 * very last moment, and up until that point the WIM will be seen as the old
3331 * By default, wimlib_overwrite() does the append-style overwrite described
3332 * above, unless resources in the WIM are arranged in an unusual way or if
3333 * images have been deleted from the WIM. Use the flag
3334 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3335 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3336 * images have been deleted from the WIM.
3338 * If this function completes successfully, no more functions should be called
3339 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
3340 * the WIM file anew.
3343 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3344 * been in-memory changes made to it, which are then reflected in the
3346 * @param write_flags
3347 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3348 * @param num_threads
3349 * Number of threads to use for compression (see wimlib_write()).
3351 * @return 0 on success; nonzero on error. This function may return most error
3352 * codes returned by wimlib_write() as well as the following error codes:
3354 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3355 * The WIM was going to be modified in-place (with no temporary file), but
3356 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3357 * because another thread or process has mounted an image from the WIM
3358 * read-write or is currently modifying the WIM in-place.
3359 * @retval ::WIMLIB_ERR_NO_FILENAME
3360 * @p wim corresponds to a ::WIMStruct created with wimlib_create_new_wim()
3361 * rather than a WIM read with wimlib_open_wim().
3362 * @retval ::WIMLIB_ERR_RENAME
3363 * The temporary file that the WIM was written to could not be renamed to
3364 * the original filename of @p wim.
3365 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3366 * The WIM file is considered read-only because of any of the reasons
3367 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3370 * If a progress function is registered with @p wim, it will receive the
3371 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3372 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3373 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3376 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3379 * @ingroup G_wim_information
3381 * Prints information about one image, or all images, contained in a WIM.
3384 * Pointer to the ::WIMStruct to query. This need not represent a
3385 * standalone WIM (e.g. it could represent part of a split WIM).
3387 * The image about which to print information. Can be the number of an
3388 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3391 * @return This function has no return value. No error checking is done when
3392 * printing the information. If @p image is invalid, an error message is
3396 wimlib_print_available_images(const WIMStruct *wim, int image);
3399 * @ingroup G_wim_information
3401 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3402 * in a way that can be accessed programatically.
3405 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3408 * @ingroup G_nonstandalone_wims
3410 * Reference resources from other WIM files or split WIM parts. This function
3411 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3412 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3413 * from other files, before calling a function such as wimlib_extract_image()
3414 * that requires the resources to be present.
3417 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3418 * necessarily "standalone". In the case of split WIMs, this should be the
3419 * first part, since only the first part contains the metadata resources.
3420 * In the case of delta WIMs, this should be the delta WIM rather than the
3421 * WIM on which it is based.
3422 * @param resource_wimfiles_or_globs
3423 * Array of paths to WIM files and/or split WIM parts to reference.
3424 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3425 * ref_flags, these are treated as globs rather than literal paths. That
3426 * is, using this function you can specify zero or more globs, each of
3427 * which expands to one or more literal paths.
3429 * Number of entries in @p resource_wimfiles_or_globs.
3431 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3432 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3434 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3435 * pass to internal calls to wimlib_open_wim() on the reference files.
3437 * @return 0 on success; nonzero on error.
3439 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3440 * One of the specified globs did not match any paths (only with both
3441 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3442 * specified in @p ref_flags).
3443 * @retval ::WIMLIB_ERR_NOMEM
3444 * Failed to allocate memory.
3445 * @retval ::WIMLIB_ERR_READ
3446 * I/O or permissions error while processing a file glob.
3448 * This function can additionally return most values that can be returned by
3449 * wimlib_open_wim().
3452 wimlib_reference_resource_files(WIMStruct *wim,
3453 const wimlib_tchar * const *resource_wimfiles_or_globs,
3459 * @ingroup G_nonstandalone_wims
3461 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3462 * where the caller must open the ::WIMStruct for each referenced file itself.
3465 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3466 * necessarily "standalone". In the case of split WIMs, this should be the
3467 * first part, since only the first part contains the metadata resources.
3468 * @param resource_wims
3469 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3470 * split WIM parts to reference.
3471 * @param num_resource_wims
3472 * Number of entries in @p resource_wims.
3474 * Currently ignored (set to 0).
3476 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3477 * @p resource_wims are referenced internally by @p wim and must not be freed
3478 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3479 * been freed with wimlib_free(), or immediately before freeing @p wim with
3482 * @retval ::WIMLIB_ERR_INVALID_PARAM
3483 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3484 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3485 * @retval ::WIMLIB_ERR_NOMEM
3486 * Failed to allocate memory.
3489 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3490 unsigned num_resource_wims, int ref_flags);
3493 * @ingroup G_modifying_wims
3495 * Declares that a newly added image is mostly the same as a prior image, but
3496 * captured at a later point in time, possibly with some modifications in the
3497 * intervening time. This is designed to be used in incremental backups of the
3498 * same filesystem or directory tree.
3500 * This function compares the metadata of the directory tree of the newly added
3501 * image against that of the old image. Any files that are present in both the
3502 * newly added image and the old image and have timestamps that indicate they
3503 * haven't been modified are deemed not to have been modified and have their
3504 * SHA1 message digest copied from the old image. Because of this and because
3505 * WIM uses single-instance streams, such files need not be read from the
3506 * filesystem when the WIM is being written or overwritten. Note that these
3507 * unchanged files will still be "archived" and will be logically present in the
3508 * new image; the optimization is that they don't need to actually be read from
3509 * the filesystem because the WIM already contains them.
3511 * This function is provided to optimize incremental backups. The resulting WIM
3512 * file will still be the same regardless of whether this function is called.
3513 * (This is, however, assuming that timestamps have not been manipulated or
3514 * unmaintained as to trick this function into thinking a file has not been
3515 * modified when really it has. To partly guard against such cases, other
3516 * metadata such as file sizes will be checked as well.)
3518 * This function must be called after adding the new image (e.g. with
3519 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3520 * wimlib_overwrite()).
3523 * Pointer to the ::WIMStruct for a WIM.
3525 * 1-based index in the WIM of the newly added image. This image can have
3526 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3527 * wimlib_add_empty_image() followed by wimlib_update_image().
3528 * @param template_wim
3529 * The ::WIMStruct for the WIM containing the template image. This can be
3530 * the same as @p wim, or it can be a different ::WIMStruct.
3531 * @param template_image
3532 * 1-based index in the WIM of a template image that reflects a prior state
3533 * of the directory tree being captured.
3535 * Reserved; must be 0.
3537 * @return 0 on success; nonzero on error.
3539 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3540 * @p new_image and/or @p template_image were not a valid image indices in
3542 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3543 * The specified ::WIMStruct did not actually contain the metadata resource
3544 * for the new or template image; for example, it was a non-first part of a
3546 * @retval ::WIMLIB_ERR_NOMEM
3547 * Failed to allocate needed memory.
3548 * @retval ::WIMLIB_ERR_INVALID_PARAM
3549 * @p new_image was equal to @p template_image, or @p new_image specified
3550 * an image that had not been modified since opening the WIM.
3552 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3553 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3554 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3555 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3556 * different reasons) to read the metadata resource for the template image.
3559 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3560 WIMStruct *template_wim, int template_image,
3564 * @ingroup G_general
3566 * Registers a progress function with a ::WIMStruct.
3569 * The ::WIMStruct for which to register the progress function.
3571 * Pointer to the progress function to register. If the WIM already has a
3572 * progress function registered, it will be replaced with this one. If @p
3573 * NULL, the current progress function (if any) will be unregistered.
3575 * The value which will be passed as the third argument to calls to @p
3579 wimlib_register_progress_function(WIMStruct *wim,
3580 wimlib_progress_func_t progfunc,
3584 * @ingroup G_modifying_wims
3586 * Rename the @p source_path to the @p dest_path in the specified @p image of
3589 * This just builds an appropriate ::wimlib_rename_command and passes it to
3590 * wimlib_update_image().
3593 wimlib_rename_path(WIMStruct *wim, int image,
3594 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3597 * @ingroup G_wim_information
3599 * Translates a string specifying the name or number of an image in the WIM into
3600 * the number of the image. The images are numbered starting at 1.
3603 * Pointer to the ::WIMStruct for a WIM.
3604 * @param image_name_or_num
3605 * A string specifying the name or number of an image in the WIM. If it
3606 * parses to a positive integer, this integer is taken to specify the
3607 * number of the image, indexed starting at 1. Otherwise, it is taken to
3608 * be the name of an image, as given in the XML data for the WIM file. It
3609 * also may be the keyword "all" or the string "*", both of which will
3610 * resolve to ::WIMLIB_ALL_IMAGES.
3612 * There is no way to search for an image actually named "all", "*", or an
3613 * integer number, or an image that has no name. However, you can use
3614 * wimlib_get_image_name() to get the name of any image.
3617 * If the string resolved to a single existing image, the number of that
3618 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3619 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3620 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3621 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3622 * images in @p wim has no name.
3625 wimlib_resolve_image(WIMStruct *wim,
3626 const wimlib_tchar *image_name_or_num);
3629 * @ingroup G_modifying_wims
3631 * Changes the description of an image in the WIM.
3634 * Pointer to the ::WIMStruct for a WIM.
3636 * The number of the image for which to change the description.
3637 * @param description
3638 * The new description to give the image. It may be @c NULL, which
3639 * indicates that the image is to be given no description.
3641 * @return 0 on success; nonzero on error.
3642 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3643 * @p image does not specify a single existing image in @p wim.
3644 * @retval ::WIMLIB_ERR_NOMEM
3645 * Failed to allocate the memory needed to duplicate the @p description
3647 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3648 * @p wim is considered read-only because of any of the reasons mentioned
3649 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3652 wimlib_set_image_descripton(WIMStruct *wim, int image,
3653 const wimlib_tchar *description);
3656 * @ingroup G_writing_and_overwriting_wims
3658 * Set the compression chunk size of a WIM to use in subsequent calls to
3659 * wimlib_write() or wimlib_overwrite().
3661 * A larger compression chunk size will likely result in a better compression
3662 * ratio, but the speed of random access to the WIM will be reduced.
3663 * Furthermore, the effect of a larger compression chunk size is limited by the
3664 * size of each stream ("file") being compressed.
3667 * ::WIMStruct for a WIM.
3669 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3670 * on the compression format. See the documentation for each
3671 * ::wimlib_compression_type constant for more information. As a special
3672 * case, if @p chunk_size is specified as 0, the chunk size is set to the
3673 * default for the currently selected output compression type.
3675 * @return 0 on success; nonzero on error.
3677 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3678 * @p chunk_size is not a supported chunk size for the currently selected
3679 * output compression type.
3682 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3685 * @ingroup G_writing_and_overwriting_wims
3687 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3688 * packed streams (solid blocks).
3691 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3694 * @ingroup G_writing_and_overwriting_wims
3696 * Set the compression type of a WIM to use in subsequent calls to
3697 * wimlib_write() or wimlib_overwrite().
3700 * ::WIMStruct for a WIM.
3702 * The compression type to set (one of ::wimlib_compression_type). If this
3703 * compression type is incompatible with the current output chunk size
3704 * (either the default or as set with wimlib_set_output_chunk_size()), the
3705 * output chunk size is reset to the default for that compression type.
3707 * @return 0 on success; nonzero on error.
3709 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3710 * @p ctype did not specify a valid compression type.
3713 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3716 * @ingroup G_writing_and_overwriting_wims
3718 * Similar to wimlib_set_output_compression_type(), but set the compression type
3719 * for writing packed streams (solid blocks).
3722 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3725 * @ingroup G_modifying_wims
3727 * Set basic information about a WIM.
3730 * Pointer to the ::WIMStruct for a WIM.
3732 * A struct ::wimlib_wim_info that contains the information to set. Only
3733 * the information explicitly specified in the @p which flags need be
3736 * Flags that specify which information to set. This is a bitwise OR of
3737 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3738 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3740 * @return 0 on success; nonzero on failure.
3741 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3742 * The WIM file is considered read-only because of any of the reasons
3743 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3744 * flag. However, as a special case, if you are using
3745 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3746 * function will not fail due to the readonly flag being previously set.
3747 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3748 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3749 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3753 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3757 * @ingroup G_modifying_wims
3759 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3760 * (something like "Core" or "Ultimate")
3763 * Pointer to the ::WIMStruct for a WIM.
3765 * The number of the image for which to change the description.
3767 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3768 * indicates that the image is to be given no \<FLAGS\> element.
3770 * @return 0 on success; nonzero on error.
3771 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3772 * @p image does not specify a single existing image in @p wim.
3773 * @retval ::WIMLIB_ERR_NOMEM
3774 * Failed to allocate the memory needed to duplicate the @p flags string.
3775 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3776 * @p wim is considered read-only because of any of the reasons mentioned
3777 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3780 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3783 * @ingroup G_modifying_wims
3785 * Changes the name of an image in the WIM.
3788 * Pointer to the ::WIMStruct for a WIM.
3790 * The number of the image for which to change the name.
3792 * New name to give the new image. If @c NULL or empty, the new image is
3793 * given no name. If nonempty, it must specify a name that does not
3794 * already exist in @p wim.
3796 * @return 0 on success; nonzero on error.
3797 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3798 * There is already an image named @p name in @p wim.
3799 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3800 * @p image does not specify a single existing image in @p wim.
3801 * @retval ::WIMLIB_ERR_NOMEM
3802 * Failed to allocate the memory needed to duplicate the @p name string.
3803 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3804 * @p wim is considered read-only because of any of the reasons mentioned
3805 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3808 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3811 * @ingroup G_general
3813 * Set the functions that wimlib uses to allocate and free memory.
3815 * These settings are global and not per-WIM.
3817 * The default is to use the default @c malloc() and @c free() from the C
3820 * Please note that some external functions, such as those in @c libntfs-3g, may
3821 * use the standard memory allocation functions regardless of this setting.
3823 * @param malloc_func
3824 * A function equivalent to @c malloc() that wimlib will use to allocate
3825 * memory. If @c NULL, the allocator function is set back to the default
3826 * @c malloc() from the C library.
3828 * A function equivalent to @c free() that wimlib will use to free memory.
3829 * If @c NULL, the free function is set back to the default @c free() from
3831 * @param realloc_func
3832 * A function equivalent to @c realloc() that wimlib will use to reallocate
3833 * memory. If @c NULL, the free function is set back to the default @c
3834 * realloc() from the C library.
3838 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3839 void (*free_func)(void *),
3840 void *(*realloc_func)(void *, size_t));
3843 * @ingroup G_general
3845 * Sets whether wimlib is to print error messages to @c stderr when a function
3846 * fails. These error messages may provide information that cannot be
3847 * determined only from the error code that is returned. Not every error will
3848 * result in an error message being printed.
3850 * This setting is global and not per-WIM.
3852 * By default, error messages are not printed.
3854 * This can be called before wimlib_global_init().
3856 * @param show_messages
3857 * @c true if error messages are to be printed; @c false if error messages
3858 * are not to be printed.
3860 * @return 0 on success; nonzero on error.
3861 * @retval ::WIMLIB_ERR_UNSUPPORTED
3862 * @p show_messages was @c true, but wimlib was compiled with the @c
3863 * --without-error-messages option. Therefore, error messages cannot be
3867 wimlib_set_print_errors(bool show_messages);
3870 * @ingroup G_nonstandalone_wims
3872 * Splits a WIM into multiple parts.
3875 * The ::WIMStruct for the WIM to split.
3877 * Name of the SWM file to create. This will be the name of the first
3878 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3879 * appended before the suffix.
3881 * The maximum size per part, in bytes. Unfortunately, it is not
3882 * guaranteed that this will really be the maximum size per part, because
3883 * some file resources in the WIM may be larger than this size, and the WIM
3884 * file format provides no way to split up file resources among multiple
3886 * @param write_flags
3887 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3888 * flags will be used to write each split WIM part. Specify 0 here to get
3889 * the default behavior.
3891 * @return 0 on success; nonzero on error. This function may return most error
3892 * codes that can be returned by wimlib_write() as well as the following error
3895 * @retval ::WIMLIB_ERR_INVALID_PARAM
3896 * @p swm_name was not a nonempty string, or @p part_size was 0.
3898 * If a progress function is registered with @p wim, for each split WIM part
3899 * that is written it will receive the messages
3900 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3901 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
3904 wimlib_split(WIMStruct *wim,
3905 const wimlib_tchar *swm_name,
3910 * @ingroup G_mounting_wim_images
3912 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3914 * When unmounting a read-write mounted image, the default behavior is to
3915 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
3916 * WIM image to be committed.
3919 * The directory the WIM image was mounted on.
3920 * @param unmount_flags
3921 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
3923 * @return 0 on success; nonzero on error. The possible error codes include:
3925 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
3926 * There is no WIM image mounted on the specified directory.
3927 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
3928 * The read-write mounted WIM image cannot be committed because there are
3929 * file descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
3931 * @retval ::WIMLIB_ERR_MQUEUE
3932 * Could not create a POSIX message queue.
3933 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
3934 * The WIM image was mounted by a different user.
3935 * @retval ::WIMLIB_ERR_UNSUPPORTED
3936 * Mounting is not supported, either because the platform is Windows, or
3937 * because the platform is UNIX-like and wimlib was compiled using @c
3940 * Note: you can also unmount the image by using the @c umount() system call, or
3941 * by using the @c umount or @c fusermount programs. However, you need to call
3942 * this function if you want changes to be committed.
3945 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
3948 * @ingroup G_mounting_wim_images
3950 * Same as wimlib_unmount_image(), but allows specifying a progress function.
3951 * If changes are committed from a read-write mount, the progress function will
3952 * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
3955 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
3957 wimlib_progress_func_t progfunc,
3961 * @ingroup G_modifying_wims
3963 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3966 * Pointer to the ::WIMStruct for the WIM file to update.
3968 * The 1-based index of the image in the WIM to update. It cannot be
3969 * ::WIMLIB_ALL_IMAGES.
3971 * An array of ::wimlib_update_command's that specify the update operations
3974 * Number of commands in @p cmds.
3975 * @param update_flags
3976 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3978 * @return 0 on success; nonzero on error. On failure, all update commands will
3979 * be rolled back, and no visible changes shall have been made to @p wim.
3980 * Possible error codes include:
3982 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3983 * The capture configuration structure specified for an add command was
3985 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3986 * @p image did not specify a single, existing image in @p wim.
3987 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3988 * Attempted to perform an add command that conflicted with previously
3989 * existing files in the WIM when an overlay was attempted.
3990 * @retval ::WIMLIB_ERR_INVALID_PARAM
3991 * An unknown operation type was specified in the update commands; or,
3992 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3993 * in the @p add_flags, but the same image had previously already been
3994 * added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3995 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3996 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3997 * specified in the @p add_flags for an add command in which @p
3998 * wim_target_path was not the root directory of the WIM image.
3999 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4000 * (Windows only): While executing an add command, tried to capture a
4001 * reparse point with invalid data.
4002 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4003 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
4004 * for a WIM path that corresponded to a directory; or, a rename command
4005 * attempted to rename a directory to a non-directory.
4006 * @retval ::WIMLIB_ERR_NOMEM
4007 * Failed to allocate needed memory.
4008 * @retval ::WIMLIB_ERR_NOTDIR
4009 * A rename command attempted to rename a directory to a non-directory; or,
4010 * an add command was executed that attempted to set the root of the WIM
4011 * image as a non-directory; or, a path component used as a directory in a
4012 * rename command was not, in fact, a directory.
4013 * @retval ::WIMLIB_ERR_NOTEMPTY
4014 * A rename command attempted to rename a directory to a non-empty
4016 * @retval ::WIMLIB_ERR_NTFS_3G
4017 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4018 * error occurred while reading data from the NTFS volume using libntfs-3g.
4019 * @retval ::WIMLIB_ERR_OPEN
4020 * Failed to open a file to be captured while executing an add command.
4021 * @retval ::WIMLIB_ERR_OPENDIR
4022 * Failed to open a directory to be captured while executing an add command.
4023 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4024 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4025 * WIM path that did not exist; or, a rename command attempted to rename a
4026 * file that does not exist.
4027 * @retval ::WIMLIB_ERR_READ
4028 * While executing an add command, failed to read data from a file or
4029 * directory to be captured.
4030 * @retval ::WIMLIB_ERR_READLINK
4031 * While executing an add command, failed to read the target of a symbolic
4032 * link or junction point.
4033 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
4034 * (Windows only) Failed to perform a reparse point fixup because of
4035 * problems with the data of a reparse point.
4036 * @retval ::WIMLIB_ERR_STAT
4037 * While executing an add command, failed to get attributes for a file or
4039 * @retval ::WIMLIB_ERR_UNSUPPORTED
4040 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
4041 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
4042 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
4043 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
4044 * add_flags for an update command.
4045 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4046 * While executing an add command, attempted to capture a file that was not
4047 * a supported file type (e.g. a device file). Only if
4048 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
4049 * for an update command.
4050 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4051 * The WIM file is considered read-only because of any of the reasons
4052 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
4055 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4056 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4057 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4058 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4059 * different reasons) to read the metadata resource for an image that needed to
4063 wimlib_update_image(WIMStruct *wim,
4065 const struct wimlib_update_command *cmds,
4070 * @ingroup G_writing_and_overwriting_wims
4072 * Writes a WIM to a file.
4074 * This brings in resources from any external locations, such as directory trees
4075 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4076 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
4078 * By default, the new WIM file is written as stand-alone. Using the
4079 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4080 * instead. However, this function cannot directly write a "split" WIM; use
4081 * wimlib_split() for that.
4084 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
4085 * changes made to it, which are then reflected in the output file.
4087 * The path to the file to write the WIM to.
4089 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4090 * images are to be included in the new on-disk WIM file. If for some
4091 * reason you only want to include a single image, specify the index of
4092 * that image instead.
4093 * @param write_flags
4094 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
4095 * @param num_threads
4096 * Number of threads to use for compressing data. If 0, the number of
4097 * threads is taken to be the number of online processors. Note: if no
4098 * data compression needs to be done, no additional threads will be created
4099 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
4100 * exporting an image from a compressed WIM to another WIM of the same
4101 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
4104 * @return 0 on success; nonzero on error.
4106 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4107 * @p image does not specify a single existing image in @p wim, and is not
4108 * ::WIMLIB_ALL_IMAGES.
4109 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4110 * A file that had previously been scanned for inclusion in the WIM by
4111 * wimlib_add_image() was concurrently modified, so it failed the SHA1
4112 * message digest check.
4113 * @retval ::WIMLIB_ERR_INVALID_PARAM
4114 * @p path was @c NULL.
4115 * @retval ::WIMLIB_ERR_NOMEM
4116 * Failed to allocate needed memory.
4117 * @retval ::WIMLIB_ERR_OPEN
4118 * Failed to open @p path for writing, or some file resources in @p wim
4119 * refer to files in the outside filesystem, and one of these files could
4120 * not be opened for reading.
4121 * @retval ::WIMLIB_ERR_READ
4122 * An error occurred when trying to read data from the WIM file associated
4123 * with @p wim, or some file resources in @p wim refer to files in the
4124 * outside filesystem, and a read error occurred when reading one of these
4126 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4127 * A stream that needed to be written could not be found in the stream
4128 * lookup table of @p wim. This error can occur if, for example, @p wim is
4129 * part of a split WIM but needed resources from the other split WIM parts
4130 * were not referenced with wimlib_reference_resources() or
4131 * wimlib_reference_resource_files() before the call to wimlib_write().
4132 * @retval ::WIMLIB_ERR_WRITE
4133 * An error occurred when trying to write data to the new WIM file.
4135 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4136 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4137 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4138 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4139 * different reasons) to read the metadata resource for an image that needed to
4142 * If a progress function is registered with @p wim, it will receive the
4143 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4144 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4145 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4148 wimlib_write(WIMStruct *wim,
4149 const wimlib_tchar *path,
4152 unsigned num_threads);
4155 * @ingroup G_writing_and_overwriting_wims
4157 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
4158 * file descriptor, which need not be seekable if the write is done in a special
4159 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
4160 * write_flags. This can, for example, allow capturing a WIM image and
4161 * streaming it over the network. See the documentation for
4162 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
4164 * The file descriptor @p fd will @b not be closed when the write is complete;
4165 * the calling code is responsible for this.
4167 * Returns 0 on success; nonzero on failure. The possible error codes include
4168 * those that can be returned by wimlib_write() as well as the following:
4170 * @retval ::WIMLIB_ERR_INVALID_PARAM
4171 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4172 * specified in @p write_flags.
4175 wimlib_write_to_fd(WIMStruct *wim,
4179 unsigned num_threads);
4182 * @defgroup G_compression Compression and decompression functions
4184 * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
4185 * exported for convenience only, as they are already used by wimlib internally
4188 * These functions can be used for general-purpose lossless data compression,
4189 * but some limitations apply; for example, none of the compressors or
4190 * decompressors currently support sliding windows, and there also exist
4191 * slightly different variants of these formats that are not supported
4197 /** Header for compression parameters to pass to wimlib_create_compressor() or
4198 * wimlib_set_default_compressor_params(). */
4199 struct wimlib_compressor_params_header {
4200 /** Size of the parameters, in bytes. */
4204 /** Header for decompression parameters to pass to wimlib_create_decompressor()
4205 * or wimlib_set_default_decompressor_params() */
4206 struct wimlib_decompressor_params_header {
4207 /** Size of the parameters, in bytes. */
4211 /** LZX compression parameters that can optionally be passed to
4212 * wimlib_create_compressor() with the compression type
4213 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
4214 struct wimlib_lzx_compressor_params {
4215 /** hdr.size Must be set to the size of this structure, in bytes. */
4216 struct wimlib_compressor_params_header hdr;
4218 /** Relatively fast LZX compression algorithm with a decent compression
4220 #define WIMLIB_LZX_ALGORITHM_FAST 0
4222 /** Slower LZX compression algorithm that provides a better compression
4223 * ratio. This is the default. */
4224 #define WIMLIB_LZX_ALGORITHM_SLOW 1
4226 /** Algorithm to use to perform the compression: either
4227 * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW. The
4228 * format is still LZX; this refers to the method the code will use to
4229 * perform LZX-compatible compression. */
4230 uint32_t algorithm : 3;
4232 /** If set to 1, the default parameters for the specified algorithm are
4233 * used rather than the ones specified in the following union. */
4234 uint32_t use_defaults : 1;
4237 /** Parameters for the fast algorithm. */
4238 struct wimlib_lzx_fast_params {
4239 uint32_t fast_reserved1[10];
4242 /** Parameters for the "slow" algorithm. */
4243 struct wimlib_lzx_slow_params {
4244 /** If set to 1, the compressor can output length 2
4245 * matches. If set 0, the compressor can only output
4246 * matches of length 3 or greater. Suggested value: 1
4248 uint32_t use_len2_matches : 1;
4250 uint32_t slow_reserved1 : 31;
4252 /** Matches with length (in bytes) greater than or equal
4253 * to this value are immediately taken without spending
4254 * time on minimum-cost measurements. Suggested value:
4256 uint32_t nice_match_length;
4258 /** Number of passes to compute a match/literal sequence
4259 * for each LZX block. This is for an iterative
4260 * algorithm that attempts to minimize the cost of the
4261 * match/literal sequence by using a cost model provided
4262 * by the previous iteration. Must be at least 1.
4263 * Suggested value: 2. */
4264 uint32_t num_optim_passes;
4266 /** Reserved; set to 0. */
4267 uint32_t slow_reserved_blocksplit;
4269 /** Maximum depth to search for matches at each
4270 * position. Suggested value: 50. */
4271 uint32_t max_search_depth;
4273 /* Note: max_matches_per_pos has been removed and no
4274 * longer has any effect. */
4276 uint32_t slow_reserved2[3];
4278 /** Assumed cost of a main symbol with zero frequency.
4279 * Must be at least 1 and no more than 16. Suggested
4281 uint8_t main_nostat_cost;
4283 /** Assumed cost of a length symbol with zero frequency.
4284 * Must be at least 1 and no more than 16. Suggested
4286 uint8_t len_nostat_cost;
4288 /** Assumed cost of an aligned symbol with zero
4289 * frequency. Must be at least 1 and no more than 8.
4290 * Suggested value: 7. */
4291 uint8_t aligned_nostat_cost;
4293 uint8_t slow_reserved3[5];
4298 /** LZMS compression parameters that can optionally be passed to
4299 * wimlib_create_compressor() with the compression type
4300 * ::WIMLIB_COMPRESSION_TYPE_LZMS. */
4301 struct wimlib_lzms_compressor_params {
4302 /** hdr.size Must be set to the size of this structure, in bytes. */
4303 struct wimlib_compressor_params_header hdr;
4305 /** Minimum match length to output. This must be at least 2. Suggested
4307 uint32_t min_match_length;
4309 /** Maximum match length to output. This must be at least @p
4310 * min_match_length. Suggested value: @p UINT32_MAX. */
4311 uint32_t max_match_length;
4313 /** Matches with length (in bytes) greater than or equal to this value
4314 * are immediately taken without spending time on minimum-cost
4315 * measurements. The minimum of @p max_match_length and @p
4316 * nice_match_length may not exceed 65536. Suggested value: 32. */
4317 uint32_t nice_match_length;
4319 /** Maximum depth to search for matches at each position. Suggested
4321 uint32_t max_search_depth;
4323 /* Note: max_matches_per_pos has been removed and no longer has any
4328 /** Length of the array for the near-optimal LZ parsing algorithm. This
4329 * must be at least 1. Suggested value: 1024. */
4330 uint32_t optim_array_length;
4332 uint64_t reserved2[4];
4335 /** Opaque compressor handle. */
4336 struct wimlib_compressor;
4338 /** Opaque decompressor handle. */
4339 struct wimlib_decompressor;
4342 * Set the default compression parameters for the specified compression type.
4343 * This will affect both explicit and library-internal calls to
4344 * wimlib_create_compressor().
4347 * Compression type for which to set the default compression parameters.
4349 * Compression-type specific parameters. This may be @c NULL, in which
4350 * case the "default default" parameters are restored.
4352 * @return 0 on success; nonzero on error.
4354 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4355 * @p ctype was not a supported compression type.
4356 * @retval ::WIMLIB_ERR_INVALID_PARAM
4357 * @p params were invalid.
4358 * @retval ::WIMLIB_ERR_NOMEM
4359 * Not enough memory to duplicate the parameters (perhaps @c params->size
4363 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
4364 const struct wimlib_compressor_params_header *params);
4367 * Returns the approximate number of bytes needed to allocate a compressor with
4368 * wimlib_create_compressor() for the specified compression type, block size,
4369 * and parameters. @p params may be @c NULL, in which case the current default
4370 * parameters for @p ctype are used. Returns 0 if the compression type or
4371 * parameters are invalid.
4374 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4375 size_t max_block_size,
4376 const struct wimlib_compressor_params_header *params);
4379 * Allocate a compressor for the specified compression type using the specified
4380 * parameters. This function is part of wimlib's compression API; it is not
4381 * necessary to call this to process a WIM file.
4384 * Compression type for which to create the compressor.
4385 * @param max_block_size
4386 * Maximum block size to support. The exact meaning and allowed values for
4387 * this parameter depend on the compression type, but it at least specifies
4388 * the maximum allowed value for @p uncompressed_size to wimlib_compress().
4389 * @param extra_params
4390 * An optional pointer to extra compressor parameters for the specified
4391 * compression type. For LZX, a pointer to ::wimlib_lzx_compressor_params
4392 * may be specified here. For LZMS, a pointer to
4393 * ::wimlib_lzms_compressor_params may be specified here. If left @c NULL,
4394 * the default parameters are used.
4395 * @param compressor_ret
4396 * A location into which to return the pointer to the allocated compressor,
4397 * which can be used for any number of calls to wimlib_compress() before
4398 * being freed with wimlib_free_compressor().
4400 * @return 0 on success; nonzero on error.
4402 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4403 * @p ctype was not a supported compression type.
4404 * @retval ::WIMLIB_ERR_INVALID_PARAM
4405 * The compression parameters were invalid.
4406 * @retval ::WIMLIB_ERR_NOMEM
4407 * Insufficient memory to allocate the compressor.
4410 wimlib_create_compressor(enum wimlib_compression_type ctype,
4411 size_t max_block_size,
4412 const struct wimlib_compressor_params_header *extra_params,
4413 struct wimlib_compressor **compressor_ret);
4416 * Losslessly compress a block of data using a compressor previously created
4417 * with wimlib_create_compressor().
4419 * @param uncompressed_data
4420 * Buffer containing the data to compress.
4421 * @param uncompressed_size
4422 * Size, in bytes, of the data to compress.
4423 * @param compressed_data
4424 * Buffer into which to write the compressed data.
4425 * @param compressed_size_avail
4426 * Number of bytes available in @p compressed_data.
4428 * A compressor previously allocated with wimlib_create_compressor().
4431 * The size of the compressed data, in bytes, or 0 if the input data could
4432 * not be compressed to @p compressed_size_avail or fewer bytes.
4435 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4436 void *compressed_data, size_t compressed_size_avail,
4437 struct wimlib_compressor *compressor);
4440 * Free a compressor previously allocated with wimlib_create_compressor().
4443 * The compressor to free.
4446 wimlib_free_compressor(struct wimlib_compressor *compressor);
4449 * Set the default decompression parameters for the specified compression type.
4450 * This will affect both explicit and library-internal calls to
4451 * wimlib_create_decompressor().
4454 * Compression type for which to set the default decompression parameters.
4456 * Compression-type specific parameters. This may be @c NULL, in which
4457 * case the "default default" parameters are restored.
4459 * @return 0 on success; nonzero on error.
4461 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4462 * @p ctype was not a supported compression type.
4463 * @retval ::WIMLIB_ERR_NOMEM
4464 * Not enough memory to duplicate the parameters (perhaps @c params->size
4468 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4469 const struct wimlib_decompressor_params_header *params);
4472 * Allocate a decompressor for the specified compression type using the
4473 * specified parameters. This function is part of wimlib's compression API; it
4474 * is not necessary to call this to process a WIM file.
4477 * Compression type for which to create the decompressor.
4478 * @param max_block_size
4479 * Maximum block size to support. The exact meaning and allowed values for
4480 * this parameter depend on the compression type, but it at least specifies
4481 * the maximum allowed value for @p uncompressed_size to
4482 * wimlib_decompress().
4483 * @param extra_params
4484 * An optional pointer to extra decompressor parameters for the specified
4485 * compression type. If @c NULL, the default parameters are used.
4486 * @param decompressor_ret
4487 * A location into which to return the pointer to the allocated
4488 * decompressor, which can be used for any number of calls to
4489 * wimlib_decompress() before being freed with wimlib_free_decompressor().
4491 * @return 0 on success; nonzero on error.
4493 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4494 * @p ctype was not a supported compression type.
4495 * @retval ::WIMLIB_ERR_INVALID_PARAM
4496 * The decompression parameters were invalid.
4497 * @retval ::WIMLIB_ERR_NOMEM
4498 * Insufficient memory to allocate the decompressor.
4501 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4502 size_t max_block_size,
4503 const struct wimlib_decompressor_params_header *extra_params,
4504 struct wimlib_decompressor **decompressor_ret);
4507 * Decompress a block of data using a decompressor previously created with
4508 * wimlib_create_decompressor().
4510 * @param compressed_data
4511 * Buffer containing the data to decompress.
4512 * @param compressed_size
4513 * Size, in bytes, of the data to decompress.
4514 * @param uncompressed_data
4515 * Buffer into which to write the uncompressed data.
4516 * @param uncompressed_size
4517 * Size, in bytes, of the data when uncompressed.
4518 * @param decompressor
4519 * A decompressor previously allocated with wimlib_create_decompressor().
4521 * @return 0 on success; nonzero on error.
4524 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4525 void *uncompressed_data, size_t uncompressed_size,
4526 struct wimlib_decompressor *decompressor);
4529 * Free a decompressor previously allocated with wimlib_create_decompressor().
4531 * @param decompressor
4532 * The decompressor to free.
4535 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4547 #endif /* _WIMLIB_H */