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 * @section sec_intro Introduction
36 * This is the documentation for the library interface of wimlib 1.6.3, a C
37 * library for creating, modifying, extracting, and mounting files in the
38 * Windows Imaging Format. This documentation is intended for developers only.
39 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
40 * program, please see the README file or manual pages.
42 * @section sec_installing_and_compiling Installing and Compiling
44 * wimlib uses the GNU autotools, so, on UNIX-like systems, it should be easy to
45 * install with <code>configure && make && sudo make install</code>; however,
46 * please see the README for more information about installing it.
48 * To use wimlib in your program after installing it, include wimlib.h and link
49 * your program with @c -lwim.
51 * As of wimlib 1.5.0, wimlib.h is also compatible with C++.
53 * Note: before calling any other function declared in wimlib.h,
54 * wimlib_global_init() can (and in some cases, must) be called. See its
55 * documentation for more details.
57 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
59 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
60 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
61 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
62 * which creates a new ::WIMStruct that initially contains no images and does
63 * not yet have a backing on-disk file. See @ref G_creating_and_opening_wims
66 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
67 * Images can be extracted (or "applied") using wimlib_extract_image(), added
68 * (or "captured" or "appended") using wimlib_add_image(), deleted using
69 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
70 * modified using wimlib_update_image(). However, changes made to a WIM
71 * represented by a ::WIMStruct have no persistent effect until the WIM is
72 * actually written to an on-disk file. This can be done using wimlib_write(),
73 * but if the WIM was originally opened using wimlib_open_wim(), then
74 * wimlib_overwrite() can be used instead. See @ref G_extracting_wims, @ref
75 * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
77 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
78 * files is a multi-step process. For example, to add, or "append" an image to
79 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
80 * append</b>, you must call the following functions:
82 * 1. wimlib_open_wim()
83 * 2. wimlib_add_image()
84 * 3. wimlib_overwrite()
86 * This design is very much on purpose as it makes the library more useful in
87 * general by allowing functions to be composed in different ways. For example,
88 * you can make multiple changes to a WIM and commit them all to the underlying
89 * file in only one overwrite operation, which is more efficient.
91 * @section sec_cleaning_up Cleaning up
93 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
94 * all resources associated with it. Also, when you are completely done with
95 * using wimlib in your program, you can call wimlib_global_cleanup() to free
96 * any other resources allocated by the library.
98 * @section sec_error_handling Error Handling
100 * Most functions in wimlib return 0 on success and a positive error code on
101 * failure. Use wimlib_get_error_string() to get a string that describes an
102 * error code. wimlib also can print error messages to standard error itself
103 * when an error happens, and these may be more informative than the error code;
104 * to enable this, call wimlib_set_print_errors(). Please note that this is for
105 * convenience only, and some errors can occur without a message being printed.
106 * Currently, error messages and strings (as well as all documentation, for that
107 * matter) are only available in English.
109 * @section sec_encodings Locales and character encodings
111 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
112 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
115 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
116 * and the encoding is UTF-16LE.
118 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
119 * and the encoding is the locale-dependent multibyte encoding. I recommend you
120 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
121 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
122 * call wimlib_global_init() after having set your desired locale.
124 * @section sec_advanced Additional information and features
127 * @subsection subsec_mounting_wim_images Mounting WIM images
129 * See @ref G_mounting_wim_images.
131 * @subsection subsec_progress_functions Progress Messages
133 * See @ref G_progress.
135 * @subsection subsec_non_standalone_wims Non-standalone WIMs
137 * See @ref G_nonstandalone_wims.
139 * @subsection subsec_pipable_wims Pipable WIMs
141 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
142 * compatible with Microsoft's software. To create a pipable WIM, call
143 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
144 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
145 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
146 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
147 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
148 * s using a seekable file descriptor using the regular function calls (e.g.
149 * wimlib_open_wim(), wimlib_extract_image()).
151 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
152 * capture</b> for more information about pipable WIMs.
154 * @subsection subsec_thread_safety Thread Safety
156 * wimlib is thread-safe, with the following exceptions:
157 * - Different threads cannot operate on the same ::WIMStruct at the same time;
158 * they must use different ::WIMStruct's.
159 * - You must call wimlib_global_init() in one thread before calling any other
161 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
162 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
163 * concurrently in the same process, will daemonize the entire process when it
164 * does so for the first time. This includes changing the working directory
165 * to the root directory.
167 * @subsection subsec_limitations Limitations
169 * This section documents some technical limitations of wimlib not already
170 * documented in the man page for @b wimlib-imagex.
172 * - The old WIM format from Vista pre-releases is not supported.
173 * - wimlib does not provide a clone of the @b PEImg tool, or the @b DISM
174 * functionality other than that already present in @b ImageX, that allows you
175 * to make certain Windows-specific modifications to a Windows PE image, such
176 * as adding a driver or Windows component. Such a tool could be implemented
179 * @subsection more_info More information
181 * You are advised to read the README as well as the manual pages for
182 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
183 * the API documentation.
186 /** @defgroup G_general General
188 * @brief Declarations and structures shared across the library.
191 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
193 * @brief Create new WIMs and open existing WIMs.
196 /** @defgroup G_wim_information Retrieving WIM information and directory listings
198 * @brief Retrieve information about a WIM or WIM image.
201 /** @defgroup G_modifying_wims Modifying WIMs
203 * @brief Make changes to a WIM.
205 * @section sec_adding_images Capturing and adding WIM images
207 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
208 * appending an image to an existing WIM is a multi-step process, but at its
209 * core is wimlib_add_image() or an equivalent function. Normally,
210 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
211 * ::WIMStruct as a new image. However, when supported by the build of the
212 * library, there is also a special NTFS volume capture mode (entered when
213 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
214 * from an unmounted NTFS volume.
216 * Another function, wimlib_add_image_multisource() is also provided. It
217 * generalizes wimlib_add_image() to allow combining multiple files or directory
218 * trees into a single WIM image in a configurable way.
220 * For maximum customization of WIM image creation, it is also possible to add a
221 * completely empty WIM image with wimlib_add_empty_image(), then update it with
222 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
223 * wimlib_add_image_multisource() do internally.)
225 * Note that some details of how image addition/capture works are documented
226 * more fully in the manual page for <b>wimlib-imagex capture</b>.
228 * @section sec_deleting_images Deleting WIM images
230 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
231 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
232 * be made persistent in an on-disk WIM file.
234 * @section sec_exporting_images Exporting WIM images
236 * wimlib_export_image() can copy, or "export", an image from one WIM to
239 * @section sec_other_modifications Other modifications
241 * wimlib_update_image() can add, delete, and rename files in a WIM image.
243 * wimlib_set_image_name(), wimlib_set_image_descripton(), and
244 * wimlib_set_image_flags() can change other image metadata.
246 * wimlib_set_wim_info() can change information about the WIM file itself, such
250 /** @defgroup G_extracting_wims Extracting WIMs
252 * @brief Extract files, directories, and images from a WIM.
254 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
255 * represented by a ::WIMStruct. This normally extracts the image to a
256 * directory, but when supported by the build of the library there is also a
257 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
258 * is specified) that allows extracting a WIM image directly to an unmounted
259 * NTFS volume. Various other flags allow further customization of image
262 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
263 * of (possibly wildcard) paths from a WIM image.
265 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
266 * over a pipe; see @ref subsec_pipable_wims.
268 * Some details of how WIM extraction works are documented more fully in the
269 * manual pages for <b>wimlib-imagex apply</b> and <b>wimlib-imagex extract</b>.
272 /** @defgroup G_mounting_wim_images Mounting WIM images
274 * @brief Mount and unmount WIM images.
276 * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
277 * mounting images from WIM files either read-only or read-write. To mount an
278 * image, call wimlib_mount_image(). To unmount an image, call
279 * wimlib_unmount_image(). Mounting can be done without root privileges because
280 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
281 * compiled with the <code>--without-fuse</code> flag, these functions will be
282 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED. Note that mounting an
283 * image read-write is an alternative to calling wimlib_update_image().
286 /** @defgroup G_progress Progress Messages
288 * @brief Track the progress of long WIM operations.
290 * When operating on large archives, operations such as extraction will
291 * naturally take a while to complete. Because of this and to improve the
292 * potential user-friendliness of library clients, a number of functions take a
293 * pointer to a progress function of type ::wimlib_progress_func_t. This
294 * function will be called periodically during the WIM operation(s) to report on
295 * the progress of the operation (for example, how many bytes have been written
299 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
301 * @brief Write and overwrite on-disk WIM files.
303 * As described in @ref sec_basic_wim_handling_concepts, these functions are
304 * critical to the design of the library as they allow new or modified WIMs to
305 * actually be written to on-disk files. Generally, wimlib_write() is the
306 * function you need to call to write a new WIM file, and wimlib_overwrite() is
307 * the function you need to call to persistently update an existing WIM file.
310 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
312 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
314 * Normally, ::WIMStruct represents a WIM file, but there's a bit more to it
315 * than that. Normally, WIM files are "standalone". However, WIM files can
316 * also be arranged in non-standalone ways, such as a set of on-disk files that
317 * together form a single "split WIM" or "delta WIM". Such arrangements are
318 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
319 * created from one of these on-disk files initially only partially represents
320 * the full WIM and needs to, in effect, be logically combined with other
321 * ::WIMStruct's before performing certain operations, such as extracting files
322 * with wimlib_extract_image() or wimlib_extract_paths(). This is done by
323 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
325 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
326 * specialized function (wimlib_split()) is needed to create a split WIM.
335 #include <inttypes.h>
338 /** @ingroup G_general
341 /** Major version of the library (for example, the 1 in 1.2.5). */
342 #define WIMLIB_MAJOR_VERSION 1
344 /** Minor version of the library (for example, the 2 in 1.2.5). */
345 #define WIMLIB_MINOR_VERSION 6
347 /** Patch version of the library (for example, the 5 in 1.2.5). */
348 #define WIMLIB_PATCH_VERSION 3
355 /** @ingroup G_general
359 * Opaque structure that represents a WIM file. This is an in-memory structure
360 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
361 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
362 * continuing to exist so that data can be read from it as needed.
364 * Most functions in this library will work the same way regardless of whether a
365 * given ::WIMStruct was obtained through wimlib_open_wim() or
366 * wimlib_create_new_wim(). Exceptions are documented.
368 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
369 * file from a ::WIMStruct.
371 * See @ref sec_basic_wim_handling_concepts for more information.
373 #ifndef WIMLIB_WIMSTRUCT_DECLARED
374 typedef struct WIMStruct WIMStruct;
375 #define WIMLIB_WIMSTRUCT_DECLARED
379 typedef wchar_t wimlib_tchar;
381 /** See @ref sec_encodings */
382 typedef char wimlib_tchar;
386 /** Path separator for WIM paths passed back to progress callbacks. */
387 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
388 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
390 /** Path separator for WIM paths passed back to progress callbacks. */
391 # define WIMLIB_WIM_PATH_SEPARATOR '/'
392 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
395 /** Use this to specify the root directory of the WIM image. */
396 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
398 /** Use this to test if the specified path refers to the root directory of the
400 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
401 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
405 # define _wimlib_deprecated __attribute__((deprecated))
407 # define _wimlib_deprecated
410 #define WIMLIB_GUID_LEN 16
413 * Specifies the compression type of a WIM file.
415 enum wimlib_compression_type {
416 /** An invalid compression type. */
417 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
419 /** The WIM does not include any compressed resources. */
420 WIMLIB_COMPRESSION_TYPE_NONE = 0,
422 /** Compressed resources in the WIM use XPRESS compression. */
423 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
425 /** Compressed resources in the WIM use LZX compression. */
426 WIMLIB_COMPRESSION_TYPE_LZX = 2,
428 /** Compressed resources in the WIM use LZMS compression. Note: LZMS
429 * compression is only compatible with wimlib v1.6.0 and later and with
430 * WIMGAPI Windows 8 and later (and some restrictions apply on the
432 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
436 /** @ingroup G_progress
439 /** Possible values of the first parameter to the user-supplied
440 * ::wimlib_progress_func_t progress function */
441 enum wimlib_progress_msg {
443 /** A WIM image is about to be extracted. @p info will point to
444 * ::wimlib_progress_info.extract. This message is received once per
445 * image for calls to wimlib_extract_image() and
446 * wimlib_extract_image_from_pipe(). */
447 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
449 /** One or more file or directory trees within a WIM image is about to
450 * be extracted. @p info will point to ::wimlib_progress_info.extract.
451 * This message is received only once per wimlib_extract_paths() and
452 * wimlib_extract_pathlist(), since wimlib combines all paths into a
453 * single extraction operation for optimization purposes. */
454 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
456 /** File data is currently being extracted. @p info will point to
457 * ::wimlib_progress_info.extract. This is the main message to track
458 * the progress of an extraction operation. */
459 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
461 /** Starting to read a new part of a split pipable WIM over the pipe.
462 * @p info will point to ::wimlib_progress_info.extract. */
463 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
465 /** Confirms that the image has been successfully extracted. @p info
466 * will point to ::wimlib_progress_info.extract. This is paired with
467 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
468 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
470 /** Confirms that the files or directory trees have been successfully
471 * extracted. @p info will point to ::wimlib_progress_info.extract.
472 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
473 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
475 /** The directory or NTFS volume is about to be scanned for metadata.
476 * @p info will point to ::wimlib_progress_info.scan. This message is
477 * received once per call to wimlib_add_image(), or once per capture
478 * source passed to wimlib_add_image_multisource(), or once per add
479 * command passed to wimlib_update_image(). */
480 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
482 /** A directory or file has been scanned. @p info will point to
483 * ::wimlib_progress_info.scan, and its @p cur_path member will be
484 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
486 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
488 /** Confirms that the directory or NTFS volume has been successfully
489 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
490 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
491 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
493 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
495 /** File resources ("streams") are currently being written to the WIM.
496 * @p info will point to ::wimlib_progress_info.write_streams. This
497 * message may be received many times while the WIM file is being
498 * written or appended to with wimlib_write(), wimlib_overwrite(), or
499 * wimlib_write_to_fd(). */
500 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
502 /** Per-image metadata is about to be written to the WIM file. @p info
503 * will not be valid. */
504 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
506 /** Confirms that per-image metadata has been successfully been written
507 * to the WIM file. @p info will not be valid. This message is paired
508 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
510 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
512 /** wimlib_overwrite() has successfully renamed the temporary file to
513 * the original WIM file, thereby committing the update. @p info will
514 * point to ::wimlib_progress_info.rename. Note: this message is not
515 * received if wimlib_overwrite() chose to append to the WIM file
517 WIMLIB_PROGRESS_MSG_RENAME = 15,
519 /** The contents of the WIM file are being checked against the integrity
520 * table. @p info will point to ::wimlib_progress_info.integrity. This
521 * message is only received (and may be received many times) when
522 * wimlib_open_wim() is called with the
523 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
524 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
526 /** An integrity table is being calculated for the WIM being written.
527 * @p info will point to ::wimlib_progress_info.integrity. This message
528 * is only received (and may be received many times) when a WIM file is
529 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
530 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
532 /** A wimlib_split() operation is in progress, and a new split part is
533 * about to be started. @p info will point to
534 * ::wimlib_progress_info.split. */
535 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
537 /** A wimlib_split() operation is in progress, and a split part has been
538 * finished. @p info will point to ::wimlib_progress_info.split. */
539 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
541 /** A WIM update command is just about to be executed. @p info will
542 * point to ::wimlib_progress_info.update. This message is received
543 * once per update command when wimlib_update_image() is called with the
544 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
545 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
547 /** A WIM update command has just been executed. @p info will point to
548 * ::wimlib_progress_info.update. This message is received once per
549 * update command when wimlib_update_image() is called with the flag
550 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
551 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
553 /** A file in the WIM image is being replaced as a result of a
554 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
555 * @p info will point to ::wimlib_progress_info.replace. This is only
556 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
558 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
560 /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
561 * a file is being extracted normally (not as a WIMBoot "pointer file")
562 * due to it matching a pattern in the [PrepopulateList] section of the
563 * configuration file \Windows\System32\WimBootCompress.ini in the WIM
564 * image. @info will point to ::wimlib_progress_info.wimboot_exclude.
566 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
569 /** A pointer to this union is passed to the user-supplied
570 * ::wimlib_progress_func_t progress function. One (or none) of the structures
571 * contained in this union will be applicable for the operation
572 * (::wimlib_progress_msg) indicated in the first argument to the progress
574 union wimlib_progress_info {
576 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
577 * document them if they aren't given a name... */
579 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
580 * the primary message for tracking the progress of writing a WIM file.
582 struct wimlib_progress_info_write_streams {
583 /** Total number of uncompressed bytes of stream data being
584 * written. This can be thought of as the total uncompressed
585 * size of the files being archived, with some caveats. WIM
586 * files use single-instance streams, so the size provided here
587 * only counts distinct streams, except for the following
588 * exception: the size provided here may include the sizes of
589 * all newly added (e.g. with wimlib_add_image() streams,
590 * pending automatic de-duplication during the write operation
591 * itself. When each such stream de-duplication occurs, this
592 * number will be decreased by the size of the duplicate stream
593 * that need not be written.
595 * In the case of a wimlib_overwrite() that the library opted to
596 * perform in-place, both @p total_streams and @p total_bytes
597 * will only count the streams actually being written and not
598 * pre-existing streams in the WIM file. */
599 uint64_t total_bytes;
601 /** Total number of streams being written. This can be thought
602 * of as the total number of files being archived, with some
603 * caveats. In general, a single file or directory may contain
604 * multiple data streams, each of which will be represented
605 * separately in this number. Furthermore, WIM files use
606 * single-instance streams, so the stream count provided here
607 * only counts distinct streams, except for the following
608 * exception: the stream count provided here may include newly
609 * added (e.g. with wimlib_add_image() streams, pending
610 * automatic de-duplication during the write operation itself.
611 * When each such stream de-duplication occurs, this number will
612 * be decreased by 1 to account for the duplicate stream that
613 * need not be written. */
614 uint64_t total_streams;
616 /** Number of uncompressed bytes of stream data that have been
617 * written so far. This number be 0 initially, and will be
618 * equal to @p total_bytes at the end of the write operation.
619 * Note that @p total_bytes (but not @p completed_bytes) may
620 * decrease throughout the write operation due to the discovery
621 * of stream duplications. */
622 uint64_t completed_bytes;
624 /** Number of streams that have been written so far. This
625 * number will be 0 initially, and will be equal to @p
626 * total_streams at the end of the write operation. Note that
627 * @p total_streams (but not @p completed_streams) may decrease
628 * throughout the write operation due to the discovery of stream
631 * For applications that wish to calculate a simple "percent
632 * complete" for the write operation, it will likely be more
633 * accurate to calculate the percentage from @p completed_bytes
634 * and @p total_bytes rather than @p completed_streams and
635 * @p total_streams because the time for the operation to
636 * complete is mainly determined by the number of bytes that
637 * need to be read, compressed, and written, not just the number
638 * of files being archived. */
639 uint64_t completed_streams;
641 /** Number of threads that are being used to compress streams,
642 * or 1 if streams are being written uncompressed. */
643 uint32_t num_threads;
645 /** The compression type being used to write the streams, as one
646 * of the ::wimlib_compression_type constants. */
647 int32_t compression_type;
649 /** Number of split WIM parts from which streams are being
650 * written (may be 0 if irrelevant). */
651 uint32_t total_parts;
653 /** This is currently broken and will always be 0. */
654 uint32_t completed_parts;
657 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
658 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
659 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
660 struct wimlib_progress_info_scan {
661 /** Top-level directory being scanned; or, when capturing an NTFS
662 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
663 * to the file or block device that contains the NTFS volume
665 const wimlib_tchar *source;
667 /** Path to the file (or directory) that has been scanned, valid
668 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
669 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
670 * relative to the root of the NTFS volume. */
671 const wimlib_tchar *cur_path;
673 /** Dentry scan status, valid on
674 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
676 /** The file looks okay and will be captured. */
677 WIMLIB_SCAN_DENTRY_OK = 0,
679 /** File is being excluded from capture due to the
680 * capture configuration. */
681 WIMLIB_SCAN_DENTRY_EXCLUDED,
683 /** File is being excluded from capture due to being
684 * unsupported (e.g. an encrypted or device file). */
685 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
687 /** The file is an absolute symbolic link or junction
688 * point and it is being excluded from capture because
689 * it points outside of the capture directory and
690 * reparse-point fixups are enabled. (Reparse point
691 * fixups can be disabled by using the flag
692 * ::WIMLIB_ADD_FLAG_NORPFIX.) */
693 WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
697 /** Target path in the WIM image. Only valid on
698 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
699 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
700 const wimlib_tchar *wim_target_path;
702 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
703 * of @p WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK, this is
704 * the target of the absolute symbolic link or junction
706 const wimlib_tchar *symlink_target;
709 /** Number of directories scanned so far, including the root
710 * directory but excluding any unsupported/excluded directories.
712 * Details: On Windows and in NTFS capture mode, a reparse point
713 * counts as a directory if and only if it has
714 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
715 * counts as a directory if and only if when fully dereferenced
716 * it points to an accessible directory. If a file has multiple
717 * names (hard links), it is only counted one time. */
718 uint64_t num_dirs_scanned;
720 /** Number of non-directories scanned so far, excluding any
721 * unsupported/excluded files.
723 * Details: On Windows and in NTFS capture mode, a reparse point
724 * counts as a non-directory if and only if it does not have
725 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
726 * counts as a non-directory if and only if when fully
727 * dereferenced it points to a non-directory or its target is
728 * inaccessible. If a file has multiple names (hard links), it
729 * is only counted one time. */
730 uint64_t num_nondirs_scanned;
732 /** Number of bytes of file data that have been detected so far.
734 * Details: This data may not actually have been read yet, and
735 * it will not actually be written to the WIM file until
736 * wimlib_write() or wimlib_overwrite() has been called. Data
737 * from excluded files is not counted. This number includes
738 * default file contents as well as named data streams and
739 * reparse point data. The size of reparse point data is
740 * tallied after any reparse-point fixups, and in the case of
741 * capturing a symbolic link on a UNIX-like system, the creation
742 * of the reparse point data itself. If a file has multiple
743 * names (hard links), its size(s) are only counted one time.
744 * On Windows, encrypted files have their encrypted size
745 * counted, not their unencrypted size; however, compressed
746 * files have their uncompressed size counted. */
747 uint64_t num_bytes_scanned;
750 /** Valid on messages
751 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
752 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
753 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
754 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
755 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
756 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
758 * Note: most of the time of an extraction operation will be spent
759 * extracting streams, and the application will receive
760 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
761 * completed_bytes and @p total_bytes, the application can calculate a
762 * percentage complete. However, note that this message does not, in
763 * general, actually provide information about which "file" is currently
764 * being extracted. This is because wimlib, by default, extracts the
765 * individual data streams in whichever order it determines to be the
768 struct wimlib_progress_info_extract {
769 /** Number of the image from which files are being extracted
773 /** Extraction flags being used. */
774 uint32_t extract_flags;
776 /** Full path to the WIM file from which files are being
777 * extracted, or @c NULL if the WIMStruct has no associated
779 const wimlib_tchar *wimfile_name;
781 /** Name of the image from which files are being extracted, or
782 * the empty string if the image is unnamed. */
783 const wimlib_tchar *image_name;
785 /** Path to the directory or NTFS volume to which the files are
786 * being extracted. */
787 const wimlib_tchar *target;
790 const wimlib_tchar *reserved;
792 /** Number of bytes of uncompressed data that will be extracted.
793 * If a file has multiple names (hard links), its size (or
794 * sizes, in the case of named data streams) is only counted one
795 * time. For "reparse points" and symbolic links, the size to
796 * be extracted is the size of the reparse data buffer.
798 * This number will stay constant throughout the extraction. */
799 uint64_t total_bytes;
801 /** Number of bytes of uncompressed data that have been
802 * extracted so far. This initially be 0 and will equal to @p
803 * total_bytes at the end of the extraction. */
804 uint64_t completed_bytes;
806 /** Number of (not necessarily unique) streams that will be
807 * extracted. This may be more or less than the number of
808 * "files" to be extracted due to hard links as well as
809 * potentially multiple streams per file (named data streams).
810 * A "stream" may be the default contents of a file, a named
811 * data stream, or a reparse data buffer. */
812 uint64_t num_streams;
815 const wimlib_tchar *reserved_2;
817 /** Currently only used for
818 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
819 uint32_t part_number;
821 /** Currently only used for
822 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
823 uint32_t total_parts;
825 /** Currently only used for
826 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
827 uint8_t guid[WIMLIB_GUID_LEN];
830 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
831 struct wimlib_progress_info_rename {
832 /** Name of the temporary file that the WIM was written to. */
833 const wimlib_tchar *from;
835 /** Name of the original WIM file to which the temporary file is
837 const wimlib_tchar *to;
840 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
841 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
842 struct wimlib_progress_info_update {
843 /** Pointer to the update command that will be executed or has
844 * just been executed. */
845 const struct wimlib_update_command *command;
847 /** Number of update commands that have been completed so far.
849 size_t completed_commands;
851 /** Number of update commands that are being executed as part of
852 * this call to wimlib_update_image(). */
853 size_t total_commands;
856 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
857 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
858 struct wimlib_progress_info_integrity {
859 /** Number of bytes from the end of the WIM header to the end of
860 * the lookup table (the area that is covered by the SHA1
861 * integrity checks.) */
862 uint64_t total_bytes;
864 /** Number of bytes that have been SHA1-summed so far. Will be
865 * 0 initially, and equal @p total_bytes at the end. */
866 uint64_t completed_bytes;
868 /** Number of chunks that the checksummed region is divided
870 uint32_t total_chunks;
872 /** Number of chunks that have been SHA1-summed so far. Will
873 * be 0 initially, and equal to @p total_chunks at the end. */
874 uint32_t completed_chunks;
876 /** Size of the chunks used for the integrity calculation. */
879 /** Filename of the WIM (only valid if the message is
880 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
881 const wimlib_tchar *filename;
884 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
885 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
886 struct wimlib_progress_info_split {
887 /** Total size of the original WIM's file and metadata resources
889 uint64_t total_bytes;
891 /** Number of bytes of file and metadata resources that have
892 * been copied out of the original WIM so far. Will be 0
893 * initially, and equal to @p total_bytes at the end. */
894 uint64_t completed_bytes;
896 /** Number of the split WIM part that is about to be started
897 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
898 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
899 unsigned cur_part_number;
901 /** Total number of split WIM parts that are being written. */
902 unsigned total_parts;
904 /** Name of the split WIM part that is about to be started
905 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
906 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
907 const wimlib_tchar *part_name;
910 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
911 struct wimlib_progress_info_replace {
912 /** Path to the file in the WIM image that is being replaced */
913 const wimlib_tchar *path_in_wim;
916 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
917 struct wimlib_progress_info_wimboot_exclude {
918 /** Path to the file in the WIM image */
919 const wimlib_tchar *path_in_wim;
921 /** Path to which the file is being extracted */
922 const wimlib_tchar *extraction_path;
926 /** A user-supplied function that will be called periodically during certain WIM
927 * operations. The first argument will be the type of operation that is being
928 * performed or is about to be started or has been completed. The second
929 * argument will be a pointer to one of a number of structures depending on the
930 * first argument. It may be @c NULL for some message types.
932 * The return value of the progress function is currently ignored, but it may do
933 * something in the future. (Set it to 0 for now.)
935 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
936 const union wimlib_progress_info *info);
939 /** @ingroup G_modifying_wims
942 /** An array of these structures is passed to wimlib_add_image_multisource() to
943 * specify the sources from which to create a WIM image. */
944 struct wimlib_capture_source {
945 /** Absolute or relative path to a file or directory on the external
946 * filesystem to be included in the WIM image. */
947 wimlib_tchar *fs_source_path;
949 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
950 * specify the root directory of the WIM image. */
951 wimlib_tchar *wim_target_path;
953 /** Reserved; set to 0. */
957 /** Set or unset the WIM header flag that marks it read-only
958 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
959 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
960 * is distinct from basic file permissions; this flag can be set on a WIM file
961 * that is physically writable. If this flag is set, all further operations to
962 * modify the WIM will fail, except calling wimlib_overwrite() with
963 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
964 * allows you to set this flag persistently on the underlying WIM file.
966 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
968 /** Set the GUID (globally unique identifier) of the WIM file to the value
969 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
970 #define WIMLIB_CHANGE_GUID 0x00000002
972 /** Change the bootable image of the WIM to the value specified in
973 * ::wimlib_wim_info.boot_index of the @p info parameter. */
974 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
976 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
977 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
978 * indicates whether an image in the WIM has been captured with reparse-point
979 * fixups enabled. wimlib also treats this flag as specifying whether to do
980 * reparse-point fixups by default when capturing or applying WIM images. */
981 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
984 /** @ingroup G_wim_information
987 /** General information about a WIM file. */
988 struct wimlib_wim_info {
990 /** Globally unique identifier for the WIM file. Note: all parts of a
991 * split WIM should have an identical value in this field. */
992 uint8_t guid[WIMLIB_GUID_LEN];
994 /** Number of images in the WIM. */
995 uint32_t image_count;
997 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1001 /** Version of the WIM file. */
1002 uint32_t wim_version;
1004 /** Chunk size used for compression. */
1005 uint32_t chunk_size;
1007 /** For split WIMs, the 1-based index of this part within the split WIM;
1009 uint16_t part_number;
1011 /** For split WIMs, the total number of parts in the split WIM;
1013 uint16_t total_parts;
1015 /** One of the ::wimlib_compression_type values that specifies the
1016 * method used to compress resources in the WIM. */
1017 int32_t compression_type;
1019 /** Size of the WIM file in bytes, excluding the XML data and integrity
1021 uint64_t total_bytes;
1023 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1024 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1025 * this will always be 0, even if the ::WIMStruct was written to
1026 * somewhere by calling wimlib_write() with the
1027 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1028 uint32_t has_integrity_table : 1;
1030 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1031 * wimlib_create_new_wim(). */
1032 uint32_t opened_from_file : 1;
1034 /** 1 if the WIM is considered readonly for any reason. */
1035 uint32_t is_readonly : 1;
1037 /** 1 if reparse-point fixups are supposedly enabled for one or more
1038 * images in the WIM. */
1039 uint32_t has_rpfix : 1;
1041 /** 1 if the WIM is marked as read-only. */
1042 uint32_t is_marked_readonly : 1;
1044 /** 1 if the WIM is part of a spanned set. */
1045 uint32_t spanned : 1;
1047 uint32_t write_in_progress : 1;
1048 uint32_t metadata_only : 1;
1049 uint32_t resource_only : 1;
1051 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1052 uint32_t pipable : 1;
1053 uint32_t reserved_flags : 22;
1054 uint32_t reserved[9];
1057 /** Information about a unique stream in the WIM file. (A stream is the same
1058 * thing as a "resource", except in the case of packed resources.) */
1059 struct wimlib_resource_entry {
1060 /** Uncompressed size of the stream in bytes. */
1061 uint64_t uncompressed_size;
1063 /** Compressed size of the stream in bytes. This will be the same as @p
1064 * uncompressed_size if the stream is uncompressed. Or, if @p
1065 * is_packed_streams is 1, this will be 0. */
1066 uint64_t compressed_size;
1068 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1069 * if @p packed is 1, then this is actually the offset at which this
1070 * stream begins in the uncompressed contents of the packed resource.
1074 /** SHA1 message digest of the stream's uncompressed contents. */
1075 uint8_t sha1_hash[20];
1077 /** Which part number of the split WIM this stream is in. This should
1078 * be the same as the part number provided by wimlib_get_wim_info(). */
1079 uint32_t part_number;
1081 /** Number of times this stream is referenced over all WIM images. */
1082 uint32_t reference_count;
1084 /** 1 if this stream is compressed. */
1085 uint32_t is_compressed : 1;
1087 /** 1 if this stream is a metadata resource rather than a file resource.
1089 uint32_t is_metadata : 1;
1091 uint32_t is_free : 1;
1092 uint32_t is_spanned : 1;
1094 /** 1 if this stream was not found in the lookup table of the
1095 * ::WIMStruct. This normally implies a missing call to
1096 * wimlib_reference_resource_files() or wimlib_reference_resources().
1098 uint32_t is_missing : 1;
1100 /** 1 if this stream is located in a packed resource which may contain
1101 * other streams (all compressed together) as well. */
1102 uint32_t packed : 1;
1104 uint32_t reserved_flags : 26;
1106 /** If @p packed is 1, then this will specify the offset of the packed
1107 * resource in the WIM. */
1108 uint64_t raw_resource_offset_in_wim;
1110 /** If @p is_packed_streams is 1, then this will specify the compressed
1111 * size of the packed resource in the WIM. */
1112 uint64_t raw_resource_compressed_size;
1114 uint64_t reserved[2];
1117 /** A stream of a file in the WIM. */
1118 struct wimlib_stream_entry {
1119 /** Name of the stream, or NULL if the stream is unnamed. */
1120 const wimlib_tchar *stream_name;
1121 /** Location, size, etc. of the stream within the WIM file. */
1122 struct wimlib_resource_entry resource;
1123 uint64_t reserved[4];
1126 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1127 * Roughly, the information about a "file" in the WIM--- but really a directory
1128 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1129 * field can be used to distinguish actual file inodes. */
1130 struct wimlib_dir_entry {
1131 /** Name of the file, or NULL if this file is unnamed (only possible for
1132 * the root directory) */
1133 const wimlib_tchar *filename;
1135 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1137 const wimlib_tchar *dos_name;
1139 /** Full path to this file within the WIM image. */
1140 const wimlib_tchar *full_path;
1142 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1143 * children, ..., etc. */
1146 /** Pointer to the security descriptor for this file, in Windows
1147 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1148 * security descriptor. */
1149 const char *security_descriptor;
1151 /** Length of the above security descriptor. */
1152 size_t security_descriptor_size;
1154 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1155 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1156 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1157 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1158 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1159 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1160 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1161 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1162 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1163 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1164 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1165 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1166 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1167 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1168 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1169 /** File attributes, such as whether the file is a directory or not.
1170 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1171 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1172 * on other platforms. */
1173 uint32_t attributes;
1175 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1176 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1177 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1178 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1179 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1180 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1181 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1182 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1183 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1184 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1185 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1186 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1187 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1188 * attributes), this will give the reparse tag. This tells you whether
1189 * the reparse point is a symbolic link, junction point, or some other,
1190 * more unusual kind of reparse point. */
1191 uint32_t reparse_tag;
1193 /* Number of (hard) links to this file. */
1196 /** Number of named data streams that this file has. Normally 0. */
1197 uint32_t num_named_streams;
1199 /** Roughly, the inode number of this file. However, it may be 0 if
1200 * @p num_links == 1. */
1201 uint64_t hard_link_group_id;
1203 /** Time this file was created. */
1204 struct timespec creation_time;
1206 /** Time this file was last written to. */
1207 struct timespec last_write_time;
1209 /** Time this file was last accessed. */
1210 struct timespec last_access_time;
1211 uint64_t reserved[16];
1213 /** Array of streams that make up this file. The first entry will
1214 * always exist and will correspond to the unnamed data stream (default
1215 * file contents), so it will have @p stream_name == @c NULL. There
1216 * will then be @p num_named_streams additional entries that specify the
1217 * named data streams, if any, each of which will have @p stream_name !=
1219 struct wimlib_stream_entry streams[];
1223 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1226 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1230 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1233 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1236 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1237 * just on the specified path. */
1238 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1240 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1241 * itself; only its children (in the case of a non-empty directory) */
1242 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1244 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1245 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1246 * table of the ::WIMStruct. The default behavior without this flag is to fill
1247 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1248 * wimlib_resource_entry::is_missing "is_missing" flag. */
1249 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1253 /** @ingroup G_modifying_wims
1256 /** Directly capture an NTFS volume rather than a generic directory. This flag
1257 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1258 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1259 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1261 /** Follow symlinks; archive and dump the files they point to. Currently only
1262 * supported on UNIX-like systems. */
1263 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1265 /** Call the progress function with the message
1266 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1268 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1270 /** Mark the image being added as the bootable image of the WIM. Not valid for
1271 * wimlib_update_image(). */
1272 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1274 /** Store the UNIX owner, group, and mode. This is done by adding a special
1275 * alternate data stream to each regular file, symbolic link, and directory to
1276 * contain this information. Please note that this flag is for convenience
1277 * only; Microsoft's implementation will not understand this special
1279 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1281 /** Do not capture security descriptors. Only has an effect in NTFS capture
1282 * mode, or in Windows native builds. */
1283 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1285 /** Fail immediately if the full security descriptor of any file or directory
1286 * cannot be accessed. Only has an effect in Windows native builds. The
1287 * default behavior without this flag is to first try omitting the SACL from the
1288 * security descriptor, then to try omitting the security descriptor entirely.
1290 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1292 /** Call the progress function with the message
1293 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1294 * capture. This is a subset of the messages provided by
1295 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1296 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1298 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1299 * in the case of Windows) that point inside the directory being captured to
1300 * instead be absolute relative to the directory being captured, rather than the
1301 * current root; also exclude absolute symbolic links that point outside the
1302 * directory tree being captured.
1304 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1305 * the WIM header or if this is the first image being added.
1306 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1307 * reparse point fixups enabled and currently cannot be unset. */
1308 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1310 /** Don't do reparse point fixups. The default behavior is described in the
1311 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1312 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1314 /** Do not automatically exclude unsupported files or directories from capture;
1315 * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1316 * UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1317 * such a file is encountered. */
1318 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1321 * Automatically select a capture configuration appropriate for capturing
1322 * filesystems containing Windows operating systems. For example,
1323 * "pagefile.sys" and "System Volume Information" will be excluded.
1325 * When this flag is specified, the corresponding @p config parameter or member
1328 * Note that the default behavior--- that is, when this flag is not specified
1329 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1330 * no files are excluded from capture.
1332 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1335 * Capture image as WIMBoot compatible. In addition, if no capture
1336 * configuration file is explicitly specified use the capture configuration file
1337 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1338 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1339 * configuration file is explicitly specified, use it and also place it at
1340 * /Windows/System32/WimBootCompress.ini in the WIM image.
1342 * Note: this will not by itself change the compression type. Before writing
1343 * the WIM file, it's recommended to also do:
1346 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1347 * wimlib_set_output_chunk_size(wim, 4096);
1350 * since that makes access to the data faster (at the cost of a worse
1351 * compression ratio compared to the 32768-byte LZX chunks usually used).
1353 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1356 * If the add command involves adding a non-directory file to a location at
1357 * which there already exists a nondirectory file in the WIM image, issue
1358 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This only has an
1359 * effect when updating an existing image with wimlib_update_image().
1360 * This was the default behavior in wimlib v1.6.2 and earlier.
1362 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1364 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1365 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1366 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1367 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1368 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1369 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1370 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1371 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1372 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1373 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1374 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1375 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1376 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1377 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT WIMLIB_ADD_FLAG_WIMBOOT
1381 /** @ingroup G_modifying_wims
1384 /** Do not issue an error if the path to delete does not exist. */
1385 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1387 /** Delete the file or directory tree recursively; if not specified, an error is
1388 * issued if the path to delete is a directory. */
1389 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1392 /** @ingroup G_modifying_wims
1396 * If a single image is being exported, mark it bootable in the destination WIM.
1397 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1398 * the image in the source WIM (if any) that is marked as bootable is also
1399 * marked as bootable in the destination WIM.
1401 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1403 /** Give the exported image(s) no names. Avoids problems with image name
1406 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1408 /** Give the exported image(s) no descriptions. */
1409 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1411 /** This advises the library that the program is finished with the source
1412 * WIMStruct and will not attempt to access it after the call to
1413 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1414 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1417 * Mark each exported image as WIMBoot-compatible.
1419 * Note: by itself, this does change the destination WIM's compression type, nor
1420 * does it add the file \Windows\System32\WimBootCompress.ini in the WIM image.
1421 * Before writing the destination WIM, it's recommended to do something like:
1424 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1425 * wimlib_set_output_chunk_size(wim, 4096);
1426 * wimlib_add_tree(wim, image, L"myconfig.ini",
1427 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1430 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1433 /** @ingroup G_extracting_wims
1436 /** Extract the image directly to an NTFS volume rather than a generic directory.
1437 * This mode is only available if wimlib was compiled with libntfs-3g support;
1438 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1439 * extraction target will be interpreted as the path to an NTFS volume image (as
1440 * a regular file or block device) rather than a directory. It will be opened
1441 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1442 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1443 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1444 * wimlib_extract_paths() when passed multiple paths. */
1445 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1447 /** UNIX-like systems only: Extract special UNIX data captured with
1448 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1449 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1450 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1452 /** Do not extract security descriptors. This flag cannot be combined with
1453 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1454 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1456 /** Fail immediately if the full security descriptor of any file or directory
1457 * cannot be set exactly as specified in the WIM file. On Windows, the default
1458 * behavior without this flag when wimlib does not have permission to set the
1459 * correct security descriptor is to fall back to setting the security
1460 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1461 * owner omitted, then not at all. This flag cannot be combined with
1462 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1463 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1465 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1466 * reparse-point fixups on, so absolute symbolic links or junction points will
1467 * be fixed to be absolute relative to the actual extraction root. Reparse-
1468 * point fixups are done by default for wimlib_extract_image() and
1469 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1470 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1471 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1473 /** Force reparse-point fixups on extraction off, regardless of the state of the
1474 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1475 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1476 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1478 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1479 * paths, each of which must name a regular file, to standard output. */
1480 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1482 /** Instead of ignoring files and directories with names that cannot be
1483 * represented on the current platform (note: Windows has more restrictions on
1484 * filenames than POSIX-compliant systems), try to replace characters or append
1485 * junk to the names so that they can be extracted in some form. */
1486 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1488 /** On Windows, when there exist two or more files with the same case
1489 * insensitive name but different case sensitive names, try to extract them all
1490 * by appending junk to the end of them, rather than arbitrarily extracting only
1492 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1494 /** Do not ignore failure to set timestamps on extracted files. */
1495 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1497 /** Do not ignore failure to set short names on extracted files. */
1498 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1500 /** On Windows, do not ignore failure to extract symbolic links and junctions
1501 * due to permissions problems. By default, such failures are ignored since the
1502 * default configuration of Windows only allows the Administrator to create
1503 * symbolic links. */
1504 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1506 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1507 * behavior is currently less than satisfactory. Do not use (yet). */
1508 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1510 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1511 * paths to extract as wildcard patterns ("globs") which may contain the
1512 * wildcard characters @c ? and @c *. The @c ? character matches any
1513 * non-path-separator character, whereas the @c * character matches zero or more
1514 * non-path-separator characters. Consequently, each glob may match zero or
1515 * more actual paths in the WIM image. By default, if a glob does not match any
1516 * files, a warning but not an error will be issued, even if the glob did not
1517 * actually contain wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
1518 * to get an error instead. */
1519 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1521 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1522 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1523 * one of the provided globs did not match a file. */
1524 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1526 /** Do not extract Windows file attributes such as readonly, hidden, etc. */
1527 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1529 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1530 * preserve the directory structure of the archive when extracting --- that is,
1531 * place each extracted file or directory tree directly in the target directory.
1533 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1535 /** Windows only: Extract files as "pointers" back to the WIM archive. See the
1536 * documentation for the <b>--wimboot</b> option of <b>wimlib-imagex apply</b>
1537 * for more information. */
1538 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1541 /** @ingroup G_mounting_wim_images
1544 /** Mount the WIM image read-write rather than the default of read-only. */
1545 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1547 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1548 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1550 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1551 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1553 /** Access alternate data streams in the mounted WIM image through extended file
1554 * attributes. This is the default mode. */
1555 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1557 /** Access alternate data streams in the mounted WIM image by specifying the
1558 * file name, a colon, then the alternate file stream name. */
1559 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1561 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1562 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1563 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1565 /** Allow other users to see the mounted filesystem. (this passes the @c
1566 * allow_other option to FUSE mount) */
1567 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1570 /** @ingroup G_creating_and_opening_wims
1573 /** Verify the WIM contents against the WIM's integrity table, if present. This
1574 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1575 * checksummed and checked against the SHA1 message digests specified in the
1576 * integrity table. ::WIMLIB_ERR_INTEGRITY is returned if there are any
1577 * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1578 * integrity table is invalid). */
1579 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1581 /** Issue an error if the WIM is part of a split WIM. Software can provide
1582 * this flag for convenience if it explicitly does not want to support split
1584 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1586 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1587 * is not. A WIM is considered writable only if it is writable at the
1588 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1589 * header, and is not part of a spanned set. It is not required to provide this
1590 * flag before attempting to make changes to the WIM, but with this flag you get
1591 * an error sooner rather than later. */
1592 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1595 /** @ingroup G_mounting_wim_images
1598 /** See ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
1599 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1601 /** Unless this flag is given, changes to a read-write mounted WIM are
1602 * discarded. Ignored for read-only mounts. */
1603 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1605 /** See ::WIMLIB_WRITE_FLAG_REBUILD. */
1606 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1608 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1609 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1611 /** Do a "lazy" unmount (detach filesystem immediately, even if busy). */
1612 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1614 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1615 * image, causes the modified image to be committed as a new, unnamed image
1616 * appended to the archive. The original image will be unmodified. */
1617 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
1620 /** @ingroup G_modifying_wims
1623 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1624 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1625 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1628 /** @ingroup G_writing_and_overwriting_wims
1632 * Include an integrity table in the resulting WIM file.
1634 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1635 * include an integrity table if and only if one was present before. For
1636 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1637 * to not include an integrity table.
1639 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1642 * Do not include an integrity table in the resulting WIM file. This is the
1643 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
1646 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1649 * Write the WIM as "pipable". After writing a WIM with this flag specified,
1650 * images from it can be applied directly from a pipe using
1651 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1652 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1653 * with this flag will not be compatible with Microsoft's software.
1655 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1656 * write the WIM as pipable if and only if it was pipable before. For
1657 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1658 * to write the WIM as non-pipable.
1660 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1663 * Do not write the WIM as "pipable". This is the default behavior, unless the
1664 * ::WIMStruct was created by opening a pipable WIM.
1666 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1669 * When writing streams to the WIM file, recompress them, even if their data is
1670 * already available in the desired compressed form (for example, in a WIM file
1671 * from which an image has been exported using wimlib_export_image()).
1673 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
1674 * compression ratio for the same compression type and chunk size. wimlib's LZX
1675 * compressor currently can be given different parameters in order to achieve
1676 * different balances between compression ratio and time. In its default mode
1677 * as of v1.5.3, it usually compresses slightly better than the competing
1678 * Microsoft implementation.
1680 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can also be used in combination with
1681 * ::WIMLIB_WRITE_FLAG_PACK_STREAMS to prevent any solid blocks from being
1682 * re-used. (Otherwise, solid blocks are re-used somewhat more liberally than
1683 * normal compressed blocks.)
1685 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
1686 * that would not otherwise be written. For example, a call to
1687 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
1688 * cause already-existing streams in the WIM file to be recompressed. To force
1689 * the WIM file to be fully rebuilt and recompressed, combine
1690 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
1692 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1695 * Immediately before closing the WIM file, sync its data to disk.
1697 * wimlib_overwrite() will set this flag automatically if it decides to
1698 * overwrite the WIM file via a temporary file instead of in-place.
1700 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1703 * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
1704 * could be updated merely be appending to it.
1706 * When rebuilding the WIM file, stream reference counts will be recomputed, and
1707 * any streams with 0 reference count (e.g. from deleted files or images) will
1708 * not be included in the resulting WIM file.
1710 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
1711 * data to be recompressed. Otherwise, compressed data is re-used if possible.
1713 * wimlib_write() ignores this flag.
1715 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1718 * For wimlib_overwrite(), override the default behavior after one or more calls
1719 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
1720 * flag, only minimal changes to correctly remove the image from the WIM file
1721 * will be taken. In particular, all streams will be retained, even if they are
1722 * no longer referenced. This may not be what you want, because no space will
1723 * be saved by deleting an image in this way.
1725 * wimlib_write() ignores this flag.
1727 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1730 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
1731 * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header. This can be used
1732 * following a call to wimlib_set_wim_info() with the
1733 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
1736 * wimlib_write() ignores this flag.
1738 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1741 * Do not include streams already present in other WIMs. This flag can be used
1742 * to write a "delta" WIM after resources from the WIM on which the delta is to
1743 * be based were referenced with wimlib_reference_resource_files() or
1744 * wimlib_reference_resources().
1746 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1749 * Advises the library that for writes of all WIM images, all streams needed for
1750 * the WIM are already present (not in external resource WIMs) and their
1751 * reference counts are correct, so the code does not need to recalculate which
1752 * streams are referenced. This is for optimization purposes only, since with
1753 * this flag specified, the metadata resources may not need to be decompressed
1756 * wimlib_overwrite() will set this flag automatically.
1758 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1761 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
1763 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
1766 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
1769 * When writing streams in the resulting WIM file, pack multiple streams into a
1770 * single compressed resource instead of compressing them independently. This
1771 * is also known as creating a "solid archive". This tends to produce a better
1772 * compression ratio at the cost of much slower random access.
1774 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
1775 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
1776 * created with this flag use a different version number in their header (3584
1777 * instead of 68864) and are also called "ESD files".
1779 * If this flag is passed to wimlib_overwrite(), any new data streams will be
1780 * written in solid mode. Use both ::WIMLIB_WRITE_FLAG_REBUILD and
1781 * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
1782 * all streams recompressed in solid mode.
1784 * Currently, new solid blocks will, by default, be written using LZMS
1785 * compression with 32 MiB (33554432 byte) chunks. Use
1786 * wimlib_set_output_pack_compression_type() and/or
1787 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
1788 * the WIM's main compression type and chunk size; you can have a WIM that
1789 * nominally uses LZX compression and 32768 byte chunks but actually contains
1790 * LZMS-compressed solid blocks, for example. However, if including solid
1791 * blocks, I suggest that you set the WIM's main compression type to LZMS as
1792 * well, either by creating the WIM with
1793 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
1794 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
1796 * This flag will be set by default when writing or overwriting a WIM file that
1797 * either already contains packed streams, or has had packed streams exported
1798 * into it and the WIM's main compression type is LZMS.
1800 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
1803 /** @ingroup G_general
1806 /** Assume that strings are represented in UTF-8, even if this is not the
1807 * locale's character encoding. This flag is ignored on Windows, where wimlib
1808 * always uses UTF-16LE. */
1809 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1811 /** Windows-only: do not attempt to acquire additional privileges (currently
1812 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1813 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1814 * for the case where the calling program manages these privileges itself.
1815 * Note: no error is issued if privileges cannot be acquired, although related
1816 * errors may be reported later, depending on if the operations performed
1817 * actually require additional privileges or not. */
1818 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1820 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1821 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1822 * to read all possible data and metadata for a capture operation could not be
1823 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1825 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1827 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1828 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1829 * to restore all possible data and metadata for an apply operation could not be
1830 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1832 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1834 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1836 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
1838 /** Default to interpreting WIM paths case insensitively (default on Windows).
1839 * This does not apply to mounted images. */
1840 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
1843 /** @ingroup G_nonstandalone_wims
1846 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
1847 * Ignored by wimlib_reference_resources(). */
1848 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1850 /** For wimlib_reference_resource_files(), issue an error
1851 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1852 * default behavior without this flag is to issue no error at that point, but
1853 * then attempt to open the glob as a literal path, which of course will fail
1854 * anyway if no file exists at that path. No effect if
1855 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
1856 * wimlib_reference_resources(). */
1857 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1860 /** @ingroup G_modifying_wims
1863 /** The specific type of update to perform. */
1864 enum wimlib_update_op {
1865 /** Add a new file or directory tree to the WIM image in a
1866 * certain location. */
1867 WIMLIB_UPDATE_OP_ADD = 0,
1869 /** Delete a file or directory tree from the WIM image. */
1870 WIMLIB_UPDATE_OP_DELETE,
1872 /** Rename a file or directory tree in the WIM image. */
1873 WIMLIB_UPDATE_OP_RENAME,
1876 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1877 struct wimlib_add_command {
1878 /** Filesystem path to the file or directory tree to add. */
1879 wimlib_tchar *fs_source_path;
1881 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1882 * specify the root directory of the WIM image. */
1883 wimlib_tchar *wim_target_path;
1885 /** Path to capture configuration file to use, or @c NULL for default.
1887 wimlib_tchar *config_file;
1889 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1893 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1894 struct wimlib_delete_command {
1896 /** Path, specified from the root of the WIM image, for the file or
1897 * directory tree within the WIM image to be deleted. */
1898 wimlib_tchar *wim_path;
1900 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1904 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1905 struct wimlib_rename_command {
1907 /** Path, specified from the root of the WIM image, for the source file
1908 * or directory tree within the WIM image. */
1909 wimlib_tchar *wim_source_path;
1911 /** Path, specified from the root of the WIM image, for the destination
1912 * file or directory tree within the WIM image. */
1913 wimlib_tchar *wim_target_path;
1915 /** Reserved; set to 0. */
1919 /** Specification of an update to perform on a WIM image. */
1920 struct wimlib_update_command {
1922 enum wimlib_update_op op;
1925 struct wimlib_add_command add;
1926 struct wimlib_delete_command delete_; /* Underscore is for C++
1928 struct wimlib_rename_command rename;
1933 /** @ingroup G_general
1937 * Possible values of the error code returned by many functions in wimlib.
1939 * See the documentation for each wimlib function to see specifically what error
1940 * codes can be returned by a given function, and what they mean.
1942 enum wimlib_error_code {
1943 WIMLIB_ERR_SUCCESS = 0,
1944 WIMLIB_ERR_ALREADY_LOCKED,
1945 WIMLIB_ERR_DECOMPRESSION,
1946 WIMLIB_ERR_DELETE_STAGING_DIR,
1947 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1950 WIMLIB_ERR_FUSERMOUNT,
1951 WIMLIB_ERR_GLOB_HAD_NO_MATCHES,
1952 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1953 WIMLIB_ERR_IMAGE_COUNT,
1954 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1955 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES,
1956 WIMLIB_ERR_INTEGRITY,
1957 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1958 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1959 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1960 WIMLIB_ERR_INVALID_HEADER,
1961 WIMLIB_ERR_INVALID_IMAGE,
1962 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1963 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1964 WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1965 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1966 WIMLIB_ERR_INVALID_OVERLAY,
1967 WIMLIB_ERR_INVALID_PARAM,
1968 WIMLIB_ERR_INVALID_PART_NUMBER,
1969 WIMLIB_ERR_INVALID_PIPABLE_WIM,
1970 WIMLIB_ERR_INVALID_REPARSE_DATA,
1971 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1972 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1973 WIMLIB_ERR_INVALID_UTF16_STRING,
1974 WIMLIB_ERR_INVALID_UTF8_STRING,
1975 WIMLIB_ERR_IS_DIRECTORY,
1976 WIMLIB_ERR_IS_SPLIT_WIM,
1977 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1979 WIMLIB_ERR_METADATA_NOT_FOUND,
1984 WIMLIB_ERR_NOTEMPTY,
1985 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1986 WIMLIB_ERR_NOT_A_WIM_FILE,
1987 WIMLIB_ERR_NOT_PIPABLE,
1988 WIMLIB_ERR_NO_FILENAME,
1992 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1994 WIMLIB_ERR_READLINK,
1997 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1998 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1999 WIMLIB_ERR_RESOURCE_ORDER,
2000 WIMLIB_ERR_SET_ATTRIBUTES,
2001 WIMLIB_ERR_SET_REPARSE_DATA,
2002 WIMLIB_ERR_SET_SECURITY,
2003 WIMLIB_ERR_SET_SHORT_NAME,
2004 WIMLIB_ERR_SET_TIMESTAMPS,
2005 WIMLIB_ERR_SPLIT_INVALID,
2008 WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
2009 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
2010 WIMLIB_ERR_UNKNOWN_VERSION,
2011 WIMLIB_ERR_UNSUPPORTED,
2012 WIMLIB_ERR_UNSUPPORTED_FILE,
2013 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
2014 WIMLIB_ERR_WIM_IS_READONLY,
2017 WIMLIB_ERR_WIM_IS_ENCRYPTED,
2022 /** Used to indicate no WIM image or an invalid WIM image. */
2023 #define WIMLIB_NO_IMAGE 0
2025 /** Used to specify all images in the WIM. */
2026 #define WIMLIB_ALL_IMAGES (-1)
2031 * @ingroup G_modifying_wims
2033 * Appends an empty image to a WIM file. This empty image will initially
2034 * contain no files or directories, although if written without further
2035 * modifications, a root directory will be created automatically for it. After
2036 * calling this function, you can use wimlib_update_image() to add files to the
2037 * new WIM image. This gives you slightly more control over making the new
2038 * image compared to calling wimlib_add_image() or
2039 * wimlib_add_image_multisource() directly.
2042 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2045 * Name to give the new image. If @c NULL or empty, the new image is given
2046 * no name. If nonempty, it must specify a name that does not already
2048 * @param new_idx_ret
2049 * If non-<code>NULL</code>, the index of the newly added image is returned
2052 * @return 0 on success; nonzero on failure. The possible error codes are:
2054 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2055 * There is already an image in @p wim named @p name.
2056 * @retval ::WIMLIB_ERR_NOMEM
2057 * Failed to allocate the memory needed to add the new image.
2058 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2059 * The WIM file is considered read-only because of any of the reasons
2060 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2064 wimlib_add_empty_image(WIMStruct *wim,
2065 const wimlib_tchar *name,
2069 * @ingroup G_modifying_wims
2071 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2073 * The directory tree or NTFS volume is scanned immediately to load the dentry
2074 * tree into memory, and file attributes and symbolic links are read. However,
2075 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2078 * See the manual page for the @b wimlib-imagex program for more information
2079 * about the "normal" capture mode versus the NTFS capture mode (entered by
2080 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2082 * Note that @b no changes are committed to the underlying WIM file (if
2083 * any) until wimlib_write() or wimlib_overwrite() is called.
2086 * Pointer to the ::WIMStruct for a WIM file to which the image will be
2089 * A path to a directory or unmounted NTFS volume that will be captured as
2092 * Name to give the new image. If @c NULL or empty, the new image is given
2093 * no name. If nonempty, it must specify a name that does not already
2095 * @param config_file
2096 * Path to capture configuration file, or @c NULL. This file may specify,
2097 * among other things, which files to exclude from capture. See the man
2098 * page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2099 * details of the file format. If @c NULL, the default capture
2100 * configuration shall be used. Ordinarily, the default capture
2101 * configuration will result in no files being excluded from capture purely
2102 * based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2103 * ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2105 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2106 * @param progress_func
2107 * If non-NULL, a function that will be called periodically with the
2108 * progress of the current operation. The progress messages that will be
2109 * received are ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
2110 * ::WIMLIB_PROGRESS_MSG_SCAN_END, and, if ::WIMLIB_ADD_FLAG_VERBOSE was
2111 * included in @p add_flags, also ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2113 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2114 * discarded so that it appears to be in the same state as when this function
2117 * This function is implemented by calling wimlib_add_empty_image(), then
2118 * calling wimlib_update_image() with a single "add" command, so any error code
2119 * returned by wimlib_add_empty_image() may be returned, as well as any error
2120 * codes returned by wimlib_update_image() other than ones documented as only
2121 * being returned specifically by an update involving delete or rename commands.
2124 wimlib_add_image(WIMStruct *wim,
2125 const wimlib_tchar *source,
2126 const wimlib_tchar *name,
2127 const wimlib_tchar *config_file,
2129 wimlib_progress_func_t progress_func);
2132 * @ingroup G_modifying_wims
2134 * This function is equivalent to wimlib_add_image() except it allows for
2135 * multiple sources to be combined into a single WIM image. This is done by
2136 * specifying the @p sources and @p num_sources parameters instead of the @p
2137 * source parameter of wimlib_add_image(). The rest of the parameters are the
2138 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2139 * capture</b> for full details on how this mode works.
2141 * In addition to the error codes that wimlib_add_image() can return,
2142 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2143 * when trying to overlay a non-directory on a directory or when otherwise
2144 * trying to overlay multiple conflicting files to the same location in the WIM
2145 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2146 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2147 * was not exactly one capture source with the target being the root directory.
2148 * (In this respect, there is no advantage to using
2149 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2152 wimlib_add_image_multisource(WIMStruct *wim,
2153 const struct wimlib_capture_source *sources,
2155 const wimlib_tchar *name,
2156 const wimlib_tchar *config_file,
2158 wimlib_progress_func_t progress_func);
2161 * @ingroup G_modifying_wims
2163 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2164 * location @p wim_target_path within the specified @p image of the @p wim.
2166 * This just builds an appropriate ::wimlib_add_command and passes it to
2167 * wimlib_update_image().
2170 wimlib_add_tree(WIMStruct *wim, int image,
2171 const wimlib_tchar *fs_source_path,
2172 const wimlib_tchar *wim_target_path, int add_flags);
2175 * @ingroup G_creating_and_opening_wims
2177 * Creates a ::WIMStruct for a new WIM file.
2179 * This only creates an in-memory structure for a WIM that initially contains no
2180 * images. No on-disk file is created until wimlib_write() is called.
2183 * The type of compression to be used in the new WIM file, as one of the
2184 * ::wimlib_compression_type constants.
2186 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2187 * written to the memory location pointed to by this paramater. The
2188 * ::WIMStruct must be freed using using wimlib_free() when finished with
2190 * @return 0 on success; nonzero on error.
2191 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2192 * @p ctype was not a supported compression type.
2193 * @retval ::WIMLIB_ERR_NOMEM
2194 * Failed to allocate needed memory.
2197 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2200 * @ingroup G_modifying_wims
2202 * Deletes an image, or all images, from a WIM file.
2204 * All streams referenced by the image(s) being deleted are removed from the
2205 * lookup table of the WIM if they are not referenced by any other images in the
2208 * Please note that @b no changes are committed to the underlying WIM file (if
2209 * any) until wimlib_write() or wimlib_overwrite() is called.
2212 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2215 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2217 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2218 * to be left unmodified only if @p image specified a single image. If instead
2219 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2220 * possible for some but not all of the images to have been deleted when a
2221 * failure status is returned.
2223 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2224 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2225 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2226 * The WIM file is considered read-only because of any of the reasons
2227 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2230 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2231 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2232 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2233 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2234 * different reasons) to read the metadata resource for an image that needed to
2238 wimlib_delete_image(WIMStruct *wim, int image);
2241 * @ingroup G_modifying_wims
2243 * Delete the @p path from the specified @p image of the @p wim.
2245 * This just builds an appropriate ::wimlib_delete_command and passes it to
2246 * wimlib_update_image().
2249 wimlib_delete_path(WIMStruct *wim, int image,
2250 const wimlib_tchar *path, int delete_flags);
2253 * @ingroup G_modifying_wims
2255 * Exports an image, or all the images, from a WIM file, into another WIM file.
2257 * The destination image is made to share the same dentry tree and security data
2258 * structure as the source image. This places some restrictions on additional
2259 * functions that may be called. wimlib_mount_image() may not be called on
2260 * either the source image or the destination image without an intervening call
2261 * to a function that un-shares the images, such as wimlib_free() on @p
2262 * dest_wim, or wimlib_delete_image() on either the source or destination image.
2263 * Furthermore, you may not call wimlib_free() on @p src_wim before calling
2264 * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
2265 * have references back to @p src_wim.
2267 * If this function fails, all changes to @p dest_wim are rolled back.
2269 * Please note that no changes are committed to the underlying WIM file of @p
2270 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2273 * The WIM from which to export the images, specified as a pointer to the
2274 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2275 * split WIM. In the case of a WIM file that is not standalone, this
2276 * ::WIMStruct must have had any needed external resources previously
2277 * referenced using wimlib_reference_resources() or
2278 * wimlib_reference_resource_files().
2280 * The image to export from @p src_wim, as either a 1-based image index to
2281 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2283 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2286 * For single-image exports, the name to give the exported image in @p
2287 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2288 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2289 * that case, the names are all taken from @p src_wim. This parameter is
2290 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2291 * @param dest_description
2292 * For single-image exports, the description to give the exported image in
2293 * the new WIM file. If left @c NULL, the description from @p src_wim is
2294 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2295 * NULL; in that case, the description are all taken from @p src_wim. This
2296 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2297 * @param export_flags
2298 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2299 * @param progress_func
2300 * Currently ignored, but reserved for a function that will be called with
2301 * information about the operation. Use NULL if no additional information
2304 * @return 0 on success; nonzero on error.
2305 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2306 * One or more of the names being given to an exported image was already in
2307 * use in the destination WIM.
2308 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2309 * @p src_image does not exist in @p src_wim and was not
2310 * ::WIMLIB_ALL_IMAGES.
2311 * @retval ::WIMLIB_ERR_INVALID_PARAM
2312 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2313 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2315 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2316 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2317 * example, one of them was a non-first part of a split WIM.
2318 * @retval ::WIMLIB_ERR_NOMEM
2319 * Failed to allocate needed memory.
2320 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2321 * A resource that needed to be exported could not be found in either the
2322 * source or destination WIMs. This error can occur if, for example, @p
2323 * src_wim is part of a split WIM but needed resources from the other split
2324 * WIM parts were not referenced with wimlib_reference_resources() or
2325 * wimlib_reference_resource_files() before the call to
2326 * wimlib_export_image().
2327 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2328 * @p dest_wim is considered read-only because of any of the reasons
2329 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2332 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2333 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2334 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2335 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2336 * different reasons) to read the metadata resource for an image in @p src_wim
2337 * that needed to be exported.
2340 wimlib_export_image(WIMStruct *src_wim, int src_image,
2341 WIMStruct *dest_wim,
2342 const wimlib_tchar *dest_name,
2343 const wimlib_tchar *dest_description,
2345 wimlib_progress_func_t progress_func);
2349 * @ingroup G_extracting_wims
2351 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2354 * The exact behavior of how wimlib extracts files from a WIM image is
2355 * controllable by the @p extract_flags parameter, but there also are
2356 * differences depending on the platform (UNIX-like vs Windows). See the manual
2357 * page for <b>wimlib-imagex apply</b> for more information, including about the
2358 * special "NTFS volume extraction mode" entered by providing
2359 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2362 * The WIM from which to extract the image(s), specified as a pointer to
2363 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2364 * of a split WIM. In the case of a WIM file that is not standalone, this
2365 * ::WIMStruct must have had any needed external resources previously
2366 * referenced using wimlib_reference_resources() or
2367 * wimlib_reference_resource_files().
2369 * The image to extract, specified as either the 1-based index of a single
2370 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2371 * to be extracted. ::WIMLIB_ALL_IMAGES cannot be used if
2372 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2374 * Directory to extract the WIM image(s) to; or, with
2375 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2376 * the unmounted NTFS volume to which to extract the image.
2377 * @param extract_flags
2378 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2379 * @param progress_func
2380 * If non-NULL, a function that will be called periodically with the
2381 * progress of the current operation. The main message to look for is
2382 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS; however, there are others as
2385 * @return 0 on success; nonzero on error.
2386 * @retval ::WIMLIB_ERR_DECOMPRESSION
2387 * Failed to decompress data contained in the WIM.
2388 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2389 * The metadata for one of the images to extract was invalid.
2390 * @retval ::WIMLIB_ERR_INVALID_PARAM
2391 * The extraction flags were invalid; more details may be found in the
2392 * documentation for the specific extraction flags that were specified. Or
2393 * @p target was @c NULL or the empty string, or @p wim was @c NULL.
2394 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2395 * The SHA1 message digest of an extracted stream did not match the SHA1
2396 * message digest given in the WIM.
2397 * @retval ::WIMLIB_ERR_LINK
2398 * Failed to create a symbolic link or a hard link.
2399 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2400 * The metadata resource for one of the images to extract was not found.
2401 * This can happen if @p wim represents a non-first part of a split WIM.
2402 * @retval ::WIMLIB_ERR_MKDIR
2403 * Failed create a directory.
2404 * @retval ::WIMLIB_ERR_NOMEM
2405 * Failed to allocate needed memory.
2406 * @retval ::WIMLIB_ERR_OPEN
2407 * Could not create a file, or failed to open an already-extracted file.
2408 * @retval ::WIMLIB_ERR_READ
2409 * Failed to read data from the WIM.
2410 * @retval ::WIMLIB_ERR_READLINK
2411 * Failed to determine the target of a symbolic link in the WIM.
2412 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2413 * Failed to fix the target of an absolute symbolic link (e.g. if the
2414 * target would have exceeded the maximum allowed length). (Only if
2415 * reparse data was supported by the extraction mode and
2416 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2418 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2419 * One of the files or directories that needed to be extracted referenced a
2420 * stream not present in the WIM's lookup table (or in any of the lookup
2421 * tables of the split WIM parts).
2422 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2423 * Failed to set attributes on a file.
2424 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2425 * Failed to set reparse data on a file (only if reparse data was supported
2426 * by the extraction mode).
2427 * @retval ::WIMLIB_ERR_SET_SECURITY
2428 * Failed to set security descriptor on a file
2429 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2431 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2432 * Failed to set the short name of a file (only if
2433 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2434 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2435 * Failed to set timestamps on a file (only if
2436 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2437 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2438 * Unexpected end-of-file occurred when reading data from the WIM.
2439 * @retval ::WIMLIB_ERR_UNSUPPORTED
2440 * A requested extraction flag, or the data or metadata that must be
2441 * extracted to support it, is unsupported in the build and configuration
2442 * of wimlib, or on the current platform or extraction mode or target
2443 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2444 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2445 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2446 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2447 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2448 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2449 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2450 * image contains one or more files with short names, but extracting short
2451 * names is not supported --- on Windows, this occurs if the target volume
2452 * does not support short names, while on non-Windows, this occurs if
2453 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2454 * @retval ::WIMLIB_ERR_WIMBOOT
2455 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2456 * there was a problem creating WIMBoot pointer files.
2457 * @retval ::WIMLIB_ERR_WRITE
2458 * Failed to write data to a file being extracted.
2461 wimlib_extract_image(WIMStruct *wim, int image,
2462 const wimlib_tchar *target,
2464 wimlib_progress_func_t progress_func);
2467 * @ingroup G_extracting_wims
2469 * Since wimlib v1.5.0: Extract one image from a pipe on which a pipable WIM is
2472 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2473 * about pipable WIMs.
2475 * This function operates in a special way to read the WIM fully sequentially.
2476 * As a result, there is no ::WIMStruct is made visible to library users, and
2477 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2478 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2479 * seekable file, not a pipe.)
2482 * File descriptor, which may be a pipe, opened for reading and positioned
2483 * at the start of the pipable WIM.
2484 * @param image_num_or_name
2485 * String that specifies the 1-based index or name of the image to extract.
2486 * It is translated to an image index using the same rules that
2487 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2488 * only a single image (not all images) can be specified. Alternatively,
2489 * specify @p NULL here to use the first image in the WIM if it contains
2490 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2492 * Same as the corresponding parameter to wimlib_extract_image().
2493 * @param extract_flags
2494 * Same as the corresponding parameter to wimlib_extract_image().
2495 * @param progress_func
2496 * Same as the corresponding parameter to wimlib_extract_image(), except
2497 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
2498 * received by the progress function.
2500 * @return 0 on success; nonzero on error. The possible error codes include
2501 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2504 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2505 * Data read from the pipable WIM was invalid.
2506 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2507 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2510 wimlib_extract_image_from_pipe(int pipe_fd,
2511 const wimlib_tchar *image_num_or_name,
2512 const wimlib_tchar *target, int extract_flags,
2513 wimlib_progress_func_t progress_func);
2516 * @ingroup G_extracting_wims
2518 * Since wimlib v1.6.0: Similar to wimlib_extract_paths(), but the paths to
2519 * extract from the WIM image are specified in the UTF-8 text file named by @p
2520 * path_list_file which itself contains the list of paths to use, one per line.
2521 * Leading and trailing whitespace, and otherwise empty lines and lines
2522 * beginning with the ';' character are ignored. No quotes are needed as paths
2523 * are otherwise delimited by the newline character.
2525 * The error codes are the same as those returned by wimlib_extract_paths(),
2526 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2527 * cannot read the path list file (::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2528 * ::WIMLIB_ERR_READ, ::WIMLIB_ERR_NOMEM, or ::WIMLIB_ERR_INVALID_UTF8_STRING).
2531 wimlib_extract_pathlist(WIMStruct *wim, int image,
2532 const wimlib_tchar *target,
2533 const wimlib_tchar *path_list_file,
2535 wimlib_progress_func_t progress_func);
2538 * @ingroup G_extracting_wims
2540 * Since wimlib v1.6.0: Extract zero or more paths (files or directory trees)
2541 * from the specified WIM image.
2543 * By default, each path will be extracted to a corresponding subdirectory of
2544 * the target based on its location in the WIM image. For example, if one of
2545 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2546 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
2547 * can be changed by providing the flag
2548 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2549 * or directory tree to be placed directly in the target directory --- so the
2550 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2552 * Symbolic links will not be dereferenced when paths in the WIM image are
2556 * WIM from which to extract the paths, specified as a pointer to the
2557 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2558 * split WIM. In the case of a WIM file that is not standalone, this
2559 * ::WIMStruct must have had any needed external resources previously
2560 * referenced using wimlib_reference_resources() or
2561 * wimlib_reference_resource_files().
2563 * 1-based index of the WIM image from which to extract the paths.
2565 * Array of paths to extract. Each element must be the absolute path to a
2566 * file or directory within the WIM image. Separators may be either
2567 * forwards or backwards slashes, and leading path separators are optional.
2568 * The paths will be interpreted either case-sensitively (UNIX default) or
2569 * case-insensitively (Windows default); this can be changed by
2570 * wimlib_global_init().
2572 * By default, the characters @c * and @c ? are interpreted literally.
2573 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2576 * By default, if any paths to extract do not exist, the error code
2577 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
2578 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2580 * Number of paths specified in @p paths.
2582 * Directory to which to extract the paths; or with
2583 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2584 * unmounted NTFS volume to which to extract the paths. Unlike the @p
2585 * paths being extracted, the @p target must be native path. On UNIX-like
2586 * systems it may not contain backslashes, for example.
2587 * @param extract_flags
2588 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2589 * @param progress_func
2590 * If non-NULL, a function that will be called periodically with the
2591 * progress of the current operation. The main message to look for is
2592 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS; however, there are others as
2593 * well. Note: because the extraction code is stream-based and not
2594 * file-based, there is no way to get information about which path is
2595 * currently being extracted, but based on byte count you can still
2596 * calculate an approximate percentage complete for the extraction overall
2597 * which may be all you really need anyway.
2599 * @return 0 on success; nonzero on error. Most of the error codes are the same
2600 * as those returned by wimlib_extract_image(). Below, some of the error codes
2601 * returned in situations specific to path-mode extraction are documented:
2603 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2604 * @p image was ::WIMLIB_ALL_IMAGES or was otherwise not a valid single
2606 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2607 * One of the paths to extract did not exist in the WIM image. This error
2608 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2609 * specified in @p extract_flags, or if both
2610 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2611 * were specified in @p extract_flags.
2612 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2613 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2614 * one of the paths to extract did not name a regular file.
2617 wimlib_extract_paths(WIMStruct *wim,
2619 const wimlib_tchar *target,
2620 const wimlib_tchar * const *paths,
2623 wimlib_progress_func_t progress_func);
2626 * @ingroup G_wim_information
2628 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2629 * includes a string of XML that describes the images contained in the WIM.
2631 * See wimlib_get_xml_data() to read the XML data into memory instead.
2634 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2635 * have to be standalone (e.g. it could be part of a split WIM).
2637 * @c stdout, or a FILE* opened for writing, to extract the data to.
2639 * @return 0 on success; nonzero on error.
2640 * @retval ::WIMLIB_ERR_INVALID_PARAM
2641 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2642 * @retval ::WIMLIB_ERR_NOMEM
2643 * @retval ::WIMLIB_ERR_READ
2644 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2645 * Failed to read the XML data from the WIM.
2646 * @retval ::WIMLIB_ERR_WRITE
2647 * Failed to completely write the XML data to @p fp.
2650 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2653 * @ingroup G_general
2655 * Frees all memory allocated for a WIMStruct and closes all files associated
2659 * Pointer to the ::WIMStruct for a WIM file.
2661 * @return This function has no return value.
2664 wimlib_free(WIMStruct *wim);
2667 * @ingroup G_general
2669 * Converts a ::wimlib_compression_type value into a string.
2672 * The ::wimlib_compression_type value to convert.
2675 * A statically allocated string naming the compression algorithm,
2676 * such as "None", "LZX", "XPRESS", or "Invalid".
2678 extern const wimlib_tchar *
2679 wimlib_get_compression_type_string(int ctype);
2682 * @ingroup G_general
2684 * Converts an error code into a string describing it.
2687 * The error code returned by one of wimlib's functions.
2690 * Pointer to a statically allocated string describing the error code,
2691 * or @c NULL if the error code is not valid.
2693 extern const wimlib_tchar *
2694 wimlib_get_error_string(enum wimlib_error_code code);
2697 * @ingroup G_wim_information
2699 * Returns the description of the specified image.
2702 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2703 * to be standalone (e.g. it could be part of a split WIM).
2705 * The number of the image, numbered starting at 1.
2708 * The description of the image, or @c NULL if there is no such image, or
2709 * @c NULL if the specified image has no description. The description
2710 * string is in library-internal memory and may not be modified or freed;
2711 * in addition, the string will become invalid if the description of the
2712 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2714 extern const wimlib_tchar *
2715 wimlib_get_image_description(const WIMStruct *wim, int image);
2718 * @ingroup G_wim_information
2720 * Returns the name of the specified image.
2723 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2724 * to be standalone (e.g. it could be part of a split WIM).
2726 * The number of the image, numbered starting at 1.
2729 * The name of the image, or @c NULL if there is no such image, or an empty
2730 * string if the image is unnamed. The name string is in
2731 * library-internal memory and may not be modified or freed; in addition,
2732 * the string will become invalid if the name of the image is changed, the
2733 * image is deleted, or the ::WIMStruct is destroyed.
2735 extern const wimlib_tchar *
2736 wimlib_get_image_name(const WIMStruct *wim, int image);
2739 * @ingroup G_general
2741 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
2742 * the major version, the next 10 bits contain the minor version, and the low 10
2743 * bits contain the patch version.
2745 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
2746 * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
2747 * corresponding header file.
2750 wimlib_get_version(void);
2753 * @ingroup G_wim_information
2755 * Get basic information about a WIM file.
2758 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2759 * to be standalone (e.g. it could be part of a split WIM).
2761 * A ::wimlib_wim_info structure that will be filled in with information
2762 * about the WIM file.
2767 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2770 * @ingroup G_wim_information
2772 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
2773 * includes a string of XML that describes the images contained in the WIM.
2775 * See wimlib_extract_xml_data() to extract the XML data to a file stream
2779 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2780 * have to be standalone (e.g. it could be part of a split WIM).
2782 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
2783 * XML data is written to this location.
2784 * @param bufsize_ret
2785 * The size of the XML data in bytes is written to this location.
2787 * @return 0 on success; nonzero on error.
2788 * @retval ::WIMLIB_ERR_INVALID_PARAM
2789 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2790 * @p buf_ret or @p bufsize_ret was @c NULL.
2791 * @retval ::WIMLIB_ERR_NOMEM
2792 * @retval ::WIMLIB_ERR_READ
2793 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2794 * Failed to read the XML data from the WIM.
2797 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2800 * @ingroup G_general
2802 * Initialization function for wimlib. Call before using any other wimlib
2803 * function except wimlib_set_print_errors(). If not done manually, this
2804 * function will be called automatically with @p init_flags set to
2805 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
2806 * after it has already successfully run.
2809 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2811 * @return 0 on success; nonzero on failure. Currently, only the following
2812 * error code is defined:
2814 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2815 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2816 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2817 * init_flags, but the corresponding privileges could not be acquired.
2820 wimlib_global_init(int init_flags);
2823 * @ingroup G_general
2825 * Cleanup function for wimlib. You are not required to call this function, but
2826 * it will release any global resources allocated by the library.
2829 wimlib_global_cleanup(void);
2832 * @ingroup G_wim_information
2834 * Determines if an image name is already used by some image in the WIM.
2837 * Pointer to the ::WIMStruct for a WIM file.
2839 * The name to check.
2842 * @c true if there is already an image in @p wim named @p name; @c false
2843 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2844 * the empty string, @c false is returned.
2847 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2850 * @ingroup G_wim_information
2852 * Iterate through a file or directory tree in the WIM image. By specifying
2853 * appropriate flags and a callback function, you can get the attributes of a
2854 * file in the WIM, get a directory listing, or even get a listing of the entire
2858 * The WIM containing the image(s) over which to iterate, specified as a
2859 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2860 * or part 1 of a split WIM. In the case of a WIM file that is not
2861 * standalone, this ::WIMStruct should have had any needed external
2862 * resources previously referenced using wimlib_reference_resources() or
2863 * wimlib_reference_resource_files(). If not, see
2864 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2865 * the behavior when resources are missing.
2868 * The 1-based number of the image in @p wim that contains the files or
2869 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2870 * iteration on all images in the WIM.
2873 * Path in the WIM image at which to do the iteration.
2876 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2879 * A callback function that will receive each directory entry.
2882 * An extra parameter that will always be passed to the callback function
2885 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2886 * first nonzero value that was returned from @p cb. However, additional error
2887 * codes may be returned, including the following:
2889 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2890 * @p path did not exist in the WIM image.
2891 * @retval ::WIMLIB_ERR_NOMEM
2892 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2894 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2895 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2896 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2897 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2898 * different reasons) to read the metadata resource for an image over which
2899 * iteration needed to be done.
2902 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2904 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2907 * @ingroup G_wim_information
2909 * Iterate through the lookup table of a WIM file. This can be used to directly
2910 * get a listing of the unique resources contained in a WIM file over all
2911 * images. Both file resources and metadata resources are included. However,
2912 * only resources actually included in the file represented by @a wim, plus
2913 * explicitly referenced external resources (via wimlib_reference_resources() or
2914 * wimlib_reference_resource_files()) are included in the iteration. For
2915 * example, if @p wim represents just one part of a split WIM, then only
2916 * resources in that part will be included, unless other resources were
2917 * explicitly referenced.
2920 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2921 * to be standalone (e.g. it could be part of a split WIM).
2924 * Reserved; set to 0.
2927 * A callback function that will receive each resource.
2930 * An extra parameter that will always be passed to the callback function
2933 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
2934 * that was returned from @p cb.
2937 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2938 wimlib_iterate_lookup_table_callback_t cb,
2942 * @ingroup G_nonstandalone_wims
2944 * Joins a split WIM into a stand-alone one-part WIM.
2947 * An array of strings that gives the filenames of all parts of the split
2948 * WIM. No specific order is required, but all parts must be included with
2951 * Number of filenames in @p swms.
2952 * @param swm_open_flags
2953 * Open flags for the split WIM parts (e.g.
2954 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
2955 * @param wim_write_flags
2956 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
2957 * be used to write the joined WIM.
2958 * @param output_path
2959 * The path to write the joined WIM file to.
2960 * @param progress_func
2961 * If non-NULL, a function that will be called periodically with the
2962 * progress of the current operation.
2964 * @return 0 on success; nonzero on error. This function may return most error
2965 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
2966 * as the following error code:
2968 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2969 * The split WIMs do not form a valid WIM because they do not include all
2970 * the parts of the original WIM, there are duplicate parts, or not all the
2971 * parts have the same GUID and compression type.
2973 * Note: wimlib is generalized enough that this function is not actually needed
2974 * to join a split WIM; instead, you could open the first part of the split WIM,
2975 * then reference the other parts with wimlib_reference_resource_files(), then
2976 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
2977 * an easy-to-use wrapper around this that has some advantages (e.g. extra
2981 wimlib_join(const wimlib_tchar * const *swms,
2983 const wimlib_tchar *output_path,
2985 int wim_write_flags,
2986 wimlib_progress_func_t progress_func);
2990 * @ingroup G_mounting_wim_images
2992 * Mounts an image in a WIM file on a directory read-only or read-write.
2994 * As this is implemented using FUSE (Filesystme in UserSpacE), this is not
2995 * supported if wimlib was configured with @c --without-fuse. This includes
2996 * Windows builds of wimlib; ::WIMLIB_ERR_UNSUPPORTED will be returned in such
2999 * Calling this function daemonizes the process, unless
3000 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early occur occurs. If the
3001 * mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified), modifications
3002 * to the WIM are staged in a temporary directory.
3004 * It is safe to mount multiple images from the same underlying WIM file
3005 * read-only at the same time, but only if different ::WIMStruct's are used. It
3006 * is @b not safe to mount multiple images from the same WIM file read-write at
3009 * wimlib_mount_image() cannot be used on an image that was exported with
3010 * wimlib_export_image() while the dentry trees for both images are still in
3011 * memory. In addition, wimlib_mount_image() may not be used to mount an image
3012 * that already has modifications pending (e.g. an image added with
3013 * wimlib_add_image()).
3016 * Pointer to the ::WIMStruct containing the image to be mounted.
3018 * The number of the image to mount, indexed starting from it. It must be
3019 * an existing, single image.
3021 * The path to an existing empty directory to mount the image on.
3022 * @param mount_flags
3023 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG.
3024 * @param staging_dir
3025 * If non-NULL, the name of a directory in which the staging directory will
3026 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
3027 * in @p mount_flags. If left @c NULL, the staging directory is created in
3028 * the same directory as the WIM file that @p wim was originally read from.
3030 * @return 0 on success; nonzero on error.
3032 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3033 * A read-write mount was requested, but an exclusive advisory lock on
3034 * the on-disk WIM file could not be acquired because another thread or
3035 * process has mounted an image from the WIM read-write or is currently
3036 * modifying the WIM in-place.
3037 * @retval ::WIMLIB_ERR_FUSE
3038 * A non-zero status was returned by @c fuse_main().
3039 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3040 * @p image does not specify an existing, single image in @p wim.
3041 * @retval ::WIMLIB_ERR_INVALID_PARAM
3042 * @p image is shared among multiple ::WIMStruct's as a result of a call to
3043 * wimlib_export_image(), or @p image has been added with
3044 * wimlib_add_image().
3045 * @retval ::WIMLIB_ERR_MKDIR
3046 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3047 * staging directory could not be created.
3048 * @retval ::WIMLIB_ERR_NOTDIR
3049 * Could not determine the current working directory.
3050 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3051 * One of the dentries in the image referenced a stream not present in the
3052 * WIM's lookup table (or in any of the lookup tables of the split WIM
3054 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3055 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but @p
3056 * wim is considered read-only because of any of the reasons mentioned in
3057 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3058 * @retval ::WIMLIB_ERR_UNSUPPORTED
3059 * Mounting is not supported, either because the platform is Windows, or
3060 * because the platform is UNIX-like and wimlib was compiled with @c
3063 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3064 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3065 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3066 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3067 * different reasons) to read the metadata resource for the image to mount.
3070 wimlib_mount_image(WIMStruct *wim,
3072 const wimlib_tchar *dir,
3074 const wimlib_tchar *staging_dir);
3077 * @ingroup G_creating_and_opening_wims
3079 * Opens a WIM file and creates a ::WIMStruct for it.
3082 * The path to the WIM file to open.
3085 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3087 * @param progress_func
3088 * If non-NULL, a function that will be called periodically with the
3089 * progress of the current operation. Currently, the only messages sent
3090 * will be ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY, and only if
3091 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags.
3094 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3095 * is written to the memory location pointed to by this parameter. The
3096 * ::WIMStruct can be freed using using wimlib_free() when finished with
3099 * @return 0 on success; nonzero on error.
3100 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3101 * The WIM is not the non-first part of a split WIM, and the number of
3102 * metadata resources found in the WIM did not match the image count given
3103 * in the WIM header, or the number of <IMAGE> elements in the XML
3104 * data for the WIM did not match the image count given in the WIM header.
3105 * @retval ::WIMLIB_ERR_INTEGRITY
3106 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
3107 * wim_file contains an integrity table, but the SHA1 message digest for a
3108 * chunk of the WIM does not match the corresponding message digest given
3109 * in the integrity table.
3110 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3111 * Resources in @p wim_file are compressed, but the chunk size was invalid
3112 * for the WIM's compression type.
3113 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3114 * The header of @p wim_file says that resources in the WIM are compressed,
3115 * but the header flag for a recognized compression type is not set.
3116 * @retval ::WIMLIB_ERR_INVALID_HEADER
3117 * The header of @p wim_file was otherwise invalid.
3118 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3119 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
3120 * wim_file contains an integrity table, but the integrity table is
3122 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3123 * The lookup table for the WIM was invalid.
3124 * @retval ::WIMLIB_ERR_INVALID_PARAM
3125 * @p wim_ret was @c NULL.
3126 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3127 * @p wim_file is a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3128 * specified in @p open_flags.
3129 * @retval ::WIMLIB_ERR_NOMEM
3130 * Failed to allocated needed memory.
3131 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3132 * @p wim_file does not begin with the expected magic characters.
3133 * @retval ::WIMLIB_ERR_OPEN
3134 * Failed to open the file @p wim_file for reading.
3135 * @retval ::WIMLIB_ERR_READ
3136 * Failed to read data from @p wim_file.
3137 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3138 * Unexpected end-of-file while reading data from @p wim_file.
3139 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3140 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3141 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3142 * The WIM cannot be opened because it contains encrypted segments. (It
3143 * may be a Windows 8 "ESD" file).
3144 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3145 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3146 * considered read-only because of any of the reasons mentioned in the
3147 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3148 * @retval ::WIMLIB_ERR_XML
3149 * The XML data for @p wim_file is invalid.
3152 wimlib_open_wim(const wimlib_tchar *wim_file,
3154 WIMStruct **wim_ret,
3155 wimlib_progress_func_t progress_func);
3158 * @ingroup G_writing_and_overwriting_wims
3160 * Overwrites the file that the WIM was originally read from, with changes made.
3161 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3162 * rather than wimlib_create_new_wim().
3164 * There are two ways that a WIM may be overwritten. The first is to do a full
3165 * rebuild. In this mode, the new WIM is written to a temporary file and then
3166 * renamed to the original file after it is has been completely written. The
3167 * temporary file is made in the same directory as the original WIM file. A
3168 * full rebuild may take a while, but can be used even if images have been
3169 * modified or deleted, will produce a WIM with no holes, and has little chance
3170 * of unintentional data loss because the temporary WIM is fsync()ed before
3171 * being renamed to the original WIM.
3173 * The second way to overwrite a WIM is by appending to the end of it and
3174 * overwriting the header. This can be much faster than a full rebuild, but the
3175 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3176 * begins with writing any new file resources *after* everything in the old WIM,
3177 * even though this will leave a hole where the old lookup table, XML data, and
3178 * integrity were. This is done so that the WIM remains valid even if the
3179 * operation is aborted mid-write. The WIM header is only overwritten at the
3180 * very last moment, and up until that point the WIM will be seen as the old
3183 * By default, wimlib_overwrite() does the append-style overwrite described
3184 * above, unless resources in the WIM are arranged in an unusual way or if
3185 * images have been deleted from the WIM. Use the flag
3186 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3187 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3188 * images have been deleted from the WIM.
3190 * In the temporary-file overwrite mode, no changes are made to the WIM on
3191 * failure, and the temporary file is deleted if possible. Abnormal termination
3192 * of the program will result in the temporary file being orphaned. In the
3193 * direct append mode, the WIM is truncated to the original length on failure;
3194 * and while abnormal termination of the program will result in extra data
3195 * appended to the original WIM, it should still be a valid WIM.
3197 * If this function completes successfully, no more functions should be called
3198 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
3199 * the WIM file anew.
3202 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3203 * been in-memory changes made to it, which are then reflected in the
3205 * @param write_flags
3206 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3207 * @param num_threads
3208 * Number of threads to use for compression (see wimlib_write()).
3209 * @param progress_func
3210 * If non-NULL, a function that will be called periodically with the
3211 * progress of the current operation.
3213 * @return 0 on success; nonzero on error. This function may return most error
3214 * codes returned by wimlib_write() as well as the following error codes:
3216 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3217 * The WIM was going to be modified in-place (with no temporary file), but
3218 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3219 * because another thread or process has mounted an image from the WIM
3220 * read-write or is currently modifying the WIM in-place.
3221 * @retval ::WIMLIB_ERR_NO_FILENAME
3222 * @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
3223 * than a WIM read with wimlib_open_wim().
3224 * @retval ::WIMLIB_ERR_RENAME
3225 * The temporary file that the WIM was written to could not be renamed to
3226 * the original filename of @p wim.
3227 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3228 * The WIM file is considered read-only because of any of the reasons
3229 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3233 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
3234 wimlib_progress_func_t progress_func);
3237 * @ingroup G_wim_information
3239 * Prints information about one image, or all images, contained in a WIM.
3242 * Pointer to the ::WIMStruct for a WIM file.
3244 * The image about which to print information. Can be the number of an
3245 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3248 * @return This function has no return value. No error checking is done when
3249 * printing the information. If @p image is invalid, an error message is
3253 wimlib_print_available_images(const WIMStruct *wim, int image);
3256 * @ingroup G_wim_information
3258 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3259 * in a way that can be accessed programatically.
3262 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3265 * @ingroup G_nonstandalone_wims
3267 * Reference resources from other WIM files or split WIM parts. This function
3268 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3269 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3270 * from other files, before calling a function such as wimlib_extract_image()
3271 * that requires the resources to be present.
3274 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3275 * necessarily "standalone". In the case of split WIMs, this should be the
3276 * first part, since only the first part contains the metadata resources.
3277 * In the case of delta WIMs, this should be the delta WIM rather than the
3278 * WIM on which it is based.
3279 * @param resource_wimfiles_or_globs
3280 * Array of paths to WIM files and/or split WIM parts to reference.
3281 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3282 * ref_flags, these are treated as globs rather than literal paths. That
3283 * is, using this function you can specify zero or more globs, each of
3284 * which expands to one or more literal paths.
3286 * Number of entries in @p resource_wimfiles_or_globs.
3288 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3289 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3291 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3292 * pass to internal calls to wimlib_open_wim() on the reference files.
3293 * @param progress_func
3294 * Passed to internal calls to wimlib_open_wim() on the reference files.
3296 * @return 0 on success; nonzero on error.
3298 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3299 * One of the specified globs did not match any paths (only with both
3300 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3301 * specified in @p ref_flags).
3302 * @retval ::WIMLIB_ERR_NOMEM
3303 * Failed to allocate memory.
3304 * @retval ::WIMLIB_ERR_READ
3305 * I/O or permissions error while processing a file glob.
3307 * This function can additionally return most values that can be returned by
3308 * wimlib_open_wim().
3311 wimlib_reference_resource_files(WIMStruct *wim,
3312 const wimlib_tchar * const *resource_wimfiles_or_globs,
3316 wimlib_progress_func_t progress_func);
3319 * @ingroup G_nonstandalone_wims
3321 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3322 * where the caller must open the ::WIMStruct for each referenced file itself.
3325 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3326 * necessarily "standalone". In the case of split WIMs, this should be the
3327 * first part, since only the first part contains the metadata resources.
3328 * @param resource_wims
3329 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3330 * split WIM parts to reference.
3331 * @param num_resource_wims
3332 * Number of entries in @p resource_wims.
3334 * Currently ignored (set to 0).
3336 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3337 * @p resource_wims are referenced internally by @p wim and must not be freed
3338 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3339 * been freed with wimlib_free(), or immediately before freeing @p wim with
3342 * @retval ::WIMLIB_ERR_INVALID_PARAM
3343 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3344 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3345 * @retval ::WIMLIB_ERR_NOMEM
3346 * Failed to allocate memory.
3349 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3350 unsigned num_resource_wims, int ref_flags);
3353 * @ingroup G_modifying_wims
3355 * Declares that a newly added image is mostly the same as a prior image, but
3356 * captured at a later point in time, possibly with some modifications in the
3357 * intervening time. This is designed to be used in incremental backups of the
3358 * same filesystem or directory tree.
3360 * This function compares the metadata of the directory tree of the newly added
3361 * image against that of the old image. Any files that are present in both the
3362 * newly added image and the old image and have timestamps that indicate they
3363 * haven't been modified are deemed not to have been modified and have their
3364 * SHA1 message digest copied from the old image. Because of this and because
3365 * WIM uses single-instance streams, such files need not be read from the
3366 * filesystem when the WIM is being written or overwritten. Note that these
3367 * unchanged files will still be "archived" and will be logically present in the
3368 * new image; the optimization is that they don't need to actually be read from
3369 * the filesystem because the WIM already contains them.
3371 * This function is provided to optimize incremental backups. The resulting WIM
3372 * file will still be the same regardless of whether this function is called.
3373 * (This is, however, assuming that timestamps have not been manipulated or
3374 * unmaintained as to trick this function into thinking a file has not been
3375 * modified when really it has. To partly guard against such cases, other
3376 * metadata such as file sizes will be checked as well.)
3378 * This function must be called after adding the new image (e.g. with
3379 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3380 * wimlib_overwrite()).
3383 * Pointer to the ::WIMStruct for a WIM.
3385 * 1-based index in the WIM of the newly added image. This image can have
3386 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3387 * wimlib_add_empty_image() followed by wimlib_update_image().
3388 * @param template_wim
3389 * The ::WIMStruct for the WIM containing the template image. This can be
3390 * the same as @p wim, or it can be a different ::WIMStruct.
3391 * @param template_image
3392 * 1-based index in the WIM of a template image that reflects a prior state
3393 * of the directory tree being captured.
3395 * Reserved; must be 0.
3396 * @param progress_func
3397 * Currently ignored, but reserved for a function that will be called with
3398 * information about the operation. Use NULL if no additional information
3401 * @return 0 on success; nonzero on error.
3403 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3404 * @p new_image and/or @p template_image were not a valid image indices in
3406 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3407 * The specified ::WIMStruct did not actually contain the metadata resource
3408 * for the new or template image; for example, it was a non-first part of a
3410 * @retval ::WIMLIB_ERR_NOMEM
3411 * Failed to allocate needed memory.
3412 * @retval ::WIMLIB_ERR_INVALID_PARAM
3413 * @p new_image was equal to @p template_image, or @p new_image specified
3414 * an image that had not been modified since opening the WIM.
3416 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3417 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3418 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3419 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3420 * different reasons) to read the metadata resource for the template image.
3423 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3424 WIMStruct *template_wim, int template_image,
3425 int flags, wimlib_progress_func_t progress_func);
3428 * @ingroup G_modifying_wims
3430 * Rename the @p source_path to the @p dest_path in the specified @p image of
3433 * This just builds an appropriate ::wimlib_rename_command and passes it to
3434 * wimlib_update_image().
3437 wimlib_rename_path(WIMStruct *wim, int image,
3438 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3441 * @ingroup G_wim_information
3443 * Translates a string specifying the name or number of an image in the WIM into
3444 * the number of the image. The images are numbered starting at 1.
3447 * Pointer to the ::WIMStruct for a WIM.
3448 * @param image_name_or_num
3449 * A string specifying the name or number of an image in the WIM. If it
3450 * parses to a positive integer, this integer is taken to specify the
3451 * number of the image, indexed starting at 1. Otherwise, it is taken to
3452 * be the name of an image, as given in the XML data for the WIM file. It
3453 * also may be the keyword "all" or the string "*", both of which will
3454 * resolve to ::WIMLIB_ALL_IMAGES.
3456 * There is no way to search for an image actually named "all", "*", or an
3457 * integer number, or an image that has no name. However, you can use
3458 * wimlib_get_image_name() to get the name of any image.
3461 * If the string resolved to a single existing image, the number of that
3462 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3463 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3464 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3465 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3466 * images in @p wim has no name.
3469 wimlib_resolve_image(WIMStruct *wim,
3470 const wimlib_tchar *image_name_or_num);
3473 * @ingroup G_modifying_wims
3475 * Changes the description of an image in the WIM.
3478 * Pointer to the ::WIMStruct for a WIM.
3480 * The number of the image for which to change the description.
3481 * @param description
3482 * The new description to give the image. It may be @c NULL, which
3483 * indicates that the image is to be given no description.
3485 * @return 0 on success; nonzero on error.
3486 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3487 * @p image does not specify a single existing image in @p wim.
3488 * @retval ::WIMLIB_ERR_NOMEM
3489 * Failed to allocate the memory needed to duplicate the @p description
3491 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3492 * @p wim is considered read-only because of any of the reasons mentioned
3493 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3496 wimlib_set_image_descripton(WIMStruct *wim, int image,
3497 const wimlib_tchar *description);
3500 * @ingroup G_writing_and_overwriting_wims
3502 * Set the compression chunk size of a WIM to use in subsequent calls to
3503 * wimlib_write() or wimlib_overwrite().
3505 * For compatibility reasons, using this function is not generally recommended.
3506 * See the documentation for the @c --chunk-size option of <b>wimlib-imagex
3507 * capture</b> for more information.
3509 * A larger compression chunk size will likely result in a better compression
3510 * ratio, but the speed of random access to the WIM will be reduced.
3511 * Furthermore, the effect of a larger compression chunk size is limited by the
3512 * size of each stream ("file") being compressed.
3515 * ::WIMStruct for a WIM.
3517 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3518 * on the compression format; see the documentation for the @c --chunk-size
3519 * option of <b>wimlib-imagex capture</b> for more information. As a
3520 * special case, if @p chunk_size is specified as 0, the chunk size is set
3521 * to the default for the currently selected output compression type.
3523 * @return 0 on success; nonzero on error.
3525 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3526 * @p chunk_size is not a supported chunk size for the currently selected
3527 * output compression type.
3530 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3533 * @ingroup G_writing_and_overwriting_wims
3535 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3536 * packed streams (solid blocks).
3539 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3542 * @ingroup G_writing_and_overwriting_wims
3544 * Set the compression type of a WIM to use in subsequent calls to
3545 * wimlib_write() or wimlib_overwrite().
3548 * ::WIMStruct for a WIM.
3550 * The compression type to set (one of ::wimlib_compression_type). If this
3551 * compression type is incompatible with the current output chunk size
3552 * (either the default or as set with wimlib_set_output_chunk_size()), the
3553 * output chunk size is reset to the default for that compression type.
3555 * @return 0 on success; nonzero on error.
3557 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3558 * @p ctype did not specify a valid compression type.
3561 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3564 * @ingroup G_writing_and_overwriting_wims
3566 * Similar to wimlib_set_output_compression_type(), but set the compression type
3567 * for writing packed streams (solid blocks).
3570 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3573 * @ingroup G_modifying_wims
3575 * Set basic information about a WIM.
3578 * Pointer to the ::WIMStruct for a WIM.
3580 * A struct ::wimlib_wim_info that contains the information to set. Only
3581 * the information explicitly specified in the @p which flags need be
3584 * Flags that specify which information to set. This is a bitwise OR of
3585 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3586 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3588 * @return 0 on success; nonzero on failure.
3589 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3590 * The WIM file is considered read-only because of any of the reasons
3591 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3592 * flag. However, as a special case, if you are using
3593 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3594 * function will not fail due to the readonly flag being previously set.
3595 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3596 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3597 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3601 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3605 * @ingroup G_modifying_wims
3607 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3608 * (something like "Core" or "Ultimate")
3611 * Pointer to the ::WIMStruct for a WIM.
3613 * The number of the image for which to change the description.
3615 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3616 * indicates that the image is to be given no \<FLAGS\> element.
3618 * @return 0 on success; nonzero on error.
3619 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3620 * @p image does not specify a single existing image in @p wim.
3621 * @retval ::WIMLIB_ERR_NOMEM
3622 * Failed to allocate the memory needed to duplicate the @p flags string.
3623 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3624 * @p wim is considered read-only because of any of the reasons mentioned
3625 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3628 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3631 * @ingroup G_modifying_wims
3633 * Changes the name of an image in the WIM.
3636 * Pointer to the ::WIMStruct for a WIM.
3638 * The number of the image for which to change the name.
3640 * New name to give the new image. If @c NULL or empty, the new image is
3641 * given no name. If nonempty, it must specify a name that does not
3642 * already exist in @p wim.
3644 * @return 0 on success; nonzero on error.
3645 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3646 * There is already an image named @p name in @p wim.
3647 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3648 * @p image does not specify a single existing image in @p wim.
3649 * @retval ::WIMLIB_ERR_NOMEM
3650 * Failed to allocate the memory needed to duplicate the @p name string.
3651 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3652 * @p wim is considered read-only because of any of the reasons mentioned
3653 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3656 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3659 * @ingroup G_general
3661 * Set the functions that wimlib uses to allocate and free memory.
3663 * These settings are global and not per-WIM.
3665 * The default is to use the default @c malloc() and @c free() from the C
3668 * Please note that some external functions, such as those in @c libntfs-3g, may
3669 * use the standard memory allocation functions.
3671 * @param malloc_func
3672 * A function equivalent to @c malloc() that wimlib will use to allocate
3673 * memory. If @c NULL, the allocator function is set back to the default
3674 * @c malloc() from the C library.
3676 * A function equivalent to @c free() that wimlib will use to free memory.
3677 * If @c NULL, the free function is set back to the default @c free() from
3679 * @param realloc_func
3680 * A function equivalent to @c realloc() that wimlib will use to reallocate
3681 * memory. If @c NULL, the free function is set back to the default @c
3682 * realloc() from the C library.
3686 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3687 void (*free_func)(void *),
3688 void *(*realloc_func)(void *, size_t));
3691 * @ingroup G_general
3693 * Sets whether wimlib is to print error messages to @c stderr when a function
3694 * fails. These error messages may provide information that cannot be
3695 * determined only from the error code that is returned. Not every error will
3696 * result in an error message being printed.
3698 * This setting is global and not per-WIM.
3700 * By default, error messages are not printed.
3702 * This can be called before wimlib_global_init().
3704 * @param show_messages
3705 * @c true if error messages are to be printed; @c false if error messages
3706 * are not to be printed.
3708 * @return 0 on success; nonzero on error.
3709 * @retval ::WIMLIB_ERR_UNSUPPORTED
3710 * @p show_messages was @c true, but wimlib was compiled with the @c
3711 * --without-error-messages option. Therefore, error messages cannot be
3715 wimlib_set_print_errors(bool show_messages);
3718 * @ingroup G_nonstandalone_wims
3720 * Splits a WIM into multiple parts.
3723 * The ::WIMStruct for the WIM to split.
3725 * Name of the SWM file to create. This will be the name of the first
3726 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3727 * appended before the suffix.
3729 * The maximum size per part, in bytes. Unfortunately, it is not
3730 * guaranteed that this will really be the maximum size per part, because
3731 * some file resources in the WIM may be larger than this size, and the WIM
3732 * file format provides no way to split up file resources among multiple
3734 * @param write_flags
3735 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3736 * flags will be used to write each split WIM part. Specify 0 here to get
3737 * the default behavior.
3738 * @param progress_func
3739 * If non-NULL, a function that will be called periodically with the
3740 * progress of the current operation
3741 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3742 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
3744 * @return 0 on success; nonzero on error. This function may return most error
3745 * codes that can be returned by wimlib_write() as well as the following error
3748 * @retval ::WIMLIB_ERR_INVALID_PARAM
3749 * @p swm_name was not a nonempty string, or @p part_size was 0.
3751 * Note: the WIM's uncompressed and compressed resources are not checksummed
3752 * when they are copied from the joined WIM to the split WIM parts, nor are
3753 * compressed resources re-compressed (unless explicitly requested with
3754 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
3757 wimlib_split(WIMStruct *wim,
3758 const wimlib_tchar *swm_name,
3761 wimlib_progress_func_t progress_func);
3764 * @ingroup G_mounting_wim_images
3766 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3768 * The image to unmount is specified by the path to the mountpoint, not the
3769 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
3770 * touched and also may have been allocated in a different process.
3772 * To unmount the image, the process calling this function communicates with the
3773 * process that is managing the mounted WIM image. This function blocks until it
3774 * is known whether the unmount succeeded or failed. In the case of a
3775 * read-write mounted WIM, the unmount is not considered to have succeeded until
3776 * all changes have been saved to the underlying WIM file.
3779 * The directory that the WIM image was mounted on.
3780 * @param unmount_flags
3781 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
3782 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
3783 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
3785 * @param progress_func
3786 * If non-NULL, a function that will be called periodically with the
3787 * progress of the current operation. Currently, only
3788 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS will be sent.
3790 * @return 0 on success; nonzero on error.
3792 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
3793 * The filesystem daemon was unable to remove the staging directory and the
3794 * temporary files that it contains.
3795 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
3796 * The filesystem daemon appears to have terminated before sending an exit
3798 * @retval ::WIMLIB_ERR_FORK
3799 * Could not @c fork() the process.
3800 * @retval ::WIMLIB_ERR_FUSERMOUNT
3801 * The @b fusermount program could not be executed or exited with a failure
3803 * @retval ::WIMLIB_ERR_MQUEUE
3804 * Could not open a POSIX message queue to communicate with the filesystem
3805 * daemon servicing the mounted filesystem, could not send a message
3806 * through the queue, or could not receive a message through the queue.
3807 * @retval ::WIMLIB_ERR_NOMEM
3808 * Failed to allocate needed memory.
3809 * @retval ::WIMLIB_ERR_OPEN
3810 * The filesystem daemon could not open a temporary file for writing the
3812 * @retval ::WIMLIB_ERR_READ
3813 * A read error occurred when the filesystem daemon tried to a file from
3814 * the staging directory
3815 * @retval ::WIMLIB_ERR_RENAME
3816 * The filesystem daemon failed to rename the newly written WIM file to the
3817 * original WIM file.
3818 * @retval ::WIMLIB_ERR_UNSUPPORTED
3819 * Mounting is not supported, either because the platform is Windows, or
3820 * because the platform is UNIX-like and wimlib was compiled with @c
3822 * @retval ::WIMLIB_ERR_WRITE
3823 * A write error occurred when the filesystem daemon was writing to the new
3824 * WIM file, or the filesystem daemon was unable to flush changes that had
3825 * been made to files in the staging directory.
3828 wimlib_unmount_image(const wimlib_tchar *dir,
3830 wimlib_progress_func_t progress_func);
3833 * @ingroup G_modifying_wims
3835 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3838 * Pointer to the ::WIMStruct for the WIM file to update.
3840 * The 1-based index of the image in the WIM to update. It cannot be
3841 * ::WIMLIB_ALL_IMAGES.
3843 * An array of ::wimlib_update_command's that specify the update operations
3846 * Number of commands in @p cmds.
3847 * @param update_flags
3848 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3849 * @param progress_func
3850 * If non-NULL, a function that will be called periodically with the
3851 * progress of the current operation.
3853 * @return 0 on success; nonzero on error. On failure, all update commands will
3854 * be rolled back, and no visible changes shall have been made to @p wim.
3855 * Possible error codes include:
3857 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3858 * The capture configuration structure specified for an add command was
3860 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3861 * @p image did not specify a single, existing image in @p wim.
3862 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3863 * Attempted to perform an add command that conflicted with previously
3864 * existing files in the WIM when an overlay was attempted.
3865 * @retval ::WIMLIB_ERR_INVALID_PARAM
3866 * An unknown operation type was specified in the update commands; or,
3867 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3868 * in the @p add_flags, but the same image had previously already been
3869 * added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3870 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3871 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3872 * specified in the @p add_flags for an add command in which @p
3873 * wim_target_path was not the root directory of the WIM image.
3874 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3875 * (Windows only): While executing an add command, tried to capture a
3876 * reparse point with invalid data.
3877 * @retval ::WIMLIB_ERR_IS_DIRECTORY
3878 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3879 * for a WIM path that corresponded to a directory; or, a rename command
3880 * attempted to rename a directory to a non-directory.
3881 * @retval ::WIMLIB_ERR_NOMEM
3882 * Failed to allocate needed memory.
3883 * @retval ::WIMLIB_ERR_NOTDIR
3884 * A rename command attempted to rename a directory to a non-directory; or,
3885 * an add command was executed that attempted to set the root of the WIM
3886 * image as a non-directory; or, a path component used as a directory in a
3887 * rename command was not, in fact, a directory.
3888 * @retval ::WIMLIB_ERR_NOTEMPTY
3889 * A rename command attempted to rename a directory to a non-empty
3891 * @retval ::WIMLIB_ERR_NTFS_3G
3892 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3893 * error occurred while reading data from the NTFS volume using libntfs-3g.
3894 * @retval ::WIMLIB_ERR_OPEN
3895 * Failed to open a file to be captured while executing an add command.
3896 * @retval ::WIMLIB_ERR_OPENDIR
3897 * Failed to open a directory to be captured while executing an add command.
3898 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3899 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3900 * WIM path that did not exist; or, a rename command attempted to rename a
3901 * file that does not exist.
3902 * @retval ::WIMLIB_ERR_READ
3903 * While executing an add command, failed to read data from a file or
3904 * directory to be captured.
3905 * @retval ::WIMLIB_ERR_READLINK
3906 * While executing an add command, failed to read the target of a symbolic
3907 * link or junction point.
3908 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3909 * (Windows only) Failed to perform a reparse point fixup because of
3910 * problems with the data of a reparse point.
3911 * @retval ::WIMLIB_ERR_STAT
3912 * While executing an add command, failed to get attributes for a file or
3914 * @retval ::WIMLIB_ERR_UNSUPPORTED
3915 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
3916 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
3917 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3918 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
3919 * add_flags for an update command.
3920 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
3921 * While executing an add command, attempted to capture a file that was not
3922 * a supported file type (e.g. a device file). Only if
3923 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
3924 * for an update command.
3925 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3926 * The WIM file is considered read-only because of any of the reasons
3927 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3930 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3931 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3932 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3933 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3934 * different reasons) to read the metadata resource for an image that needed to
3938 wimlib_update_image(WIMStruct *wim,
3940 const struct wimlib_update_command *cmds,
3943 wimlib_progress_func_t progress_func);
3946 * @ingroup G_writing_and_overwriting_wims
3948 * Writes a WIM to a file.
3950 * This brings in resources from any external locations, such as directory trees
3951 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3952 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3954 * By default, the new WIM file is written as stand-alone. Using the
3955 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
3956 * instead. However, this function cannot directly write a "split" WIM; use
3957 * wimlib_split() for that.
3960 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
3961 * changes made to it, which are then reflected in the output file.
3963 * The path to the file to write the WIM to.
3965 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
3966 * images are to be included in the new on-disk WIM file. If for some
3967 * reason you only want to include a single image, specify the index of
3968 * that image instead.
3969 * @param write_flags
3970 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3971 * @param num_threads
3972 * Number of threads to use for compressing data. If 0, the number of
3973 * threads is taken to be the number of online processors. Note: if no
3974 * data compression needs to be done, no additional threads will be created
3975 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
3976 * exporting an image from a compressed WIM to another WIM of the same
3977 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
3979 * @param progress_func
3980 * If non-NULL, a function that will be called periodically with the
3981 * progress of the current operation. The possible messages are
3982 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3983 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3984 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3986 * @return 0 on success; nonzero on error.
3988 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3989 * @p image does not specify a single existing image in @p wim, and is not
3990 * ::WIMLIB_ALL_IMAGES.
3991 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3992 * A file that had previously been scanned for inclusion in the WIM by
3993 * wimlib_add_image() was concurrently modified, so it failed the SHA1
3994 * message digest check.
3995 * @retval ::WIMLIB_ERR_INVALID_PARAM
3996 * @p path was @c NULL.
3997 * @retval ::WIMLIB_ERR_NOMEM
3998 * Failed to allocate needed memory.
3999 * @retval ::WIMLIB_ERR_OPEN
4000 * Failed to open @p path for writing, or some file resources in @p wim
4001 * refer to files in the outside filesystem, and one of these files could
4002 * not be opened for reading.
4003 * @retval ::WIMLIB_ERR_READ
4004 * An error occurred when trying to read data from the WIM file associated
4005 * with @p wim, or some file resources in @p wim refer to files in the
4006 * outside filesystem, and a read error occurred when reading one of these
4008 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4009 * A stream that needed to be written could not be found in the stream
4010 * lookup table of @p wim. This error can occur if, for example, @p wim is
4011 * part of a split WIM but needed resources from the other split WIM parts
4012 * were not referenced with wimlib_reference_resources() or
4013 * wimlib_reference_resource_files() before the call to wimlib_write().
4014 * @retval ::WIMLIB_ERR_WRITE
4015 * An error occurred when trying to write data to the new WIM file.
4017 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4018 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4019 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4020 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4021 * different reasons) to read the metadata resource for an image that needed to
4025 wimlib_write(WIMStruct *wim,
4026 const wimlib_tchar *path,
4029 unsigned num_threads,
4030 wimlib_progress_func_t progress_func);
4033 * @ingroup G_writing_and_overwriting_wims
4035 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
4036 * file descriptor, which need not be seekable if the write is done in a special
4037 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
4038 * write_flags. This can, for example, allow capturing a WIM image and
4039 * streaming it over the network. See the documentation for
4040 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
4042 * The file descriptor @p fd will @b not be closed when the write is complete;
4043 * the calling code is responsible for this.
4045 * Returns 0 on success; nonzero on failure. The possible error codes include
4046 * those that can be returned by wimlib_write() as well as the following:
4048 * @retval ::WIMLIB_ERR_INVALID_PARAM
4049 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4050 * specified in @p write_flags.
4053 wimlib_write_to_fd(WIMStruct *wim,
4057 unsigned num_threads,
4058 wimlib_progress_func_t progress_func);
4061 * @defgroup G_compression Compression and decompression functions
4063 * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
4064 * exported for convenience only, as they are already used by wimlib internally
4067 * These functions can be used for general-purpose lossless data compression,
4068 * but some limitations apply; for example, none of the compressors or
4069 * decompressors currently support sliding windows, and there also exist
4070 * slightly different variants of these formats that are not supported
4076 /** Header for compression parameters to pass to wimlib_create_compressor() or
4077 * wimlib_set_default_compressor_params(). */
4078 struct wimlib_compressor_params_header {
4079 /** Size of the parameters, in bytes. */
4083 /** Header for decompression parameters to pass to wimlib_create_decompressor()
4084 * or wimlib_set_default_decompressor_params() */
4085 struct wimlib_decompressor_params_header {
4086 /** Size of the parameters, in bytes. */
4090 /** LZX compression parameters that can optionally be passed to
4091 * wimlib_create_compressor() with the compression type
4092 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
4093 struct wimlib_lzx_compressor_params {
4094 /** hdr.size Must be set to the size of this structure, in bytes. */
4095 struct wimlib_compressor_params_header hdr;
4097 /** Relatively fast LZX compression algorithm with a decent compression
4098 * ratio; the suggested default. */
4099 #define WIMLIB_LZX_ALGORITHM_FAST 0
4101 /** Slower LZX compression algorithm that provides a better compression
4103 #define WIMLIB_LZX_ALGORITHM_SLOW 1
4105 /** Algorithm to use to perform the compression: either
4106 * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW. The
4107 * format is still LZX; this refers to the method the code will use to
4108 * perform LZX-compatible compression. */
4109 uint32_t algorithm : 3;
4111 /** If set to 1, the default parameters for the specified algorithm are
4112 * used rather than the ones specified in the following union. */
4113 uint32_t use_defaults : 1;
4116 /** Parameters for the fast algorithm. */
4117 struct wimlib_lzx_fast_params {
4118 uint32_t fast_reserved1[10];
4121 /** Parameters for the slow algorithm. */
4122 struct wimlib_lzx_slow_params {
4123 /** If set to 1, the compressor can output length 2
4124 * matches. If set 0, the compressor only outputs
4125 * matches of length 3 or greater. Suggested value: 1
4127 uint32_t use_len2_matches : 1;
4129 uint32_t slow_reserved1 : 31;
4131 /** Matches with length (in bytes) greater than or equal
4132 * to this value are immediately taken without spending
4133 * time on minimum-cost measurements. Suggested value:
4135 uint32_t nice_match_length;
4137 /** Number of passes to compute a match/literal sequence
4138 * for each LZX block. This is for an iterative
4139 * algorithm that attempts to minimize the cost of the
4140 * match/literal sequence by using a cost model provided
4141 * by the previous iteration. Must be at least 1.
4142 * Suggested value: 2. */
4143 uint32_t num_optim_passes;
4145 /** Reserved; set to 0. */
4146 uint32_t slow_reserved_blocksplit;
4148 /** Maximum depth to search for matches at each
4149 * position. Suggested value: 50. */
4150 uint32_t max_search_depth;
4152 /** Maximum number of potentially good matches to
4153 * consider for each position. Suggested value: 3. */
4154 uint32_t max_matches_per_pos;
4156 uint32_t slow_reserved2[2];
4158 /** Assumed cost of a main symbol with zero frequency.
4159 * Must be at least 1 and no more than 16. Suggested
4161 uint8_t main_nostat_cost;
4163 /** Assumed cost of a length symbol with zero frequency.
4164 * Must be at least 1 and no more than 16. Suggested
4166 uint8_t len_nostat_cost;
4168 /** Assumed cost of an aligned symbol with zero
4169 * frequency. Must be at least 1 and no more than 8.
4170 * Suggested value: 7. */
4171 uint8_t aligned_nostat_cost;
4173 uint8_t slow_reserved3[5];
4178 /** LZMS compression parameters that can optionally be passed to
4179 * wimlib_create_compressor() with the compression type
4180 * ::WIMLIB_COMPRESSION_TYPE_LZMS. */
4181 struct wimlib_lzms_compressor_params {
4182 /** hdr.size Must be set to the size of this structure, in bytes. */
4183 struct wimlib_compressor_params_header hdr;
4185 /** Minimum match length to output. This must be at least 2. Suggested
4187 uint32_t min_match_length;
4189 /** Maximum match length to output. This must be at least @p
4190 * min_match_length. Suggested value: @p UINT32_MAX. */
4191 uint32_t max_match_length;
4193 /** Matches with length (in bytes) greater than or equal to this value
4194 * are immediately taken without spending time on minimum-cost
4195 * measurements. The minimum of @p max_match_length and @p
4196 * nice_match_length may not exceed 65536. Suggested value: 32. */
4197 uint32_t nice_match_length;
4199 /** Maximum depth to search for matches at each position. Suggested
4201 uint32_t max_search_depth;
4203 /** Maximum number of potentially good matches to consider at each
4204 * position. Suggested value: 3. */
4205 uint32_t max_matches_per_pos;
4207 /** Length of the array for the near-optimal LZ parsing algorithm. This
4208 * must be at least 1. Suggested value: 1024. */
4209 uint32_t optim_array_length;
4211 uint64_t reserved2[4];
4214 /** Opaque compressor handle. */
4215 struct wimlib_compressor;
4217 /** Opaque decompressor handle. */
4218 struct wimlib_decompressor;
4221 * Set the default compression parameters for the specified compression type.
4222 * This will affect both explicit and wimlib-internal calls to
4223 * wimlib_create_compressor().
4226 * Compression type for which to set the default compression parameters.
4228 * Compression-type specific parameters. This may be @c NULL, in which
4229 * case the "default default" parameters are restored.
4231 * @return 0 on success; nonzero on error.
4233 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4234 * @p ctype was not a supported compression type.
4235 * @retval ::WIMLIB_ERR_INVALID_PARAM
4236 * @p params were invalid.
4237 * @retval ::WIMLIB_ERR_NOMEM
4238 * Not enough memory to duplicate the parameters (perhaps @c params->size
4242 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
4243 const struct wimlib_compressor_params_header *params);
4246 * Returns the approximate number of bytes needed to allocate a compressor with
4247 * wimlib_create_compressor() for the specified compression type, block size,
4248 * and parameters. @p params may be @c NULL, in which case the current default
4249 * parameters for @p ctype are used. Returns 0 if the compression type or
4250 * parameters are invalid.
4253 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4254 size_t max_block_size,
4255 const struct wimlib_compressor_params_header *params);
4258 * Allocate a compressor for the specified compression type using the specified
4262 * Compression type for which to create the compressor.
4263 * @param max_block_size
4264 * Maximum block size to support. The exact meaning and allowed values for
4265 * this parameter depend on the compression type, but it at least specifies
4266 * the maximum allowed value for @p uncompressed_size to wimlib_compress().
4267 * @param extra_params
4268 * An optional pointer to extra compressor parameters for the specified
4269 * compression type. For LZX, a pointer to ::wimlib_lzx_compressor_params
4270 * may be specified here. If left @c NULL, the default parameters are
4272 * @param compressor_ret
4273 * A location into which to return the pointer to the allocated compressor,
4274 * which can be used for any number of calls to wimlib_compress() before
4275 * being freed with wimlib_free_compressor().
4277 * @return 0 on success; nonzero on error.
4279 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4280 * @p ctype was not a supported compression type.
4281 * @retval ::WIMLIB_ERR_INVALID_PARAM
4282 * The compression parameters were invalid.
4283 * @retval ::WIMLIB_ERR_NOMEM
4284 * Insufficient memory to allocate the compressor.
4287 wimlib_create_compressor(enum wimlib_compression_type ctype,
4288 size_t max_block_size,
4289 const struct wimlib_compressor_params_header *extra_params,
4290 struct wimlib_compressor **compressor_ret);
4293 * Losslessly compress a block of data using a compressor previously created
4294 * with wimlib_create_compressor().
4296 * @param uncompressed_data
4297 * Buffer containing the data to compress.
4298 * @param uncompressed_size
4299 * Size, in bytes, of the data to compress.
4300 * @param compressed_data
4301 * Buffer into which to write the compressed data.
4302 * @param compressed_size_avail
4303 * Number of bytes available in @p compressed_data.
4305 * A compressor previously allocated with wimlib_create_compressor().
4308 * The size of the compressed data, in bytes, or 0 if the input data could
4309 * not be compressed to @p compressed_size_avail or fewer bytes.
4312 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4313 void *compressed_data, size_t compressed_size_avail,
4314 struct wimlib_compressor *compressor);
4317 * Free a compressor previously allocated with wimlib_create_compressor().
4320 * The compressor to free.
4323 wimlib_free_compressor(struct wimlib_compressor *compressor);
4326 * Set the default decompression parameters for the specified compression type.
4327 * This will affect both explicit and wimlib-internal calls to
4328 * wimlib_create_decompressor().
4331 * Compression type for which to set the default decompression parameters.
4333 * Compression-type specific parameters. This may be @c NULL, in which
4334 * case the "default default" parameters are restored.
4336 * @return 0 on success; nonzero on error.
4338 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4339 * @p ctype was not a supported compression type.
4340 * @retval ::WIMLIB_ERR_NOMEM
4341 * Not enough memory to duplicate the parameters (perhaps @c params->size
4345 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4346 const struct wimlib_decompressor_params_header *params);
4349 * Allocate a decompressor for the specified compression type using the
4350 * specified parameters.
4353 * Compression type for which to create the decompressor.
4354 * @param max_block_size
4355 * Maximum block size to support. The exact meaning and allowed values for
4356 * this parameter depend on the compression type, but it at least specifies
4357 * the maximum allowed value for @p uncompressed_size to
4358 * wimlib_decompress().
4359 * @param extra_params
4360 * An optional pointer to extra decompressor parameters for the specified
4361 * compression type. If @c NULL, the default parameters are used.
4362 * @param decompressor_ret
4363 * A location into which to return the pointer to the allocated
4364 * decompressor, which can be used for any number of calls to
4365 * wimlib_decompress() before being freed with wimlib_free_decompressor().
4367 * @return 0 on success; nonzero on error.
4369 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4370 * @p ctype was not a supported compression type.
4371 * @retval ::WIMLIB_ERR_INVALID_PARAM
4372 * The decompression parameters were invalid.
4373 * @retval ::WIMLIB_ERR_NOMEM
4374 * Insufficient memory to allocate the decompressor.
4377 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4378 size_t max_block_size,
4379 const struct wimlib_decompressor_params_header *extra_params,
4380 struct wimlib_decompressor **decompressor_ret);
4383 * Decompress a block of data using a decompressor previously created with
4384 * wimlib_create_decompressor().
4386 * @param compressed_data
4387 * Buffer containing the data to decompress.
4388 * @param compressed_size
4389 * Size, in bytes, of the data to decompress.
4390 * @param uncompressed_data
4391 * Buffer into which to write the uncompressed data.
4392 * @param uncompressed_size
4393 * Size, in bytes, of the data when uncompressed.
4394 * @param decompressor
4395 * A decompressor previously allocated with wimlib_create_decompressor().
4397 * @return 0 on success; nonzero on error.
4400 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4401 void *uncompressed_data, size_t uncompressed_size,
4402 struct wimlib_decompressor *decompressor);
4405 * Free a decompressor previously allocated with wimlib_create_decompressor().
4407 * @param decompressor
4408 * The decompressor to free.
4411 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4423 #endif /* _WIMLIB_H */