3 * @brief External header for wimlib.
5 * This file contains extensive comments for generating documentation with
6 * Doxygen. The built HTML documentation can be viewed at
7 * http://wimlib.sourceforge.net. Make sure to see the <a
8 * href="modules.html">Modules page</a> to make more sense of the declarations
13 * Copyright (C) 2012, 2013, 2014 Eric Biggers
15 * This file is part of wimlib, a library for working with WIM files.
17 * wimlib is free software; you can redistribute it and/or modify it under the
18 * terms of the GNU General Public License as published by the Free
19 * Software Foundation; either version 3 of the License, or (at your option)
22 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
23 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
24 * A PARTICULAR PURPOSE. See the GNU General Public License for more
27 * You should have received a copy of the GNU General Public License
28 * along with wimlib; if not, see http://www.gnu.org/licenses/.
34 * This is the documentation for the library interface of wimlib 1.7.1, a C
35 * library for creating, modifying, extracting, and mounting files in the
36 * Windows Imaging Format. This documentation is intended for developers only.
37 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
38 * program, please see the manual pages and also the <a
39 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/README">README
42 * @section sec_installing Installing
46 * Download the source code from <a
47 * href="http://sourceforge.net/projects/wimlib/files">http://sourceforge.net/projects/wimlib/files</a>.
48 * Install the library by running <c>configure && make && sudo make install</c>.
49 * See the README for information about configuration options. To use wimlib in
50 * your program after installing it, include wimlib.h and link your program with
55 * Download the Windows binary distribution with the appropriate architecture
56 * (i686 or x86_64 --- also called "x86" and "amd64" respectively) from <a
57 * href="http://sourceforge.net/projects/wimlib/files">http://sourceforge.net/projects/wimlib/files</a>.
58 * Link your program with the libwim-15.dll file. Make sure to also download
59 * the source code so you can get wimlib.h, as it is not included in the binary
60 * distribution. If you need to access the DLL from other programming
61 * languages, note that the calling convention is "cdecl".
63 * @section sec_examples Examples
65 * Several examples are located in the <a
66 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/examples">examples</a>
67 * directory of the source distribution.
69 * There is also the <a
70 * href="http://sourceforge.net/p/wimlib/code/ci/master/tree/programs/imagex.c">
71 * source code of <b>wimlib-imagex</b></a>, which is complicated but uses most
72 * capabilities of wimlib.
74 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
76 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
77 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
78 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
79 * which creates a new ::WIMStruct that initially contains no images and does
80 * not yet have a backing on-disk file. See @ref G_creating_and_opening_wims
83 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
84 * Images can be extracted (or "applied") using wimlib_extract_image(), added
85 * (or "captured" or "appended") using wimlib_add_image(), deleted using
86 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
87 * modified using wimlib_update_image(). However, changes made to a WIM
88 * represented by a ::WIMStruct have no persistent effect until the WIM is
89 * actually written to an on-disk file. This can be done using wimlib_write(),
90 * but if the WIM was originally opened using wimlib_open_wim(), then
91 * wimlib_overwrite() can be used instead. See @ref G_extracting_wims, @ref
92 * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
94 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
95 * files is a multi-step process. For example, to add, or "append" an image to
96 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
97 * append</b>, you must call the following functions:
99 * 1. wimlib_open_wim()
100 * 2. wimlib_add_image()
101 * 3. wimlib_overwrite()
103 * This design is very much on purpose as it makes the library more useful in
104 * general by allowing functions to be composed in different ways. For example,
105 * you can make multiple changes to a WIM and commit them all to the underlying
106 * file in only one overwrite operation, which is more efficient.
108 * Note: before calling any other function declared in wimlib.h,
109 * wimlib_global_init() can (and in some cases, must) be called. See its
110 * documentation for more details.
112 * @section sec_cleaning_up Cleaning up
114 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
115 * all resources associated with it. Also, when you are completely done with
116 * using wimlib in your program, you can call wimlib_global_cleanup() to free
117 * any other resources allocated by the library.
119 * @section sec_error_handling Error Handling
121 * Most functions in wimlib return 0 on success and a positive error code on
122 * failure. Use wimlib_get_error_string() to get a string that describes an
123 * error code. wimlib also can print error messages to standard error itself
124 * when an error happens, and these may be more informative than the error code;
125 * to enable this, call wimlib_set_print_errors(). Please note that this is for
126 * convenience only, and some errors can occur without a message being printed.
127 * Currently, error messages and strings (as well as all documentation, for that
128 * matter) are only available in English.
130 * @section sec_encodings Locales and character encodings
132 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
133 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
136 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
137 * and the encoding is UTF-16LE.
139 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
140 * and the encoding is the locale-dependent multibyte encoding. I recommend you
141 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
142 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
143 * call wimlib_global_init() after having set your desired locale.
145 * @section sec_advanced Additional information and features
148 * @subsection subsec_mounting_wim_images Mounting WIM images
150 * See @ref G_mounting_wim_images.
152 * @subsection subsec_progress_functions Progress Messages
154 * See @ref G_progress.
156 * @subsection subsec_non_standalone_wims Non-standalone WIMs
158 * See @ref G_nonstandalone_wims.
160 * @subsection subsec_pipable_wims Pipable WIMs
162 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
163 * compatible with Microsoft's software. To create a pipable WIM, call
164 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
165 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
166 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
167 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
168 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
169 * s using a seekable file descriptor using the regular function calls (e.g.
170 * wimlib_open_wim(), wimlib_extract_image()).
172 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
173 * capture</b> for more information about pipable WIMs.
175 * @subsection subsec_thread_safety Thread Safety
177 * wimlib is thread-safe, with the following exceptions:
178 * - Different threads cannot operate on the same ::WIMStruct at the same time;
179 * they must use different ::WIMStruct's.
180 * - You must call wimlib_global_init() in one thread before calling any other
182 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
183 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
184 * concurrently in the same process, will daemonize the entire process when it
185 * does so for the first time. This includes changing the working directory
186 * to the root directory.
188 * @subsection subsec_limitations Limitations
190 * This section documents some technical limitations of wimlib not already
191 * documented in the man page for @b wimlib-imagex.
193 * - The old WIM format from Vista pre-releases is not supported.
194 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
195 * functionality other than that already present in @b ImageX, that allows you
196 * to make certain Windows-specific modifications to a Windows PE image, such
197 * as adding a driver or Windows component. Such a tool could be implemented
200 * @subsection more_info More information
202 * You are advised to read the README as well as the manual pages for
203 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
204 * the API documentation.
207 /** @defgroup G_general General
209 * @brief Declarations and structures shared across the library.
212 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
214 * @brief Create new WIMs and open existing WIMs.
217 /** @defgroup G_wim_information Retrieving WIM information and directory listings
219 * @brief Retrieve information about a WIM or WIM image.
222 /** @defgroup G_modifying_wims Modifying WIMs
224 * @brief Make changes to a WIM.
226 * @section sec_adding_images Capturing and adding WIM images
228 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
229 * appending an image to an existing WIM is a multi-step process, but at its
230 * core is wimlib_add_image() or an equivalent function. Normally,
231 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
232 * ::WIMStruct as a new image. However, when supported by the build of the
233 * library, there is also a special NTFS volume capture mode (entered when
234 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
235 * from an unmounted NTFS volume.
237 * Another function, wimlib_add_image_multisource() is also provided. It
238 * generalizes wimlib_add_image() to allow combining multiple files or directory
239 * trees into a single WIM image in a configurable way.
241 * For maximum customization of WIM image creation, it is also possible to add a
242 * completely empty WIM image with wimlib_add_empty_image(), then update it with
243 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
244 * wimlib_add_image_multisource() do internally.)
246 * Note that some details of how image addition/capture works are documented
247 * more fully in the manual page for <b>wimlib-imagex capture</b>.
249 * @section sec_deleting_images Deleting WIM images
251 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
252 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
253 * be made persistent in an on-disk WIM file.
255 * @section sec_exporting_images Exporting WIM images
257 * wimlib_export_image() can copy, or "export", an image from one WIM to
260 * @section sec_other_modifications Other modifications
262 * wimlib_update_image() can add, delete, and rename files in a WIM image.
264 * wimlib_set_image_name(), wimlib_set_image_descripton(), and
265 * wimlib_set_image_flags() can change other image metadata.
267 * wimlib_set_wim_info() can change information about the WIM file itself, such
271 /** @defgroup G_extracting_wims Extracting WIMs
273 * @brief Extract files, directories, and images from a WIM.
275 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
276 * represented by a ::WIMStruct. This normally extracts the image to a
277 * directory, but when supported by the build of the library there is also a
278 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
279 * is specified) that allows extracting a WIM image directly to an unmounted
280 * NTFS volume. Various other flags allow further customization of image
283 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
284 * of (possibly wildcard) paths from a WIM image.
286 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
287 * over a pipe; see @ref subsec_pipable_wims.
289 * Some details of how WIM extraction works are documented more fully in the
290 * manual pages for <b>wimlib-imagex apply</b> and <b>wimlib-imagex extract</b>.
293 /** @defgroup G_mounting_wim_images Mounting WIM images
295 * @brief Mount and unmount WIM images.
297 * On Linux, wimlib supports mounting images from WIM files either read-only or
298 * read-write. To mount an image, call wimlib_mount_image(). To unmount an
299 * image, call wimlib_unmount_image(). Mounting can be done without root
300 * privileges because it is implemented using FUSE (Filesystem in Userspace).
302 * If wimlib is compiled using the <code>--without-fuse</code> flag, these
303 * functions will be available but will fail with ::WIMLIB_ERR_UNSUPPORTED.
305 * Note: if mounting is unsupported, wimlib still provides another way to modify
306 * a WIM image (wimlib_update_image()).
310 * @defgroup G_progress Progress Messages
312 * @brief Track the progress of long WIM operations.
314 * Library users can provide a progress function which will be called
315 * periodically during operations such as extracting a WIM image or writing a
316 * WIM image. A ::WIMStruct can have a progress function of type
317 * ::wimlib_progress_func_t associated with it by calling
318 * wimlib_register_progress_function() or by opening the ::WIMStruct using
319 * wimlib_open_wim_with_progress(). Once this is done, the progress function
320 * will be called automatically during many operations, such as
321 * wimlib_extract_image() and wimlib_write().
323 * Some functions that do not operate directly on a user-provided ::WIMStruct,
324 * such as wimlib_join(), also take the progress function directly using an
325 * extended version of the function, such as wimlib_join_with_progress().
327 * In wimlib v1.7.0 and later, progress functions are no longer just
328 * unidirectional. You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause
329 * the current operation to be aborted. wimlib v1.7.0 also added the third
330 * argument to ::wimlib_progress_func_t, which is a user-supplied context.
333 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
335 * @brief Write and overwrite on-disk WIM files.
337 * As described in @ref sec_basic_wim_handling_concepts, these functions are
338 * fundamental to the design of the library as they allow new or modified
339 * ::WIMStruct's to actually be written to on-disk files. Call wimlib_write()
340 * to write a new WIM file, or wimlib_overwrite() to persistently update an
344 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
346 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
348 * Normally, a ::WIMStruct represents a WIM file, but there's a bit more to it
349 * than that. Normally, WIM files are "standalone". However, WIM files can
350 * also be arranged in non-standalone ways, such as a set of on-disk files that
351 * together form a single "split WIM" or "delta WIM". Such arrangements are
352 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
353 * created from one of these on-disk files initially only partially represents
354 * the full WIM and needs to, in effect, be logically combined with other
355 * ::WIMStruct's before performing certain operations, such as extracting files
356 * with wimlib_extract_image() or wimlib_extract_paths(). This is done by
357 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
359 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
360 * specialized function (wimlib_split()) is needed to create a split WIM.
369 #include <inttypes.h>
373 # define _wimlib_deprecated __attribute__((deprecated))
375 # define _wimlib_deprecated
378 /** @addtogroup G_general
381 /** Major version of the library (for example, the 1 in 1.2.5). */
382 #define WIMLIB_MAJOR_VERSION 1
384 /** Minor version of the library (for example, the 2 in 1.2.5). */
385 #define WIMLIB_MINOR_VERSION 7
387 /** Patch version of the library (for example, the 5 in 1.2.5). */
388 #define WIMLIB_PATCH_VERSION 1
395 * Opaque structure that represents a WIM file. This is an in-memory structure
396 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
397 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
398 * continuing to exist so that data can be read from it as needed.
400 * Most functions in this library will work the same way regardless of whether a
401 * given ::WIMStruct was obtained through wimlib_open_wim() or
402 * wimlib_create_new_wim(). Exceptions are documented.
404 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
405 * file from a ::WIMStruct.
407 * See @ref sec_basic_wim_handling_concepts for more information.
409 #ifndef WIMLIB_WIMSTRUCT_DECLARED
410 typedef struct WIMStruct WIMStruct;
411 #define WIMLIB_WIMSTRUCT_DECLARED
415 typedef wchar_t wimlib_tchar;
417 /** See @ref sec_encodings */
418 typedef char wimlib_tchar;
422 /** Path separator for WIM paths passed back to progress callbacks.
423 * This is forward slash on UNIX and backslash on Windows. */
424 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
425 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
427 /** Path separator for WIM paths passed back to progress callbacks.
428 * This is forward slash on UNIX and backslash on Windows. */
429 # define WIMLIB_WIM_PATH_SEPARATOR '/'
430 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
433 /** Use this to specify the root directory of the WIM image. */
434 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
436 /** Use this to test if the specified path refers to the root directory of the
438 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
439 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
442 /** Length of a Globally Unique Identifier (GUID) */
443 #define WIMLIB_GUID_LEN 16
446 * Specifies a compression format. Pass one of these values to
447 * wimlib_create_new_wim(), wimlib_set_output_compression_type(),
448 * wimlib_create_compressor(), or wimlib_create_decompressor().
450 * A WIM file has one default compression type and chunk size. Normally, each
451 * resource in the WIM file is compressed with this compression type. However,
452 * resources may be stored as uncompressed; for example, wimlib will do so if a
453 * resource does not compress to less than its original size. In addition, a
454 * WIM with the new version number of 3584, or "ESD file", might contain solid
455 * blocks with different compression types.
457 enum wimlib_compression_type {
461 * This is a valid argument to wimlib_create_new_wim() and
462 * wimlib_set_output_compression_type(), but not to the functions in the
463 * compression API such as wimlib_create_compressor().
465 WIMLIB_COMPRESSION_TYPE_NONE = 0,
468 * The XPRESS compression format. This format combines Lempel-Ziv
469 * factorization with Huffman encoding. Compression and decompression
470 * are both fast. This format supports chunk sizes that are powers of 2
471 * between <c>2^12</c> and <c>2^16</c>, inclusively.
473 * wimlib's XPRESS compressor will, with the default settings, usually
474 * produce a better compression ratio, and work more quickly, than the
475 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
476 * Non-default compression levels are also supported. For example,
477 * level 80 will enable two-pass optimal parsing, which is significantly
478 * slower but usually improves compression by several percent over the
479 * default level of 50.
481 * If using wimlib_create_compressor() to create an XPRESS compressor
482 * directly, the @p max_block_size parameter may be any positive value
485 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
488 * The LZX compression format. This format combines Lempel-Ziv
489 * factorization with Huffman encoding, but with more features and
490 * complexity than XPRESS. Compression is slow to somewhat fast,
491 * depending on the settings. Decompression is fast but slower than
492 * XPRESS. This format supports chunk sizes that are powers of 2
493 * between <c>2^15</c> and <c>2^21</c>, inclusively. Note: chunk sizes
494 * other than <c>2^15</c> are not compatible with the Microsoft
497 * wimlib's LZX compressor will, with the default settings, usually
498 * produce a better compression ratio, and work more quickly, than the
499 * implementation in Microsoft's WIMGAPI (as of Windows 8.1).
500 * Non-default compression levels are also supported. For example,
501 * level 20 will provide fast compression, almost as fast as XPRESS.
503 * If using wimlib_create_compressor() to create an LZX compressor
504 * directly, the @p max_block_size parameter may be any positive value
507 WIMLIB_COMPRESSION_TYPE_LZX = 2,
510 * The LZMS compression format. This format combines Lempel-Ziv
511 * factorization with adaptive Huffman encoding and range coding.
512 * Compression and decompression are both fairly slow. This format
513 * supports chunk sizes that are powers of 2 between <c>2^15</c> and
514 * <c>2^30</c>, inclusively. This format is best used for large chunk
515 * sizes. Note: LZMS compression is only compatible with wimlib v1.6.0
516 * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
517 * later. Also, chunk sizes larger than <c>2^26</c> are not compatible
518 * with the Microsoft implementation.
520 * wimlib's LZMS compressor is currently faster but will usually not
521 * compress as much as the implementation in Microsoft's WIMGAPI
524 * If using wimlib_create_compressor() to create an LZMS compressor
525 * directly, the @p max_block_size parameter may be any positive value
526 * up to <c>2^31 - 2</c>.
528 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
532 /** @addtogroup G_progress
535 /** Possible values of the first parameter to the user-supplied
536 * ::wimlib_progress_func_t progress function */
537 enum wimlib_progress_msg {
539 /** A WIM image is about to be extracted. @p info will point to
540 * ::wimlib_progress_info.extract. This message is received once per
541 * image for calls to wimlib_extract_image() and
542 * wimlib_extract_image_from_pipe(). */
543 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
545 /** One or more file or directory trees within a WIM image is about to
546 * be extracted. @p info will point to ::wimlib_progress_info.extract.
547 * This message is received only once per wimlib_extract_paths() and
548 * wimlib_extract_pathlist(), since wimlib combines all paths into a
549 * single extraction operation for optimization purposes. */
550 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
552 /** This message may be sent periodically (not for every file) while
553 * files or directories are being created, prior to data stream
554 * extraction. @p info will point to ::wimlib_progress_info.extract.
556 WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE = 3,
558 /** File data is currently being extracted. @p info will point to
559 * ::wimlib_progress_info.extract. This is the main message to track
560 * the progress of an extraction operation. */
561 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
563 /** Starting to read a new part of a split pipable WIM over the pipe.
564 * @p info will point to ::wimlib_progress_info.extract. */
565 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
567 /** This message may be sent periodically (not for every file) while
568 * file and directory metadata is being applied, following data stream
569 * extraction. @p info will point to ::wimlib_progress_info.extract.
571 WIMLIB_PROGRESS_MSG_EXTRACT_METADATA = 6,
573 /** Confirms that the image has been successfully extracted. @p info
574 * will point to ::wimlib_progress_info.extract. This is paired with
575 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
576 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
578 /** Confirms that the files or directory trees have been successfully
579 * extracted. @p info will point to ::wimlib_progress_info.extract.
580 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
581 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
583 /** The directory or NTFS volume is about to be scanned for metadata.
584 * @p info will point to ::wimlib_progress_info.scan. This message is
585 * received once per call to wimlib_add_image(), or once per capture
586 * source passed to wimlib_add_image_multisource(), or once per add
587 * command passed to wimlib_update_image(). */
588 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
590 /** A directory or file has been scanned. @p info will point to
591 * ::wimlib_progress_info.scan, and its @p cur_path member will be
592 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
594 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
596 /** Confirms that the directory or NTFS volume has been successfully
597 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
598 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
599 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
601 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
603 /** File resources ("streams") are currently being written to the WIM.
604 * @p info will point to ::wimlib_progress_info.write_streams. This
605 * message may be received many times while the WIM file is being
606 * written or appended to with wimlib_write(), wimlib_overwrite(), or
607 * wimlib_write_to_fd(). */
608 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
610 /** Per-image metadata is about to be written to the WIM file. @p info
611 * will not be valid. */
612 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
614 /** Confirms that per-image metadata has been successfully been written
615 * to the WIM file. @p info will not be valid. This message is paired
616 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
618 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
620 /** wimlib_overwrite() has successfully renamed the temporary file to
621 * the original WIM file, thereby committing the update. @p info will
622 * point to ::wimlib_progress_info.rename. Note: this message is not
623 * received if wimlib_overwrite() chose to append to the WIM file
625 WIMLIB_PROGRESS_MSG_RENAME = 15,
627 /** The contents of the WIM file are being checked against the integrity
628 * table. @p info will point to ::wimlib_progress_info.integrity. This
629 * message is only received (and may be received many times) when
630 * wimlib_open_wim_with_progress() is called with the
631 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
632 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
634 /** An integrity table is being calculated for the WIM being written.
635 * @p info will point to ::wimlib_progress_info.integrity. This message
636 * is only received (and may be received many times) when a WIM file is
637 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
638 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
640 /** A wimlib_split() operation is in progress, and a new split part is
641 * about to be started. @p info will point to
642 * ::wimlib_progress_info.split. */
643 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
645 /** A wimlib_split() operation is in progress, and a split part has been
646 * finished. @p info will point to ::wimlib_progress_info.split. */
647 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
649 /** A WIM update command is just about to be executed. @p info will
650 * point to ::wimlib_progress_info.update. This message is received
651 * once per update command when wimlib_update_image() is called with the
652 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
653 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
655 /** A WIM update command has just been executed. @p info will point to
656 * ::wimlib_progress_info.update. This message is received once per
657 * update command when wimlib_update_image() is called with the flag
658 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
659 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
661 /** A file in the WIM image is being replaced as a result of a
662 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
663 * @p info will point to ::wimlib_progress_info.replace. This is only
664 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
666 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
668 /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
669 * a file is being extracted normally (not as a WIMBoot "pointer file")
670 * due to it matching a pattern in the [PrepopulateList] section of the
671 * configuration file @c \\Windows\\System32\\WimBootCompress.ini in the
672 * WIM image. @p info will point to
673 * ::wimlib_progress_info.wimboot_exclude.
675 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
677 /** Starting to unmount a WIM image. @p info will point to
678 * ::wimlib_progress_info.unmount. */
679 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
681 /** wimlib has used a file's data for the last time (including all data
682 * streams, if it has multiple). @p info will point to
683 * ::wimlib_progress_info.done_with_file. This message is only received
684 * if ::WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES was provided. */
685 WIMLIB_PROGRESS_MSG_DONE_WITH_FILE = 26,
687 /** wimlib_verify_wim() is starting to verify the metadata for an image.
688 * @p info will point to ::wimlib_progress_info.verify_image. */
689 WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE = 27,
691 /** wimlib_verify_wim() has finished verifying the metadata for an
692 * image. @p info will point to ::wimlib_progress_info.verify_image.
694 WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE = 28,
696 /** wimlib_verify_wim() is verifying stream integrity. @p info will
697 * point to ::wimlib_progress_info.verify_streams. */
698 WIMLIB_PROGRESS_MSG_VERIFY_STREAMS = 29,
701 /** Valid return values from user-provided progress functions
702 * (::wimlib_progress_func_t).
704 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
707 enum wimlib_progress_status {
709 /** The operation should be continued. This is the normal return value.
711 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
713 /** The operation should be aborted. This will cause the current
714 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
715 WIMLIB_PROGRESS_STATUS_ABORT = 1,
719 * A pointer to this union is passed to the user-supplied
720 * ::wimlib_progress_func_t progress function. One (or none) of the structures
721 * contained in this union will be applicable for the operation
722 * (::wimlib_progress_msg) indicated in the first argument to the progress
724 union wimlib_progress_info {
726 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
727 * document them if they aren't given a name... */
729 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
730 * the primary message for tracking the progress of writing a WIM file.
732 struct wimlib_progress_info_write_streams {
733 /** Total number of uncompressed bytes of stream data being
734 * written. This can be thought of as the total uncompressed
735 * size of the files being archived, with some caveats. WIM
736 * files use single-instance streams, so the size provided here
737 * only counts distinct streams, except for the following
738 * exception: the size provided here may include the sizes of
739 * all newly added (e.g. with wimlib_add_image() streams,
740 * pending automatic de-duplication during the write operation
741 * itself. When each such stream de-duplication occurs, this
742 * number will be decreased by the size of the duplicate stream
743 * that need not be written.
745 * In the case of a wimlib_overwrite() that the library opted to
746 * perform in-place, both @p total_streams and @p total_bytes
747 * will only count the streams actually being written and not
748 * pre-existing streams in the WIM file. */
749 uint64_t total_bytes;
751 /** Total number of streams being written. This can be thought
752 * of as the total number of files being archived, with some
753 * caveats. In general, a single file or directory may contain
754 * multiple data streams, each of which will be represented
755 * separately in this number. Furthermore, WIM files use
756 * single-instance streams, so the stream count provided here
757 * only counts distinct streams, except for the following
758 * exception: the stream count provided here may include newly
759 * added (e.g. with wimlib_add_image() streams, pending
760 * automatic de-duplication during the write operation itself.
761 * When each such stream de-duplication occurs, this number will
762 * be decreased by 1 to account for the duplicate stream that
763 * need not be written. */
764 uint64_t total_streams;
766 /** Number of uncompressed bytes of stream data that have been
767 * written so far. This number be 0 initially, and will be
768 * equal to @p total_bytes at the end of the write operation.
769 * Note that @p total_bytes (but not @p completed_bytes) may
770 * decrease throughout the write operation due to the discovery
771 * of stream duplications. */
772 uint64_t completed_bytes;
774 /** Number of streams that have been written so far. This
775 * number will be 0 initially, and will be equal to @p
776 * total_streams at the end of the write operation. Note that
777 * @p total_streams (but not @p completed_streams) may decrease
778 * throughout the write operation due to the discovery of stream
781 * For applications that wish to calculate a simple "percent
782 * complete" for the write operation, it will likely be more
783 * accurate to calculate the percentage from @p completed_bytes
784 * and @p total_bytes rather than @p completed_streams and
785 * @p total_streams because the time for the operation to
786 * complete is mainly determined by the number of bytes that
787 * need to be read, compressed, and written, not just the number
788 * of files being archived. */
789 uint64_t completed_streams;
791 /** Number of threads that are being used to compress streams,
792 * or 1 if streams are being written uncompressed. */
793 uint32_t num_threads;
795 /** The compression type being used to write the streams, as one
796 * of the ::wimlib_compression_type constants. */
797 int32_t compression_type;
799 /** Number of split WIM parts from which streams are being
800 * written (may be 0 if irrelevant). */
801 uint32_t total_parts;
803 /** This is currently broken and will always be 0. */
804 uint32_t completed_parts;
807 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
808 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
809 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
810 struct wimlib_progress_info_scan {
811 /** Top-level directory being scanned; or, when capturing an NTFS
812 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
813 * to the file or block device that contains the NTFS volume
815 const wimlib_tchar *source;
817 /** Path to the file (or directory) that has been scanned, valid
818 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
819 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
820 * relative to the root of the NTFS volume. */
821 const wimlib_tchar *cur_path;
823 /** Dentry scan status, valid on
824 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
826 /** The file looks okay and will be captured. */
827 WIMLIB_SCAN_DENTRY_OK = 0,
829 /** File is being excluded from capture due to the
830 * capture configuration. */
831 WIMLIB_SCAN_DENTRY_EXCLUDED,
833 /** File is being excluded from capture due to being
834 * unsupported (e.g. an encrypted or device file). */
835 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
837 /** The file is an absolute symbolic link or junction
838 * that points into the capture directory, and
839 * reparse-point fixups are enabled, so its target is
840 * being adjusted. (Reparse point fixups can be
841 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
843 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
845 /** Reparse-point fixups are enabled, but the file is an
846 * absolute symbolic link or junction that does
847 * <b>not</b> point into the capture directory, so its
848 * target is <b>not</b> being adjusted. */
849 WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK,
853 /** Target path in the WIM image. Only valid on
854 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
855 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
856 const wimlib_tchar *wim_target_path;
858 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
859 * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
860 * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
861 * target of the absolute symbolic link or junction. */
862 const wimlib_tchar *symlink_target;
865 /** Number of directories scanned so far, including the root
866 * directory but excluding any unsupported/excluded directories.
868 * Details: On Windows and in NTFS capture mode, a reparse point
869 * counts as a directory if and only if it has
870 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
871 * counts as a directory if and only if when fully dereferenced
872 * it points to an accessible directory. If a file has multiple
873 * names (hard links), it is only counted one time. */
874 uint64_t num_dirs_scanned;
876 /** Number of non-directories scanned so far, excluding any
877 * unsupported/excluded files.
879 * Details: On Windows and in NTFS capture mode, a reparse point
880 * counts as a non-directory if and only if it does not have
881 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
882 * counts as a non-directory if and only if when fully
883 * dereferenced it points to a non-directory or its target is
884 * inaccessible. If a file has multiple names (hard links), it
885 * is only counted one time. */
886 uint64_t num_nondirs_scanned;
888 /** Number of bytes of file data that have been detected so far.
890 * Details: This data may not actually have been read yet, and
891 * it will not actually be written to the WIM file until
892 * wimlib_write() or wimlib_overwrite() has been called. Data
893 * from excluded files is not counted. This number includes
894 * default file contents as well as named data streams and
895 * reparse point data. The size of reparse point data is
896 * tallied after any reparse-point fixups, and in the case of
897 * capturing a symbolic link on a UNIX-like system, the creation
898 * of the reparse point data itself. If a file has multiple
899 * names (hard links), its size(s) are only counted one time.
900 * On Windows, encrypted files have their encrypted size
901 * counted, not their unencrypted size; however, compressed
902 * files have their uncompressed size counted. */
903 uint64_t num_bytes_scanned;
906 /** Valid on messages
907 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
908 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
909 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
910 * ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE,
911 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
912 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA,
913 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
914 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
916 * Note: most of the time of an extraction operation will be spent
917 * extracting streams, and the application will receive
918 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
919 * completed_bytes and @p total_bytes, the application can calculate a
920 * percentage complete. However, note that this message does not, in
921 * general, actually provide information about which "file" is currently
922 * being extracted. This is because wimlib, by default, extracts the
923 * individual data streams in whichever order it determines to be the
926 struct wimlib_progress_info_extract {
927 /** Number of the image from which files are being extracted
931 /** Extraction flags being used. */
932 uint32_t extract_flags;
934 /** Full path to the WIM file from which files are being
935 * extracted, or @c NULL if the WIMStruct has no associated
937 const wimlib_tchar *wimfile_name;
939 /** Name of the image from which files are being extracted, or
940 * the empty string if the image is unnamed. */
941 const wimlib_tchar *image_name;
943 /** Path to the directory or NTFS volume to which the files are
944 * being extracted. */
945 const wimlib_tchar *target;
948 const wimlib_tchar *reserved;
950 /** Number of bytes of uncompressed data that will be extracted.
951 * If a file has multiple names (hard links), its size (or
952 * sizes, in the case of named data streams) is only counted one
953 * time. For "reparse points" and symbolic links, the size to
954 * be extracted is the size of the reparse data buffer.
956 * This number will stay constant throughout the extraction. */
957 uint64_t total_bytes;
959 /** Number of bytes of uncompressed data that have been
960 * extracted so far. This initially be 0 and will equal to @p
961 * total_bytes at the end of the extraction. */
962 uint64_t completed_bytes;
964 /** Number of (not necessarily unique) streams that will be
965 * extracted. This may be more or less than the number of
966 * "files" to be extracted due to hard links as well as
967 * potentially multiple streams per file (named data streams).
968 * A "stream" may be the default contents of a file, a named
969 * data stream, or a reparse data buffer. */
970 uint64_t total_streams;
972 /** Number of (not necessarily unique) streams that have been
973 * extracted so far. */
974 uint64_t completed_streams;
976 /** Currently only used for
977 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
978 uint32_t part_number;
980 /** Currently only used for
981 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
982 uint32_t total_parts;
984 /** Currently only used for
985 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
986 uint8_t guid[WIMLIB_GUID_LEN];
989 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
990 struct wimlib_progress_info_rename {
991 /** Name of the temporary file that the WIM was written to. */
992 const wimlib_tchar *from;
994 /** Name of the original WIM file to which the temporary file is
996 const wimlib_tchar *to;
999 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1000 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
1001 struct wimlib_progress_info_update {
1002 /** Pointer to the update command that will be executed or has
1003 * just been executed. */
1004 const struct wimlib_update_command *command;
1006 /** Number of update commands that have been completed so far.
1008 size_t completed_commands;
1010 /** Number of update commands that are being executed as part of
1011 * this call to wimlib_update_image(). */
1012 size_t total_commands;
1015 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
1016 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
1017 struct wimlib_progress_info_integrity {
1018 /** Number of bytes from the end of the WIM header to the end of
1019 * the lookup table (the area that is covered by the SHA1
1020 * integrity checks.) */
1021 uint64_t total_bytes;
1023 /** Number of bytes that have been SHA1-summed so far. Will be
1024 * 0 initially, and equal @p total_bytes at the end. */
1025 uint64_t completed_bytes;
1027 /** Number of chunks that the checksummed region is divided
1029 uint32_t total_chunks;
1031 /** Number of chunks that have been SHA1-summed so far. Will
1032 * be 0 initially, and equal to @p total_chunks at the end. */
1033 uint32_t completed_chunks;
1035 /** Size of the chunks used for the integrity calculation. */
1036 uint32_t chunk_size;
1038 /** Filename of the WIM (only valid if the message is
1039 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
1040 const wimlib_tchar *filename;
1043 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
1044 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
1045 struct wimlib_progress_info_split {
1046 /** Total size of the original WIM's file and metadata resources
1048 uint64_t total_bytes;
1050 /** Number of bytes of file and metadata resources that have
1051 * been copied out of the original WIM so far. Will be 0
1052 * initially, and equal to @p total_bytes at the end. */
1053 uint64_t completed_bytes;
1055 /** Number of the split WIM part that is about to be started
1056 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1057 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
1058 unsigned cur_part_number;
1060 /** Total number of split WIM parts that are being written. */
1061 unsigned total_parts;
1063 /** Name of the split WIM part that is about to be started
1064 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
1065 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
1066 * As of wimlib v1.7.0, the library user may change this when
1067 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
1068 * cause the next split WIM part to be written to a different
1070 wimlib_tchar *part_name;
1073 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
1074 struct wimlib_progress_info_replace {
1075 /** Path to the file in the WIM image that is being replaced */
1076 const wimlib_tchar *path_in_wim;
1079 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
1080 struct wimlib_progress_info_wimboot_exclude {
1081 /** Path to the file in the WIM image */
1082 const wimlib_tchar *path_in_wim;
1084 /** Path to which the file is being extracted */
1085 const wimlib_tchar *extraction_path;
1088 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
1089 struct wimlib_progress_info_unmount {
1090 /** Path to directory being unmounted */
1091 const wimlib_tchar *mountpoint;
1093 /** Path to WIM file being unmounted */
1094 const wimlib_tchar *mounted_wim;
1096 /** 1-based index of image being unmounted. */
1097 uint32_t mounted_image;
1099 /** Flags that were passed to wimlib_mount_image() when the
1100 * mountpoint was set up. */
1101 uint32_t mount_flags;
1103 /** Flags passed to wimlib_unmount_image(). */
1104 uint32_t unmount_flags;
1107 /** Valid on messages ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE. */
1108 struct wimlib_progress_info_done_with_file {
1109 /* Path to the file whose data has been written to the WIM file,
1110 * or is currently being asynchronously compressed in memory,
1111 * and therefore is no longer needed by wimlib.
1113 * WARNING: The file data will not actually be accessible in the
1114 * WIM file until the WIM file has been completely written.
1115 * Ordinarily you should <b>not</b> treat this message as a
1116 * green light to go ahead and delete the specified file, since
1117 * that would result in data loss if the WIM file cannot be
1118 * successfully created for any reason.
1120 * If a file has multiple names (hard links),
1121 * ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE will only be received
1122 * for one name. Also, this message will not be received for
1123 * empty files or reparse points (or symbolic links), unless
1124 * they have nonempty named data streams.
1126 const wimlib_tchar *path_to_file;
1129 /** Valid on messages ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE and
1130 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE. */
1131 struct wimlib_progress_info_verify_image {
1132 const wimlib_tchar *wimfile;
1133 uint32_t total_images;
1134 uint32_t current_image;
1137 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS. */
1138 struct wimlib_progress_info_verify_streams {
1139 const wimlib_tchar *wimfile;
1140 uint64_t total_streams;
1141 uint64_t total_bytes;
1142 uint64_t completed_streams;
1143 uint64_t completed_bytes;
1148 * A user-supplied function that will be called periodically during certain WIM
1151 * The first argument will be the type of operation that is being performed or
1152 * is about to be started or has been completed.
1154 * The second argument will be a pointer to one of a number of structures
1155 * depending on the first argument. It may be @c NULL for some message types.
1156 * Note that although this argument is not @c const, users should not modify it
1157 * except in explicitly documented cases.
1159 * The third argument will be a user-supplied value that was provided when
1160 * registering or specifying the progress function.
1162 * This function must return one of the ::wimlib_progress_status values. By
1163 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1165 typedef enum wimlib_progress_status
1166 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1167 union wimlib_progress_info *info,
1171 /** @addtogroup G_modifying_wims
1174 /** An array of these structures is passed to wimlib_add_image_multisource() to
1175 * specify the sources from which to create a WIM image. */
1176 struct wimlib_capture_source {
1177 /** Absolute or relative path to a file or directory on the external
1178 * filesystem to be included in the WIM image. */
1179 wimlib_tchar *fs_source_path;
1181 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1182 * specify the root directory of the WIM image. */
1183 wimlib_tchar *wim_target_path;
1185 /** Reserved; set to 0. */
1189 /** Set or unset the WIM header flag that marks it read-only
1190 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
1191 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
1192 * is distinct from basic file permissions; this flag can be set on a WIM file
1193 * that is physically writable. If this flag is set, all further operations to
1194 * modify the WIM will fail, except calling wimlib_overwrite() with
1195 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
1196 * allows you to set this flag persistently on the underlying WIM file.
1198 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1200 /** Set the GUID (globally unique identifier) of the WIM file to the value
1201 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1202 #define WIMLIB_CHANGE_GUID 0x00000002
1204 /** Change the bootable image of the WIM to the value specified in
1205 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1206 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1208 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1209 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
1210 * indicates whether an image in the WIM has been captured with reparse-point
1211 * fixups enabled. wimlib also treats this flag as specifying whether to do
1212 * reparse-point fixups by default when capturing or applying WIM images. */
1213 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1217 /** @addtogroup G_wim_information */
1221 /** General information about a WIM file. */
1222 struct wimlib_wim_info {
1224 /** Globally unique identifier for the WIM file. Note: all parts of a
1225 * split WIM should have an identical value in this field. */
1226 uint8_t guid[WIMLIB_GUID_LEN];
1228 /** Number of images in the WIM. */
1229 uint32_t image_count;
1231 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1233 uint32_t boot_index;
1235 /** Version of the WIM file. */
1236 uint32_t wim_version;
1238 /** Chunk size used for compression. */
1239 uint32_t chunk_size;
1241 /** For split WIMs, the 1-based index of this part within the split WIM;
1243 uint16_t part_number;
1245 /** For split WIMs, the total number of parts in the split WIM;
1247 uint16_t total_parts;
1249 /** One of the ::wimlib_compression_type values that specifies the
1250 * method used to compress resources in the WIM. */
1251 int32_t compression_type;
1253 /** Size of the WIM file in bytes, excluding the XML data and integrity
1255 uint64_t total_bytes;
1257 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1258 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1259 * this will always be 0, even if the ::WIMStruct was written to
1260 * somewhere by calling wimlib_write() with the
1261 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1262 uint32_t has_integrity_table : 1;
1264 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1265 * wimlib_create_new_wim(). */
1266 uint32_t opened_from_file : 1;
1268 /** 1 if the WIM is considered readonly for any reason. */
1269 uint32_t is_readonly : 1;
1271 /** 1 if reparse-point fixups are enabled for one or more images in the
1273 uint32_t has_rpfix : 1;
1275 /** 1 if the WIM is marked read-only. */
1276 uint32_t is_marked_readonly : 1;
1278 /** 1 if the WIM is part of a spanned set. */
1279 uint32_t spanned : 1;
1281 uint32_t write_in_progress : 1;
1282 uint32_t metadata_only : 1;
1283 uint32_t resource_only : 1;
1285 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1286 uint32_t pipable : 1;
1287 uint32_t reserved_flags : 22;
1288 uint32_t reserved[9];
1291 /** Information about a unique stream in the WIM file. (A stream is the same
1292 * thing as a "resource", except in the case of packed resources.) */
1293 struct wimlib_resource_entry {
1294 /** Uncompressed size of the stream in bytes. */
1295 uint64_t uncompressed_size;
1297 /** Compressed size of the stream in bytes. This will be the same as @p
1298 * uncompressed_size if the stream is uncompressed. Or, if @p packed is
1299 * 1, this will be 0. */
1300 uint64_t compressed_size;
1302 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1303 * if @p packed is 1, then this is actually the offset at which this
1304 * stream begins in the uncompressed contents of the packed resource.
1308 /** SHA1 message digest of the stream's uncompressed contents. */
1309 uint8_t sha1_hash[20];
1311 /** Which part of WIM this stream is in. */
1312 uint32_t part_number;
1314 /** Number of times this stream is referenced over all WIM images. */
1315 uint32_t reference_count;
1317 /** 1 if this stream is compressed. */
1318 uint32_t is_compressed : 1;
1320 /** 1 if this stream is a metadata resource rather than a file resource.
1322 uint32_t is_metadata : 1;
1324 uint32_t is_free : 1;
1325 uint32_t is_spanned : 1;
1327 /** 1 if this stream was not found in the lookup table of the
1328 * ::WIMStruct. This normally implies a missing call to
1329 * wimlib_reference_resource_files() or wimlib_reference_resources().
1331 uint32_t is_missing : 1;
1333 /** 1 if this stream is located in a packed resource which may contain
1334 * other streams (all compressed together) as well. */
1335 uint32_t packed : 1;
1337 uint32_t reserved_flags : 26;
1339 /** If @p packed is 1, then this will specify the offset of the packed
1340 * resource in the WIM. */
1341 uint64_t raw_resource_offset_in_wim;
1343 /** If @p packed is 1, then this will specify the compressed size of the
1344 * packed resource in the WIM. */
1345 uint64_t raw_resource_compressed_size;
1347 uint64_t reserved[2];
1351 * Information about a stream of a particular file in the WIM.
1353 * Normally, only WIM images captured from NTFS filesystems will have multiple
1354 * streams per file. In practice, this is a rarely used feature of the
1357 struct wimlib_stream_entry {
1358 /** Name of the stream, or NULL if the stream is unnamed. */
1359 const wimlib_tchar *stream_name;
1360 /** Location, size, and other information about the stream's data as
1361 * stored in the WIM file. */
1362 struct wimlib_resource_entry resource;
1363 uint64_t reserved[4];
1366 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1367 * Roughly, the information about a "file" in the WIM--- but really a directory
1368 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1369 * field can be used to distinguish actual file inodes. */
1370 struct wimlib_dir_entry {
1371 /** Name of the file, or NULL if this file is unnamed. Only the root
1372 * directory of an image will be unnamed. */
1373 const wimlib_tchar *filename;
1375 /** 8.3 name (or "DOS name", or "short name") of this file; or NULL if
1376 * this file has no such name. */
1377 const wimlib_tchar *dos_name;
1379 /** Full path to this file within the WIM image. Path separators will
1380 * be ::WIMLIB_WIM_PATH_SEPARATOR. */
1381 const wimlib_tchar *full_path;
1383 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1384 * children, ..., etc. */
1387 /** Pointer to the security descriptor for this file, in Windows
1388 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1389 * security descriptor. */
1390 const char *security_descriptor;
1392 /** Length of the above security descriptor. */
1393 size_t security_descriptor_size;
1395 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1396 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1397 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1398 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1399 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1400 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1401 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1402 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1403 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1404 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1405 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1406 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1407 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1408 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1409 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1410 /** File attributes, such as whether the file is a directory or not.
1411 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1412 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1413 * on other platforms. */
1414 uint32_t attributes;
1416 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1417 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1418 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1419 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1420 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1421 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1422 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1423 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1424 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1425 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1426 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1427 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1428 /** If the file is a reparse point (FILE_ATTRIBUTE_REPARSE_POINT set in
1429 * the attributes), this will give the reparse tag. This tells you
1430 * whether the reparse point is a symbolic link, junction point, or some
1431 * other, more unusual kind of reparse point. */
1432 uint32_t reparse_tag;
1434 /** Number of links to this file's inode (hard links).
1436 * Currently, this will always be 1 for directories. However, it can be
1437 * greater than 1 for nondirectory files. */
1440 /** Number of named data streams this file has. Normally 0. */
1441 uint32_t num_named_streams;
1443 /** A unique identifier for this file's inode. However, as a special
1444 * case, if the inode only has a single link (@p num_links == 1), this
1447 * Note: if a WIM image is captured from a filesystem, this value is not
1448 * guaranteed to be the same as the original number of the inode on the
1450 uint64_t hard_link_group_id;
1452 /** Time this file was created. */
1453 struct timespec creation_time;
1455 /** Time this file was last written to. */
1456 struct timespec last_write_time;
1458 /** Time this file was last accessed. */
1459 struct timespec last_access_time;
1461 /** The UNIX user ID of this file. This is a wimlib extension.
1463 * This field is only valid if @p unix_mode != 0. */
1466 /** The UNIX group ID of this file. This is a wimlib extension.
1468 * This field is only valid if @p unix_mode != 0. */
1471 /** The UNIX mode of this file. This is a wimlib extension.
1473 * If this field is 0, then @p unix_uid, @p unix_gid, @p unix_mode, and
1474 * @p unix_rdev are all unknown (fields are not present in the WIM
1478 /** The UNIX device ID (major and minor number) of this file. This is a
1481 * This field is only valid if @p unix_mode != 0. */
1484 uint64_t reserved[14];
1487 * Array of streams that make up this file.
1489 * The first entry will always exist and will correspond to the unnamed
1490 * data stream (default file contents), so it will have <c>stream_name
1491 * == NULL</c>. Alternatively, for reparse point files, the first entry
1492 * will corresponding to the reparse data stream.
1494 * Then, following the first entry, there be @p num_named_streams
1495 * additional entries that specify the named data streams, if any, each
1496 * of which will have <c>stream_name != NULL</c>.
1498 struct wimlib_stream_entry streams[];
1502 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1505 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1509 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1512 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1515 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1516 * just on the specified path. */
1517 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1519 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1520 * itself; only its children (in the case of a non-empty directory) */
1521 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1523 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1524 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1525 * table of the ::WIMStruct. The default behavior without this flag is to fill
1526 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1527 * wimlib_resource_entry::is_missing "is_missing" flag. */
1528 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1532 /** @addtogroup G_modifying_wims
1535 /** UNIX-like systems only: Directly capture an NTFS volume rather than a
1536 * generic directory. This requires that wimlib was compiled with support for
1539 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1540 * ::WIMLIB_ADD_FLAG_UNIX_DATA.
1542 * Do not use this flag on Windows, where wimlib already supports all
1543 * Windows-native filesystems, including NTFS, through the Windows APIs. */
1544 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1546 /** Follow symbolic links when scanning the directory tree. Currently only
1547 * supported on UNIX-like systems. */
1548 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1550 /** Call the progress function with the message
1551 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1553 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1555 /** Mark the image being added as the bootable image of the WIM. This flag is
1556 * valid only for wimlib_add_image() and wimlib_add_image_multisource().
1558 * Note that you can also change the bootable image of a WIM using
1559 * wimlib_set_wim_info().
1561 * Note: ::WIMLIB_ADD_FLAG_BOOT does something different from, and independent
1562 * from, ::WIMLIB_ADD_FLAG_WIMBOOT. */
1563 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1565 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1566 * (major and minor number) of each file. Also allows capturing special files
1567 * such as device nodes and FIFOs. See the documentation for the
1568 * <b>--unix-data</b> option to <b>wimlib-imagex capture</b> for more
1570 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1572 /** Do not capture security descriptors. Only has an effect in NTFS capture
1573 * mode, or in Windows native builds. */
1574 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1576 /** Fail immediately if the full security descriptor of any file or directory
1577 * cannot be accessed. Only has an effect in Windows native builds. The
1578 * default behavior without this flag is to first try omitting the SACL from the
1579 * security descriptor, then to try omitting the security descriptor entirely.
1581 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1583 /** Call the progress function with the message
1584 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1585 * capture. This is a subset of the messages provided by
1586 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1587 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1589 /** Reparse-point fixups: Modify absolute symbolic links (and junctions, in the
1590 * case of Windows) that point inside the directory being captured to instead be
1591 * absolute relative to the directory being captured.
1593 * Without this flag, the default is to do reparse-point fixups if
1594 * WIM_HDR_FLAG_RP_FIX is set in the WIM header or if this is the first image
1595 * being added. WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is
1596 * captured with reparse point fixups enabled and currently cannot be unset. */
1597 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1599 /** Don't do reparse point fixups. See ::WIMLIB_ADD_FLAG_RPFIX. */
1600 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1602 /** Do not automatically exclude unsupported files or directories from capture;
1603 * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1604 * UNIX-like systems when not also using ::WIMLIB_ADD_FLAG_UNIX_DATA. Instead,
1605 * fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when such a file is encountered. */
1606 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1609 * Automatically select a capture configuration appropriate for capturing
1610 * filesystems containing Windows operating systems. For example,
1611 * "/pagefile.sys" and "System Volume Information" will be excluded.
1613 * When this flag is specified, the corresponding @p config parameter (for
1614 * wimlib_add_image()) or member (for wimlib_update_image()) must be @c NULL.
1615 * Otherwise, ::WIMLIB_ERR_INVALID_PARAM will be returned.
1617 * Note that the default behavior--- that is, when neither
1618 * ::WIMLIB_ADD_FLAG_WINCONFIG nor ::WIMLIB_ADD_FLAG_WIMBOOT is specified and @p
1619 * config is @c NULL--- is to use no capture configuration, meaning that no
1620 * files are excluded from capture.
1622 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1625 * Capture image as WIMBoot compatible. In addition, if no capture
1626 * configuration file is explicitly specified use the capture configuration file
1627 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1628 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1629 * configuration file is explicitly specified, use it and also place it at
1630 * /Windows/System32/WimBootCompress.ini in the WIM image.
1632 * Note: this will not by itself change the compression type. Before writing
1633 * the WIM file, it's recommended to also do:
1636 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1637 * wimlib_set_output_chunk_size(wim, 4096);
1640 * since that makes access to the data faster (at the cost of a worse
1641 * compression ratio compared to the 32768-byte LZX chunks usually used).
1643 * Note: ::WIMLIB_ADD_FLAG_WIMBOOT does something different from, and
1644 * independent from, ::WIMLIB_ADD_FLAG_BOOT.
1646 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1649 * If the add command involves adding a non-directory file to a location at
1650 * which there already exists a nondirectory file in the WIM image, issue
1651 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This only has an
1652 * effect when updating an existing image with wimlib_update_image().
1653 * This was the default behavior in wimlib v1.6.2 and earlier.
1655 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1657 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1658 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1659 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1660 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1661 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1662 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1663 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1664 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1665 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1666 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1667 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1668 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1669 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1670 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT WIMLIB_ADD_FLAG_WIMBOOT
1674 /** @addtogroup G_modifying_wims
1677 /** Do not issue an error if the path to delete does not exist. */
1678 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1680 /** Delete the file or directory tree recursively; if not specified, an error is
1681 * issued if the path to delete is a directory. */
1682 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1685 /** @addtogroup G_modifying_wims
1689 * If a single image is being exported, mark it bootable in the destination WIM.
1690 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1691 * the image in the source WIM (if any) that is marked as bootable is also
1692 * marked as bootable in the destination WIM.
1694 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1696 /** Give the exported image(s) no names. Avoids problems with image name
1699 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1701 /** Give the exported image(s) no descriptions. */
1702 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1704 /** This advises the library that the program is finished with the source
1705 * WIMStruct and will not attempt to access it after the call to
1706 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1707 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1710 * Mark each exported image as WIMBoot-compatible.
1712 * Note: by itself, this does change the destination WIM's compression type, nor
1713 * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1714 * image. Before writing the destination WIM, it's recommended to do something
1718 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1719 * wimlib_set_output_chunk_size(wim, 4096);
1720 * wimlib_add_tree(wim, image, L"myconfig.ini",
1721 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1724 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1727 /** @addtogroup G_extracting_wims
1730 /** Extract the image directly to an NTFS volume rather than a generic directory.
1731 * This mode is only available if wimlib was compiled with libntfs-3g support;
1732 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1733 * extraction target will be interpreted as the path to an NTFS volume image (as
1734 * a regular file or block device) rather than a directory. It will be opened
1735 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1736 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1737 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1738 * wimlib_extract_paths() when passed multiple paths. */
1739 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1741 /** UNIX-like systems only: Extract special UNIX data captured with
1742 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1743 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1744 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1746 /** Do not extract security descriptors. This flag cannot be combined with
1747 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1748 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1750 /** Fail immediately if the full security descriptor of any file or directory
1751 * cannot be set exactly as specified in the WIM file. On Windows, the default
1752 * behavior without this flag when wimlib does not have permission to set the
1753 * correct security descriptor is to fall back to setting the security
1754 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1755 * owner omitted, then not at all. This flag cannot be combined with
1756 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1757 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1759 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1760 * reparse-point fixups on, so absolute symbolic links or junction points will
1761 * be fixed to be absolute relative to the actual extraction root. Reparse-
1762 * point fixups are done by default for wimlib_extract_image() and
1763 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1764 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1765 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1767 /** Force reparse-point fixups on extraction off, regardless of the state of the
1768 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1769 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1770 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1772 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1773 * paths, each of which must name a regular file, to standard output. */
1774 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1776 /** Instead of ignoring files and directories with names that cannot be
1777 * represented on the current platform (note: Windows has more restrictions on
1778 * filenames than POSIX-compliant systems), try to replace characters or append
1779 * junk to the names so that they can be extracted in some form.
1781 * Note: this flag is unlikely to have any effect when extracting a WIM image
1782 * that was captured on Windows.
1784 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1786 /** On Windows, when there exist two or more files with the same case
1787 * insensitive name but different case sensitive names, try to extract them all
1788 * by appending junk to the end of them, rather than arbitrarily extracting only
1791 * Note: this flag is unlikely to have any effect when extracting a WIM image
1792 * that was captured on Windows.
1794 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1796 /** Do not ignore failure to set timestamps on extracted files. This flag
1797 * currently only has an effect when extracting to a directory on UNIX-like
1799 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1801 /** Do not ignore failure to set short names on extracted files. This flag
1802 * currently only has an effect on Windows. */
1803 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1805 /** Do not ignore failure to extract symbolic links and junctions due to
1806 * permissions problems. This flag currently only has an effect on Windows. By
1807 * default, such failures are ignored since the default configuration of Windows
1808 * only allows the Administrator to create symbolic links. */
1809 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1811 /** Reserved for future use. */
1812 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1814 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1815 * paths to extract as wildcard patterns ("globs") which may contain the
1816 * wildcard characters @c ? and @c *. The @c ? character matches any
1817 * non-path-separator character, whereas the @c * character matches zero or more
1818 * non-path-separator characters. Consequently, each glob may match zero or
1819 * more actual paths in the WIM image.
1821 * By default, if a glob does not match any files, a warning but not an error
1822 * will be issued. This is the case even if the glob did not actually contain
1823 * wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error
1826 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1828 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1829 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1830 * one of the provided globs did not match a file. */
1831 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1833 /** Do not extract Windows file attributes such as readonly, hidden, etc.
1835 * This flag has an effect on Windows as well as in the NTFS-3g extraction mode.
1837 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1839 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1840 * preserve the directory structure of the archive when extracting --- that is,
1841 * place each extracted file or directory tree directly in the target directory.
1843 * The target directory will still be created if it does not already exist. */
1844 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1846 /** Windows only: Extract files as "pointers" back to the WIM archive.
1848 * The effects of this option are fairly complex. See the documentation for the
1849 * <b>--wimboot</b> option of <b>wimlib-imagex apply</b> for more information.
1851 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1854 /** @addtogroup G_mounting_wim_images
1857 /** Mount the WIM image read-write rather than the default of read-only. */
1858 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1860 /** Enable FUSE debugging by passing the @c -d option to @c fuse_main(). */
1861 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1863 /** Do not allow accessing named data streams in the mounted WIM image. */
1864 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1866 /** Access named data streams in the mounted WIM image through extended file
1867 * attributes named "user.X", where X is the name of a data stream. This is the
1869 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1871 /** Access named data streams in the mounted WIM image by specifying the file
1872 * name, a colon, then the name of the data stream. */
1873 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1875 /** Use UNIX metadata if available in the WIM image. See
1876 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1877 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1879 /** Allow other users to see the mounted filesystem. This passes the @c
1880 * allow_other option to fuse_main(). */
1881 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1884 /** @addtogroup G_creating_and_opening_wims
1887 /** Verify the WIM contents against the WIM's integrity table, if present. This
1888 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1889 * checksummed and checked against the SHA1 message digests specified in the
1890 * integrity table. If there are any mismatches, ::WIMLIB_ERR_INTEGRITY is
1891 * issued. If the WIM file does not contain an integrity table, this flag has
1893 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1895 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
1896 * WIM. Software can provide this flag for convenience if it explicitly does
1897 * not want to support split WIMs. */
1898 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1900 /** Check if the WIM is writable and issue an error
1901 * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not. A WIM is considered writable
1902 * only if it is writable at the filesystem level, does not have the
1903 * WIM_HDR_FLAG_READONLY flag set in its header, and is not part of a spanned
1904 * set. It is not required to provide this flag before attempting to make
1905 * changes to the WIM, but with this flag you get an error sooner rather than
1907 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1910 /** @addtogroup G_mounting_wim_images
1913 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
1914 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1915 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1917 /** Commit changes to the read-write mounted WIM image.
1918 * If this flag is not specified, changes will be discarded. */
1919 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1921 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
1922 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1923 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1925 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
1926 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1927 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1930 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
1931 * image, forces all file descriptors to the open WIM image to be closed before
1934 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
1935 * this flag has no effect.
1937 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
1939 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1940 * WIM image, causes the modified image to be committed to the WIM file as a
1941 * new, unnamed image appended to the archive. The original image in the WIM
1942 * file will be unmodified. */
1943 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
1946 /** @addtogroup G_modifying_wims
1949 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1950 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1951 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1954 /** @addtogroup G_writing_and_overwriting_wims
1958 * Include an integrity table in the resulting WIM file.
1960 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1961 * include an integrity table if and only if one was present before. For
1962 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1963 * to not include an integrity table.
1965 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1968 * Do not include an integrity table in the resulting WIM file. This is the
1969 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
1972 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1975 * Write the WIM as "pipable". After writing a WIM with this flag specified,
1976 * images from it can be applied directly from a pipe using
1977 * wimlib_extract_image_from_pipe(). See the documentation for the
1978 * <b>--pipable</b> option of <b>wimlib-imagex capture</b> for more information.
1979 * Beware: WIMs written with this flag will not be compatible with Microsoft's
1982 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1983 * write the WIM as pipable if and only if it was pipable before. For
1984 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1985 * to write the WIM as non-pipable.
1987 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1990 * Do not write the WIM as "pipable". This is the default behavior, unless the
1991 * ::WIMStruct was created by opening a pipable WIM.
1993 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1996 * When writing streams to the WIM file, recompress them, even if their data is
1997 * already available in the desired compressed form (for example, in a WIM file
1998 * from which an image has been exported using wimlib_export_image()).
2000 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
2001 * compression ratio for the same compression type and chunk size. Simply using
2002 * the default compression settings may suffice for this, especially if the WIM
2003 * file was created using another program/library that may not use as
2004 * sophisticated compression algorithms. Or,
2005 * wimlib_set_default_compression_level() can be called beforehand to set an
2006 * even higher compression level than the default.
2008 * If the WIM contains solid blocks, then ::WIMLIB_WRITE_FLAG_RECOMPRESS can be
2009 * used in combination with ::WIMLIB_WRITE_FLAG_PACK_STREAMS to prevent any
2010 * solid blocks from being re-used. Otherwise, solid blocks are re-used
2011 * somewhat more liberally than normal compressed blocks.
2013 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
2014 * that would not otherwise be written. For example, a call to
2015 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
2016 * cause already-existing streams in the WIM file to be recompressed. To force
2017 * the WIM file to be fully rebuilt and recompressed, combine
2018 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
2020 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
2023 * Immediately before closing the WIM file, sync its data to disk.
2025 * This flag forces the function to wait until the data is safely on disk before
2026 * returning success. Otherwise, modern operating systems tend to cache data
2027 * for some time (in some cases, 30+ seconds) before actually writing it to
2028 * disk, even after reporting to the application that the writes have succeeded.
2030 * wimlib_overwrite() will set this flag automatically if it decides to
2031 * overwrite the WIM file via a temporary file instead of in-place. This is
2032 * necessary on POSIX systems; it will, for example, avoid problems with delayed
2033 * allocation on ext4.
2035 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
2038 * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
2039 * could be updated in-place by appending to it.
2041 * When rebuilding the WIM file, stream reference counts will be recomputed, and
2042 * any streams with 0 reference count (e.g. from deleted files or images) will
2043 * not be included in the resulting WIM file. This can free up space that is
2044 * currently not being used.
2046 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
2047 * data to be recompressed. Otherwise, compressed data is re-used if possible.
2049 * wimlib_write() ignores this flag.
2051 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
2054 * For wimlib_overwrite(), override the default behavior after one or more calls
2055 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
2056 * flag, only minimal changes to correctly remove the image from the WIM file
2057 * will be taken. In particular, all streams will be retained, even if they are
2058 * no longer referenced. This may not be what you want, because no space will
2059 * be saved by deleting an image in this way.
2061 * wimlib_write() ignores this flag.
2063 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
2066 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
2067 * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header. This can be used
2068 * following a call to wimlib_set_wim_info() with the
2069 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
2072 * wimlib_write() ignores this flag.
2074 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
2077 * Do not include streams already present in other WIMs. This flag can be used
2078 * to write a "delta" WIM after resources from the WIM on which the delta is to
2079 * be based were referenced with wimlib_reference_resource_files() or
2080 * wimlib_reference_resources().
2082 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
2085 * Advises the library that for writes of all WIM images, all streams needed for
2086 * the WIM are already present (not in external resource WIMs) and their
2087 * reference counts are correct, so the code does not need to recalculate which
2088 * streams are referenced. This is for optimization purposes only, since with
2089 * this flag specified, the metadata resources may not need to be decompressed
2092 * wimlib_overwrite() will set this flag automatically.
2094 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
2097 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
2099 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
2102 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
2105 * When writing streams in the resulting WIM file, pack multiple streams into a
2106 * single compressed resource instead of compressing them independently. This
2107 * is also known as creating a "solid archive". This tends to produce a better
2108 * compression ratio at the cost of much slower random access.
2110 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
2111 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
2112 * created with this flag use a different version number in their header (3584
2113 * instead of 68864) and are also called "ESD files".
2115 * If this flag is passed to wimlib_overwrite(), any new data streams will be
2116 * written in solid mode. Use both ::WIMLIB_WRITE_FLAG_REBUILD and
2117 * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
2118 * all streams recompressed in solid mode.
2120 * Currently, new solid blocks will, by default, be written using LZMS
2121 * compression with 32 MiB (33554432 byte) chunks. Use
2122 * wimlib_set_output_pack_compression_type() and/or
2123 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
2124 * the WIM's main compression type and chunk size; you can have a WIM that
2125 * nominally uses LZX compression and 32768 byte chunks but actually contains
2126 * LZMS-compressed solid blocks, for example. However, if including solid
2127 * blocks, I suggest that you set the WIM's main compression type to LZMS as
2128 * well, either by creating the WIM with
2129 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
2130 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
2132 * This flag will be set by default when writing or overwriting a WIM file that
2133 * either already contains packed streams, or has had packed streams exported
2134 * into it and the WIM's main compression type is LZMS.
2136 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
2139 * Send ::WIMLIB_PROGRESS_MSG_DONE_WITH_FILE messages while writing the WIM
2140 * file. This is only needed in the unusual case that the library user needs to
2141 * know exactly when wimlib has read each file for the last time.
2143 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
2146 /** @addtogroup G_general
2149 /** Assume that strings are represented in UTF-8, even if this is not the
2150 * locale's character encoding. This flag is ignored on Windows, where wimlib
2151 * always uses UTF-16LE. */
2152 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
2154 /** Windows-only: do not attempt to acquire additional privileges (currently
2155 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
2156 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
2157 * for the case where the calling program manages these privileges itself.
2158 * Note: no error is issued if privileges cannot be acquired, although related
2159 * errors may be reported later, depending on if the operations performed
2160 * actually require additional privileges or not. */
2161 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
2163 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2164 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2165 * to read all possible data and metadata for a capture operation could not be
2166 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
2168 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
2170 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
2171 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
2172 * to restore all possible data and metadata for an apply operation could not be
2173 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
2175 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
2177 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
2179 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
2181 /** Default to interpreting WIM paths case insensitively (default on Windows).
2182 * This does not apply to mounted images. */
2183 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
2186 /** @addtogroup G_nonstandalone_wims
2189 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
2190 * Ignored by wimlib_reference_resources(). */
2191 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
2193 /** For wimlib_reference_resource_files(), issue an error
2194 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
2195 * default behavior without this flag is to issue no error at that point, but
2196 * then attempt to open the glob as a literal path, which of course will fail
2197 * anyway if no file exists at that path. No effect if
2198 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
2199 * wimlib_reference_resources(). */
2200 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
2203 /** @addtogroup G_modifying_wims
2206 /** The specific type of update to perform. */
2207 enum wimlib_update_op {
2208 /** Add a new file or directory tree to the WIM image in a
2209 * certain location. */
2210 WIMLIB_UPDATE_OP_ADD = 0,
2212 /** Delete a file or directory tree from the WIM image. */
2213 WIMLIB_UPDATE_OP_DELETE,
2215 /** Rename a file or directory tree in the WIM image. */
2216 WIMLIB_UPDATE_OP_RENAME,
2219 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
2220 struct wimlib_add_command {
2221 /** Filesystem path to the file or directory tree to add. */
2222 wimlib_tchar *fs_source_path;
2224 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
2225 * specify the root directory of the WIM image. */
2226 wimlib_tchar *wim_target_path;
2228 /** Path to capture configuration file to use, or @c NULL for default.
2230 wimlib_tchar *config_file;
2232 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2236 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2237 struct wimlib_delete_command {
2239 /** Path, specified from the root of the WIM image, for the file or
2240 * directory tree within the WIM image to be deleted. */
2241 wimlib_tchar *wim_path;
2243 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
2247 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2248 struct wimlib_rename_command {
2250 /** Path, specified from the root of the WIM image, for the source file
2251 * or directory tree within the WIM image. */
2252 wimlib_tchar *wim_source_path;
2254 /** Path, specified from the root of the WIM image, for the destination
2255 * file or directory tree within the WIM image. */
2256 wimlib_tchar *wim_target_path;
2258 /** Reserved; set to 0. */
2262 /** Specification of an update to perform on a WIM image. */
2263 struct wimlib_update_command {
2265 enum wimlib_update_op op;
2268 struct wimlib_add_command add;
2269 struct wimlib_delete_command delete_; /* Underscore is for C++
2271 struct wimlib_rename_command rename;
2276 /** @addtogroup G_general
2280 * Possible values of the error code returned by many functions in wimlib.
2282 * See the documentation for each wimlib function to see specifically what error
2283 * codes can be returned by a given function, and what they mean.
2285 enum wimlib_error_code {
2286 WIMLIB_ERR_SUCCESS = 0,
2287 WIMLIB_ERR_ALREADY_LOCKED = 1,
2288 WIMLIB_ERR_DECOMPRESSION = 2,
2289 WIMLIB_ERR_FUSE = 6,
2290 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2291 WIMLIB_ERR_ICONV_NOT_AVAILABLE = 9,
2292 WIMLIB_ERR_IMAGE_COUNT = 10,
2293 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2294 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2295 WIMLIB_ERR_INTEGRITY = 13,
2296 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2297 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2298 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2299 WIMLIB_ERR_INVALID_HEADER = 17,
2300 WIMLIB_ERR_INVALID_IMAGE = 18,
2301 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2302 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2303 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2304 WIMLIB_ERR_INVALID_MULTIBYTE_STRING = 22,
2305 WIMLIB_ERR_INVALID_OVERLAY = 23,
2306 WIMLIB_ERR_INVALID_PARAM = 24,
2307 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2308 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2309 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2310 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2311 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2312 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2313 WIMLIB_ERR_IS_DIRECTORY = 32,
2314 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2315 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE = 34,
2316 WIMLIB_ERR_LINK = 35,
2317 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2318 WIMLIB_ERR_MKDIR = 37,
2319 WIMLIB_ERR_MQUEUE = 38,
2320 WIMLIB_ERR_NOMEM = 39,
2321 WIMLIB_ERR_NOTDIR = 40,
2322 WIMLIB_ERR_NOTEMPTY = 41,
2323 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2324 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2325 WIMLIB_ERR_NOT_PIPABLE = 44,
2326 WIMLIB_ERR_NO_FILENAME = 45,
2327 WIMLIB_ERR_NTFS_3G = 46,
2328 WIMLIB_ERR_OPEN = 47,
2329 WIMLIB_ERR_OPENDIR = 48,
2330 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2331 WIMLIB_ERR_READ = 50,
2332 WIMLIB_ERR_READLINK = 51,
2333 WIMLIB_ERR_RENAME = 52,
2334 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2335 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2336 WIMLIB_ERR_RESOURCE_ORDER = 56,
2337 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2338 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2339 WIMLIB_ERR_SET_SECURITY = 59,
2340 WIMLIB_ERR_SET_SHORT_NAME = 60,
2341 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2342 WIMLIB_ERR_SPLIT_INVALID = 62,
2343 WIMLIB_ERR_STAT = 63,
2344 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2345 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2346 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2347 WIMLIB_ERR_UNSUPPORTED = 68,
2348 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2349 WIMLIB_ERR_WIM_IS_READONLY = 71,
2350 WIMLIB_ERR_WRITE = 72,
2351 WIMLIB_ERR_XML = 73,
2352 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2353 WIMLIB_ERR_WIMBOOT = 75,
2354 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2355 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2356 WIMLIB_ERR_MKNOD = 78,
2357 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2358 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2359 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2363 /** Used to indicate no WIM image or an invalid WIM image. */
2364 #define WIMLIB_NO_IMAGE 0
2366 /** Used to specify all images in the WIM. */
2367 #define WIMLIB_ALL_IMAGES (-1)
2372 * @ingroup G_modifying_wims
2374 * Appends an empty image to a WIM file. This empty image will initially
2375 * contain no files or directories, although if written without further
2376 * modifications, a root directory will be created automatically for it. After
2377 * calling this function, you can use wimlib_update_image() to add files to the
2378 * new WIM image. This gives you slightly more control over making the new
2379 * image compared to calling wimlib_add_image() or
2380 * wimlib_add_image_multisource() directly.
2383 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2386 * Name to give the new image. If @c NULL or empty, the new image is given
2387 * no name. If nonempty, it must specify a name that does not already
2389 * @param new_idx_ret
2390 * If non-<code>NULL</code>, the index of the newly added image is returned
2393 * @return 0 on success; nonzero on failure. The possible error codes are:
2395 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2396 * There is already an image in @p wim named @p name.
2397 * @retval ::WIMLIB_ERR_NOMEM
2398 * Failed to allocate the memory needed to add the new image.
2399 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2400 * The WIM file is considered read-only because of any of the reasons
2401 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2405 wimlib_add_empty_image(WIMStruct *wim,
2406 const wimlib_tchar *name,
2410 * @ingroup G_modifying_wims
2412 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2414 * The directory tree or NTFS volume is scanned immediately to load the dentry
2415 * tree into memory, and file attributes and symbolic links are read. However,
2416 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2419 * See the manual page for the @b wimlib-imagex program for more information
2420 * about the "normal" capture mode versus the NTFS capture mode (entered by
2421 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2423 * Note that @b no changes are committed to the underlying WIM file (if
2424 * any) until wimlib_write() or wimlib_overwrite() is called.
2427 * Pointer to the ::WIMStruct to which to add the image.
2429 * A path to a directory or unmounted NTFS volume that will be captured as
2432 * Name to give the new image. If @c NULL or empty, the new image is given
2433 * no name. If nonempty, it must specify a name that does not already
2435 * @param config_file
2436 * Path to capture configuration file, or @c NULL. This file may specify,
2437 * among other things, which files to exclude from capture. See the man
2438 * page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2439 * details of the file format. If @c NULL, the default capture
2440 * configuration shall be used. Ordinarily, the default capture
2441 * configuration will result in no files being excluded from capture purely
2442 * based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2443 * ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2445 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2447 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2448 * discarded so that it appears to be in the same state as when this function
2451 * This function is implemented by calling wimlib_add_empty_image(), then
2452 * calling wimlib_update_image() with a single "add" command, so any error code
2453 * returned by wimlib_add_empty_image() may be returned, as well as any error
2454 * codes returned by wimlib_update_image() other than ones documented as only
2455 * being returned specifically by an update involving delete or rename commands.
2457 * If a progress function is registered with @p wim, it will receive the
2458 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2459 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2460 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2463 wimlib_add_image(WIMStruct *wim,
2464 const wimlib_tchar *source,
2465 const wimlib_tchar *name,
2466 const wimlib_tchar *config_file,
2470 * @ingroup G_modifying_wims
2472 * This function is equivalent to wimlib_add_image() except it allows for
2473 * multiple sources to be combined into a single WIM image. This is done by
2474 * specifying the @p sources and @p num_sources parameters instead of the @p
2475 * source parameter of wimlib_add_image(). The rest of the parameters are the
2476 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2477 * capture</b> for full details on how this mode works.
2479 * In addition to the error codes that wimlib_add_image() can return,
2480 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2481 * when trying to overlay a non-directory on a directory or when otherwise
2482 * trying to overlay multiple conflicting files to the same location in the WIM
2483 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2484 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2485 * was not exactly one capture source with the target being the root directory.
2486 * (In this respect, there is no advantage to using
2487 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2490 wimlib_add_image_multisource(WIMStruct *wim,
2491 const struct wimlib_capture_source *sources,
2493 const wimlib_tchar *name,
2494 const wimlib_tchar *config_file,
2498 * @ingroup G_modifying_wims
2500 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2501 * location @p wim_target_path within the specified @p image of the @p wim.
2503 * This just builds an appropriate ::wimlib_add_command and passes it to
2504 * wimlib_update_image().
2507 wimlib_add_tree(WIMStruct *wim, int image,
2508 const wimlib_tchar *fs_source_path,
2509 const wimlib_tchar *wim_target_path, int add_flags);
2512 * @ingroup G_creating_and_opening_wims
2514 * Creates a ::WIMStruct for a new WIM file.
2516 * This only creates an in-memory structure for a WIM that initially contains no
2517 * images. No on-disk file is created until wimlib_write() is called.
2520 * The type of compression to be used in the new WIM file, as one of the
2521 * ::wimlib_compression_type constants.
2523 * This choice is not necessarily final; if desired, it can still be
2524 * changed at any time before the WIM is written to disk, using
2525 * wimlib_set_output_compression_type(). In addition, if you wish to use a
2526 * non-default chunk size, you will need to call
2527 * wimlib_set_output_chunk_size().
2529 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2530 * written to the memory location pointed to by this parameter. The
2531 * ::WIMStruct must be freed using using wimlib_free() when finished with
2533 * @return 0 on success; nonzero on error.
2534 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2535 * @p ctype was not a supported compression type.
2536 * @retval ::WIMLIB_ERR_NOMEM
2537 * Failed to allocate needed memory.
2540 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2543 * @ingroup G_modifying_wims
2545 * Deletes an image, or all images, from a WIM file.
2547 * Note: no changes are committed to the underlying WIM file (if any) until
2548 * wimlib_write() or wimlib_overwrite() is called.
2551 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2554 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2557 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2558 * to be left unmodified only if @p image specified a single image. If instead
2559 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2560 * possible for some but not all of the images to have been deleted when a
2561 * failure status is returned.
2563 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2564 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2565 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2566 * The WIM file is considered read-only because of any of the reasons
2567 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2570 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2571 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2572 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2573 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2574 * different reasons) to read the metadata resource for an image that needed to
2578 wimlib_delete_image(WIMStruct *wim, int image);
2581 * @ingroup G_modifying_wims
2583 * Delete the @p path from the specified @p image of the @p wim.
2585 * This just builds an appropriate ::wimlib_delete_command and passes it to
2586 * wimlib_update_image().
2589 wimlib_delete_path(WIMStruct *wim, int image,
2590 const wimlib_tchar *path, int delete_flags);
2593 * @ingroup G_modifying_wims
2595 * Exports an image, or all the images, from a WIM file, into another WIM file.
2597 * The destination image is made to share the same dentry tree and security data
2598 * structure as the source image. This places some restrictions on additional
2599 * functions that may be called. For example, you may not call wimlib_free() on
2600 * @p src_wim before calling wimlib_write() or wimlib_overwrite() on @p dest_wim
2601 * because @p dest_wim will have references back to @p src_wim.
2603 * If this function fails, all changes to @p dest_wim are rolled back.
2605 * Please note that no changes are committed to the underlying WIM file of @p
2606 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2609 * The WIM from which to export the images, specified as a pointer to the
2610 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2611 * split WIM. In the case of a WIM file that is not standalone, this
2612 * ::WIMStruct must have had any needed external resources previously
2613 * referenced using wimlib_reference_resources() or
2614 * wimlib_reference_resource_files().
2616 * The image to export from @p src_wim, as either a 1-based image index to
2617 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2619 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2622 * For single-image exports, the name to give the exported image in @p
2623 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2624 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2625 * that case, the names are all taken from @p src_wim. This parameter is
2626 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2627 * @param dest_description
2628 * For single-image exports, the description to give the exported image in
2629 * the new WIM file. If left @c NULL, the description from @p src_wim is
2630 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2631 * NULL; in that case, the description are all taken from @p src_wim. This
2632 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2633 * @param export_flags
2634 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2636 * @return 0 on success; nonzero on error.
2637 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2638 * One or more of the names being given to an exported image was already in
2639 * use in the destination WIM.
2640 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2641 * @p src_image does not exist in @p src_wim and was not
2642 * ::WIMLIB_ALL_IMAGES.
2643 * @retval ::WIMLIB_ERR_INVALID_PARAM
2644 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2645 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2647 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2648 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2649 * example, one of them was a non-first part of a split WIM.
2650 * @retval ::WIMLIB_ERR_NOMEM
2651 * Failed to allocate needed memory.
2652 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2653 * A resource that needed to be exported could not be found in either the
2654 * source or destination WIMs. This error can occur if, for example, @p
2655 * src_wim is part of a split WIM but needed resources from the other split
2656 * WIM parts were not referenced with wimlib_reference_resources() or
2657 * wimlib_reference_resource_files() before the call to
2658 * wimlib_export_image().
2659 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2660 * @p dest_wim is considered read-only because of any of the reasons
2661 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2664 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2665 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2666 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2667 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2668 * different reasons) to read the metadata resource for an image in @p src_wim
2669 * that needed to be exported.
2672 wimlib_export_image(WIMStruct *src_wim, int src_image,
2673 WIMStruct *dest_wim,
2674 const wimlib_tchar *dest_name,
2675 const wimlib_tchar *dest_description,
2679 * @ingroup G_extracting_wims
2681 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2684 * The exact behavior of how wimlib extracts files from a WIM image is
2685 * controllable by the @p extract_flags parameter, but there also are
2686 * differences depending on the platform (UNIX-like vs Windows). See the manual
2687 * page for <b>wimlib-imagex apply</b> for more information, including about the
2688 * NTFS-3g extraction mode.
2691 * The WIM from which to extract the image(s), specified as a pointer to
2692 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2693 * of a split WIM. In the case of a WIM file that is not standalone, this
2694 * ::WIMStruct must have had any needed external resources previously
2695 * referenced using wimlib_reference_resources() or
2696 * wimlib_reference_resource_files().
2698 * The image to extract, specified as either the 1-based index of a single
2699 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2700 * to be extracted. However, ::WIMLIB_ALL_IMAGES cannot be used if
2701 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2703 * Directory to extract the WIM image(s) to; or, with
2704 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2705 * the unmounted NTFS volume to which to extract the image.
2706 * @param extract_flags
2707 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2709 * @return 0 on success; nonzero on error.
2710 * @retval ::WIMLIB_ERR_DECOMPRESSION
2711 * Failed to decompress data contained in the WIM.
2712 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2713 * The metadata for one of the images to extract was invalid.
2714 * @retval ::WIMLIB_ERR_INVALID_PARAM
2715 * The extraction flags were invalid; more details may be found in the
2716 * documentation for the specific extraction flags that were specified. Or
2717 * @p target was @c NULL or an empty string, or @p wim was @c NULL.
2718 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2719 * The SHA1 message digest of an extracted stream did not match the SHA1
2720 * message digest given in the WIM. In other words, the WIM file is
2721 * corrupted, so the data cannot be extracted in its original form.
2722 * @retval ::WIMLIB_ERR_LINK
2723 * Failed to create a symbolic link or a hard link.
2724 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2725 * The metadata resource for one of the images to extract was not found.
2726 * This can happen if @p wim represents a non-first part of a split WIM.
2727 * @retval ::WIMLIB_ERR_MKDIR
2728 * Failed create a directory.
2729 * @retval ::WIMLIB_ERR_NOMEM
2730 * Failed to allocate needed memory.
2731 * @retval ::WIMLIB_ERR_OPEN
2732 * Could not create a file, or failed to open an already-extracted file.
2733 * @retval ::WIMLIB_ERR_READ
2734 * Failed to read data from the WIM.
2735 * @retval ::WIMLIB_ERR_READLINK
2736 * Failed to determine the target of a symbolic link in the WIM.
2737 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2738 * Failed to fix the target of an absolute symbolic link (e.g. if the
2739 * target would have exceeded the maximum allowed length). (Only if
2740 * reparse data was supported by the extraction mode and
2741 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2743 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2744 * One of the files or directories that needed to be extracted referenced a
2745 * stream not present in the WIM's lookup table (or in any of the lookup
2746 * tables of the split WIM parts). This can happen if the WIM is not
2747 * standalone and the necessary resource WIMs, or split WIM parts, were not
2748 * referenced with wimlib_reference_resource_files().
2749 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2750 * Failed to set attributes on a file.
2751 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2752 * Failed to set reparse data on a file (only if reparse data was supported
2753 * by the extraction mode).
2754 * @retval ::WIMLIB_ERR_SET_SECURITY
2755 * Failed to set security descriptor on a file.
2756 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2757 * Failed to set the short name of a file.
2758 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2759 * Failed to set timestamps on a file.
2760 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2761 * Unexpected end-of-file occurred when reading data from the WIM.
2762 * @retval ::WIMLIB_ERR_UNSUPPORTED
2763 * A requested extraction flag, or the data or metadata that must be
2764 * extracted to support it, is unsupported in the build and configuration
2765 * of wimlib, or on the current platform or extraction mode or target
2766 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2767 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2768 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2769 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2770 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2771 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2772 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2773 * image contains one or more files with short names, but extracting short
2774 * names is not supported --- on Windows, this occurs if the target volume
2775 * does not support short names, while on non-Windows, this occurs if
2776 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2777 * @retval ::WIMLIB_ERR_WIMBOOT
2778 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2779 * there was a problem creating WIMBoot pointer files.
2780 * @retval ::WIMLIB_ERR_WRITE
2781 * Failed to write data to a file being extracted.
2783 * If a progress function is registered with @p wim, then as each image is
2784 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2785 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE messages, then zero
2786 * or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then zero or more
2787 * ::WIMLIB_PROGRESS_MSG_EXTRACT_METADATA messages, then
2788 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2791 wimlib_extract_image(WIMStruct *wim, int image,
2792 const wimlib_tchar *target, int extract_flags);
2795 * @ingroup G_extracting_wims
2797 * Extract one image from a pipe on which a pipable WIM is being sent.
2799 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE, and @ref
2800 * subsec_pipable_wims, for more information about pipable WIMs.
2802 * This function operates in a special way to read the WIM fully sequentially.
2803 * As a result, there is no ::WIMStruct is made visible to library users, and
2804 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2805 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2806 * seekable file, not a pipe.)
2809 * File descriptor, which may be a pipe, opened for reading and positioned
2810 * at the start of the pipable WIM.
2811 * @param image_num_or_name
2812 * String that specifies the 1-based index or name of the image to extract.
2813 * It is translated to an image index using the same rules that
2814 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2815 * only a single image (not all images) can be specified. Alternatively,
2816 * specify @p NULL here to use the first image in the WIM if it contains
2817 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2819 * Same as the corresponding parameter to wimlib_extract_image().
2820 * @param extract_flags
2821 * Same as the corresponding parameter to wimlib_extract_image().
2823 * @return 0 on success; nonzero on error. The possible error codes include
2824 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2827 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2828 * Data read from the pipable WIM was invalid.
2829 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2830 * The WIM being piped over @p pipe_fd is a normal WIM, not a pipable WIM.
2833 wimlib_extract_image_from_pipe(int pipe_fd,
2834 const wimlib_tchar *image_num_or_name,
2835 const wimlib_tchar *target, int extract_flags);
2838 * @ingroup G_extracting_wims
2840 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2841 * function. The progress function will be used while extracting the WIM image
2842 * and will receive the normal extraction progress messages, such as
2843 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2844 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2847 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2848 const wimlib_tchar *image_num_or_name,
2849 const wimlib_tchar *target,
2851 wimlib_progress_func_t progfunc,
2855 * @ingroup G_extracting_wims
2857 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
2858 * image are specified in the ASCII, UTF-8, or UTF-16LE text file named by @p
2859 * path_list_file which itself contains the list of paths to use, one per line.
2860 * Leading and trailing whitespace is ignored. Empty lines and lines beginning
2861 * with the ';' or '#' characters are ignored. No quotes are needed, as paths
2862 * are otherwise delimited by the newline character. However, quotes will be
2863 * stripped if present.
2865 * The error codes are the same as those returned by wimlib_extract_paths(),
2866 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2867 * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2868 * ::WIMLIB_ERR_READ).
2871 wimlib_extract_pathlist(WIMStruct *wim, int image,
2872 const wimlib_tchar *target,
2873 const wimlib_tchar *path_list_file,
2877 * @ingroup G_extracting_wims
2879 * Extract zero or more paths (files or directory trees) from the specified WIM
2882 * By default, each path will be extracted to a corresponding subdirectory of
2883 * the target based on its location in the WIM image. For example, if one of
2884 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2885 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
2886 * can be changed by providing the flag
2887 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2888 * or directory tree to be placed directly in the target directory --- so the
2889 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2891 * Symbolic links will not be dereferenced when paths in the WIM image are
2895 * WIM from which to extract the paths, specified as a pointer to the
2896 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2897 * split WIM. In the case of a WIM file that is not standalone, this
2898 * ::WIMStruct must have had any needed external resources previously
2899 * referenced using wimlib_reference_resources() or
2900 * wimlib_reference_resource_files().
2902 * 1-based index of the WIM image from which to extract the paths.
2904 * Array of paths to extract. Each element must be the absolute path to a
2905 * file or directory within the WIM image. Separators may be either
2906 * forwards or backwards slashes, and leading path separators are optional.
2907 * The paths will be interpreted either case-sensitively (UNIX default) or
2908 * case-insensitively (Windows default); however, the behavior can be
2909 * configured explicitly at library initialization time by passing an
2910 * appropriate flag to wimlib_global_init().
2912 * By default, the characters @c * and @c ? are interpreted literally.
2913 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2916 * By default, if any paths to extract do not exist, the error code
2917 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
2918 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2920 * Number of paths specified in @p paths.
2922 * Directory to which to extract the paths; or with
2923 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2924 * unmounted NTFS volume to which to extract the paths. Unlike the @p
2925 * paths being extracted, the @p target must be native path. On UNIX-like
2926 * systems it may not contain backslashes, for example.
2927 * @param extract_flags
2928 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2930 * @return 0 on success; nonzero on error. Most of the error codes are the same
2931 * as those returned by wimlib_extract_image(). Below, some of the error codes
2932 * returned in situations specific to path-mode extraction are documented:
2934 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2935 * One of the paths to extract did not exist in the WIM image. This error
2936 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2937 * specified in @p extract_flags, or if both
2938 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2939 * were specified in @p extract_flags.
2940 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2941 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2942 * one of the paths to extract did not name a regular file.
2944 * If a progress function is registered with @p wim, it will receive
2945 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. Note that because the extraction code
2946 * is stream-based and not file-based, there is no way to get information about
2947 * which path is currently being extracted, but based on byte count you can
2948 * still calculate an approximate percentage complete for the extraction overall
2949 * which may be all you really need anyway.
2952 wimlib_extract_paths(WIMStruct *wim,
2954 const wimlib_tchar *target,
2955 const wimlib_tchar * const *paths,
2960 * @ingroup G_wim_information
2962 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2963 * includes a string of XML that describes the images contained in the WIM.
2965 * See wimlib_get_xml_data() to read the XML data into memory instead.
2968 * Pointer to the ::WIMStruct to query. This need not represent a
2969 * standalone WIM (e.g. it could represent part of a split WIM).
2971 * @c stdout, or a FILE* opened for writing, to extract the data to.
2973 * @return 0 on success; nonzero on error.
2974 * @retval ::WIMLIB_ERR_INVALID_PARAM
2975 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2976 * @retval ::WIMLIB_ERR_NOMEM
2977 * Failed to allocate needed memory.
2978 * @retval ::WIMLIB_ERR_READ
2979 * Error reading the XML data from the WIM file.
2980 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2981 * Error reading the XML data from the WIM file.
2982 * @retval ::WIMLIB_ERR_WRITE
2983 * Failed to completely write the XML data to @p fp.
2986 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2989 * @ingroup G_general
2991 * Frees all memory allocated for a WIMStruct and closes all files associated
2995 * Pointer to the ::WIMStruct to free.
2997 * @return This function has no return value.
3000 wimlib_free(WIMStruct *wim);
3003 * @ingroup G_general
3005 * Converts a ::wimlib_compression_type value into a string.
3008 * The ::wimlib_compression_type value to convert.
3011 * A statically allocated string naming the compression algorithm,
3012 * such as "None", "LZX", "XPRESS", or "Invalid".
3014 extern const wimlib_tchar *
3015 wimlib_get_compression_type_string(int ctype);
3018 * @ingroup G_general
3020 * Converts an error code into a string describing it.
3023 * The error code returned by one of wimlib's functions.
3026 * Pointer to a statically allocated string describing the error code. If
3027 * the error code is for some reason not recognized by the library, the
3028 * string will be "Unknown error".
3030 extern const wimlib_tchar *
3031 wimlib_get_error_string(enum wimlib_error_code code);
3034 * @ingroup G_wim_information
3036 * Returns the description of the specified image.
3039 * Pointer to the ::WIMStruct to query. This need not represent a
3040 * standalone WIM (e.g. it could represent part of a split WIM).
3042 * The number of the image, numbered starting at 1.
3045 * The description of the image, or @c NULL if there is no such image, or
3046 * @c NULL if the specified image has no description. The description
3047 * string is in library-internal memory and may not be modified or freed;
3048 * in addition, the string will become invalid if the description of the
3049 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
3051 extern const wimlib_tchar *
3052 wimlib_get_image_description(const WIMStruct *wim, int image);
3055 * @ingroup G_wim_information
3057 * Returns the name of the specified image.
3060 * Pointer to the ::WIMStruct to query. This need not represent a
3061 * standalone WIM (e.g. it could represent part of a split WIM).
3063 * The number of the image, numbered starting at 1.
3066 * The name of the image, or @c NULL if there is no such image, or an empty
3067 * string if the image is unnamed. The name string is in
3068 * library-internal memory and may not be modified or freed; in addition,
3069 * the string will become invalid if the name of the image is changed, the
3070 * image is deleted, or the ::WIMStruct is destroyed.
3072 extern const wimlib_tchar *
3073 wimlib_get_image_name(const WIMStruct *wim, int image);
3076 * @ingroup G_general
3078 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
3079 * the major version, the next 10 bits contain the minor version, and the low 10
3080 * bits contain the patch version.
3082 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
3083 * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
3084 * corresponding header file.
3087 wimlib_get_version(void);
3090 * @ingroup G_wim_information
3092 * Get basic information about a WIM file.
3095 * Pointer to the ::WIMStruct to query. This need not represent a
3096 * standalone WIM (e.g. it could represent part of a split WIM).
3098 * A ::wimlib_wim_info structure that will be filled in with information
3099 * about the WIM file.
3104 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
3107 * @ingroup G_wim_information
3109 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
3110 * includes a string of XML that describes the images contained in the WIM.
3112 * See wimlib_extract_xml_data() to extract the XML data to a file stream
3116 * Pointer to the ::WIMStruct to query. This need not represent a
3117 * standalone WIM (e.g. it could represent part of a split WIM).
3119 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
3120 * XML data is written to this location.
3121 * @param bufsize_ret
3122 * The size of the XML data in bytes is written to this location.
3124 * @return 0 on success; nonzero on error.
3125 * @retval ::WIMLIB_ERR_INVALID_PARAM
3126 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
3127 * @p buf_ret or @p bufsize_ret was @c NULL.
3128 * @retval ::WIMLIB_ERR_NOMEM
3129 * @retval ::WIMLIB_ERR_READ
3130 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3131 * Failed to read the XML data from the WIM.
3134 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
3137 * @ingroup G_general
3139 * Initialization function for wimlib. Call before using any other wimlib
3140 * function except wimlib_set_print_errors(). If not done manually, this
3141 * function will be called automatically with @p init_flags set to
3142 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
3143 * after it has already successfully run.
3146 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
3148 * @return 0 on success; nonzero on failure. Currently, only the following
3149 * error code is defined:
3151 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
3152 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
3153 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
3154 * init_flags, but the corresponding privileges could not be acquired.
3157 wimlib_global_init(int init_flags);
3160 * @ingroup G_general
3162 * Cleanup function for wimlib. You are not required to call this function, but
3163 * it will release any global resources allocated by the library.
3166 wimlib_global_cleanup(void);
3169 * @ingroup G_wim_information
3171 * Determines if an image name is already used by some image in the WIM.
3174 * Pointer to the ::WIMStruct to query. This need not represent a
3175 * standalone WIM (e.g. it could represent part of a split WIM).
3177 * The name to check.
3180 * @c true if there is already an image in @p wim named @p name; @c false
3181 * if there is no image named @p name in @p wim. If @p name is @c NULL or
3182 * the empty string, @c false is returned.
3185 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
3188 * @ingroup G_wim_information
3190 * Iterate through a file or directory tree in the WIM image. By specifying
3191 * appropriate flags and a callback function, you can get the attributes of a
3192 * file in the WIM, get a directory listing, or even get a listing of the entire
3196 * The WIM containing the image(s) over which to iterate, specified as a
3197 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
3198 * or part 1 of a split WIM. In the case of a WIM file that is not
3199 * standalone, this ::WIMStruct should have had any needed external
3200 * resources previously referenced using wimlib_reference_resources() or
3201 * wimlib_reference_resource_files(). If not, see
3202 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
3203 * the behavior when resources are missing.
3206 * The 1-based number of the image in @p wim that contains the files or
3207 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
3208 * iteration on all images in the WIM.
3211 * Path in the WIM image at which to do the iteration.
3214 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
3217 * A callback function that will receive each directory entry.
3220 * An extra parameter that will always be passed to the callback function
3223 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
3224 * first nonzero value that was returned from @p cb. However, additional error
3225 * codes may be returned, including the following:
3227 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3228 * @p path did not exist in the WIM image.
3229 * @retval ::WIMLIB_ERR_NOMEM
3230 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
3232 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3233 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3234 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3235 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3236 * different reasons) to read the metadata resource for an image over which
3237 * iteration needed to be done.
3240 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3242 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3245 * @ingroup G_wim_information
3247 * Iterate through the lookup table of a WIM file. This can be used to directly
3248 * get a listing of the unique resources contained in a WIM file over all
3249 * images. Both file resources and metadata resources are included. However,
3250 * only resources actually included in the file represented by @a wim, plus
3251 * explicitly referenced external resources (via wimlib_reference_resources() or
3252 * wimlib_reference_resource_files()) are included in the iteration. For
3253 * example, if @p wim represents just one part of a split WIM, then only
3254 * resources in that part will be included, unless other resources were
3255 * explicitly referenced.
3258 * Pointer to the ::WIMStruct to query. This need not represent a
3259 * standalone WIM (e.g. it could represent part of a split WIM).
3262 * Reserved; set to 0.
3265 * A callback function that will receive each resource.
3268 * An extra parameter that will always be passed to the callback function
3271 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3272 * that was returned from @p cb.
3275 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3276 wimlib_iterate_lookup_table_callback_t cb,
3280 * @ingroup G_nonstandalone_wims
3282 * Joins a split WIM into a stand-alone one-part WIM.
3285 * An array of strings that gives the filenames of all parts of the split
3286 * WIM. No specific order is required, but all parts must be included with
3289 * Number of filenames in @p swms.
3290 * @param swm_open_flags
3291 * Open flags for the split WIM parts (e.g.
3292 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3293 * @param wim_write_flags
3294 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3295 * be used to write the joined WIM.
3296 * @param output_path
3297 * The path to write the joined WIM file to.
3299 * @return 0 on success; nonzero on error. This function may return most error
3300 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
3301 * as the following error code:
3303 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3304 * The split WIMs do not form a valid WIM because they do not include all
3305 * the parts of the original WIM, there are duplicate parts, or not all the
3306 * parts have the same GUID and compression type.
3308 * Note: wimlib is generalized enough that this function is not actually needed
3309 * to join a split WIM; instead, you could open the first part of the split WIM,
3310 * then reference the other parts with wimlib_reference_resource_files(), then
3311 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3312 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3316 wimlib_join(const wimlib_tchar * const *swms,
3318 const wimlib_tchar *output_path,
3320 int wim_write_flags);
3323 * @ingroup G_nonstandalone_wims
3325 * Same as wimlib_join(), but allows specifying a progress function. The
3326 * progress function will receive the write progress messages, such as
3327 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3328 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3329 * swm_open_flags, the progress function will receive a series of
3330 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3334 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3336 const wimlib_tchar *output_path,
3338 int wim_write_flags,
3339 wimlib_progress_func_t progfunc,
3344 * @ingroup G_mounting_wim_images
3346 * Mounts an image from a WIM file on a directory read-only or read-write.
3349 * Pointer to the ::WIMStruct containing the image to be mounted.
3351 * The 1-based index of the image to mount.
3353 * The path to an existing empty directory on which to mount the WIM image.
3354 * @param mount_flags
3355 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3356 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3358 * @param staging_dir
3359 * If non-NULL, the name of a directory in which a temporary directory for
3360 * storing modified or added files will be created. Ignored if
3361 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3362 * left @c NULL, the staging directory is created in the same directory as
3363 * the WIM file that @p wim was originally read from. The staging
3364 * directory is automatically deleted when the image is unmounted.
3366 * @return 0 on success; nonzero on error. The possible error codes include:
3368 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3369 * An image from the WIM file is already mounted read-write, or another
3370 * process is currently appending data to the WIM file.
3371 * @retval ::WIMLIB_ERR_FUSE
3372 * A non-zero status code was returned by @c fuse_main().
3373 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3374 * @p image does not specify an existing, single image in @p wim.
3375 * @retval ::WIMLIB_ERR_INVALID_PARAM
3376 * @p wim was @c NULL; or @p dir was NULL or an empty string; or an
3377 * unrecognized flag was specified in @p mount_flags; or the WIM image has
3378 * already been modified in memory (e.g. by wimlib_update_image()).
3379 * @retval ::WIMLIB_ERR_MKDIR
3380 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3381 * staging directory could not be created.
3382 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3383 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3384 * WIM file is considered read-only because of any of the reasons mentioned
3385 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3386 * @retval ::WIMLIB_ERR_UNSUPPORTED
3387 * Mounting is not supported in this build of the library.
3389 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3390 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3391 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3392 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3393 * different reasons) to read the metadata resource for the image to mount.
3395 * The ability to mount WIM image is implemented using FUSE (Filesystem in
3396 * UserSpacE). Depending on how FUSE is set up on your system, this function
3397 * may work as normal users in addition to the root user.
3399 * Mounting WIM images is not supported if wimlib was configured
3400 * <code>--without-fuse</code>. This includes Windows builds of wimlib;
3401 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3403 * Calling this function daemonizes the process, unless
3404 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3406 * It is safe to mount multiple images from the same underlying WIM file
3407 * read-only at the same time, but only if different ::WIMStruct's are used. It
3408 * is @b not safe to mount multiple images from the same WIM file read-write at
3411 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3412 * different process.
3415 wimlib_mount_image(WIMStruct *wim,
3417 const wimlib_tchar *dir,
3419 const wimlib_tchar *staging_dir);
3422 * @ingroup G_creating_and_opening_wims
3424 * Opens a WIM file and creates a ::WIMStruct for it.
3427 * The path to the WIM file to open.
3430 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3433 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3434 * is written to the memory location pointed to by this parameter. The
3435 * ::WIMStruct must be freed using using wimlib_free() when finished with
3438 * @return 0 on success; nonzero on error.
3439 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3440 * The number of metadata resources found in the WIM did not match the
3441 * image count specified in the WIM header, or the number of <IMAGE>
3442 * elements in the XML data of the WIM did not match the image count
3443 * specified in the WIM header.
3444 * @retval ::WIMLIB_ERR_INTEGRITY
3445 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3446 * the WIM contained an integrity table, but the SHA1 message digest for a
3447 * chunk of the WIM did not match the corresponding value in the integrity
3449 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3450 * The library did not recognize the compression chunk size of the WIM as
3451 * valid for its compression type.
3452 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3453 * The library did not recognize the compression type of the WIM.
3454 * @retval ::WIMLIB_ERR_INVALID_HEADER
3455 * The header of the WIM was otherwise invalid.
3456 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3457 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3458 * the WIM contained an integrity table, but the integrity table was
3460 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3461 * The lookup table of the WIM was invalid.
3462 * @retval ::WIMLIB_ERR_INVALID_PARAM
3463 * @p wim_ret was @c NULL; or, @p wim_file was not a nonempty string.
3464 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3465 * The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3466 * specified in @p open_flags.
3467 * @retval ::WIMLIB_ERR_NOMEM
3468 * Failed to allocated needed memory.
3469 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3470 * The file did not begin with the magic characters that identify a WIM
3472 * @retval ::WIMLIB_ERR_OPEN
3473 * Failed to open the WIM file for reading. Some possible reasons: the WIM
3474 * file does not exist, or the calling process does not have permission to
3476 * @retval ::WIMLIB_ERR_READ
3477 * Failed to read data from the WIM file.
3478 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3479 * Unexpected end-of-file while reading data from the WIM file.
3480 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3481 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3482 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3483 * The WIM cannot be opened because it contains encrypted segments. (It
3484 * may be a Windows 8 "ESD" file.)
3485 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3486 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3487 * considered read-only because of any of the reasons mentioned in the
3488 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3489 * @retval ::WIMLIB_ERR_XML
3490 * The XML data of the WIM was invalid.
3493 wimlib_open_wim(const wimlib_tchar *wim_file,
3495 WIMStruct **wim_ret);
3498 * @ingroup G_creating_and_opening_wims
3500 * Same as wimlib_open_wim(), but allows specifying a progress function and
3501 * progress context. If successful, the progress function will be registered in
3502 * the newly open ::WIMStruct, as if by an automatic call to
3503 * wimlib_register_progress_function(). In addition, if
3504 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, the
3505 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3506 * messages while checking the WIM file's integrity.
3509 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3511 WIMStruct **wim_ret,
3512 wimlib_progress_func_t progfunc,
3516 * @ingroup G_writing_and_overwriting_wims
3518 * Overwrites the file that the WIM was originally read from, with changes made.
3519 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3520 * rather than wimlib_create_new_wim().
3522 * There are two ways that a WIM may be overwritten. The first is to do a full
3523 * rebuild. In this mode, the new WIM is written to a temporary file and then
3524 * renamed to the original file after it is has been completely written. The
3525 * temporary file is made in the same directory as the original WIM file. A
3526 * full rebuild may take a while, but it will save space by producing a WIM with
3529 * The second way to overwrite a WIM is by appending to the end of it and
3530 * overwriting the header. This can be much faster than a full rebuild, but the
3531 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3532 * begins with writing any new file resources *after* everything in the old WIM,
3533 * even though this will leave a hole where the old lookup table, XML data, and
3534 * integrity were. This is done so that the WIM remains valid even if the
3535 * operation is aborted mid-write. The WIM header is only overwritten at the
3536 * very last moment, and up until that point the WIM will be seen as the old
3539 * By default, wimlib_overwrite() does the append-style overwrite described
3540 * above, unless resources in the WIM are arranged in an unusual way or if
3541 * images have been deleted from the WIM. Use the flag
3542 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3543 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3544 * images have been deleted from the WIM.
3546 * If this function completes successfully, no more functions should be called
3547 * on @p wim other than wimlib_free(). If you need to continue using the WIM,
3548 * you must use wimlib_open_wim() to read it anew.
3551 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3552 * been in-memory changes made to it, which are then reflected in the
3554 * @param write_flags
3555 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3556 * @param num_threads
3557 * Number of threads to use for compression, or 0 for the default. (See
3560 * @return 0 on success; nonzero on error. This function may return most error
3561 * codes returned by wimlib_write() as well as the following error codes:
3563 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3564 * The WIM was going to be modified in-place (with no temporary file), but
3565 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3566 * because another thread or process has mounted an image from the WIM
3567 * read-write or is currently modifying the WIM in-place.
3568 * @retval ::WIMLIB_ERR_NO_FILENAME
3569 * @p wim corresponds to a ::WIMStruct created with wimlib_create_new_wim()
3570 * rather than a WIM read with wimlib_open_wim().
3571 * @retval ::WIMLIB_ERR_RENAME
3572 * The temporary file that the WIM was written to could not be renamed to
3573 * the original filename of @p wim.
3574 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3575 * The WIM file is considered read-only because of any of the reasons
3576 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3579 * If a progress function is registered with @p wim, it will receive the
3580 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3581 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3582 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3585 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3588 * @ingroup G_wim_information
3590 * Prints information about one image, or all images, contained in a WIM.
3593 * Pointer to the ::WIMStruct to query. This need not represent a
3594 * standalone WIM (e.g. it could represent part of a split WIM).
3596 * The image about which to print information. Can be the number of an
3597 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3600 * @return This function has no return value. No error checking is done when
3601 * printing the information. If @p image is invalid, an error message is
3605 wimlib_print_available_images(const WIMStruct *wim, int image);
3608 * @ingroup G_wim_information
3610 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3611 * in a way that can be accessed programatically.
3614 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3617 * @ingroup G_nonstandalone_wims
3619 * Reference resources from other WIM files or split WIM parts. This function
3620 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3621 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3622 * from other files, before calling a function such as wimlib_extract_image()
3623 * that requires the resources to be present.
3626 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3627 * necessarily "standalone". In the case of split WIMs, this should be the
3628 * first part, since only the first part contains the metadata resources.
3629 * In the case of delta WIMs, this should be the delta WIM rather than the
3630 * WIM on which it is based.
3631 * @param resource_wimfiles_or_globs
3632 * Array of paths to WIM files and/or split WIM parts to reference.
3633 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3634 * ref_flags, these are treated as globs rather than literal paths. That
3635 * is, using this function you can specify zero or more globs, each of
3636 * which expands to one or more literal paths.
3638 * Number of entries in @p resource_wimfiles_or_globs.
3640 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3641 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3643 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3644 * pass to internal calls to wimlib_open_wim() on the reference files.
3646 * @return 0 on success; nonzero on error.
3648 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3649 * One of the specified globs did not match any paths (only with both
3650 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3651 * specified in @p ref_flags).
3652 * @retval ::WIMLIB_ERR_NOMEM
3653 * Failed to allocate memory.
3654 * @retval ::WIMLIB_ERR_READ
3655 * I/O or permissions error while processing a file glob.
3657 * This function can additionally return most values that can be returned by
3658 * wimlib_open_wim().
3661 wimlib_reference_resource_files(WIMStruct *wim,
3662 const wimlib_tchar * const *resource_wimfiles_or_globs,
3668 * @ingroup G_nonstandalone_wims
3670 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3671 * where the caller must open the ::WIMStruct for each referenced file itself.
3674 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3675 * necessarily "standalone". In the case of split WIMs, this should be the
3676 * first part, since only the first part contains the metadata resources.
3677 * @param resource_wims
3678 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3679 * split WIM parts to reference.
3680 * @param num_resource_wims
3681 * Number of entries in @p resource_wims.
3683 * Currently ignored (set to 0).
3685 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3686 * @p resource_wims are referenced internally by @p wim and must not be freed
3687 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3688 * been freed with wimlib_free(), or immediately before freeing @p wim with
3691 * @retval ::WIMLIB_ERR_INVALID_PARAM
3692 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3693 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3694 * @retval ::WIMLIB_ERR_NOMEM
3695 * Failed to allocate memory.
3698 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3699 unsigned num_resource_wims, int ref_flags);
3702 * @ingroup G_modifying_wims
3704 * Declares that a newly added image is mostly the same as a prior image, but
3705 * captured at a later point in time, possibly with some modifications in the
3706 * intervening time. This is designed to be used in incremental backups of the
3707 * same filesystem or directory tree.
3709 * This function compares the metadata of the directory tree of the newly added
3710 * image against that of the old image. Any files that are present in both the
3711 * newly added image and the old image and have timestamps that indicate they
3712 * haven't been modified are deemed not to have been modified and have their
3713 * SHA1 message digest copied from the old image. Because of this and because
3714 * WIM uses single-instance streams, such files need not be read from the
3715 * filesystem when the WIM is being written or overwritten. Note that these
3716 * unchanged files will still be "archived" and will be logically present in the
3717 * new image; the optimization is that they don't need to actually be read from
3718 * the filesystem because the WIM already contains them.
3720 * This function is provided to optimize incremental backups. The resulting WIM
3721 * file will still be the same regardless of whether this function is called.
3722 * (This is, however, assuming that timestamps have not been manipulated or
3723 * unmaintained as to trick this function into thinking a file has not been
3724 * modified when really it has. To partly guard against such cases, other
3725 * metadata such as file sizes will be checked as well.)
3727 * This function must be called after adding the new image (e.g. with
3728 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3729 * wimlib_overwrite()).
3732 * Pointer to the ::WIMStruct for a WIM.
3734 * 1-based index in the WIM of the newly added image. This image can have
3735 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3736 * wimlib_add_empty_image() followed by wimlib_update_image().
3737 * @param template_wim
3738 * The ::WIMStruct for the WIM containing the template image. This can be
3739 * the same as @p wim, or it can be a different ::WIMStruct.
3740 * @param template_image
3741 * 1-based index in the WIM of a template image that reflects a prior state
3742 * of the directory tree being captured.
3744 * Reserved; must be 0.
3746 * @return 0 on success; nonzero on error.
3748 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3749 * @p new_image and/or @p template_image were not a valid image indices in
3751 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3752 * The specified ::WIMStruct did not actually contain the metadata resource
3753 * for the new or template image; for example, it was a non-first part of a
3755 * @retval ::WIMLIB_ERR_NOMEM
3756 * Failed to allocate needed memory.
3757 * @retval ::WIMLIB_ERR_INVALID_PARAM
3758 * @p new_image was equal to @p template_image, or @p new_image specified
3759 * an image that had not been modified since opening the WIM.
3761 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3762 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3763 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3764 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3765 * different reasons) to read the metadata resource for the template image.
3768 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3769 WIMStruct *template_wim, int template_image,
3773 * @ingroup G_general
3775 * Registers a progress function with a ::WIMStruct.
3778 * The ::WIMStruct for which to register the progress function.
3780 * Pointer to the progress function to register. If the WIM already has a
3781 * progress function registered, it will be replaced with this one. If @p
3782 * NULL, the current progress function (if any) will be unregistered.
3784 * The value which will be passed as the third argument to calls to @p
3788 wimlib_register_progress_function(WIMStruct *wim,
3789 wimlib_progress_func_t progfunc,
3793 * @ingroup G_modifying_wims
3795 * Rename the @p source_path to the @p dest_path in the specified @p image of
3798 * This just builds an appropriate ::wimlib_rename_command and passes it to
3799 * wimlib_update_image().
3802 wimlib_rename_path(WIMStruct *wim, int image,
3803 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3806 * @ingroup G_wim_information
3808 * Translates a string specifying the name or number of an image in the WIM into
3809 * the number of the image. The images are numbered starting at 1.
3812 * Pointer to the ::WIMStruct for a WIM.
3813 * @param image_name_or_num
3814 * A string specifying the name or number of an image in the WIM. If it
3815 * parses to a positive integer, this integer is taken to specify the
3816 * number of the image, indexed starting at 1. Otherwise, it is taken to
3817 * be the name of an image, as given in the XML data for the WIM file. It
3818 * also may be the keyword "all" or the string "*", both of which will
3819 * resolve to ::WIMLIB_ALL_IMAGES.
3821 * There is no way to search for an image actually named "all", "*", or an
3822 * integer number, or an image that has no name. However, you can use
3823 * wimlib_get_image_name() to get the name of any image.
3826 * If the string resolved to a single existing image, the number of that
3827 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3828 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3829 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3830 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3831 * images in @p wim has no name.
3834 wimlib_resolve_image(WIMStruct *wim,
3835 const wimlib_tchar *image_name_or_num);
3838 * @ingroup G_general
3840 * Sets the file to which the library will print error and warning messages.
3842 * This version of the function takes a C library <c>FILE *</c> opened for
3843 * writing (or appending). Use wimlib_set_error_file_by_name() to specify the
3844 * file by name instead.
3846 * This also enables error messages, as if by a call to
3847 * wimlib_set_print_errors(true).
3849 * @return 0 on success; nonzero on error.
3850 * @retval ::WIMLIB_ERR_UNSUPPORTED
3851 * wimlib was compiled using the <c>--without-error-messages</c> option.
3854 wimlib_set_error_file(FILE *fp);
3857 * @ingroup G_general
3859 * Sets the path to the file to which the library will print error and warning
3860 * messages. The library will open this file for appending.
3862 * This also enables error messages, as if by a call to
3863 * wimlib_set_print_errors(true).
3865 * @return 0 on success; nonzero on error.
3866 * @retval ::WIMLIB_ERR_OPEN
3867 * The file named by @p path could not be opened for appending.
3868 * @retval ::WIMLIB_ERR_UNSUPPORTED
3869 * wimlib was compiled using the <c>--without-error-messages</c> option.
3872 wimlib_set_error_file_by_name(const wimlib_tchar *path);
3875 * @ingroup G_modifying_wims
3877 * Changes the description of an image in the WIM.
3880 * Pointer to the ::WIMStruct for a WIM.
3882 * The number of the image for which to change the description.
3883 * @param description
3884 * The new description to give the image. It may be @c NULL, which
3885 * indicates that the image is to be given no description.
3887 * @return 0 on success; nonzero on error.
3888 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3889 * @p image does not specify a single existing image in @p wim.
3890 * @retval ::WIMLIB_ERR_NOMEM
3891 * Failed to allocate the memory needed to duplicate the @p description
3893 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3894 * @p wim is considered read-only because of any of the reasons mentioned
3895 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3898 wimlib_set_image_descripton(WIMStruct *wim, int image,
3899 const wimlib_tchar *description);
3902 * @ingroup G_writing_and_overwriting_wims
3904 * Set the compression chunk size of a WIM to use in subsequent calls to
3905 * wimlib_write() or wimlib_overwrite().
3907 * A larger compression chunk size will likely result in a better compression
3908 * ratio, but the speed of random access to the WIM will be reduced.
3909 * Furthermore, the effect of a larger compression chunk size is limited by the
3910 * size of each stream ("file") being compressed.
3913 * ::WIMStruct for a WIM.
3915 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3916 * on the compression format. See the documentation for each
3917 * ::wimlib_compression_type constant for more information. As a special
3918 * case, if @p chunk_size is specified as 0, the chunk size is set to the
3919 * default for the currently selected output compression type.
3921 * @return 0 on success; nonzero on error.
3923 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3924 * @p chunk_size is not a supported chunk size for the currently selected
3925 * output compression type.
3928 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3931 * @ingroup G_writing_and_overwriting_wims
3933 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3934 * packed streams (solid blocks).
3937 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3940 * @ingroup G_writing_and_overwriting_wims
3942 * Set the compression type of a WIM to use in subsequent calls to
3943 * wimlib_write() or wimlib_overwrite().
3946 * ::WIMStruct for a WIM.
3948 * The compression type to set (one of ::wimlib_compression_type). If this
3949 * compression type is incompatible with the current output chunk size
3950 * (either the default or as set with wimlib_set_output_chunk_size()), the
3951 * output chunk size is reset to the default for that compression type.
3953 * @return 0 on success; nonzero on error.
3955 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3956 * @p ctype did not specify a valid compression type.
3959 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3962 * @ingroup G_writing_and_overwriting_wims
3964 * Similar to wimlib_set_output_compression_type(), but set the compression type
3965 * for writing packed streams (solid blocks).
3968 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3971 * @ingroup G_modifying_wims
3973 * Set basic information about a WIM.
3976 * Pointer to the ::WIMStruct for a WIM.
3978 * A struct ::wimlib_wim_info that contains the information to set. Only
3979 * the information explicitly specified in the @p which flags need be
3982 * Flags that specify which information to set. This is a bitwise OR of
3983 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3984 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3986 * @return 0 on success; nonzero on failure.
3987 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3988 * The WIM file is considered read-only because of any of the reasons
3989 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3990 * flag. However, as a special case, if you are using
3991 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3992 * function will not fail due to the readonly flag being previously set.
3993 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3994 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3995 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3999 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
4003 * @ingroup G_modifying_wims
4005 * Changes what is written in the \<FLAGS\> element in the WIM XML data
4006 * (something like "Core" or "Ultimate")
4009 * Pointer to the ::WIMStruct for a WIM.
4011 * The number of the image for which to change the description.
4013 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
4014 * indicates that the image is to be given no \<FLAGS\> element.
4016 * @return 0 on success; nonzero on error.
4017 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4018 * @p image does not specify a single existing image in @p wim.
4019 * @retval ::WIMLIB_ERR_NOMEM
4020 * Failed to allocate the memory needed to duplicate the @p flags string.
4021 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4022 * @p wim is considered read-only because of any of the reasons mentioned
4023 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
4026 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
4029 * @ingroup G_modifying_wims
4031 * Changes the name of an image in the WIM.
4034 * Pointer to the ::WIMStruct for a WIM.
4036 * The number of the image for which to change the name.
4038 * New name to give the new image. If @c NULL or empty, the new image is
4039 * given no name. If nonempty, it must specify a name that does not
4040 * already exist in @p wim.
4042 * @return 0 on success; nonzero on error.
4043 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
4044 * There is already an image named @p name in @p wim.
4045 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4046 * @p image does not specify a single existing image in @p wim.
4047 * @retval ::WIMLIB_ERR_NOMEM
4048 * Failed to allocate the memory needed to duplicate the @p name string.
4049 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4050 * @p wim is considered read-only because of any of the reasons mentioned
4051 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
4054 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
4057 * @ingroup G_general
4059 * Set the functions that wimlib uses to allocate and free memory.
4061 * These settings are global and not per-WIM.
4063 * The default is to use the default @c malloc() and @c free() from the C
4066 * Please note that some external functions, such as those in @c libntfs-3g, may
4067 * use the standard memory allocation functions regardless of this setting.
4069 * @param malloc_func
4070 * A function equivalent to @c malloc() that wimlib will use to allocate
4071 * memory. If @c NULL, the allocator function is set back to the default
4072 * @c malloc() from the C library.
4074 * A function equivalent to @c free() that wimlib will use to free memory.
4075 * If @c NULL, the free function is set back to the default @c free() from
4077 * @param realloc_func
4078 * A function equivalent to @c realloc() that wimlib will use to reallocate
4079 * memory. If @c NULL, the free function is set back to the default @c
4080 * realloc() from the C library.
4084 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
4085 void (*free_func)(void *),
4086 void *(*realloc_func)(void *, size_t));
4089 * @ingroup G_general
4091 * Sets whether wimlib is to print error messages to @c stderr when a function
4092 * fails. These error messages may provide information that cannot be
4093 * determined only from the error code that is returned. Not every error will
4094 * result in an error message being printed.
4096 * This setting is global and not per-WIM.
4098 * By default, error messages are not printed.
4100 * This can be called before wimlib_global_init().
4102 * @param show_messages
4103 * @c true if error messages are to be printed; @c false if error messages
4104 * are not to be printed.
4106 * @return 0 on success; nonzero on error.
4107 * @retval ::WIMLIB_ERR_UNSUPPORTED
4108 * @p show_messages was @c true, but wimlib was compiled with the @c
4109 * --without-error-messages option. Therefore, error messages cannot be
4113 wimlib_set_print_errors(bool show_messages);
4116 * @ingroup G_nonstandalone_wims
4118 * Splits a WIM into multiple parts.
4121 * The ::WIMStruct for the WIM to split.
4123 * Name of the SWM file to create. This will be the name of the first
4124 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
4125 * appended before the suffix.
4127 * The maximum size per part, in bytes. Unfortunately, it is not
4128 * guaranteed that this will really be the maximum size per part, because
4129 * some file resources in the WIM may be larger than this size, and the WIM
4130 * file format provides no way to split up file resources among multiple
4132 * @param write_flags
4133 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
4134 * flags will be used to write each split WIM part. Specify 0 here to get
4135 * the default behavior.
4137 * @return 0 on success; nonzero on error. This function may return most error
4138 * codes that can be returned by wimlib_write() as well as the following error
4141 * @retval ::WIMLIB_ERR_INVALID_PARAM
4142 * @p swm_name was not a nonempty string, or @p part_size was 0.
4144 * If a progress function is registered with @p wim, for each split WIM part
4145 * that is written it will receive the messages
4146 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
4147 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
4150 wimlib_split(WIMStruct *wim,
4151 const wimlib_tchar *swm_name,
4156 * @ingroup G_general
4158 * Perform verification checks on a WIM file.
4161 * The ::WIMStruct for the WIM file to verify. Note: for an extra layer of
4162 * verification, it is a good idea to have used
4163 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY when you opened the file.
4165 * If verifying a split WIM, specify the first part of the split WIM here,
4166 * and reference the other parts using wimlib_reference_resource_files()
4167 * before calling this function.
4169 * @param verify_flags
4170 * Reserved; must be 0.
4172 * @retval 0 if the WIM file was successfully verified; nonzero if it failed
4173 * verification or another error occurred. Some of the possible error codes
4176 * @retval ::WIMLIB_ERR_DECOMPRESSION
4177 * A compressed resource could not be decompressed.
4178 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
4179 * The metadata resource for an image is invalid.
4180 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4181 * One of the files did not decompress to its original data, as given by a
4182 * cryptographic checksum.
4183 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4184 * One of the files referenced by an image could not be located.
4186 * If a progress function is registered with @p wim, it will receive the
4187 * following progress messages: ::WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
4188 * ::WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE, and
4189 * ::WIMLIB_PROGRESS_MSG_VERIFY_STREAMS.
4192 wimlib_verify_wim(WIMStruct *wim, int verify_flags);
4195 * @ingroup G_mounting_wim_images
4197 * Unmounts a WIM image that was mounted using wimlib_mount_image().
4199 * When unmounting a read-write mounted image, the default behavior is to
4200 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
4201 * WIM image to be committed.
4204 * The directory the WIM image was mounted on.
4205 * @param unmount_flags
4206 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
4208 * @return 0 on success; nonzero on error. The possible error codes include:
4210 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
4211 * There is no WIM image mounted on the specified directory.
4212 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
4213 * The read-write mounted WIM image cannot be committed because there are
4214 * file descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
4216 * @retval ::WIMLIB_ERR_MQUEUE
4217 * Could not create a POSIX message queue.
4218 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
4219 * The WIM image was mounted by a different user.
4220 * @retval ::WIMLIB_ERR_UNSUPPORTED
4221 * Mounting is not supported in this build of the library.
4223 * Note: you can also unmount the image by using the @c umount() system call, or
4224 * by using the @c umount or @c fusermount programs. However, you need to call
4225 * this function if you want changes to be committed.
4228 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
4231 * @ingroup G_mounting_wim_images
4233 * Same as wimlib_unmount_image(), but allows specifying a progress function.
4234 * If changes are committed from a read-write mount, the progress function will
4235 * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
4238 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
4240 wimlib_progress_func_t progfunc,
4244 * @ingroup G_modifying_wims
4246 * Update a WIM image by adding, deleting, and/or renaming files or directories.
4249 * Pointer to the ::WIMStruct for the WIM file to update.
4251 * The 1-based index of the image in the WIM to update. It cannot be
4252 * ::WIMLIB_ALL_IMAGES.
4254 * An array of ::wimlib_update_command's that specify the update operations
4257 * Number of commands in @p cmds.
4258 * @param update_flags
4259 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
4261 * @return 0 on success; nonzero on error. On failure, all update commands will
4262 * be rolled back, and no visible changes shall have been made to @p wim.
4263 * Possible error codes include:
4265 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
4266 * The capture configuration structure specified for an add command was
4268 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4269 * @p image did not specify a single, existing image in @p wim.
4270 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
4271 * Attempted to perform an add command that conflicted with previously
4272 * existing files in the WIM when an overlay was attempted.
4273 * @retval ::WIMLIB_ERR_INVALID_PARAM
4274 * An unknown operation type was specified in the update commands; or,
4275 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
4276 * in the @p add_flags, but the same image had previously already been
4277 * added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
4278 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
4279 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
4280 * specified in the @p add_flags for an add command in which @p
4281 * wim_target_path was not the root directory of the WIM image.
4282 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
4283 * (Windows only): While executing an add command, tried to capture a
4284 * reparse point with invalid data.
4285 * @retval ::WIMLIB_ERR_IS_DIRECTORY
4286 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
4287 * for a WIM path that corresponded to a directory; or, a rename command
4288 * attempted to rename a directory to a non-directory.
4289 * @retval ::WIMLIB_ERR_NOMEM
4290 * Failed to allocate needed memory.
4291 * @retval ::WIMLIB_ERR_NOTDIR
4292 * A rename command attempted to rename a directory to a non-directory; or,
4293 * an add command was executed that attempted to set the root of the WIM
4294 * image as a non-directory; or, a path component used as a directory in a
4295 * rename command was not, in fact, a directory.
4296 * @retval ::WIMLIB_ERR_NOTEMPTY
4297 * A rename command attempted to rename a directory to a non-empty
4299 * @retval ::WIMLIB_ERR_NTFS_3G
4300 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
4301 * error occurred while reading data from the NTFS volume using libntfs-3g.
4302 * @retval ::WIMLIB_ERR_OPEN
4303 * Failed to open a file to be captured while executing an add command.
4304 * @retval ::WIMLIB_ERR_OPENDIR
4305 * Failed to open a directory to be captured while executing an add command.
4306 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4307 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4308 * WIM path that did not exist; or, a rename command attempted to rename a
4309 * file that does not exist.
4310 * @retval ::WIMLIB_ERR_READ
4311 * While executing an add command, failed to read data from a file or
4312 * directory to be captured.
4313 * @retval ::WIMLIB_ERR_READLINK
4314 * While executing an add command, failed to read the target of a symbolic
4315 * link or junction point.
4316 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
4317 * (Windows only) Failed to perform a reparse point fixup because of
4318 * problems with the data of a reparse point.
4319 * @retval ::WIMLIB_ERR_STAT
4320 * While executing an add command, failed to get attributes for a file or
4322 * @retval ::WIMLIB_ERR_UNSUPPORTED
4323 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
4324 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
4325 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
4326 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
4327 * add_flags for an update command.
4328 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4329 * While executing an add command, attempted to capture a file that was not
4330 * a supported file type (e.g. a device file). Only if
4331 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
4332 * for an update command.
4333 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4334 * The WIM file is considered read-only because of any of the reasons
4335 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
4338 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4339 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4340 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4341 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4342 * different reasons) to read the metadata resource for an image that needed to
4346 wimlib_update_image(WIMStruct *wim,
4348 const struct wimlib_update_command *cmds,
4353 * @ingroup G_writing_and_overwriting_wims
4355 * Writes a WIM to a file.
4357 * This brings in resources from any external locations, such as directory trees
4358 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4359 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
4361 * By default, the new WIM file is written as stand-alone. Using the
4362 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4363 * instead. However, this function cannot directly write a "split" WIM; use
4364 * wimlib_split() for that.
4367 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
4368 * changes made to it, which are then reflected in the output file.
4370 * The path to the file to write the WIM to.
4372 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4373 * images are to be included in the new on-disk WIM file. If for some
4374 * reason you only want to include a single image, specify the index of
4375 * that image instead.
4376 * @param write_flags
4377 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
4378 * @param num_threads
4379 * Number of threads to use for compressing data. If 0, the number of
4380 * threads will be set by the library automatically. This chosen value
4381 * will generally be the number of online processors, but the
4382 * implementation may take into account other information (e.g. available
4383 * memory and overall system activity).
4385 * @return 0 on success; nonzero on error.
4387 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4388 * @p image does not specify a single existing image in @p wim, and is not
4389 * ::WIMLIB_ALL_IMAGES.
4390 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4391 * A file resource failed a SHA-1 message digest check. This can happen if
4392 * a file that had previously been scanned for inclusion in the WIM by was
4393 * concurrently modified.
4394 * @retval ::WIMLIB_ERR_INVALID_PARAM
4395 * @p path was not a nonempty string, or invalid flags were passed.
4396 * @retval ::WIMLIB_ERR_NOMEM
4397 * Failed to allocate needed memory.
4398 * @retval ::WIMLIB_ERR_OPEN
4399 * Failed to open @p path for writing, or some file resources in @p wim
4400 * refer to files in the outside filesystem, and one of these files could
4401 * not be opened for reading.
4402 * @retval ::WIMLIB_ERR_READ
4403 * An error occurred when trying to read data from the WIM file associated
4404 * with @p wim, or some file resources in @p wim refer to files in the
4405 * outside filesystem, and a read error occurred when reading one of these
4407 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4408 * A stream that needed to be written could not be found in the stream
4409 * lookup table of @p wim. This error can occur if, for example, @p wim is
4410 * part of a split WIM but needed resources from the other split WIM parts
4411 * were not referenced with wimlib_reference_resources() or
4412 * wimlib_reference_resource_files() before the call to wimlib_write().
4413 * @retval ::WIMLIB_ERR_WRITE
4414 * An error occurred when trying to write data to the new WIM file.
4416 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4417 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4418 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4419 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4420 * different reasons) to read the data from a WIM archive.
4422 * If a progress function is registered with @p wim, it will receive the
4423 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4424 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4425 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4428 wimlib_write(WIMStruct *wim,
4429 const wimlib_tchar *path,
4432 unsigned num_threads);
4435 * @ingroup G_writing_and_overwriting_wims
4437 * Same as wimlib_write(), but write the WIM directly to a file descriptor,
4438 * which need not be seekable if the write is done in a special pipable WIM
4439 * format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p write_flags. This can,
4440 * for example, allow capturing a WIM image and streaming it over the network.
4441 * See @ref subsec_pipable_wims for more information about pipable WIMs.
4443 * The file descriptor @p fd will @b not be closed when the write is complete;
4444 * the calling code is responsible for this.
4446 * Returns 0 on success; nonzero on failure. The possible error codes include
4447 * those that can be returned by wimlib_write() as well as the following:
4449 * @retval ::WIMLIB_ERR_INVALID_PARAM
4450 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4451 * specified in @p write_flags.
4454 wimlib_write_to_fd(WIMStruct *wim,
4458 unsigned num_threads);
4461 * @defgroup G_compression Compression and decompression functions
4463 * @brief Functions for XPRESS, LZX, and LZMS compression and decompression.
4465 * These functions are already used by wimlib internally when appropriate for
4466 * reading and writing WIM archives. But they are exported and documented so
4467 * that they can be used in other applications or libraries for general-purpose
4468 * lossless data compression. They are implemented in highly optimized C code,
4469 * using state-of-the-art compression techniques. The main limitation is the
4470 * lack of sliding window support; this has, however, allowed the algorithms to
4471 * be optimized for block-based compression.
4476 /** Opaque compressor handle. */
4477 struct wimlib_compressor;
4479 /** Opaque decompressor handle. */
4480 struct wimlib_decompressor;
4483 * Set the default compression level for the specified compression type. This
4484 * is the compression level that wimlib_create_compressor() assumes if it is
4485 * called with @p compression_level specified as 0.
4487 * wimlib's WIM writing code (e.g. wimlib_write()) will pass 0 to
4488 * wimlib_create_compressor() internally. Therefore, calling this function will
4489 * affect the compression level of any data later written to WIM files using the
4490 * specified compression type.
4492 * The initial state, before this function is called, is that all compression
4493 * types have a default compression level of 50.
4496 * Compression type for which to set the default compression level, as one
4497 * of the ::wimlib_compression_type constants. Or, if this is the special
4498 * value -1, the default compression levels for all compression types will
4500 * @param compression_level
4501 * The default compression level to set. If 0, the "default default" level
4502 * of 50 is restored. Otherwise, a higher value indicates higher
4503 * compression, whereas a lower value indicates lower compression. See
4504 * wimlib_create_compressor() for more information.
4506 * @return 0 on success; nonzero on error.
4508 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4509 * @p ctype was neither a supported compression type nor -1.
4512 wimlib_set_default_compression_level(int ctype, unsigned int compression_level);
4515 * Returns the approximate number of bytes needed to allocate a compressor with
4516 * wimlib_create_compressor() for the specified compression type, maximum block
4517 * size, and compression level. @p compression_level may be 0, in which case
4518 * the current default compression level for @p ctype is used. Returns 0 if the
4519 * compression type is invalid, or the @p max_block_size for that compression
4523 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4524 size_t max_block_size,
4525 unsigned int compression_level);
4528 * Allocate a compressor for the specified compression type using the specified
4529 * parameters. This function is part of wimlib's compression API; it is not
4530 * necessary to call this to process a WIM file.
4533 * Compression type for which to create the compressor, as one of the
4534 * ::wimlib_compression_type constants.
4535 * @param max_block_size
4536 * The maximum compression block size to support. This specifies the
4537 * maximum allowed value for the @p uncompressed_size parameter of
4538 * wimlib_compress() when called using this compressor.
4540 * Usually, the amount of memory used by the compressor will scale in
4541 * proportion to the @p max_block_size parameter.
4542 * wimlib_get_compressor_needed_memory() can be used to query the specific
4543 * amount of memory that will be required.
4545 * This parameter must be at least 1 and must be less than or equal to a
4546 * compression-type-specific limit.
4548 * In general, the same value of @p max_block_size must be passed to
4549 * wimlib_create_decompressor() when the data is later decompressed.
4550 * However, some compression types have looser requirements regarding this.
4551 * @param compression_level
4552 * The compression level to use. If 0, the default compression level (50,
4553 * or another value as set through wimlib_set_default_compression_level())
4554 * is used. Otherwise, a higher value indicates higher compression. The
4555 * values are scaled so that 10 is low compression, 50 is medium
4556 * compression, and 100 is high compression. This is not a percentage;
4557 * values above 100 are also valid.
4559 * Using a higher-than-default compression level can result in a better
4560 * compression ratio, but can significantly reduce performance. Similarly,
4561 * using a lower-than-default compression level can result in better
4562 * performance, but can significantly worsen the compression ratio. The
4563 * exact results will depend heavily on the compression type and what
4564 * algorithms are implemented for it. If you are considering using a
4565 * non-default compression level, you should run benchmarks to see if it is
4566 * worthwhile for your application.
4568 * The compression level does not affect the format of the compressed data.
4569 * Therefore, it is a compressor-only parameter and does not need to be
4570 * passed to the decompressor.
4571 * @param compressor_ret
4572 * A location into which to return the pointer to the allocated compressor.
4573 * The allocated compressor can be used for any number of calls to
4574 * wimlib_compress() before being freed with wimlib_free_compressor().
4576 * @return 0 on success; nonzero on error.
4578 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4579 * @p ctype was not a supported compression type.
4580 * @retval ::WIMLIB_ERR_INVALID_PARAM
4581 * @p max_block_size was invalid for the compression type, or @p
4582 * compressor_ret was @c NULL.
4583 * @retval ::WIMLIB_ERR_NOMEM
4584 * Insufficient memory to allocate the compressor.
4587 wimlib_create_compressor(enum wimlib_compression_type ctype,
4588 size_t max_block_size,
4589 unsigned int compression_level,
4590 struct wimlib_compressor **compressor_ret);
4593 * Compress a buffer of data.
4595 * @param uncompressed_data
4596 * Buffer containing the data to compress.
4597 * @param uncompressed_size
4598 * Size, in bytes, of the data to compress. This cannot be greater than
4599 * the @p max_block_size with which wimlib_create_compressor() was called.
4600 * (If it is, the data will not be compressed and 0 will be returned.)
4601 * @param compressed_data
4602 * Buffer into which to write the compressed data.
4603 * @param compressed_size_avail
4604 * Number of bytes available in @p compressed_data.
4606 * A compressor previously allocated with wimlib_create_compressor().
4609 * The size of the compressed data, in bytes, or 0 if the data could not be
4610 * compressed to @p compressed_size_avail or fewer bytes.
4613 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4614 void *compressed_data, size_t compressed_size_avail,
4615 struct wimlib_compressor *compressor);
4618 * Free a compressor previously allocated with wimlib_create_compressor().
4621 * The compressor to free. If @c NULL, no action is taken.
4624 wimlib_free_compressor(struct wimlib_compressor *compressor);
4627 * Allocate a decompressor for the specified compression type. This function is
4628 * part of wimlib's compression API; it is not necessary to call this to process
4632 * Compression type for which to create the decompressor, as one of the
4633 * ::wimlib_compression_type constants.
4634 * @param max_block_size
4635 * The maximum compression block size to support. This specifies the
4636 * maximum allowed value for the @p uncompressed_size parameter of
4637 * wimlib_decompress().
4639 * In general, this parameter must be the same as the @p max_block_size
4640 * that was passed to wimlib_create_compressor() when the data was
4641 * compressed. However, some compression types have looser requirements
4643 * @param decompressor_ret
4644 * A location into which to return the pointer to the allocated
4645 * decompressor. The allocated decompressor can be used for any number of
4646 * calls to wimlib_decompress() before being freed with
4647 * wimlib_free_decompressor().
4649 * @return 0 on success; nonzero on error.
4651 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4652 * @p ctype was not a supported compression type.
4653 * @retval ::WIMLIB_ERR_INVALID_PARAM
4654 * @p max_block_size was invalid for the compression type, or @p
4655 * decompressor_ret was @c NULL.
4656 * @retval ::WIMLIB_ERR_NOMEM
4657 * Insufficient memory to allocate the decompressor.
4660 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4661 size_t max_block_size,
4662 struct wimlib_decompressor **decompressor_ret);
4665 * Decompress a buffer of data.
4667 * @param compressed_data
4668 * Buffer containing the data to decompress.
4669 * @param compressed_size
4670 * Size, in bytes, of the data to decompress.
4671 * @param uncompressed_data
4672 * Buffer into which to write the uncompressed data.
4673 * @param uncompressed_size
4674 * Size, in bytes, of the data when uncompressed. This cannot exceed the
4675 * @p max_block_size with which wimlib_create_decompressor() was called.
4676 * (If it does, the data will not be decompressed and a nonzero value will
4678 * @param decompressor
4679 * A decompressor previously allocated with wimlib_create_decompressor().
4681 * @return 0 on success; nonzero on error.
4683 * No specific error codes are defined; any nonzero value indicates that the
4684 * decompression failed. This can only occur if the data is truly invalid;
4685 * there will never be transient errors like "out of memory", for example.
4687 * This function requires that the exact uncompressed size of the data be passed
4688 * as the @p uncompressed_size parameter. If this is not done correctly,
4689 * decompression may fail or the data may be decompressed incorrectly.
4692 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4693 void *uncompressed_data, size_t uncompressed_size,
4694 struct wimlib_decompressor *decompressor);
4697 * Free a decompressor previously allocated with wimlib_create_decompressor().
4699 * @param decompressor
4700 * The decompressor to free. If @c NULL, no action is taken.
4703 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4715 #endif /* _WIMLIB_H */