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.7.0, 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().
287 * @defgroup G_progress Progress Messages
289 * @brief Track the progress of long WIM operations.
291 * Library users can provide a progress function which will be called
292 * periodically during operations such as extracting a WIM image or writing a
293 * WIM image. A ::WIMStruct can have a progress function of type
294 * ::wimlib_progress_func_t associated with it by calling
295 * wimlib_register_progress_function() or by opening the ::WIMStruct using
296 * wimlib_open_wim_with_progress(). Once this is done, the progress function
297 * will be called automatically during many operations, such as
298 * wimlib_extract_image() and wimlib_write().
300 * Some functions that do not operate directly on a user-provided ::WIMStruct,
301 * such as wimlib_join(), also take the progress function directly using an
302 * extended version of the function, such as wimlib_join_with_progress().
304 * In wimlib v1.7.0 and later, progress functions are no longer just
305 * unidirectional. You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause
306 * the current operation to be aborted. wimlib v1.7.0 also added the third
307 * argument to ::wimlib_progress_func_t, which is a user-supplied context.
310 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
312 * @brief Write and overwrite on-disk WIM files.
314 * As described in @ref sec_basic_wim_handling_concepts, these functions are
315 * critical to the design of the library as they allow new or modified WIMs to
316 * actually be written to on-disk files. Generally, wimlib_write() is the
317 * function you need to call to write a new WIM file, and wimlib_overwrite() is
318 * the function you need to call to persistently update an existing WIM file.
321 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
323 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
325 * Normally, ::WIMStruct represents a WIM file, but there's a bit more to it
326 * than that. Normally, WIM files are "standalone". However, WIM files can
327 * also be arranged in non-standalone ways, such as a set of on-disk files that
328 * together form a single "split WIM" or "delta WIM". Such arrangements are
329 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
330 * created from one of these on-disk files initially only partially represents
331 * the full WIM and needs to, in effect, be logically combined with other
332 * ::WIMStruct's before performing certain operations, such as extracting files
333 * with wimlib_extract_image() or wimlib_extract_paths(). This is done by
334 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
336 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
337 * specialized function (wimlib_split()) is needed to create a split WIM.
346 #include <inttypes.h>
349 /** @ingroup G_general
352 /** Major version of the library (for example, the 1 in 1.2.5). */
353 #define WIMLIB_MAJOR_VERSION 1
355 /** Minor version of the library (for example, the 2 in 1.2.5). */
356 #define WIMLIB_MINOR_VERSION 7
358 /** Patch version of the library (for example, the 5 in 1.2.5). */
359 #define WIMLIB_PATCH_VERSION 0
366 /** @ingroup G_general
370 * Opaque structure that represents a WIM file. This is an in-memory structure
371 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
372 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
373 * continuing to exist so that data can be read from it as needed.
375 * Most functions in this library will work the same way regardless of whether a
376 * given ::WIMStruct was obtained through wimlib_open_wim() or
377 * wimlib_create_new_wim(). Exceptions are documented.
379 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
380 * file from a ::WIMStruct.
382 * See @ref sec_basic_wim_handling_concepts for more information.
384 #ifndef WIMLIB_WIMSTRUCT_DECLARED
385 typedef struct WIMStruct WIMStruct;
386 #define WIMLIB_WIMSTRUCT_DECLARED
390 typedef wchar_t wimlib_tchar;
392 /** See @ref sec_encodings */
393 typedef char wimlib_tchar;
397 /** Path separator for WIM paths passed back to progress callbacks. */
398 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
399 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
401 /** Path separator for WIM paths passed back to progress callbacks. */
402 # define WIMLIB_WIM_PATH_SEPARATOR '/'
403 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
406 /** Use this to specify the root directory of the WIM image. */
407 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
409 /** Use this to test if the specified path refers to the root directory of the
411 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
412 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR && \
416 # define _wimlib_deprecated __attribute__((deprecated))
418 # define _wimlib_deprecated
421 #define WIMLIB_GUID_LEN 16
424 * Specifies the compression type of a WIM file.
426 enum wimlib_compression_type {
427 /** An invalid compression type. */
428 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
430 /** The WIM does not include any compressed resources. */
431 WIMLIB_COMPRESSION_TYPE_NONE = 0,
433 /** Compressed resources in the WIM use XPRESS compression. */
434 WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
436 /** Compressed resources in the WIM use LZX compression. */
437 WIMLIB_COMPRESSION_TYPE_LZX = 2,
439 /** Compressed resources in the WIM use LZMS compression. Note: LZMS
440 * compression is only compatible with wimlib v1.6.0 and later and with
441 * WIMGAPI Windows 8 and later (and some restrictions apply on the
443 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
447 /** @ingroup G_progress
450 /** Possible values of the first parameter to the user-supplied
451 * ::wimlib_progress_func_t progress function */
452 enum wimlib_progress_msg {
454 /** A WIM image is about to be extracted. @p info will point to
455 * ::wimlib_progress_info.extract. This message is received once per
456 * image for calls to wimlib_extract_image() and
457 * wimlib_extract_image_from_pipe(). */
458 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
460 /** One or more file or directory trees within a WIM image is about to
461 * be extracted. @p info will point to ::wimlib_progress_info.extract.
462 * This message is received only once per wimlib_extract_paths() and
463 * wimlib_extract_pathlist(), since wimlib combines all paths into a
464 * single extraction operation for optimization purposes. */
465 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
467 /** File data is currently being extracted. @p info will point to
468 * ::wimlib_progress_info.extract. This is the main message to track
469 * the progress of an extraction operation. */
470 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
472 /** Starting to read a new part of a split pipable WIM over the pipe.
473 * @p info will point to ::wimlib_progress_info.extract. */
474 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
476 /** Confirms that the image has been successfully extracted. @p info
477 * will point to ::wimlib_progress_info.extract. This is paired with
478 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
479 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
481 /** Confirms that the files or directory trees have been successfully
482 * extracted. @p info will point to ::wimlib_progress_info.extract.
483 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
484 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
486 /** The directory or NTFS volume is about to be scanned for metadata.
487 * @p info will point to ::wimlib_progress_info.scan. This message is
488 * received once per call to wimlib_add_image(), or once per capture
489 * source passed to wimlib_add_image_multisource(), or once per add
490 * command passed to wimlib_update_image(). */
491 WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
493 /** A directory or file has been scanned. @p info will point to
494 * ::wimlib_progress_info.scan, and its @p cur_path member will be
495 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
497 WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
499 /** Confirms that the directory or NTFS volume has been successfully
500 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
501 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
502 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
504 WIMLIB_PROGRESS_MSG_SCAN_END = 11,
506 /** File resources ("streams") are currently being written to the WIM.
507 * @p info will point to ::wimlib_progress_info.write_streams. This
508 * message may be received many times while the WIM file is being
509 * written or appended to with wimlib_write(), wimlib_overwrite(), or
510 * wimlib_write_to_fd(). */
511 WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
513 /** Per-image metadata is about to be written to the WIM file. @p info
514 * will not be valid. */
515 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
517 /** Confirms that per-image metadata has been successfully been written
518 * to the WIM file. @p info will not be valid. This message is paired
519 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
521 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
523 /** wimlib_overwrite() has successfully renamed the temporary file to
524 * the original WIM file, thereby committing the update. @p info will
525 * point to ::wimlib_progress_info.rename. Note: this message is not
526 * received if wimlib_overwrite() chose to append to the WIM file
528 WIMLIB_PROGRESS_MSG_RENAME = 15,
530 /** The contents of the WIM file are being checked against the integrity
531 * table. @p info will point to ::wimlib_progress_info.integrity. This
532 * message is only received (and may be received many times) when
533 * wimlib_open_wim_with_progress() is called with the
534 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
535 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
537 /** An integrity table is being calculated for the WIM being written.
538 * @p info will point to ::wimlib_progress_info.integrity. This message
539 * is only received (and may be received many times) when a WIM file is
540 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
541 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
543 /** A wimlib_split() operation is in progress, and a new split part is
544 * about to be started. @p info will point to
545 * ::wimlib_progress_info.split. */
546 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
548 /** A wimlib_split() operation is in progress, and a split part has been
549 * finished. @p info will point to ::wimlib_progress_info.split. */
550 WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
552 /** A WIM update command is just about to be executed. @p info will
553 * point to ::wimlib_progress_info.update. This message is received
554 * once per update command when wimlib_update_image() is called with the
555 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
556 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
558 /** A WIM update command has just been executed. @p info will point to
559 * ::wimlib_progress_info.update. This message is received once per
560 * update command when wimlib_update_image() is called with the flag
561 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
562 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
564 /** A file in the WIM image is being replaced as a result of a
565 * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
566 * @p info will point to ::wimlib_progress_info.replace. This is only
567 * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
569 WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
571 /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
572 * a file is being extracted normally (not as a WIMBoot "pointer file")
573 * due to it matching a pattern in the [PrepopulateList] section of the
574 * configuration file \Windows\System32\WimBootCompress.ini in the WIM
575 * image. @p info will point to ::wimlib_progress_info.wimboot_exclude.
577 WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
579 /** Starting to unmount a WIM image. @p info will point to
580 * ::wimlib_progress_info.unmount. */
581 WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
584 /** Valid return values from user-provided progress functions
585 * (::wimlib_progress_func_t).
587 * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
590 enum wimlib_progress_status {
592 /** The operation should be continued. This is the normal return value.
594 WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
596 /** The operation should be aborted. This will cause the current
597 * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS. */
598 WIMLIB_PROGRESS_STATUS_ABORT = 1,
601 /** A pointer to this union is passed to the user-supplied
602 * ::wimlib_progress_func_t progress function. One (or none) of the structures
603 * contained in this union will be applicable for the operation
604 * (::wimlib_progress_msg) indicated in the first argument to the progress
606 union wimlib_progress_info {
608 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
609 * document them if they aren't given a name... */
611 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
612 * the primary message for tracking the progress of writing a WIM file.
614 struct wimlib_progress_info_write_streams {
615 /** Total number of uncompressed bytes of stream data being
616 * written. This can be thought of as the total uncompressed
617 * size of the files being archived, with some caveats. WIM
618 * files use single-instance streams, so the size provided here
619 * only counts distinct streams, except for the following
620 * exception: the size provided here may include the sizes of
621 * all newly added (e.g. with wimlib_add_image() streams,
622 * pending automatic de-duplication during the write operation
623 * itself. When each such stream de-duplication occurs, this
624 * number will be decreased by the size of the duplicate stream
625 * that need not be written.
627 * In the case of a wimlib_overwrite() that the library opted to
628 * perform in-place, both @p total_streams and @p total_bytes
629 * will only count the streams actually being written and not
630 * pre-existing streams in the WIM file. */
631 uint64_t total_bytes;
633 /** Total number of streams being written. This can be thought
634 * of as the total number of files being archived, with some
635 * caveats. In general, a single file or directory may contain
636 * multiple data streams, each of which will be represented
637 * separately in this number. Furthermore, WIM files use
638 * single-instance streams, so the stream count provided here
639 * only counts distinct streams, except for the following
640 * exception: the stream count provided here may include newly
641 * added (e.g. with wimlib_add_image() streams, pending
642 * automatic de-duplication during the write operation itself.
643 * When each such stream de-duplication occurs, this number will
644 * be decreased by 1 to account for the duplicate stream that
645 * need not be written. */
646 uint64_t total_streams;
648 /** Number of uncompressed bytes of stream data that have been
649 * written so far. This number be 0 initially, and will be
650 * equal to @p total_bytes at the end of the write operation.
651 * Note that @p total_bytes (but not @p completed_bytes) may
652 * decrease throughout the write operation due to the discovery
653 * of stream duplications. */
654 uint64_t completed_bytes;
656 /** Number of streams that have been written so far. This
657 * number will be 0 initially, and will be equal to @p
658 * total_streams at the end of the write operation. Note that
659 * @p total_streams (but not @p completed_streams) may decrease
660 * throughout the write operation due to the discovery of stream
663 * For applications that wish to calculate a simple "percent
664 * complete" for the write operation, it will likely be more
665 * accurate to calculate the percentage from @p completed_bytes
666 * and @p total_bytes rather than @p completed_streams and
667 * @p total_streams because the time for the operation to
668 * complete is mainly determined by the number of bytes that
669 * need to be read, compressed, and written, not just the number
670 * of files being archived. */
671 uint64_t completed_streams;
673 /** Number of threads that are being used to compress streams,
674 * or 1 if streams are being written uncompressed. */
675 uint32_t num_threads;
677 /** The compression type being used to write the streams, as one
678 * of the ::wimlib_compression_type constants. */
679 int32_t compression_type;
681 /** Number of split WIM parts from which streams are being
682 * written (may be 0 if irrelevant). */
683 uint32_t total_parts;
685 /** This is currently broken and will always be 0. */
686 uint32_t completed_parts;
689 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
690 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
691 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
692 struct wimlib_progress_info_scan {
693 /** Top-level directory being scanned; or, when capturing an NTFS
694 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
695 * to the file or block device that contains the NTFS volume
697 const wimlib_tchar *source;
699 /** Path to the file (or directory) that has been scanned, valid
700 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing an NTFS
701 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
702 * relative to the root of the NTFS volume. */
703 const wimlib_tchar *cur_path;
705 /** Dentry scan status, valid on
706 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
708 /** The file looks okay and will be captured. */
709 WIMLIB_SCAN_DENTRY_OK = 0,
711 /** File is being excluded from capture due to the
712 * capture configuration. */
713 WIMLIB_SCAN_DENTRY_EXCLUDED,
715 /** File is being excluded from capture due to being
716 * unsupported (e.g. an encrypted or device file). */
717 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
719 /** The file is an absolute symbolic link or junction
720 * point and it is being excluded from capture because
721 * it points outside of the capture directory and
722 * reparse-point fixups are enabled. (Reparse point
723 * fixups can be disabled by using the flag
724 * ::WIMLIB_ADD_FLAG_NORPFIX.) */
725 WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
727 /** The file is an absolute symbolic link or junction
728 * that points into the capture directory, and
729 * reparse-point fixups are enabled, so its target is
730 * being adjusted. (Reparse point fixups can be
731 * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
733 WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
737 /** Target path in the WIM image. Only valid on
738 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
739 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
740 const wimlib_tchar *wim_target_path;
742 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
743 * of @p WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK or @p
744 * WIMLIB_SCAN_DENTRY_FIXED_SYMLINK, this is the target
745 * of the absolute symbolic link or junction. */
746 const wimlib_tchar *symlink_target;
749 /** Number of directories scanned so far, including the root
750 * directory but excluding any unsupported/excluded directories.
752 * Details: On Windows and in NTFS capture mode, a reparse point
753 * counts as a directory if and only if it has
754 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
755 * counts as a directory if and only if when fully dereferenced
756 * it points to an accessible directory. If a file has multiple
757 * names (hard links), it is only counted one time. */
758 uint64_t num_dirs_scanned;
760 /** Number of non-directories scanned so far, excluding any
761 * unsupported/excluded files.
763 * Details: On Windows and in NTFS capture mode, a reparse point
764 * counts as a non-directory if and only if it does not have
765 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
766 * counts as a non-directory if and only if when fully
767 * dereferenced it points to a non-directory or its target is
768 * inaccessible. If a file has multiple names (hard links), it
769 * is only counted one time. */
770 uint64_t num_nondirs_scanned;
772 /** Number of bytes of file data that have been detected so far.
774 * Details: This data may not actually have been read yet, and
775 * it will not actually be written to the WIM file until
776 * wimlib_write() or wimlib_overwrite() has been called. Data
777 * from excluded files is not counted. This number includes
778 * default file contents as well as named data streams and
779 * reparse point data. The size of reparse point data is
780 * tallied after any reparse-point fixups, and in the case of
781 * capturing a symbolic link on a UNIX-like system, the creation
782 * of the reparse point data itself. If a file has multiple
783 * names (hard links), its size(s) are only counted one time.
784 * On Windows, encrypted files have their encrypted size
785 * counted, not their unencrypted size; however, compressed
786 * files have their uncompressed size counted. */
787 uint64_t num_bytes_scanned;
790 /** Valid on messages
791 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
792 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
793 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
794 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
795 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
796 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
798 * Note: most of the time of an extraction operation will be spent
799 * extracting streams, and the application will receive
800 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
801 * completed_bytes and @p total_bytes, the application can calculate a
802 * percentage complete. However, note that this message does not, in
803 * general, actually provide information about which "file" is currently
804 * being extracted. This is because wimlib, by default, extracts the
805 * individual data streams in whichever order it determines to be the
808 struct wimlib_progress_info_extract {
809 /** Number of the image from which files are being extracted
813 /** Extraction flags being used. */
814 uint32_t extract_flags;
816 /** Full path to the WIM file from which files are being
817 * extracted, or @c NULL if the WIMStruct has no associated
819 const wimlib_tchar *wimfile_name;
821 /** Name of the image from which files are being extracted, or
822 * the empty string if the image is unnamed. */
823 const wimlib_tchar *image_name;
825 /** Path to the directory or NTFS volume to which the files are
826 * being extracted. */
827 const wimlib_tchar *target;
830 const wimlib_tchar *reserved;
832 /** Number of bytes of uncompressed data that will be extracted.
833 * If a file has multiple names (hard links), its size (or
834 * sizes, in the case of named data streams) is only counted one
835 * time. For "reparse points" and symbolic links, the size to
836 * be extracted is the size of the reparse data buffer.
838 * This number will stay constant throughout the extraction. */
839 uint64_t total_bytes;
841 /** Number of bytes of uncompressed data that have been
842 * extracted so far. This initially be 0 and will equal to @p
843 * total_bytes at the end of the extraction. */
844 uint64_t completed_bytes;
846 /** Number of (not necessarily unique) streams that will be
847 * extracted. This may be more or less than the number of
848 * "files" to be extracted due to hard links as well as
849 * potentially multiple streams per file (named data streams).
850 * A "stream" may be the default contents of a file, a named
851 * data stream, or a reparse data buffer. */
852 uint64_t num_streams;
855 const wimlib_tchar *reserved_2;
857 /** Currently only used for
858 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
859 uint32_t part_number;
861 /** Currently only used for
862 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
863 uint32_t total_parts;
865 /** Currently only used for
866 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
867 uint8_t guid[WIMLIB_GUID_LEN];
870 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
871 struct wimlib_progress_info_rename {
872 /** Name of the temporary file that the WIM was written to. */
873 const wimlib_tchar *from;
875 /** Name of the original WIM file to which the temporary file is
877 const wimlib_tchar *to;
880 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
881 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
882 struct wimlib_progress_info_update {
883 /** Pointer to the update command that will be executed or has
884 * just been executed. */
885 const struct wimlib_update_command *command;
887 /** Number of update commands that have been completed so far.
889 size_t completed_commands;
891 /** Number of update commands that are being executed as part of
892 * this call to wimlib_update_image(). */
893 size_t total_commands;
896 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
897 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
898 struct wimlib_progress_info_integrity {
899 /** Number of bytes from the end of the WIM header to the end of
900 * the lookup table (the area that is covered by the SHA1
901 * integrity checks.) */
902 uint64_t total_bytes;
904 /** Number of bytes that have been SHA1-summed so far. Will be
905 * 0 initially, and equal @p total_bytes at the end. */
906 uint64_t completed_bytes;
908 /** Number of chunks that the checksummed region is divided
910 uint32_t total_chunks;
912 /** Number of chunks that have been SHA1-summed so far. Will
913 * be 0 initially, and equal to @p total_chunks at the end. */
914 uint32_t completed_chunks;
916 /** Size of the chunks used for the integrity calculation. */
919 /** Filename of the WIM (only valid if the message is
920 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
921 const wimlib_tchar *filename;
924 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
925 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
926 struct wimlib_progress_info_split {
927 /** Total size of the original WIM's file and metadata resources
929 uint64_t total_bytes;
931 /** Number of bytes of file and metadata resources that have
932 * been copied out of the original WIM so far. Will be 0
933 * initially, and equal to @p total_bytes at the end. */
934 uint64_t completed_bytes;
936 /** Number of the split WIM part that is about to be started
937 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
938 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
939 unsigned cur_part_number;
941 /** Total number of split WIM parts that are being written. */
942 unsigned total_parts;
944 /** Name of the split WIM part that is about to be started
945 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
946 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
947 * As of wimlib v1.7.0, the library user may change this when
948 * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
949 * cause the next split WIM part to be written to a different
951 wimlib_tchar *part_name;
954 /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM */
955 struct wimlib_progress_info_replace {
956 /** Path to the file in the WIM image that is being replaced */
957 const wimlib_tchar *path_in_wim;
960 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE */
961 struct wimlib_progress_info_wimboot_exclude {
962 /** Path to the file in the WIM image */
963 const wimlib_tchar *path_in_wim;
965 /** Path to which the file is being extracted */
966 const wimlib_tchar *extraction_path;
969 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN. */
970 struct wimlib_progress_info_unmount {
971 /** Path to directory being unmounted */
972 const wimlib_tchar *mountpoint;
974 /** Path to WIM file being unmounted */
975 const wimlib_tchar *mounted_wim;
977 /** 1-based index of image being unmounted. */
978 uint32_t mounted_image;
980 /** Flags that were passed to wimlib_mount_image() when the
981 * mountpoint was set up. */
982 uint32_t mount_flags;
984 /** Flags passed to wimlib_unmount_image(). */
985 uint32_t unmount_flags;
990 * A user-supplied function that will be called periodically during certain WIM
993 * The first argument will be the type of operation that is being performed or
994 * is about to be started or has been completed.
996 * The second argument will be a pointer to one of a number of structures
997 * depending on the first argument. It may be @c NULL for some message types.
998 * Note that although this argument is not @c const, users should not modify it
999 * except in explicitly documented cases.
1001 * The third argument will be a user-supplied value that was provided when
1002 * registering or specifying the progress function.
1004 * This function must return one of the ::wimlib_progress_status values. By
1005 * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1007 typedef enum wimlib_progress_status
1008 (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1009 union wimlib_progress_info *info,
1013 /** @ingroup G_modifying_wims
1016 /** An array of these structures is passed to wimlib_add_image_multisource() to
1017 * specify the sources from which to create a WIM image. */
1018 struct wimlib_capture_source {
1019 /** Absolute or relative path to a file or directory on the external
1020 * filesystem to be included in the WIM image. */
1021 wimlib_tchar *fs_source_path;
1023 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1024 * specify the root directory of the WIM image. */
1025 wimlib_tchar *wim_target_path;
1027 /** Reserved; set to 0. */
1031 /** Set or unset the WIM header flag that marks it read-only
1032 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
1033 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
1034 * is distinct from basic file permissions; this flag can be set on a WIM file
1035 * that is physically writable. If this flag is set, all further operations to
1036 * modify the WIM will fail, except calling wimlib_overwrite() with
1037 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
1038 * allows you to set this flag persistently on the underlying WIM file.
1040 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1042 /** Set the GUID (globally unique identifier) of the WIM file to the value
1043 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1044 #define WIMLIB_CHANGE_GUID 0x00000002
1046 /** Change the bootable image of the WIM to the value specified in
1047 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1048 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1050 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1051 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
1052 * indicates whether an image in the WIM has been captured with reparse-point
1053 * fixups enabled. wimlib also treats this flag as specifying whether to do
1054 * reparse-point fixups by default when capturing or applying WIM images. */
1055 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1058 /** @ingroup G_wim_information
1061 /** General information about a WIM file. */
1062 struct wimlib_wim_info {
1064 /** Globally unique identifier for the WIM file. Note: all parts of a
1065 * split WIM should have an identical value in this field. */
1066 uint8_t guid[WIMLIB_GUID_LEN];
1068 /** Number of images in the WIM. */
1069 uint32_t image_count;
1071 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1073 uint32_t boot_index;
1075 /** Version of the WIM file. */
1076 uint32_t wim_version;
1078 /** Chunk size used for compression. */
1079 uint32_t chunk_size;
1081 /** For split WIMs, the 1-based index of this part within the split WIM;
1083 uint16_t part_number;
1085 /** For split WIMs, the total number of parts in the split WIM;
1087 uint16_t total_parts;
1089 /** One of the ::wimlib_compression_type values that specifies the
1090 * method used to compress resources in the WIM. */
1091 int32_t compression_type;
1093 /** Size of the WIM file in bytes, excluding the XML data and integrity
1095 uint64_t total_bytes;
1097 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1098 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1099 * this will always be 0, even if the ::WIMStruct was written to
1100 * somewhere by calling wimlib_write() with the
1101 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1102 uint32_t has_integrity_table : 1;
1104 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1105 * wimlib_create_new_wim(). */
1106 uint32_t opened_from_file : 1;
1108 /** 1 if the WIM is considered readonly for any reason. */
1109 uint32_t is_readonly : 1;
1111 /** 1 if reparse-point fixups are supposedly enabled for one or more
1112 * images in the WIM. */
1113 uint32_t has_rpfix : 1;
1115 /** 1 if the WIM is marked as read-only. */
1116 uint32_t is_marked_readonly : 1;
1118 /** 1 if the WIM is part of a spanned set. */
1119 uint32_t spanned : 1;
1121 uint32_t write_in_progress : 1;
1122 uint32_t metadata_only : 1;
1123 uint32_t resource_only : 1;
1125 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1126 uint32_t pipable : 1;
1127 uint32_t reserved_flags : 22;
1128 uint32_t reserved[9];
1131 /** Information about a unique stream in the WIM file. (A stream is the same
1132 * thing as a "resource", except in the case of packed resources.) */
1133 struct wimlib_resource_entry {
1134 /** Uncompressed size of the stream in bytes. */
1135 uint64_t uncompressed_size;
1137 /** Compressed size of the stream in bytes. This will be the same as @p
1138 * uncompressed_size if the stream is uncompressed. Or, if @p
1139 * is_packed_streams is 1, this will be 0. */
1140 uint64_t compressed_size;
1142 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1143 * if @p packed is 1, then this is actually the offset at which this
1144 * stream begins in the uncompressed contents of the packed resource.
1148 /** SHA1 message digest of the stream's uncompressed contents. */
1149 uint8_t sha1_hash[20];
1151 /** Which part number of the split WIM this stream is in. This should
1152 * be the same as the part number provided by wimlib_get_wim_info(). */
1153 uint32_t part_number;
1155 /** Number of times this stream is referenced over all WIM images. */
1156 uint32_t reference_count;
1158 /** 1 if this stream is compressed. */
1159 uint32_t is_compressed : 1;
1161 /** 1 if this stream is a metadata resource rather than a file resource.
1163 uint32_t is_metadata : 1;
1165 uint32_t is_free : 1;
1166 uint32_t is_spanned : 1;
1168 /** 1 if this stream was not found in the lookup table of the
1169 * ::WIMStruct. This normally implies a missing call to
1170 * wimlib_reference_resource_files() or wimlib_reference_resources().
1172 uint32_t is_missing : 1;
1174 /** 1 if this stream is located in a packed resource which may contain
1175 * other streams (all compressed together) as well. */
1176 uint32_t packed : 1;
1178 uint32_t reserved_flags : 26;
1180 /** If @p packed is 1, then this will specify the offset of the packed
1181 * resource in the WIM. */
1182 uint64_t raw_resource_offset_in_wim;
1184 /** If @p is_packed_streams is 1, then this will specify the compressed
1185 * size of the packed resource in the WIM. */
1186 uint64_t raw_resource_compressed_size;
1188 uint64_t reserved[2];
1191 /** A stream of a file in the WIM. */
1192 struct wimlib_stream_entry {
1193 /** Name of the stream, or NULL if the stream is unnamed. */
1194 const wimlib_tchar *stream_name;
1195 /** Location, size, etc. of the stream within the WIM file. */
1196 struct wimlib_resource_entry resource;
1197 uint64_t reserved[4];
1200 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1201 * Roughly, the information about a "file" in the WIM--- but really a directory
1202 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1203 * field can be used to distinguish actual file inodes. */
1204 struct wimlib_dir_entry {
1205 /** Name of the file, or NULL if this file is unnamed (only possible for
1206 * the root directory) */
1207 const wimlib_tchar *filename;
1209 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1211 const wimlib_tchar *dos_name;
1213 /** Full path to this file within the WIM image. */
1214 const wimlib_tchar *full_path;
1216 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1217 * children, ..., etc. */
1220 /** Pointer to the security descriptor for this file, in Windows
1221 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1222 * security descriptor. */
1223 const char *security_descriptor;
1225 /** Length of the above security descriptor. */
1226 size_t security_descriptor_size;
1228 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1229 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1230 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1231 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1232 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1233 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1234 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1235 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1236 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1237 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1238 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1239 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1240 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1241 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1242 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1243 /** File attributes, such as whether the file is a directory or not.
1244 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1245 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1246 * on other platforms. */
1247 uint32_t attributes;
1249 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1250 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1251 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1252 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1253 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1254 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1255 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1256 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1257 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1258 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1259 #define WIMLIB_REPARSE_TAG_WOF 0x80000017
1260 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1261 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1262 * attributes), this will give the reparse tag. This tells you whether
1263 * the reparse point is a symbolic link, junction point, or some other,
1264 * more unusual kind of reparse point. */
1265 uint32_t reparse_tag;
1267 /* Number of (hard) links to this file. */
1270 /** Number of named data streams that this file has. Normally 0. */
1271 uint32_t num_named_streams;
1273 /** Roughly, the inode number of this file. However, it may be 0 if
1274 * @p num_links == 1. */
1275 uint64_t hard_link_group_id;
1277 /** Time this file was created. */
1278 struct timespec creation_time;
1280 /** Time this file was last written to. */
1281 struct timespec last_write_time;
1283 /** Time this file was last accessed. */
1284 struct timespec last_access_time;
1286 /* UNIX data (wimlib extension), only valid if unix_mode != 0 */
1292 uint64_t reserved[14];
1294 /** Array of streams that make up this file. The first entry will
1295 * always exist and will correspond to the unnamed data stream (default
1296 * file contents), so it will have @p stream_name == @c NULL. There
1297 * will then be @p num_named_streams additional entries that specify the
1298 * named data streams, if any, each of which will have @p stream_name !=
1300 struct wimlib_stream_entry streams[];
1304 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1307 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1311 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1314 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1317 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1318 * just on the specified path. */
1319 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1321 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1322 * itself; only its children (in the case of a non-empty directory) */
1323 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1325 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1326 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1327 * table of the ::WIMStruct. The default behavior without this flag is to fill
1328 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1329 * wimlib_resource_entry::is_missing "is_missing" flag. */
1330 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1334 /** @ingroup G_modifying_wims
1337 /** Directly capture an NTFS volume rather than a generic directory. This flag
1338 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1339 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1340 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1342 /** Follow symlinks; archive and dump the files they point to. Currently only
1343 * supported on UNIX-like systems. */
1344 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1346 /** Call the progress function with the message
1347 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1349 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1351 /** Mark the image being added as the bootable image of the WIM. Not valid for
1352 * wimlib_update_image(). */
1353 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1355 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1356 * (major and minor number) of each file. See the documentation for the
1357 * <b>--unix-data</b> option to <b>wimlib-imagex capture</b> for more
1359 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1361 /** Do not capture security descriptors. Only has an effect in NTFS capture
1362 * mode, or in Windows native builds. */
1363 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1365 /** Fail immediately if the full security descriptor of any file or directory
1366 * cannot be accessed. Only has an effect in Windows native builds. The
1367 * default behavior without this flag is to first try omitting the SACL from the
1368 * security descriptor, then to try omitting the security descriptor entirely.
1370 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1372 /** Call the progress function with the message
1373 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1374 * capture. This is a subset of the messages provided by
1375 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1376 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1378 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1379 * in the case of Windows) that point inside the directory being captured to
1380 * instead be absolute relative to the directory being captured, rather than the
1381 * current root; also exclude absolute symbolic links that point outside the
1382 * directory tree being captured.
1384 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1385 * the WIM header or if this is the first image being added.
1386 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1387 * reparse point fixups enabled and currently cannot be unset. */
1388 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1390 /** Don't do reparse point fixups. The default behavior is described in the
1391 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1392 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1394 /** Do not automatically exclude unsupported files or directories from capture;
1395 * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1396 * UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1397 * such a file is encountered. */
1398 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1401 * Automatically select a capture configuration appropriate for capturing
1402 * filesystems containing Windows operating systems. For example,
1403 * "pagefile.sys" and "System Volume Information" will be excluded.
1405 * When this flag is specified, the corresponding @p config parameter or member
1408 * Note that the default behavior--- that is, when this flag is not specified
1409 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1410 * no files are excluded from capture.
1412 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1415 * Capture image as WIMBoot compatible. In addition, if no capture
1416 * configuration file is explicitly specified use the capture configuration file
1417 * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1418 * <c>$SOURCE</c> is the directory being captured; or, if a capture
1419 * configuration file is explicitly specified, use it and also place it at
1420 * /Windows/System32/WimBootCompress.ini in the WIM image.
1422 * Note: this will not by itself change the compression type. Before writing
1423 * the WIM file, it's recommended to also do:
1426 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1427 * wimlib_set_output_chunk_size(wim, 4096);
1430 * since that makes access to the data faster (at the cost of a worse
1431 * compression ratio compared to the 32768-byte LZX chunks usually used).
1433 #define WIMLIB_ADD_FLAG_WIMBOOT 0x00001000
1436 * If the add command involves adding a non-directory file to a location at
1437 * which there already exists a nondirectory file in the WIM image, issue
1438 * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file. This only has an
1439 * effect when updating an existing image with wimlib_update_image().
1440 * This was the default behavior in wimlib v1.6.2 and earlier.
1442 #define WIMLIB_ADD_FLAG_NO_REPLACE 0x00002000
1444 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1445 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1446 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1447 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1448 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1449 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1450 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1451 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1452 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1453 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1454 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1455 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1456 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1457 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT WIMLIB_ADD_FLAG_WIMBOOT
1461 /** @ingroup G_modifying_wims
1464 /** Do not issue an error if the path to delete does not exist. */
1465 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1467 /** Delete the file or directory tree recursively; if not specified, an error is
1468 * issued if the path to delete is a directory. */
1469 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1472 /** @ingroup G_modifying_wims
1476 * If a single image is being exported, mark it bootable in the destination WIM.
1477 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1478 * the image in the source WIM (if any) that is marked as bootable is also
1479 * marked as bootable in the destination WIM.
1481 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1483 /** Give the exported image(s) no names. Avoids problems with image name
1486 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1488 /** Give the exported image(s) no descriptions. */
1489 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1491 /** This advises the library that the program is finished with the source
1492 * WIMStruct and will not attempt to access it after the call to
1493 * wimlib_export_image(), with the exception of the call to wimlib_free(). */
1494 #define WIMLIB_EXPORT_FLAG_GIFT 0x00000008
1497 * Mark each exported image as WIMBoot-compatible.
1499 * Note: by itself, this does change the destination WIM's compression type, nor
1500 * does it add the file \Windows\System32\WimBootCompress.ini in the WIM image.
1501 * Before writing the destination WIM, it's recommended to do something like:
1504 * wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1505 * wimlib_set_output_chunk_size(wim, 4096);
1506 * wimlib_add_tree(wim, image, L"myconfig.ini",
1507 * L"\\Windows\\System32\\WimBootCompress.ini", 0);
1510 #define WIMLIB_EXPORT_FLAG_WIMBOOT 0x00000010
1513 /** @ingroup G_extracting_wims
1516 /** Extract the image directly to an NTFS volume rather than a generic directory.
1517 * This mode is only available if wimlib was compiled with libntfs-3g support;
1518 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1519 * extraction target will be interpreted as the path to an NTFS volume image (as
1520 * a regular file or block device) rather than a directory. It will be opened
1521 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1522 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1523 * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1524 * wimlib_extract_paths() when passed multiple paths. */
1525 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1527 /** UNIX-like systems only: Extract special UNIX data captured with
1528 * ::WIMLIB_ADD_FLAG_UNIX_DATA. This flag cannot be combined with
1529 * ::WIMLIB_EXTRACT_FLAG_NTFS. */
1530 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1532 /** Do not extract security descriptors. This flag cannot be combined with
1533 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1534 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1536 /** Fail immediately if the full security descriptor of any file or directory
1537 * cannot be set exactly as specified in the WIM file. On Windows, the default
1538 * behavior without this flag when wimlib does not have permission to set the
1539 * correct security descriptor is to fall back to setting the security
1540 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1541 * owner omitted, then not at all. This flag cannot be combined with
1542 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1543 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1545 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1546 * reparse-point fixups on, so absolute symbolic links or junction points will
1547 * be fixed to be absolute relative to the actual extraction root. Reparse-
1548 * point fixups are done by default for wimlib_extract_image() and
1549 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1550 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1551 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1553 /** Force reparse-point fixups on extraction off, regardless of the state of the
1554 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1555 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1556 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1558 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Extract the
1559 * paths, each of which must name a regular file, to standard output. */
1560 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1562 /** Instead of ignoring files and directories with names that cannot be
1563 * represented on the current platform (note: Windows has more restrictions on
1564 * filenames than POSIX-compliant systems), try to replace characters or append
1565 * junk to the names so that they can be extracted in some form. */
1566 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1568 /** On Windows, when there exist two or more files with the same case
1569 * insensitive name but different case sensitive names, try to extract them all
1570 * by appending junk to the end of them, rather than arbitrarily extracting only
1572 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1574 /** Do not ignore failure to set timestamps on extracted files. */
1575 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1577 /** Do not ignore failure to set short names on extracted files. */
1578 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1580 /** On Windows, do not ignore failure to extract symbolic links and junctions
1581 * due to permissions problems. By default, such failures are ignored since the
1582 * default configuration of Windows only allows the Administrator to create
1583 * symbolic links. */
1584 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1586 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1587 * behavior is currently less than satisfactory. Do not use (yet). */
1588 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1590 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1591 * paths to extract as wildcard patterns ("globs") which may contain the
1592 * wildcard characters @c ? and @c *. The @c ? character matches any
1593 * non-path-separator character, whereas the @c * character matches zero or more
1594 * non-path-separator characters. Consequently, each glob may match zero or
1595 * more actual paths in the WIM image. By default, if a glob does not match any
1596 * files, a warning but not an error will be issued, even if the glob did not
1597 * actually contain wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
1598 * to get an error instead. */
1599 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1601 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1602 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1603 * one of the provided globs did not match a file. */
1604 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1606 /** Do not extract Windows file attributes such as readonly, hidden, etc. */
1607 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1609 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1610 * preserve the directory structure of the archive when extracting --- that is,
1611 * place each extracted file or directory tree directly in the target directory.
1613 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1615 /** Windows only: Extract files as "pointers" back to the WIM archive. See the
1616 * documentation for the <b>--wimboot</b> option of <b>wimlib-imagex apply</b>
1617 * for more information. */
1618 #define WIMLIB_EXTRACT_FLAG_WIMBOOT 0x00400000
1621 /** @ingroup G_mounting_wim_images
1624 /** Mount the WIM image read-write rather than the default of read-only. */
1625 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1627 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1628 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1630 /** Do not allow accessing named data streams in the mounted WIM image. */
1631 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1633 /** Access named data streams in the mounted WIM image through extended file
1634 * attributes named "user.X", where X is the name of a data stream. This is the
1636 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1638 /** Access named data streams in the mounted WIM image by specifying the file
1639 * name, a colon, then the name of the data stream. */
1640 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1642 /** Use UNIX metadata if available in the WIM image. See
1643 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1644 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1646 /** Allow other users to see the mounted filesystem. This passes the @c
1647 * allow_other option to the FUSE mount. */
1648 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1651 /** @ingroup G_creating_and_opening_wims
1654 /** Verify the WIM contents against the WIM's integrity table, if present. This
1655 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1656 * checksummed and checked against the SHA1 message digests specified in the
1657 * integrity table. ::WIMLIB_ERR_INTEGRITY is returned if there are any
1658 * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1659 * integrity table is invalid). */
1660 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1662 /** Issue an error if the WIM is part of a split WIM. Software can provide
1663 * this flag for convenience if it explicitly does not want to support split
1665 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1667 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1668 * is not. A WIM is considered writable only if it is writable at the
1669 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1670 * header, and is not part of a spanned set. It is not required to provide this
1671 * flag before attempting to make changes to the WIM, but with this flag you get
1672 * an error sooner rather than later. */
1673 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1676 /** @ingroup G_mounting_wim_images
1679 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
1680 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1681 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1683 /** Commit changes to the read-write mounted WIM image.
1684 * If this flag is not specified, changes will be discarded. */
1685 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1687 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
1688 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1689 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1691 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
1692 * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified. */
1693 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1696 * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
1697 * image, forces all file descriptors to the open WIM image to be closed before
1700 * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
1701 * this flag has no effect.
1703 #define WIMLIB_UNMOUNT_FLAG_FORCE 0x00000010
1705 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1706 * WIM image, causes the modified image to be committed to the WIM file as a
1707 * new, unnamed image appended to the archive. The original image in the WIM
1708 * file will be unmodified. */
1709 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
1712 /** @ingroup G_modifying_wims
1715 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1716 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1717 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1720 /** @ingroup G_writing_and_overwriting_wims
1724 * Include an integrity table in the resulting WIM file.
1726 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1727 * include an integrity table if and only if one was present before. For
1728 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1729 * to not include an integrity table.
1731 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1734 * Do not include an integrity table in the resulting WIM file. This is the
1735 * default behavior, unless the ::WIMStruct was created by opening a WIM with an
1738 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1741 * Write the WIM as "pipable". After writing a WIM with this flag specified,
1742 * images from it can be applied directly from a pipe using
1743 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1744 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1745 * with this flag will not be compatible with Microsoft's software.
1747 * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1748 * write the WIM as pipable if and only if it was pipable before. For
1749 * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1750 * to write the WIM as non-pipable.
1752 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1755 * Do not write the WIM as "pipable". This is the default behavior, unless the
1756 * ::WIMStruct was created by opening a pipable WIM.
1758 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1761 * When writing streams to the WIM file, recompress them, even if their data is
1762 * already available in the desired compressed form (for example, in a WIM file
1763 * from which an image has been exported using wimlib_export_image()).
1765 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
1766 * compression ratio for the same compression type and chunk size. wimlib's LZX
1767 * compressor currently can be given different parameters in order to achieve
1768 * different balances between compression ratio and time. In its default mode
1769 * as of v1.5.3, it usually compresses slightly better than the competing
1770 * Microsoft implementation.
1772 * ::WIMLIB_WRITE_FLAG_RECOMPRESS can also be used in combination with
1773 * ::WIMLIB_WRITE_FLAG_PACK_STREAMS to prevent any solid blocks from being
1774 * re-used. (Otherwise, solid blocks are re-used somewhat more liberally than
1775 * normal compressed blocks.)
1777 * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
1778 * that would not otherwise be written. For example, a call to
1779 * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
1780 * cause already-existing streams in the WIM file to be recompressed. To force
1781 * the WIM file to be fully rebuilt and recompressed, combine
1782 * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
1784 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1787 * Immediately before closing the WIM file, sync its data to disk.
1789 * wimlib_overwrite() will set this flag automatically if it decides to
1790 * overwrite the WIM file via a temporary file instead of in-place.
1792 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1795 * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
1796 * could be updated merely be appending to it.
1798 * When rebuilding the WIM file, stream reference counts will be recomputed, and
1799 * any streams with 0 reference count (e.g. from deleted files or images) will
1800 * not be included in the resulting WIM file.
1802 * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
1803 * data to be recompressed. Otherwise, compressed data is re-used if possible.
1805 * wimlib_write() ignores this flag.
1807 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1810 * For wimlib_overwrite(), override the default behavior after one or more calls
1811 * to wimlib_delete_image(), which is to rebuild the entire WIM file. With this
1812 * flag, only minimal changes to correctly remove the image from the WIM file
1813 * will be taken. In particular, all streams will be retained, even if they are
1814 * no longer referenced. This may not be what you want, because no space will
1815 * be saved by deleting an image in this way.
1817 * wimlib_write() ignores this flag.
1819 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1822 * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
1823 * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header. This can be used
1824 * following a call to wimlib_set_wim_info() with the
1825 * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
1828 * wimlib_write() ignores this flag.
1830 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1833 * Do not include streams already present in other WIMs. This flag can be used
1834 * to write a "delta" WIM after resources from the WIM on which the delta is to
1835 * be based were referenced with wimlib_reference_resource_files() or
1836 * wimlib_reference_resources().
1838 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1841 * Advises the library that for writes of all WIM images, all streams needed for
1842 * the WIM are already present (not in external resource WIMs) and their
1843 * reference counts are correct, so the code does not need to recalculate which
1844 * streams are referenced. This is for optimization purposes only, since with
1845 * this flag specified, the metadata resources may not need to be decompressed
1848 * wimlib_overwrite() will set this flag automatically.
1850 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1853 * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
1855 * wimlib_overwrite() sets this by default, since the WIM remains, logically,
1858 #define WIMLIB_WRITE_FLAG_RETAIN_GUID 0x00000800
1861 * When writing streams in the resulting WIM file, pack multiple streams into a
1862 * single compressed resource instead of compressing them independently. This
1863 * is also known as creating a "solid archive". This tends to produce a better
1864 * compression ratio at the cost of much slower random access.
1866 * WIM files created with this flag are only compatible with wimlib v1.6.0 or
1867 * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later. WIM files
1868 * created with this flag use a different version number in their header (3584
1869 * instead of 68864) and are also called "ESD files".
1871 * If this flag is passed to wimlib_overwrite(), any new data streams will be
1872 * written in solid mode. Use both ::WIMLIB_WRITE_FLAG_REBUILD and
1873 * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
1874 * all streams recompressed in solid mode.
1876 * Currently, new solid blocks will, by default, be written using LZMS
1877 * compression with 32 MiB (33554432 byte) chunks. Use
1878 * wimlib_set_output_pack_compression_type() and/or
1879 * wimlib_set_output_pack_chunk_size() to change this. This is independent of
1880 * the WIM's main compression type and chunk size; you can have a WIM that
1881 * nominally uses LZX compression and 32768 byte chunks but actually contains
1882 * LZMS-compressed solid blocks, for example. However, if including solid
1883 * blocks, I suggest that you set the WIM's main compression type to LZMS as
1884 * well, either by creating the WIM with
1885 * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
1886 * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
1888 * This flag will be set by default when writing or overwriting a WIM file that
1889 * either already contains packed streams, or has had packed streams exported
1890 * into it and the WIM's main compression type is LZMS.
1892 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
1895 /** @ingroup G_general
1898 /** Assume that strings are represented in UTF-8, even if this is not the
1899 * locale's character encoding. This flag is ignored on Windows, where wimlib
1900 * always uses UTF-16LE. */
1901 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1903 /** Windows-only: do not attempt to acquire additional privileges (currently
1904 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1905 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1906 * for the case where the calling program manages these privileges itself.
1907 * Note: no error is issued if privileges cannot be acquired, although related
1908 * errors may be reported later, depending on if the operations performed
1909 * actually require additional privileges or not. */
1910 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1912 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1913 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1914 * to read all possible data and metadata for a capture operation could not be
1915 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1917 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1919 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1920 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1921 * to restore all possible data and metadata for an apply operation could not be
1922 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1924 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1926 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1928 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
1930 /** Default to interpreting WIM paths case insensitively (default on Windows).
1931 * This does not apply to mounted images. */
1932 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
1935 /** @ingroup G_nonstandalone_wims
1938 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
1939 * Ignored by wimlib_reference_resources(). */
1940 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1942 /** For wimlib_reference_resource_files(), issue an error
1943 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1944 * default behavior without this flag is to issue no error at that point, but
1945 * then attempt to open the glob as a literal path, which of course will fail
1946 * anyway if no file exists at that path. No effect if
1947 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
1948 * wimlib_reference_resources(). */
1949 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1952 /** @ingroup G_modifying_wims
1955 /** The specific type of update to perform. */
1956 enum wimlib_update_op {
1957 /** Add a new file or directory tree to the WIM image in a
1958 * certain location. */
1959 WIMLIB_UPDATE_OP_ADD = 0,
1961 /** Delete a file or directory tree from the WIM image. */
1962 WIMLIB_UPDATE_OP_DELETE,
1964 /** Rename a file or directory tree in the WIM image. */
1965 WIMLIB_UPDATE_OP_RENAME,
1968 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1969 struct wimlib_add_command {
1970 /** Filesystem path to the file or directory tree to add. */
1971 wimlib_tchar *fs_source_path;
1973 /** Destination path in the WIM image. Use ::WIMLIB_WIM_ROOT_PATH to
1974 * specify the root directory of the WIM image. */
1975 wimlib_tchar *wim_target_path;
1977 /** Path to capture configuration file to use, or @c NULL for default.
1979 wimlib_tchar *config_file;
1981 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1985 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1986 struct wimlib_delete_command {
1988 /** Path, specified from the root of the WIM image, for the file or
1989 * directory tree within the WIM image to be deleted. */
1990 wimlib_tchar *wim_path;
1992 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1996 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1997 struct wimlib_rename_command {
1999 /** Path, specified from the root of the WIM image, for the source file
2000 * or directory tree within the WIM image. */
2001 wimlib_tchar *wim_source_path;
2003 /** Path, specified from the root of the WIM image, for the destination
2004 * file or directory tree within the WIM image. */
2005 wimlib_tchar *wim_target_path;
2007 /** Reserved; set to 0. */
2011 /** Specification of an update to perform on a WIM image. */
2012 struct wimlib_update_command {
2014 enum wimlib_update_op op;
2017 struct wimlib_add_command add;
2018 struct wimlib_delete_command delete_; /* Underscore is for C++
2020 struct wimlib_rename_command rename;
2025 /** @ingroup G_general
2029 * Possible values of the error code returned by many functions in wimlib.
2031 * See the documentation for each wimlib function to see specifically what error
2032 * codes can be returned by a given function, and what they mean.
2034 enum wimlib_error_code {
2035 WIMLIB_ERR_SUCCESS = 0,
2036 WIMLIB_ERR_ALREADY_LOCKED = 1,
2037 WIMLIB_ERR_DECOMPRESSION = 2,
2038 WIMLIB_ERR_FUSE = 6,
2039 WIMLIB_ERR_GLOB_HAD_NO_MATCHES = 8,
2040 WIMLIB_ERR_ICONV_NOT_AVAILABLE = 9,
2041 WIMLIB_ERR_IMAGE_COUNT = 10,
2042 WIMLIB_ERR_IMAGE_NAME_COLLISION = 11,
2043 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES = 12,
2044 WIMLIB_ERR_INTEGRITY = 13,
2045 WIMLIB_ERR_INVALID_CAPTURE_CONFIG = 14,
2046 WIMLIB_ERR_INVALID_CHUNK_SIZE = 15,
2047 WIMLIB_ERR_INVALID_COMPRESSION_TYPE = 16,
2048 WIMLIB_ERR_INVALID_HEADER = 17,
2049 WIMLIB_ERR_INVALID_IMAGE = 18,
2050 WIMLIB_ERR_INVALID_INTEGRITY_TABLE = 19,
2051 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY = 20,
2052 WIMLIB_ERR_INVALID_METADATA_RESOURCE = 21,
2053 WIMLIB_ERR_INVALID_MULTIBYTE_STRING = 22,
2054 WIMLIB_ERR_INVALID_OVERLAY = 23,
2055 WIMLIB_ERR_INVALID_PARAM = 24,
2056 WIMLIB_ERR_INVALID_PART_NUMBER = 25,
2057 WIMLIB_ERR_INVALID_PIPABLE_WIM = 26,
2058 WIMLIB_ERR_INVALID_REPARSE_DATA = 27,
2059 WIMLIB_ERR_INVALID_RESOURCE_HASH = 28,
2060 WIMLIB_ERR_INVALID_UTF16_STRING = 30,
2061 WIMLIB_ERR_INVALID_UTF8_STRING = 31,
2062 WIMLIB_ERR_IS_DIRECTORY = 32,
2063 WIMLIB_ERR_IS_SPLIT_WIM = 33,
2064 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE = 34,
2065 WIMLIB_ERR_LINK = 35,
2066 WIMLIB_ERR_METADATA_NOT_FOUND = 36,
2067 WIMLIB_ERR_MKDIR = 37,
2068 WIMLIB_ERR_MQUEUE = 38,
2069 WIMLIB_ERR_NOMEM = 39,
2070 WIMLIB_ERR_NOTDIR = 40,
2071 WIMLIB_ERR_NOTEMPTY = 41,
2072 WIMLIB_ERR_NOT_A_REGULAR_FILE = 42,
2073 WIMLIB_ERR_NOT_A_WIM_FILE = 43,
2074 WIMLIB_ERR_NOT_PIPABLE = 44,
2075 WIMLIB_ERR_NO_FILENAME = 45,
2076 WIMLIB_ERR_NTFS_3G = 46,
2077 WIMLIB_ERR_OPEN = 47,
2078 WIMLIB_ERR_OPENDIR = 48,
2079 WIMLIB_ERR_PATH_DOES_NOT_EXIST = 49,
2080 WIMLIB_ERR_READ = 50,
2081 WIMLIB_ERR_READLINK = 51,
2082 WIMLIB_ERR_RENAME = 52,
2083 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED = 54,
2084 WIMLIB_ERR_RESOURCE_NOT_FOUND = 55,
2085 WIMLIB_ERR_RESOURCE_ORDER = 56,
2086 WIMLIB_ERR_SET_ATTRIBUTES = 57,
2087 WIMLIB_ERR_SET_REPARSE_DATA = 58,
2088 WIMLIB_ERR_SET_SECURITY = 59,
2089 WIMLIB_ERR_SET_SHORT_NAME = 60,
2090 WIMLIB_ERR_SET_TIMESTAMPS = 61,
2091 WIMLIB_ERR_SPLIT_INVALID = 62,
2092 WIMLIB_ERR_STAT = 63,
2093 WIMLIB_ERR_UNEXPECTED_END_OF_FILE = 65,
2094 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE = 66,
2095 WIMLIB_ERR_UNKNOWN_VERSION = 67,
2096 WIMLIB_ERR_UNSUPPORTED = 68,
2097 WIMLIB_ERR_UNSUPPORTED_FILE = 69,
2098 WIMLIB_ERR_WIM_IS_READONLY = 71,
2099 WIMLIB_ERR_WRITE = 72,
2100 WIMLIB_ERR_XML = 73,
2101 WIMLIB_ERR_WIM_IS_ENCRYPTED = 74,
2102 WIMLIB_ERR_WIMBOOT = 75,
2103 WIMLIB_ERR_ABORTED_BY_PROGRESS = 76,
2104 WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS = 77,
2105 WIMLIB_ERR_MKNOD = 78,
2106 WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY = 79,
2107 WIMLIB_ERR_NOT_A_MOUNTPOINT = 80,
2108 WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81,
2112 /** Used to indicate no WIM image or an invalid WIM image. */
2113 #define WIMLIB_NO_IMAGE 0
2115 /** Used to specify all images in the WIM. */
2116 #define WIMLIB_ALL_IMAGES (-1)
2121 * @ingroup G_modifying_wims
2123 * Appends an empty image to a WIM file. This empty image will initially
2124 * contain no files or directories, although if written without further
2125 * modifications, a root directory will be created automatically for it. After
2126 * calling this function, you can use wimlib_update_image() to add files to the
2127 * new WIM image. This gives you slightly more control over making the new
2128 * image compared to calling wimlib_add_image() or
2129 * wimlib_add_image_multisource() directly.
2132 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2135 * Name to give the new image. If @c NULL or empty, the new image is given
2136 * no name. If nonempty, it must specify a name that does not already
2138 * @param new_idx_ret
2139 * If non-<code>NULL</code>, the index of the newly added image is returned
2142 * @return 0 on success; nonzero on failure. The possible error codes are:
2144 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2145 * There is already an image in @p wim named @p name.
2146 * @retval ::WIMLIB_ERR_NOMEM
2147 * Failed to allocate the memory needed to add the new image.
2148 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2149 * The WIM file is considered read-only because of any of the reasons
2150 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2154 wimlib_add_empty_image(WIMStruct *wim,
2155 const wimlib_tchar *name,
2159 * @ingroup G_modifying_wims
2161 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2163 * The directory tree or NTFS volume is scanned immediately to load the dentry
2164 * tree into memory, and file attributes and symbolic links are read. However,
2165 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2168 * See the manual page for the @b wimlib-imagex program for more information
2169 * about the "normal" capture mode versus the NTFS capture mode (entered by
2170 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2172 * Note that @b no changes are committed to the underlying WIM file (if
2173 * any) until wimlib_write() or wimlib_overwrite() is called.
2176 * Pointer to the ::WIMStruct for a WIM file to which the image will be
2179 * A path to a directory or unmounted NTFS volume that will be captured as
2182 * Name to give the new image. If @c NULL or empty, the new image is given
2183 * no name. If nonempty, it must specify a name that does not already
2185 * @param config_file
2186 * Path to capture configuration file, or @c NULL. This file may specify,
2187 * among other things, which files to exclude from capture. See the man
2188 * page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2189 * details of the file format. If @c NULL, the default capture
2190 * configuration shall be used. Ordinarily, the default capture
2191 * configuration will result in no files being excluded from capture purely
2192 * based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2193 * ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2195 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2197 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2198 * discarded so that it appears to be in the same state as when this function
2201 * This function is implemented by calling wimlib_add_empty_image(), then
2202 * calling wimlib_update_image() with a single "add" command, so any error code
2203 * returned by wimlib_add_empty_image() may be returned, as well as any error
2204 * codes returned by wimlib_update_image() other than ones documented as only
2205 * being returned specifically by an update involving delete or rename commands.
2207 * If a progress function is registered with @p wim, it will receive the
2208 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2209 * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2210 * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2213 wimlib_add_image(WIMStruct *wim,
2214 const wimlib_tchar *source,
2215 const wimlib_tchar *name,
2216 const wimlib_tchar *config_file,
2220 * @ingroup G_modifying_wims
2222 * This function is equivalent to wimlib_add_image() except it allows for
2223 * multiple sources to be combined into a single WIM image. This is done by
2224 * specifying the @p sources and @p num_sources parameters instead of the @p
2225 * source parameter of wimlib_add_image(). The rest of the parameters are the
2226 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2227 * capture</b> for full details on how this mode works.
2229 * In addition to the error codes that wimlib_add_image() can return,
2230 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2231 * when trying to overlay a non-directory on a directory or when otherwise
2232 * trying to overlay multiple conflicting files to the same location in the WIM
2233 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2234 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2235 * was not exactly one capture source with the target being the root directory.
2236 * (In this respect, there is no advantage to using
2237 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2240 wimlib_add_image_multisource(WIMStruct *wim,
2241 const struct wimlib_capture_source *sources,
2243 const wimlib_tchar *name,
2244 const wimlib_tchar *config_file,
2248 * @ingroup G_modifying_wims
2250 * Add the file or directory tree at @p fs_source_path on the filesystem to the
2251 * location @p wim_target_path within the specified @p image of the @p wim.
2253 * This just builds an appropriate ::wimlib_add_command and passes it to
2254 * wimlib_update_image().
2257 wimlib_add_tree(WIMStruct *wim, int image,
2258 const wimlib_tchar *fs_source_path,
2259 const wimlib_tchar *wim_target_path, int add_flags);
2262 * @ingroup G_creating_and_opening_wims
2264 * Creates a ::WIMStruct for a new WIM file.
2266 * This only creates an in-memory structure for a WIM that initially contains no
2267 * images. No on-disk file is created until wimlib_write() is called.
2270 * The type of compression to be used in the new WIM file, as one of the
2271 * ::wimlib_compression_type constants.
2273 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2274 * written to the memory location pointed to by this paramater. The
2275 * ::WIMStruct must be freed using using wimlib_free() when finished with
2277 * @return 0 on success; nonzero on error.
2278 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2279 * @p ctype was not a supported compression type.
2280 * @retval ::WIMLIB_ERR_NOMEM
2281 * Failed to allocate needed memory.
2284 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2287 * @ingroup G_modifying_wims
2289 * Deletes an image, or all images, from a WIM file.
2291 * All streams referenced by the image(s) being deleted are removed from the
2292 * lookup table of the WIM if they are not referenced by any other images in the
2295 * Please note that @b no changes are committed to the underlying WIM file (if
2296 * any) until wimlib_write() or wimlib_overwrite() is called.
2299 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2302 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2304 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2305 * to be left unmodified only if @p image specified a single image. If instead
2306 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2307 * possible for some but not all of the images to have been deleted when a
2308 * failure status is returned.
2310 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2311 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2312 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2313 * The WIM file is considered read-only because of any of the reasons
2314 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2317 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2318 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2319 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2320 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2321 * different reasons) to read the metadata resource for an image that needed to
2325 wimlib_delete_image(WIMStruct *wim, int image);
2328 * @ingroup G_modifying_wims
2330 * Delete the @p path from the specified @p image of the @p wim.
2332 * This just builds an appropriate ::wimlib_delete_command and passes it to
2333 * wimlib_update_image().
2336 wimlib_delete_path(WIMStruct *wim, int image,
2337 const wimlib_tchar *path, int delete_flags);
2340 * @ingroup G_modifying_wims
2342 * Exports an image, or all the images, from a WIM file, into another WIM file.
2344 * The destination image is made to share the same dentry tree and security data
2345 * structure as the source image. This places some restrictions on additional
2346 * functions that may be called. wimlib_mount_image() may not be called on
2347 * either the source image or the destination image without an intervening call
2348 * to a function that un-shares the images, such as wimlib_free() on @p
2349 * dest_wim, or wimlib_delete_image() on either the source or destination image.
2350 * Furthermore, you may not call wimlib_free() on @p src_wim before calling
2351 * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
2352 * have references back to @p src_wim.
2354 * If this function fails, all changes to @p dest_wim are rolled back.
2356 * Please note that no changes are committed to the underlying WIM file of @p
2357 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2360 * The WIM from which to export the images, specified as a pointer to the
2361 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2362 * split WIM. In the case of a WIM file that is not standalone, this
2363 * ::WIMStruct must have had any needed external resources previously
2364 * referenced using wimlib_reference_resources() or
2365 * wimlib_reference_resource_files().
2367 * The image to export from @p src_wim, as either a 1-based image index to
2368 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2370 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2373 * For single-image exports, the name to give the exported image in @p
2374 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2375 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2376 * that case, the names are all taken from @p src_wim. This parameter is
2377 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2378 * @param dest_description
2379 * For single-image exports, the description to give the exported image in
2380 * the new WIM file. If left @c NULL, the description from @p src_wim is
2381 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2382 * NULL; in that case, the description are all taken from @p src_wim. This
2383 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2384 * @param export_flags
2385 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2387 * @return 0 on success; nonzero on error.
2388 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2389 * One or more of the names being given to an exported image was already in
2390 * use in the destination WIM.
2391 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2392 * @p src_image does not exist in @p src_wim and was not
2393 * ::WIMLIB_ALL_IMAGES.
2394 * @retval ::WIMLIB_ERR_INVALID_PARAM
2395 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2396 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2398 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2399 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2400 * example, one of them was a non-first part of a split WIM.
2401 * @retval ::WIMLIB_ERR_NOMEM
2402 * Failed to allocate needed memory.
2403 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2404 * A resource that needed to be exported could not be found in either the
2405 * source or destination WIMs. This error can occur if, for example, @p
2406 * src_wim is part of a split WIM but needed resources from the other split
2407 * WIM parts were not referenced with wimlib_reference_resources() or
2408 * wimlib_reference_resource_files() before the call to
2409 * wimlib_export_image().
2410 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2411 * @p dest_wim is considered read-only because of any of the reasons
2412 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2415 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2416 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2417 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2418 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2419 * different reasons) to read the metadata resource for an image in @p src_wim
2420 * that needed to be exported.
2423 wimlib_export_image(WIMStruct *src_wim, int src_image,
2424 WIMStruct *dest_wim,
2425 const wimlib_tchar *dest_name,
2426 const wimlib_tchar *dest_description,
2430 * @ingroup G_extracting_wims
2432 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2435 * The exact behavior of how wimlib extracts files from a WIM image is
2436 * controllable by the @p extract_flags parameter, but there also are
2437 * differences depending on the platform (UNIX-like vs Windows). See the manual
2438 * page for <b>wimlib-imagex apply</b> for more information, including about the
2439 * special "NTFS volume extraction mode" entered by providing
2440 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2443 * The WIM from which to extract the image(s), specified as a pointer to
2444 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2445 * of a split WIM. In the case of a WIM file that is not standalone, this
2446 * ::WIMStruct must have had any needed external resources previously
2447 * referenced using wimlib_reference_resources() or
2448 * wimlib_reference_resource_files().
2450 * The image to extract, specified as either the 1-based index of a single
2451 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2452 * to be extracted. ::WIMLIB_ALL_IMAGES cannot be used if
2453 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2455 * Directory to extract the WIM image(s) to; or, with
2456 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2457 * the unmounted NTFS volume to which to extract the image.
2458 * @param extract_flags
2459 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2461 * @return 0 on success; nonzero on error.
2462 * @retval ::WIMLIB_ERR_DECOMPRESSION
2463 * Failed to decompress data contained in the WIM.
2464 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2465 * The metadata for one of the images to extract was invalid.
2466 * @retval ::WIMLIB_ERR_INVALID_PARAM
2467 * The extraction flags were invalid; more details may be found in the
2468 * documentation for the specific extraction flags that were specified. Or
2469 * @p target was @c NULL or the empty string, or @p wim was @c NULL.
2470 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2471 * The SHA1 message digest of an extracted stream did not match the SHA1
2472 * message digest given in the WIM.
2473 * @retval ::WIMLIB_ERR_LINK
2474 * Failed to create a symbolic link or a hard link.
2475 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2476 * The metadata resource for one of the images to extract was not found.
2477 * This can happen if @p wim represents a non-first part of a split WIM.
2478 * @retval ::WIMLIB_ERR_MKDIR
2479 * Failed create a directory.
2480 * @retval ::WIMLIB_ERR_NOMEM
2481 * Failed to allocate needed memory.
2482 * @retval ::WIMLIB_ERR_OPEN
2483 * Could not create a file, or failed to open an already-extracted file.
2484 * @retval ::WIMLIB_ERR_READ
2485 * Failed to read data from the WIM.
2486 * @retval ::WIMLIB_ERR_READLINK
2487 * Failed to determine the target of a symbolic link in the WIM.
2488 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2489 * Failed to fix the target of an absolute symbolic link (e.g. if the
2490 * target would have exceeded the maximum allowed length). (Only if
2491 * reparse data was supported by the extraction mode and
2492 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2494 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2495 * One of the files or directories that needed to be extracted referenced a
2496 * stream not present in the WIM's lookup table (or in any of the lookup
2497 * tables of the split WIM parts).
2498 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2499 * Failed to set attributes on a file.
2500 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2501 * Failed to set reparse data on a file (only if reparse data was supported
2502 * by the extraction mode).
2503 * @retval ::WIMLIB_ERR_SET_SECURITY
2504 * Failed to set security descriptor on a file
2505 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2507 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2508 * Failed to set the short name of a file (only if
2509 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2510 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2511 * Failed to set timestamps on a file (only if
2512 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2513 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2514 * Unexpected end-of-file occurred when reading data from the WIM.
2515 * @retval ::WIMLIB_ERR_UNSUPPORTED
2516 * A requested extraction flag, or the data or metadata that must be
2517 * extracted to support it, is unsupported in the build and configuration
2518 * of wimlib, or on the current platform or extraction mode or target
2519 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2520 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2521 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2522 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2523 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS. For example, if
2524 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2525 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2526 * image contains one or more files with short names, but extracting short
2527 * names is not supported --- on Windows, this occurs if the target volume
2528 * does not support short names, while on non-Windows, this occurs if
2529 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2530 * @retval ::WIMLIB_ERR_WIMBOOT
2531 * ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2532 * there was a problem creating WIMBoot pointer files.
2533 * @retval ::WIMLIB_ERR_WRITE
2534 * Failed to write data to a file being extracted.
2536 * If a progress function is registered with @p wim, then as each image is
2537 * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2538 * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then
2539 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2542 wimlib_extract_image(WIMStruct *wim, int image,
2543 const wimlib_tchar *target, int extract_flags);
2546 * @ingroup G_extracting_wims
2548 * Since wimlib v1.5.0: Extract one image from a pipe on which a pipable WIM is
2551 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2552 * about pipable WIMs.
2554 * This function operates in a special way to read the WIM fully sequentially.
2555 * As a result, there is no ::WIMStruct is made visible to library users, and
2556 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2557 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2558 * seekable file, not a pipe.)
2561 * File descriptor, which may be a pipe, opened for reading and positioned
2562 * at the start of the pipable WIM.
2563 * @param image_num_or_name
2564 * String that specifies the 1-based index or name of the image to extract.
2565 * It is translated to an image index using the same rules that
2566 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2567 * only a single image (not all images) can be specified. Alternatively,
2568 * specify @p NULL here to use the first image in the WIM if it contains
2569 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2571 * Same as the corresponding parameter to wimlib_extract_image().
2572 * @param extract_flags
2573 * Same as the corresponding parameter to wimlib_extract_image().
2575 * @return 0 on success; nonzero on error. The possible error codes include
2576 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2579 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2580 * Data read from the pipable WIM was invalid.
2581 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2582 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2585 wimlib_extract_image_from_pipe(int pipe_fd,
2586 const wimlib_tchar *image_num_or_name,
2587 const wimlib_tchar *target, int extract_flags);
2590 * @ingroup G_extracting_wims
2592 * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2593 * function. The progress function will be used while extracting the WIM image
2594 * and will receive the normal extraction progress messages, such as
2595 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2596 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2599 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2600 const wimlib_tchar *image_num_or_name,
2601 const wimlib_tchar *target,
2603 wimlib_progress_func_t progfunc,
2607 * @ingroup G_extracting_wims
2609 * Since wimlib v1.6.0: Similar to wimlib_extract_paths(), but the paths to
2610 * extract from the WIM image are specified in the UTF-8 text file named by @p
2611 * path_list_file which itself contains the list of paths to use, one per line.
2612 * Leading and trailing whitespace, and otherwise empty lines and lines
2613 * beginning with the ';' character are ignored. No quotes are needed as paths
2614 * are otherwise delimited by the newline character.
2616 * The error codes are the same as those returned by wimlib_extract_paths(),
2617 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2618 * cannot read the path list file (::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2619 * ::WIMLIB_ERR_READ, ::WIMLIB_ERR_NOMEM, or ::WIMLIB_ERR_INVALID_UTF8_STRING).
2622 wimlib_extract_pathlist(WIMStruct *wim, int image,
2623 const wimlib_tchar *target,
2624 const wimlib_tchar *path_list_file,
2628 * @ingroup G_extracting_wims
2630 * Since wimlib v1.6.0: Extract zero or more paths (files or directory trees)
2631 * from the specified WIM image.
2633 * By default, each path will be extracted to a corresponding subdirectory of
2634 * the target based on its location in the WIM image. For example, if one of
2635 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2636 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
2637 * can be changed by providing the flag
2638 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2639 * or directory tree to be placed directly in the target directory --- so the
2640 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2642 * Symbolic links will not be dereferenced when paths in the WIM image are
2646 * WIM from which to extract the paths, specified as a pointer to the
2647 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2648 * split WIM. In the case of a WIM file that is not standalone, this
2649 * ::WIMStruct must have had any needed external resources previously
2650 * referenced using wimlib_reference_resources() or
2651 * wimlib_reference_resource_files().
2653 * 1-based index of the WIM image from which to extract the paths.
2655 * Array of paths to extract. Each element must be the absolute path to a
2656 * file or directory within the WIM image. Separators may be either
2657 * forwards or backwards slashes, and leading path separators are optional.
2658 * The paths will be interpreted either case-sensitively (UNIX default) or
2659 * case-insensitively (Windows default); this can be changed by
2660 * wimlib_global_init().
2662 * By default, the characters @c * and @c ? are interpreted literally.
2663 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2666 * By default, if any paths to extract do not exist, the error code
2667 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
2668 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2670 * Number of paths specified in @p paths.
2672 * Directory to which to extract the paths; or with
2673 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2674 * unmounted NTFS volume to which to extract the paths. Unlike the @p
2675 * paths being extracted, the @p target must be native path. On UNIX-like
2676 * systems it may not contain backslashes, for example.
2677 * @param extract_flags
2678 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2680 * @return 0 on success; nonzero on error. Most of the error codes are the same
2681 * as those returned by wimlib_extract_image(). Below, some of the error codes
2682 * returned in situations specific to path-mode extraction are documented:
2684 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2685 * @p image was ::WIMLIB_ALL_IMAGES or was otherwise not a valid single
2687 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2688 * One of the paths to extract did not exist in the WIM image. This error
2689 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2690 * specified in @p extract_flags, or if both
2691 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2692 * were specified in @p extract_flags.
2693 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2694 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2695 * one of the paths to extract did not name a regular file.
2697 * If a progress function is registered with @p wim, it will receive
2698 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. Note that because the extraction code
2699 * is stream-based and not file-based, there is no way to get information about
2700 * which path is currently being extracted, but based on byte count you can
2701 * still calculate an approximate percentage complete for the extraction overall
2702 * which may be all you really need anyway.
2705 wimlib_extract_paths(WIMStruct *wim,
2707 const wimlib_tchar *target,
2708 const wimlib_tchar * const *paths,
2713 * @ingroup G_wim_information
2715 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2716 * includes a string of XML that describes the images contained in the WIM.
2718 * See wimlib_get_xml_data() to read the XML data into memory instead.
2721 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2722 * have to be standalone (e.g. it could be part of a split WIM).
2724 * @c stdout, or a FILE* opened for writing, to extract the data to.
2726 * @return 0 on success; nonzero on error.
2727 * @retval ::WIMLIB_ERR_INVALID_PARAM
2728 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2729 * @retval ::WIMLIB_ERR_NOMEM
2730 * @retval ::WIMLIB_ERR_READ
2731 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2732 * Failed to read the XML data from the WIM.
2733 * @retval ::WIMLIB_ERR_WRITE
2734 * Failed to completely write the XML data to @p fp.
2737 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2740 * @ingroup G_general
2742 * Frees all memory allocated for a WIMStruct and closes all files associated
2746 * Pointer to the ::WIMStruct for a WIM file.
2748 * @return This function has no return value.
2751 wimlib_free(WIMStruct *wim);
2754 * @ingroup G_general
2756 * Converts a ::wimlib_compression_type value into a string.
2759 * The ::wimlib_compression_type value to convert.
2762 * A statically allocated string naming the compression algorithm,
2763 * such as "None", "LZX", "XPRESS", or "Invalid".
2765 extern const wimlib_tchar *
2766 wimlib_get_compression_type_string(int ctype);
2769 * @ingroup G_general
2771 * Converts an error code into a string describing it.
2774 * The error code returned by one of wimlib's functions.
2777 * Pointer to a statically allocated string describing the error code,
2778 * or @c NULL if the error code is not valid.
2780 extern const wimlib_tchar *
2781 wimlib_get_error_string(enum wimlib_error_code code);
2784 * @ingroup G_wim_information
2786 * Returns the description of the specified image.
2789 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2790 * to be standalone (e.g. it could be part of a split WIM).
2792 * The number of the image, numbered starting at 1.
2795 * The description of the image, or @c NULL if there is no such image, or
2796 * @c NULL if the specified image has no description. The description
2797 * string is in library-internal memory and may not be modified or freed;
2798 * in addition, the string will become invalid if the description of the
2799 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2801 extern const wimlib_tchar *
2802 wimlib_get_image_description(const WIMStruct *wim, int image);
2805 * @ingroup G_wim_information
2807 * Returns the name of the specified image.
2810 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2811 * to be standalone (e.g. it could be part of a split WIM).
2813 * The number of the image, numbered starting at 1.
2816 * The name of the image, or @c NULL if there is no such image, or an empty
2817 * string if the image is unnamed. The name string is in
2818 * library-internal memory and may not be modified or freed; in addition,
2819 * the string will become invalid if the name of the image is changed, the
2820 * image is deleted, or the ::WIMStruct is destroyed.
2822 extern const wimlib_tchar *
2823 wimlib_get_image_name(const WIMStruct *wim, int image);
2826 * @ingroup G_general
2828 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
2829 * the major version, the next 10 bits contain the minor version, and the low 10
2830 * bits contain the patch version.
2832 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
2833 * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
2834 * corresponding header file.
2837 wimlib_get_version(void);
2840 * @ingroup G_wim_information
2842 * Get basic information about a WIM file.
2845 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2846 * to be standalone (e.g. it could be part of a split WIM).
2848 * A ::wimlib_wim_info structure that will be filled in with information
2849 * about the WIM file.
2854 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2857 * @ingroup G_wim_information
2859 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
2860 * includes a string of XML that describes the images contained in the WIM.
2862 * See wimlib_extract_xml_data() to extract the XML data to a file stream
2866 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2867 * have to be standalone (e.g. it could be part of a split WIM).
2869 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
2870 * XML data is written to this location.
2871 * @param bufsize_ret
2872 * The size of the XML data in bytes is written to this location.
2874 * @return 0 on success; nonzero on error.
2875 * @retval ::WIMLIB_ERR_INVALID_PARAM
2876 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2877 * @p buf_ret or @p bufsize_ret was @c NULL.
2878 * @retval ::WIMLIB_ERR_NOMEM
2879 * @retval ::WIMLIB_ERR_READ
2880 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2881 * Failed to read the XML data from the WIM.
2884 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2887 * @ingroup G_general
2889 * Initialization function for wimlib. Call before using any other wimlib
2890 * function except wimlib_set_print_errors(). If not done manually, this
2891 * function will be called automatically with @p init_flags set to
2892 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
2893 * after it has already successfully run.
2896 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2898 * @return 0 on success; nonzero on failure. Currently, only the following
2899 * error code is defined:
2901 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2902 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2903 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2904 * init_flags, but the corresponding privileges could not be acquired.
2907 wimlib_global_init(int init_flags);
2910 * @ingroup G_general
2912 * Cleanup function for wimlib. You are not required to call this function, but
2913 * it will release any global resources allocated by the library.
2916 wimlib_global_cleanup(void);
2919 * @ingroup G_wim_information
2921 * Determines if an image name is already used by some image in the WIM.
2924 * Pointer to the ::WIMStruct for a WIM file.
2926 * The name to check.
2929 * @c true if there is already an image in @p wim named @p name; @c false
2930 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2931 * the empty string, @c false is returned.
2934 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2937 * @ingroup G_wim_information
2939 * Iterate through a file or directory tree in the WIM image. By specifying
2940 * appropriate flags and a callback function, you can get the attributes of a
2941 * file in the WIM, get a directory listing, or even get a listing of the entire
2945 * The WIM containing the image(s) over which to iterate, specified as a
2946 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2947 * or part 1 of a split WIM. In the case of a WIM file that is not
2948 * standalone, this ::WIMStruct should have had any needed external
2949 * resources previously referenced using wimlib_reference_resources() or
2950 * wimlib_reference_resource_files(). If not, see
2951 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2952 * the behavior when resources are missing.
2955 * The 1-based number of the image in @p wim that contains the files or
2956 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2957 * iteration on all images in the WIM.
2960 * Path in the WIM image at which to do the iteration.
2963 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2966 * A callback function that will receive each directory entry.
2969 * An extra parameter that will always be passed to the callback function
2972 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2973 * first nonzero value that was returned from @p cb. However, additional error
2974 * codes may be returned, including the following:
2976 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2977 * @p path did not exist in the WIM image.
2978 * @retval ::WIMLIB_ERR_NOMEM
2979 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2981 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2982 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2983 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2984 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2985 * different reasons) to read the metadata resource for an image over which
2986 * iteration needed to be done.
2989 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2991 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2994 * @ingroup G_wim_information
2996 * Iterate through the lookup table of a WIM file. This can be used to directly
2997 * get a listing of the unique resources contained in a WIM file over all
2998 * images. Both file resources and metadata resources are included. However,
2999 * only resources actually included in the file represented by @a wim, plus
3000 * explicitly referenced external resources (via wimlib_reference_resources() or
3001 * wimlib_reference_resource_files()) are included in the iteration. For
3002 * example, if @p wim represents just one part of a split WIM, then only
3003 * resources in that part will be included, unless other resources were
3004 * explicitly referenced.
3007 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
3008 * to be standalone (e.g. it could be part of a split WIM).
3011 * Reserved; set to 0.
3014 * A callback function that will receive each resource.
3017 * An extra parameter that will always be passed to the callback function
3020 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3021 * that was returned from @p cb.
3024 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3025 wimlib_iterate_lookup_table_callback_t cb,
3029 * @ingroup G_nonstandalone_wims
3031 * Joins a split WIM into a stand-alone one-part WIM.
3034 * An array of strings that gives the filenames of all parts of the split
3035 * WIM. No specific order is required, but all parts must be included with
3038 * Number of filenames in @p swms.
3039 * @param swm_open_flags
3040 * Open flags for the split WIM parts (e.g.
3041 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3042 * @param wim_write_flags
3043 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3044 * be used to write the joined WIM.
3045 * @param output_path
3046 * The path to write the joined WIM file to.
3048 * @return 0 on success; nonzero on error. This function may return most error
3049 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
3050 * as the following error code:
3052 * @retval ::WIMLIB_ERR_SPLIT_INVALID
3053 * The split WIMs do not form a valid WIM because they do not include all
3054 * the parts of the original WIM, there are duplicate parts, or not all the
3055 * parts have the same GUID and compression type.
3057 * Note: wimlib is generalized enough that this function is not actually needed
3058 * to join a split WIM; instead, you could open the first part of the split WIM,
3059 * then reference the other parts with wimlib_reference_resource_files(), then
3060 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
3061 * an easy-to-use wrapper around this that has some advantages (e.g. extra
3065 wimlib_join(const wimlib_tchar * const *swms,
3067 const wimlib_tchar *output_path,
3069 int wim_write_flags);
3072 * @ingroup G_nonstandalone_wims
3074 * Same as wimlib_join(), but allows specifying a progress function. The
3075 * progress function will receive the write progress messages, such as
3076 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM. In
3077 * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3078 * swm_open_flags, the progress function will receive a series of
3079 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3083 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3085 const wimlib_tchar *output_path,
3087 int wim_write_flags,
3088 wimlib_progress_func_t progfunc,
3093 * @ingroup G_mounting_wim_images
3095 * Mounts an image from a WIM file on a directory read-only or read-write.
3098 * Pointer to the ::WIMStruct containing the image to be mounted.
3100 * The 1-based index of the image to mount.
3102 * The path to an existing empty directory on which to mount the WIM image.
3103 * @param mount_flags
3104 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG. Use
3105 * ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3107 * @param staging_dir
3108 * If non-NULL, the name of a directory in which a temporary directory for
3109 * storing modified or added files will be created. Ignored if
3110 * ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags. If
3111 * left @c NULL, the staging directory is created in the same directory as
3112 * the WIM file that @p wim was originally read from. The staging
3113 * directory is deleted when the image is unmounted.
3115 * @return 0 on success; nonzero on error. The possible error codes include:
3117 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3118 * An image from the WIM file is already mounted read-write, or another
3119 * process is currently appending data to the WIM file.
3120 * @retval ::WIMLIB_ERR_FUSE
3121 * A non-zero status code was returned by @c fuse_main().
3122 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3123 * @p image does not specify an existing, single image in @p wim.
3124 * @retval ::WIMLIB_ERR_INVALID_PARAM
3125 * @p wim was @c NULL; or @p dir was NULL or the empty string; or an
3126 * unrecognized flag was specified in @p mount_flags; or the WIM image has
3127 * already been modified in memory (e.g. by wimlib_update_image()).
3128 * @retval ::WIMLIB_ERR_MKDIR
3129 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3130 * staging directory could not be created.
3131 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3132 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3133 * WIM file is considered read-only because of any of the reasons mentioned
3134 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3135 * @retval ::WIMLIB_ERR_UNSUPPORTED
3136 * Mounting is not supported, either because the platform is Windows, or
3137 * because the platform is UNIX-like and wimlib was compiled using
3138 * <code>--without-fuse</code>.
3140 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3141 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3142 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3143 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3144 * different reasons) to read the metadata resource for the image to mount.
3146 * The ability to mount WIM image is implemented using FUSE (Filesystem in
3147 * UserSpacE). Depending on how FUSE is set up on your system, this function
3148 * may work as normal users in addition to the root user.
3150 * Mounting WIM images is not supported if wimlib was configured
3151 * <code>--without-fuse</code>. This includes Windows builds of wimlib;
3152 * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3154 * Calling this function daemonizes the process, unless
3155 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3157 * It is safe to mount multiple images from the same underlying WIM file
3158 * read-only at the same time, but only if different ::WIMStruct's are used. It
3159 * is @b not safe to mount multiple images from the same WIM file read-write at
3162 * To unmount the image, call wimlib_unmount_image(). This may be done in a
3163 * different process.
3166 wimlib_mount_image(WIMStruct *wim,
3168 const wimlib_tchar *dir,
3170 const wimlib_tchar *staging_dir);
3173 * @ingroup G_creating_and_opening_wims
3175 * Opens a WIM file and creates a ::WIMStruct for it.
3178 * The path to the WIM file to open.
3181 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3184 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3185 * is written to the memory location pointed to by this parameter. The
3186 * ::WIMStruct can be freed using using wimlib_free() when finished with
3189 * @return 0 on success; nonzero on error.
3190 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3191 * The WIM is not the non-first part of a split WIM, and the number of
3192 * metadata resources found in the WIM did not match the image count given
3193 * in the WIM header, or the number of <IMAGE> elements in the XML
3194 * data for the WIM did not match the image count given in the WIM header.
3195 * @retval ::WIMLIB_ERR_INTEGRITY
3196 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
3197 * wim_file contains an integrity table, but the SHA1 message digest for a
3198 * chunk of the WIM does not match the corresponding message digest given
3199 * in the integrity table.
3200 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3201 * Resources in @p wim_file are compressed, but the chunk size was invalid
3202 * for the WIM's compression type.
3203 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3204 * The header of @p wim_file says that resources in the WIM are compressed,
3205 * but the header flag for a recognized compression type is not set.
3206 * @retval ::WIMLIB_ERR_INVALID_HEADER
3207 * The header of @p wim_file was otherwise invalid.
3208 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3209 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
3210 * wim_file contains an integrity table, but the integrity table is
3212 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3213 * The lookup table for the WIM was invalid.
3214 * @retval ::WIMLIB_ERR_INVALID_PARAM
3215 * @p wim_ret was @c NULL.
3216 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3217 * @p wim_file is a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3218 * specified in @p open_flags.
3219 * @retval ::WIMLIB_ERR_NOMEM
3220 * Failed to allocated needed memory.
3221 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3222 * @p wim_file does not begin with the expected magic characters.
3223 * @retval ::WIMLIB_ERR_OPEN
3224 * Failed to open the file @p wim_file for reading.
3225 * @retval ::WIMLIB_ERR_READ
3226 * Failed to read data from @p wim_file.
3227 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3228 * Unexpected end-of-file while reading data from @p wim_file.
3229 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3230 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3231 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3232 * The WIM cannot be opened because it contains encrypted segments. (It
3233 * may be a Windows 8 "ESD" file).
3234 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3235 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3236 * considered read-only because of any of the reasons mentioned in the
3237 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3238 * @retval ::WIMLIB_ERR_XML
3239 * The XML data for @p wim_file is invalid.
3242 wimlib_open_wim(const wimlib_tchar *wim_file,
3244 WIMStruct **wim_ret);
3247 * @ingroup G_creating_and_opening_wims
3249 * Same as wimlib_open_wim(), but allows specifying a progress function and
3250 * progress context. If successful, the progress function will be registered in
3251 * the newly open ::WIMStruct. In addition, if
3252 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, the
3253 * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3254 * messages while checking the WIM's integrity.
3257 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3259 WIMStruct **wim_ret,
3260 wimlib_progress_func_t progfunc,
3264 * @ingroup G_writing_and_overwriting_wims
3266 * Overwrites the file that the WIM was originally read from, with changes made.
3267 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3268 * rather than wimlib_create_new_wim().
3270 * There are two ways that a WIM may be overwritten. The first is to do a full
3271 * rebuild. In this mode, the new WIM is written to a temporary file and then
3272 * renamed to the original file after it is has been completely written. The
3273 * temporary file is made in the same directory as the original WIM file. A
3274 * full rebuild may take a while, but can be used even if images have been
3275 * modified or deleted, will produce a WIM with no holes, and has little chance
3276 * of unintentional data loss because the temporary WIM is fsync()ed before
3277 * being renamed to the original WIM.
3279 * The second way to overwrite a WIM is by appending to the end of it and
3280 * overwriting the header. This can be much faster than a full rebuild, but the
3281 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3282 * begins with writing any new file resources *after* everything in the old WIM,
3283 * even though this will leave a hole where the old lookup table, XML data, and
3284 * integrity were. This is done so that the WIM remains valid even if the
3285 * operation is aborted mid-write. The WIM header is only overwritten at the
3286 * very last moment, and up until that point the WIM will be seen as the old
3289 * By default, wimlib_overwrite() does the append-style overwrite described
3290 * above, unless resources in the WIM are arranged in an unusual way or if
3291 * images have been deleted from the WIM. Use the flag
3292 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3293 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3294 * images have been deleted from the WIM.
3296 * In the temporary-file overwrite mode, no changes are made to the WIM on
3297 * failure, and the temporary file is deleted if possible. Abnormal termination
3298 * of the program will result in the temporary file being orphaned. In the
3299 * direct append mode, the WIM is truncated to the original length on failure;
3300 * and while abnormal termination of the program will result in extra data
3301 * appended to the original WIM, it should still be a valid WIM.
3303 * If this function completes successfully, no more functions should be called
3304 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
3305 * the WIM file anew.
3308 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3309 * been in-memory changes made to it, which are then reflected in the
3311 * @param write_flags
3312 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3313 * @param num_threads
3314 * Number of threads to use for compression (see wimlib_write()).
3316 * @return 0 on success; nonzero on error. This function may return most error
3317 * codes returned by wimlib_write() as well as the following error codes:
3319 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3320 * The WIM was going to be modified in-place (with no temporary file), but
3321 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3322 * because another thread or process has mounted an image from the WIM
3323 * read-write or is currently modifying the WIM in-place.
3324 * @retval ::WIMLIB_ERR_NO_FILENAME
3325 * @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
3326 * than a WIM read with wimlib_open_wim().
3327 * @retval ::WIMLIB_ERR_RENAME
3328 * The temporary file that the WIM was written to could not be renamed to
3329 * the original filename of @p wim.
3330 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3331 * The WIM file is considered read-only because of any of the reasons
3332 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3335 * If a progress function is registered with @p wim, it will receive the
3336 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3337 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3338 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3341 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3344 * @ingroup G_wim_information
3346 * Prints information about one image, or all images, contained in a WIM.
3349 * Pointer to the ::WIMStruct for a WIM file.
3351 * The image about which to print information. Can be the number of an
3352 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3355 * @return This function has no return value. No error checking is done when
3356 * printing the information. If @p image is invalid, an error message is
3360 wimlib_print_available_images(const WIMStruct *wim, int image);
3363 * @ingroup G_wim_information
3365 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3366 * in a way that can be accessed programatically.
3369 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3372 * @ingroup G_nonstandalone_wims
3374 * Reference resources from other WIM files or split WIM parts. This function
3375 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3376 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3377 * from other files, before calling a function such as wimlib_extract_image()
3378 * that requires the resources to be present.
3381 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3382 * necessarily "standalone". In the case of split WIMs, this should be the
3383 * first part, since only the first part contains the metadata resources.
3384 * In the case of delta WIMs, this should be the delta WIM rather than the
3385 * WIM on which it is based.
3386 * @param resource_wimfiles_or_globs
3387 * Array of paths to WIM files and/or split WIM parts to reference.
3388 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3389 * ref_flags, these are treated as globs rather than literal paths. That
3390 * is, using this function you can specify zero or more globs, each of
3391 * which expands to one or more literal paths.
3393 * Number of entries in @p resource_wimfiles_or_globs.
3395 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3396 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3398 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3399 * pass to internal calls to wimlib_open_wim() on the reference files.
3401 * @return 0 on success; nonzero on error.
3403 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3404 * One of the specified globs did not match any paths (only with both
3405 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3406 * specified in @p ref_flags).
3407 * @retval ::WIMLIB_ERR_NOMEM
3408 * Failed to allocate memory.
3409 * @retval ::WIMLIB_ERR_READ
3410 * I/O or permissions error while processing a file glob.
3412 * This function can additionally return most values that can be returned by
3413 * wimlib_open_wim().
3416 wimlib_reference_resource_files(WIMStruct *wim,
3417 const wimlib_tchar * const *resource_wimfiles_or_globs,
3423 * @ingroup G_nonstandalone_wims
3425 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3426 * where the caller must open the ::WIMStruct for each referenced file itself.
3429 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3430 * necessarily "standalone". In the case of split WIMs, this should be the
3431 * first part, since only the first part contains the metadata resources.
3432 * @param resource_wims
3433 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3434 * split WIM parts to reference.
3435 * @param num_resource_wims
3436 * Number of entries in @p resource_wims.
3438 * Currently ignored (set to 0).
3440 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3441 * @p resource_wims are referenced internally by @p wim and must not be freed
3442 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3443 * been freed with wimlib_free(), or immediately before freeing @p wim with
3446 * @retval ::WIMLIB_ERR_INVALID_PARAM
3447 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3448 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3449 * @retval ::WIMLIB_ERR_NOMEM
3450 * Failed to allocate memory.
3453 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3454 unsigned num_resource_wims, int ref_flags);
3457 * @ingroup G_modifying_wims
3459 * Declares that a newly added image is mostly the same as a prior image, but
3460 * captured at a later point in time, possibly with some modifications in the
3461 * intervening time. This is designed to be used in incremental backups of the
3462 * same filesystem or directory tree.
3464 * This function compares the metadata of the directory tree of the newly added
3465 * image against that of the old image. Any files that are present in both the
3466 * newly added image and the old image and have timestamps that indicate they
3467 * haven't been modified are deemed not to have been modified and have their
3468 * SHA1 message digest copied from the old image. Because of this and because
3469 * WIM uses single-instance streams, such files need not be read from the
3470 * filesystem when the WIM is being written or overwritten. Note that these
3471 * unchanged files will still be "archived" and will be logically present in the
3472 * new image; the optimization is that they don't need to actually be read from
3473 * the filesystem because the WIM already contains them.
3475 * This function is provided to optimize incremental backups. The resulting WIM
3476 * file will still be the same regardless of whether this function is called.
3477 * (This is, however, assuming that timestamps have not been manipulated or
3478 * unmaintained as to trick this function into thinking a file has not been
3479 * modified when really it has. To partly guard against such cases, other
3480 * metadata such as file sizes will be checked as well.)
3482 * This function must be called after adding the new image (e.g. with
3483 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3484 * wimlib_overwrite()).
3487 * Pointer to the ::WIMStruct for a WIM.
3489 * 1-based index in the WIM of the newly added image. This image can have
3490 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3491 * wimlib_add_empty_image() followed by wimlib_update_image().
3492 * @param template_wim
3493 * The ::WIMStruct for the WIM containing the template image. This can be
3494 * the same as @p wim, or it can be a different ::WIMStruct.
3495 * @param template_image
3496 * 1-based index in the WIM of a template image that reflects a prior state
3497 * of the directory tree being captured.
3499 * Reserved; must be 0.
3501 * @return 0 on success; nonzero on error.
3503 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3504 * @p new_image and/or @p template_image were not a valid image indices in
3506 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3507 * The specified ::WIMStruct did not actually contain the metadata resource
3508 * for the new or template image; for example, it was a non-first part of a
3510 * @retval ::WIMLIB_ERR_NOMEM
3511 * Failed to allocate needed memory.
3512 * @retval ::WIMLIB_ERR_INVALID_PARAM
3513 * @p new_image was equal to @p template_image, or @p new_image specified
3514 * an image that had not been modified since opening the WIM.
3516 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3517 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3518 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3519 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3520 * different reasons) to read the metadata resource for the template image.
3523 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3524 WIMStruct *template_wim, int template_image,
3528 * @ingroup G_general
3530 * Registers a progress function with a ::WIMStruct.
3533 * The ::WIMStruct for which to register the progress function.
3535 * Pointer to the progress function to register. If the WIM already has a
3536 * progress function registered, it will be replaced with this one. If @p
3537 * NULL, the current progress function (if any) will be unregistered.
3539 * The value which will be passed as the third argument to calls to @p
3543 wimlib_register_progress_function(WIMStruct *wim,
3544 wimlib_progress_func_t progfunc,
3548 * @ingroup G_modifying_wims
3550 * Rename the @p source_path to the @p dest_path in the specified @p image of
3553 * This just builds an appropriate ::wimlib_rename_command and passes it to
3554 * wimlib_update_image().
3557 wimlib_rename_path(WIMStruct *wim, int image,
3558 const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3561 * @ingroup G_wim_information
3563 * Translates a string specifying the name or number of an image in the WIM into
3564 * the number of the image. The images are numbered starting at 1.
3567 * Pointer to the ::WIMStruct for a WIM.
3568 * @param image_name_or_num
3569 * A string specifying the name or number of an image in the WIM. If it
3570 * parses to a positive integer, this integer is taken to specify the
3571 * number of the image, indexed starting at 1. Otherwise, it is taken to
3572 * be the name of an image, as given in the XML data for the WIM file. It
3573 * also may be the keyword "all" or the string "*", both of which will
3574 * resolve to ::WIMLIB_ALL_IMAGES.
3576 * There is no way to search for an image actually named "all", "*", or an
3577 * integer number, or an image that has no name. However, you can use
3578 * wimlib_get_image_name() to get the name of any image.
3581 * If the string resolved to a single existing image, the number of that
3582 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3583 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3584 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3585 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3586 * images in @p wim has no name.
3589 wimlib_resolve_image(WIMStruct *wim,
3590 const wimlib_tchar *image_name_or_num);
3593 * @ingroup G_modifying_wims
3595 * Changes the description of an image in the WIM.
3598 * Pointer to the ::WIMStruct for a WIM.
3600 * The number of the image for which to change the description.
3601 * @param description
3602 * The new description to give the image. It may be @c NULL, which
3603 * indicates that the image is to be given no description.
3605 * @return 0 on success; nonzero on error.
3606 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3607 * @p image does not specify a single existing image in @p wim.
3608 * @retval ::WIMLIB_ERR_NOMEM
3609 * Failed to allocate the memory needed to duplicate the @p description
3611 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3612 * @p wim is considered read-only because of any of the reasons mentioned
3613 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3616 wimlib_set_image_descripton(WIMStruct *wim, int image,
3617 const wimlib_tchar *description);
3620 * @ingroup G_writing_and_overwriting_wims
3622 * Set the compression chunk size of a WIM to use in subsequent calls to
3623 * wimlib_write() or wimlib_overwrite().
3625 * For compatibility reasons, using this function is not generally recommended.
3626 * See the documentation for the @c --chunk-size option of <b>wimlib-imagex
3627 * capture</b> for more information.
3629 * A larger compression chunk size will likely result in a better compression
3630 * ratio, but the speed of random access to the WIM will be reduced.
3631 * Furthermore, the effect of a larger compression chunk size is limited by the
3632 * size of each stream ("file") being compressed.
3635 * ::WIMStruct for a WIM.
3637 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3638 * on the compression format; see the documentation for the @c --chunk-size
3639 * option of <b>wimlib-imagex capture</b> for more information. As a
3640 * special case, if @p chunk_size is specified as 0, the chunk size is set
3641 * to the default for the currently selected output compression type.
3643 * @return 0 on success; nonzero on error.
3645 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3646 * @p chunk_size is not a supported chunk size for the currently selected
3647 * output compression type.
3650 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3653 * @ingroup G_writing_and_overwriting_wims
3655 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3656 * packed streams (solid blocks).
3659 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3662 * @ingroup G_writing_and_overwriting_wims
3664 * Set the compression type of a WIM to use in subsequent calls to
3665 * wimlib_write() or wimlib_overwrite().
3668 * ::WIMStruct for a WIM.
3670 * The compression type to set (one of ::wimlib_compression_type). If this
3671 * compression type is incompatible with the current output chunk size
3672 * (either the default or as set with wimlib_set_output_chunk_size()), the
3673 * output chunk size is reset to the default for that compression type.
3675 * @return 0 on success; nonzero on error.
3677 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3678 * @p ctype did not specify a valid compression type.
3681 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3684 * @ingroup G_writing_and_overwriting_wims
3686 * Similar to wimlib_set_output_compression_type(), but set the compression type
3687 * for writing packed streams (solid blocks).
3690 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3693 * @ingroup G_modifying_wims
3695 * Set basic information about a WIM.
3698 * Pointer to the ::WIMStruct for a WIM.
3700 * A struct ::wimlib_wim_info that contains the information to set. Only
3701 * the information explicitly specified in the @p which flags need be
3704 * Flags that specify which information to set. This is a bitwise OR of
3705 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3706 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3708 * @return 0 on success; nonzero on failure.
3709 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3710 * The WIM file is considered read-only because of any of the reasons
3711 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3712 * flag. However, as a special case, if you are using
3713 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3714 * function will not fail due to the readonly flag being previously set.
3715 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3716 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3717 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3721 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3725 * @ingroup G_modifying_wims
3727 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3728 * (something like "Core" or "Ultimate")
3731 * Pointer to the ::WIMStruct for a WIM.
3733 * The number of the image for which to change the description.
3735 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3736 * indicates that the image is to be given no \<FLAGS\> element.
3738 * @return 0 on success; nonzero on error.
3739 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3740 * @p image does not specify a single existing image in @p wim.
3741 * @retval ::WIMLIB_ERR_NOMEM
3742 * Failed to allocate the memory needed to duplicate the @p flags string.
3743 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3744 * @p wim is considered read-only because of any of the reasons mentioned
3745 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3748 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3751 * @ingroup G_modifying_wims
3753 * Changes the name of an image in the WIM.
3756 * Pointer to the ::WIMStruct for a WIM.
3758 * The number of the image for which to change the name.
3760 * New name to give the new image. If @c NULL or empty, the new image is
3761 * given no name. If nonempty, it must specify a name that does not
3762 * already exist in @p wim.
3764 * @return 0 on success; nonzero on error.
3765 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3766 * There is already an image named @p name in @p wim.
3767 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3768 * @p image does not specify a single existing image in @p wim.
3769 * @retval ::WIMLIB_ERR_NOMEM
3770 * Failed to allocate the memory needed to duplicate the @p name string.
3771 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3772 * @p wim is considered read-only because of any of the reasons mentioned
3773 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3776 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3779 * @ingroup G_general
3781 * Set the functions that wimlib uses to allocate and free memory.
3783 * These settings are global and not per-WIM.
3785 * The default is to use the default @c malloc() and @c free() from the C
3788 * Please note that some external functions, such as those in @c libntfs-3g, may
3789 * use the standard memory allocation functions.
3791 * @param malloc_func
3792 * A function equivalent to @c malloc() that wimlib will use to allocate
3793 * memory. If @c NULL, the allocator function is set back to the default
3794 * @c malloc() from the C library.
3796 * A function equivalent to @c free() that wimlib will use to free memory.
3797 * If @c NULL, the free function is set back to the default @c free() from
3799 * @param realloc_func
3800 * A function equivalent to @c realloc() that wimlib will use to reallocate
3801 * memory. If @c NULL, the free function is set back to the default @c
3802 * realloc() from the C library.
3806 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3807 void (*free_func)(void *),
3808 void *(*realloc_func)(void *, size_t));
3811 * @ingroup G_general
3813 * Sets whether wimlib is to print error messages to @c stderr when a function
3814 * fails. These error messages may provide information that cannot be
3815 * determined only from the error code that is returned. Not every error will
3816 * result in an error message being printed.
3818 * This setting is global and not per-WIM.
3820 * By default, error messages are not printed.
3822 * This can be called before wimlib_global_init().
3824 * @param show_messages
3825 * @c true if error messages are to be printed; @c false if error messages
3826 * are not to be printed.
3828 * @return 0 on success; nonzero on error.
3829 * @retval ::WIMLIB_ERR_UNSUPPORTED
3830 * @p show_messages was @c true, but wimlib was compiled with the @c
3831 * --without-error-messages option. Therefore, error messages cannot be
3835 wimlib_set_print_errors(bool show_messages);
3838 * @ingroup G_nonstandalone_wims
3840 * Splits a WIM into multiple parts.
3843 * The ::WIMStruct for the WIM to split.
3845 * Name of the SWM file to create. This will be the name of the first
3846 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3847 * appended before the suffix.
3849 * The maximum size per part, in bytes. Unfortunately, it is not
3850 * guaranteed that this will really be the maximum size per part, because
3851 * some file resources in the WIM may be larger than this size, and the WIM
3852 * file format provides no way to split up file resources among multiple
3854 * @param write_flags
3855 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3856 * flags will be used to write each split WIM part. Specify 0 here to get
3857 * the default behavior.
3859 * @return 0 on success; nonzero on error. This function may return most error
3860 * codes that can be returned by wimlib_write() as well as the following error
3863 * @retval ::WIMLIB_ERR_INVALID_PARAM
3864 * @p swm_name was not a nonempty string, or @p part_size was 0.
3866 * Note: the WIM's uncompressed and compressed resources are not checksummed
3867 * when they are copied from the joined WIM to the split WIM parts, nor are
3868 * compressed resources re-compressed (unless explicitly requested with
3869 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
3871 * If a progress function is registered with @p wim, for each split WIM part
3872 * that is written it will receive the messages
3873 * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3874 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
3877 wimlib_split(WIMStruct *wim,
3878 const wimlib_tchar *swm_name,
3883 * @ingroup G_mounting_wim_images
3885 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3887 * When unmounting a read-write mounted image, the default behavior is to
3888 * discard changes to the image. Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
3889 * WIM image to be committed.
3892 * The directory the WIM image was mounted on.
3893 * @param unmount_flags
3894 * Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
3896 * @return 0 on success; nonzero on error. The possible error codes include:
3898 * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
3899 * There is no WIM image mounted on the specified directory.
3900 * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
3901 * The read-write mounted WIM image cannot be committed because there are
3902 * file descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
3904 * @retval ::WIMLIB_ERR_MQUEUE
3905 * Could not create a POSIX message queue.
3906 * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
3907 * The WIM image was mounted by a different user.
3908 * @retval ::WIMLIB_ERR_UNSUPPORTED
3909 * Mounting is not supported, either because the platform is Windows, or
3910 * because the platform is UNIX-like and wimlib was compiled using @c
3913 * Note: you can also unmount the image by using the @c umount() system call, or
3914 * by using the @c umount or @c fusermount programs. However, you need to call
3915 * this function if you want changes to be committed.
3918 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
3921 * @ingroup G_mounting_wim_images
3923 * Same as wimlib_unmount_image(), but allows specifying a progress function.
3924 * If changes are committed from a read-write mount, the progress function will
3925 * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
3928 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
3930 wimlib_progress_func_t progfunc,
3934 * @ingroup G_modifying_wims
3936 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3939 * Pointer to the ::WIMStruct for the WIM file to update.
3941 * The 1-based index of the image in the WIM to update. It cannot be
3942 * ::WIMLIB_ALL_IMAGES.
3944 * An array of ::wimlib_update_command's that specify the update operations
3947 * Number of commands in @p cmds.
3948 * @param update_flags
3949 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3951 * @return 0 on success; nonzero on error. On failure, all update commands will
3952 * be rolled back, and no visible changes shall have been made to @p wim.
3953 * Possible error codes include:
3955 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3956 * The capture configuration structure specified for an add command was
3958 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3959 * @p image did not specify a single, existing image in @p wim.
3960 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3961 * Attempted to perform an add command that conflicted with previously
3962 * existing files in the WIM when an overlay was attempted.
3963 * @retval ::WIMLIB_ERR_INVALID_PARAM
3964 * An unknown operation type was specified in the update commands; or,
3965 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3966 * in the @p add_flags, but the same image had previously already been
3967 * added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3968 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3969 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3970 * specified in the @p add_flags for an add command in which @p
3971 * wim_target_path was not the root directory of the WIM image.
3972 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3973 * (Windows only): While executing an add command, tried to capture a
3974 * reparse point with invalid data.
3975 * @retval ::WIMLIB_ERR_IS_DIRECTORY
3976 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3977 * for a WIM path that corresponded to a directory; or, a rename command
3978 * attempted to rename a directory to a non-directory.
3979 * @retval ::WIMLIB_ERR_NOMEM
3980 * Failed to allocate needed memory.
3981 * @retval ::WIMLIB_ERR_NOTDIR
3982 * A rename command attempted to rename a directory to a non-directory; or,
3983 * an add command was executed that attempted to set the root of the WIM
3984 * image as a non-directory; or, a path component used as a directory in a
3985 * rename command was not, in fact, a directory.
3986 * @retval ::WIMLIB_ERR_NOTEMPTY
3987 * A rename command attempted to rename a directory to a non-empty
3989 * @retval ::WIMLIB_ERR_NTFS_3G
3990 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3991 * error occurred while reading data from the NTFS volume using libntfs-3g.
3992 * @retval ::WIMLIB_ERR_OPEN
3993 * Failed to open a file to be captured while executing an add command.
3994 * @retval ::WIMLIB_ERR_OPENDIR
3995 * Failed to open a directory to be captured while executing an add command.
3996 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3997 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3998 * WIM path that did not exist; or, a rename command attempted to rename a
3999 * file that does not exist.
4000 * @retval ::WIMLIB_ERR_READ
4001 * While executing an add command, failed to read data from a file or
4002 * directory to be captured.
4003 * @retval ::WIMLIB_ERR_READLINK
4004 * While executing an add command, failed to read the target of a symbolic
4005 * link or junction point.
4006 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
4007 * (Windows only) Failed to perform a reparse point fixup because of
4008 * problems with the data of a reparse point.
4009 * @retval ::WIMLIB_ERR_STAT
4010 * While executing an add command, failed to get attributes for a file or
4012 * @retval ::WIMLIB_ERR_UNSUPPORTED
4013 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
4014 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
4015 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
4016 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
4017 * add_flags for an update command.
4018 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4019 * While executing an add command, attempted to capture a file that was not
4020 * a supported file type (e.g. a device file). Only if
4021 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
4022 * for an update command.
4023 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4024 * The WIM file is considered read-only because of any of the reasons
4025 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
4028 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4029 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4030 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4031 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4032 * different reasons) to read the metadata resource for an image that needed to
4036 wimlib_update_image(WIMStruct *wim,
4038 const struct wimlib_update_command *cmds,
4043 * @ingroup G_writing_and_overwriting_wims
4045 * Writes a WIM to a file.
4047 * This brings in resources from any external locations, such as directory trees
4048 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4049 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
4051 * By default, the new WIM file is written as stand-alone. Using the
4052 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4053 * instead. However, this function cannot directly write a "split" WIM; use
4054 * wimlib_split() for that.
4057 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
4058 * changes made to it, which are then reflected in the output file.
4060 * The path to the file to write the WIM to.
4062 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
4063 * images are to be included in the new on-disk WIM file. If for some
4064 * reason you only want to include a single image, specify the index of
4065 * that image instead.
4066 * @param write_flags
4067 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
4068 * @param num_threads
4069 * Number of threads to use for compressing data. If 0, the number of
4070 * threads is taken to be the number of online processors. Note: if no
4071 * data compression needs to be done, no additional threads will be created
4072 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
4073 * exporting an image from a compressed WIM to another WIM of the same
4074 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
4077 * @return 0 on success; nonzero on error.
4079 * @retval ::WIMLIB_ERR_INVALID_IMAGE
4080 * @p image does not specify a single existing image in @p wim, and is not
4081 * ::WIMLIB_ALL_IMAGES.
4082 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4083 * A file that had previously been scanned for inclusion in the WIM by
4084 * wimlib_add_image() was concurrently modified, so it failed the SHA1
4085 * message digest check.
4086 * @retval ::WIMLIB_ERR_INVALID_PARAM
4087 * @p path was @c NULL.
4088 * @retval ::WIMLIB_ERR_NOMEM
4089 * Failed to allocate needed memory.
4090 * @retval ::WIMLIB_ERR_OPEN
4091 * Failed to open @p path for writing, or some file resources in @p wim
4092 * refer to files in the outside filesystem, and one of these files could
4093 * not be opened for reading.
4094 * @retval ::WIMLIB_ERR_READ
4095 * An error occurred when trying to read data from the WIM file associated
4096 * with @p wim, or some file resources in @p wim refer to files in the
4097 * outside filesystem, and a read error occurred when reading one of these
4099 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4100 * A stream that needed to be written could not be found in the stream
4101 * lookup table of @p wim. This error can occur if, for example, @p wim is
4102 * part of a split WIM but needed resources from the other split WIM parts
4103 * were not referenced with wimlib_reference_resources() or
4104 * wimlib_reference_resource_files() before the call to wimlib_write().
4105 * @retval ::WIMLIB_ERR_WRITE
4106 * An error occurred when trying to write data to the new WIM file.
4108 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4109 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4110 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4111 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4112 * different reasons) to read the metadata resource for an image that needed to
4115 * If a progress function is registered with @p wim, it will receive the
4116 * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4117 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4118 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4121 wimlib_write(WIMStruct *wim,
4122 const wimlib_tchar *path,
4125 unsigned num_threads);
4128 * @ingroup G_writing_and_overwriting_wims
4130 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
4131 * file descriptor, which need not be seekable if the write is done in a special
4132 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
4133 * write_flags. This can, for example, allow capturing a WIM image and
4134 * streaming it over the network. See the documentation for
4135 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
4137 * The file descriptor @p fd will @b not be closed when the write is complete;
4138 * the calling code is responsible for this.
4140 * Returns 0 on success; nonzero on failure. The possible error codes include
4141 * those that can be returned by wimlib_write() as well as the following:
4143 * @retval ::WIMLIB_ERR_INVALID_PARAM
4144 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4145 * specified in @p write_flags.
4148 wimlib_write_to_fd(WIMStruct *wim,
4152 unsigned num_threads);
4155 * @defgroup G_compression Compression and decompression functions
4157 * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
4158 * exported for convenience only, as they are already used by wimlib internally
4161 * These functions can be used for general-purpose lossless data compression,
4162 * but some limitations apply; for example, none of the compressors or
4163 * decompressors currently support sliding windows, and there also exist
4164 * slightly different variants of these formats that are not supported
4170 /** Header for compression parameters to pass to wimlib_create_compressor() or
4171 * wimlib_set_default_compressor_params(). */
4172 struct wimlib_compressor_params_header {
4173 /** Size of the parameters, in bytes. */
4177 /** Header for decompression parameters to pass to wimlib_create_decompressor()
4178 * or wimlib_set_default_decompressor_params() */
4179 struct wimlib_decompressor_params_header {
4180 /** Size of the parameters, in bytes. */
4184 /** LZX compression parameters that can optionally be passed to
4185 * wimlib_create_compressor() with the compression type
4186 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
4187 struct wimlib_lzx_compressor_params {
4188 /** hdr.size Must be set to the size of this structure, in bytes. */
4189 struct wimlib_compressor_params_header hdr;
4191 /** Relatively fast LZX compression algorithm with a decent compression
4192 * ratio; the suggested default. */
4193 #define WIMLIB_LZX_ALGORITHM_FAST 0
4195 /** Slower LZX compression algorithm that provides a better compression
4197 #define WIMLIB_LZX_ALGORITHM_SLOW 1
4199 /** Algorithm to use to perform the compression: either
4200 * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW. The
4201 * format is still LZX; this refers to the method the code will use to
4202 * perform LZX-compatible compression. */
4203 uint32_t algorithm : 3;
4205 /** If set to 1, the default parameters for the specified algorithm are
4206 * used rather than the ones specified in the following union. */
4207 uint32_t use_defaults : 1;
4210 /** Parameters for the fast algorithm. */
4211 struct wimlib_lzx_fast_params {
4212 uint32_t fast_reserved1[10];
4215 /** Parameters for the slow algorithm. */
4216 struct wimlib_lzx_slow_params {
4217 /** If set to 1, the compressor can output length 2
4218 * matches. If set 0, the compressor only outputs
4219 * matches of length 3 or greater. Suggested value: 1
4221 uint32_t use_len2_matches : 1;
4223 uint32_t slow_reserved1 : 31;
4225 /** Matches with length (in bytes) greater than or equal
4226 * to this value are immediately taken without spending
4227 * time on minimum-cost measurements. Suggested value:
4229 uint32_t nice_match_length;
4231 /** Number of passes to compute a match/literal sequence
4232 * for each LZX block. This is for an iterative
4233 * algorithm that attempts to minimize the cost of the
4234 * match/literal sequence by using a cost model provided
4235 * by the previous iteration. Must be at least 1.
4236 * Suggested value: 2. */
4237 uint32_t num_optim_passes;
4239 /** Reserved; set to 0. */
4240 uint32_t slow_reserved_blocksplit;
4242 /** Maximum depth to search for matches at each
4243 * position. Suggested value: 50. */
4244 uint32_t max_search_depth;
4246 /** Maximum number of potentially good matches to
4247 * consider for each position. Suggested value: 3. */
4248 uint32_t max_matches_per_pos;
4250 uint32_t slow_reserved2[2];
4252 /** Assumed cost of a main symbol with zero frequency.
4253 * Must be at least 1 and no more than 16. Suggested
4255 uint8_t main_nostat_cost;
4257 /** Assumed cost of a length symbol with zero frequency.
4258 * Must be at least 1 and no more than 16. Suggested
4260 uint8_t len_nostat_cost;
4262 /** Assumed cost of an aligned symbol with zero
4263 * frequency. Must be at least 1 and no more than 8.
4264 * Suggested value: 7. */
4265 uint8_t aligned_nostat_cost;
4267 uint8_t slow_reserved3[5];
4272 /** LZMS compression parameters that can optionally be passed to
4273 * wimlib_create_compressor() with the compression type
4274 * ::WIMLIB_COMPRESSION_TYPE_LZMS. */
4275 struct wimlib_lzms_compressor_params {
4276 /** hdr.size Must be set to the size of this structure, in bytes. */
4277 struct wimlib_compressor_params_header hdr;
4279 /** Minimum match length to output. This must be at least 2. Suggested
4281 uint32_t min_match_length;
4283 /** Maximum match length to output. This must be at least @p
4284 * min_match_length. Suggested value: @p UINT32_MAX. */
4285 uint32_t max_match_length;
4287 /** Matches with length (in bytes) greater than or equal to this value
4288 * are immediately taken without spending time on minimum-cost
4289 * measurements. The minimum of @p max_match_length and @p
4290 * nice_match_length may not exceed 65536. Suggested value: 32. */
4291 uint32_t nice_match_length;
4293 /** Maximum depth to search for matches at each position. Suggested
4295 uint32_t max_search_depth;
4297 /** Maximum number of potentially good matches to consider at each
4298 * position. Suggested value: 3. */
4299 uint32_t max_matches_per_pos;
4301 /** Length of the array for the near-optimal LZ parsing algorithm. This
4302 * must be at least 1. Suggested value: 1024. */
4303 uint32_t optim_array_length;
4305 uint64_t reserved2[4];
4308 /** Opaque compressor handle. */
4309 struct wimlib_compressor;
4311 /** Opaque decompressor handle. */
4312 struct wimlib_decompressor;
4315 * Set the default compression parameters for the specified compression type.
4316 * This will affect both explicit and wimlib-internal calls to
4317 * wimlib_create_compressor().
4320 * Compression type for which to set the default compression parameters.
4322 * Compression-type specific parameters. This may be @c NULL, in which
4323 * case the "default default" parameters are restored.
4325 * @return 0 on success; nonzero on error.
4327 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4328 * @p ctype was not a supported compression type.
4329 * @retval ::WIMLIB_ERR_INVALID_PARAM
4330 * @p params were invalid.
4331 * @retval ::WIMLIB_ERR_NOMEM
4332 * Not enough memory to duplicate the parameters (perhaps @c params->size
4336 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
4337 const struct wimlib_compressor_params_header *params);
4340 * Returns the approximate number of bytes needed to allocate a compressor with
4341 * wimlib_create_compressor() for the specified compression type, block size,
4342 * and parameters. @p params may be @c NULL, in which case the current default
4343 * parameters for @p ctype are used. Returns 0 if the compression type or
4344 * parameters are invalid.
4347 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4348 size_t max_block_size,
4349 const struct wimlib_compressor_params_header *params);
4352 * Allocate a compressor for the specified compression type using the specified
4356 * Compression type for which to create the compressor.
4357 * @param max_block_size
4358 * Maximum block size to support. The exact meaning and allowed values for
4359 * this parameter depend on the compression type, but it at least specifies
4360 * the maximum allowed value for @p uncompressed_size to wimlib_compress().
4361 * @param extra_params
4362 * An optional pointer to extra compressor parameters for the specified
4363 * compression type. For LZX, a pointer to ::wimlib_lzx_compressor_params
4364 * may be specified here. If left @c NULL, the default parameters are
4366 * @param compressor_ret
4367 * A location into which to return the pointer to the allocated compressor,
4368 * which can be used for any number of calls to wimlib_compress() before
4369 * being freed with wimlib_free_compressor().
4371 * @return 0 on success; nonzero on error.
4373 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4374 * @p ctype was not a supported compression type.
4375 * @retval ::WIMLIB_ERR_INVALID_PARAM
4376 * The compression parameters were invalid.
4377 * @retval ::WIMLIB_ERR_NOMEM
4378 * Insufficient memory to allocate the compressor.
4381 wimlib_create_compressor(enum wimlib_compression_type ctype,
4382 size_t max_block_size,
4383 const struct wimlib_compressor_params_header *extra_params,
4384 struct wimlib_compressor **compressor_ret);
4387 * Losslessly compress a block of data using a compressor previously created
4388 * with wimlib_create_compressor().
4390 * @param uncompressed_data
4391 * Buffer containing the data to compress.
4392 * @param uncompressed_size
4393 * Size, in bytes, of the data to compress.
4394 * @param compressed_data
4395 * Buffer into which to write the compressed data.
4396 * @param compressed_size_avail
4397 * Number of bytes available in @p compressed_data.
4399 * A compressor previously allocated with wimlib_create_compressor().
4402 * The size of the compressed data, in bytes, or 0 if the input data could
4403 * not be compressed to @p compressed_size_avail or fewer bytes.
4406 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4407 void *compressed_data, size_t compressed_size_avail,
4408 struct wimlib_compressor *compressor);
4411 * Free a compressor previously allocated with wimlib_create_compressor().
4414 * The compressor to free.
4417 wimlib_free_compressor(struct wimlib_compressor *compressor);
4420 * Set the default decompression parameters for the specified compression type.
4421 * This will affect both explicit and wimlib-internal calls to
4422 * wimlib_create_decompressor().
4425 * Compression type for which to set the default decompression parameters.
4427 * Compression-type specific parameters. This may be @c NULL, in which
4428 * case the "default default" parameters are restored.
4430 * @return 0 on success; nonzero on error.
4432 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4433 * @p ctype was not a supported compression type.
4434 * @retval ::WIMLIB_ERR_NOMEM
4435 * Not enough memory to duplicate the parameters (perhaps @c params->size
4439 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4440 const struct wimlib_decompressor_params_header *params);
4443 * Allocate a decompressor for the specified compression type using the
4444 * specified parameters.
4447 * Compression type for which to create the decompressor.
4448 * @param max_block_size
4449 * Maximum block size to support. The exact meaning and allowed values for
4450 * this parameter depend on the compression type, but it at least specifies
4451 * the maximum allowed value for @p uncompressed_size to
4452 * wimlib_decompress().
4453 * @param extra_params
4454 * An optional pointer to extra decompressor parameters for the specified
4455 * compression type. If @c NULL, the default parameters are used.
4456 * @param decompressor_ret
4457 * A location into which to return the pointer to the allocated
4458 * decompressor, which can be used for any number of calls to
4459 * wimlib_decompress() before being freed with wimlib_free_decompressor().
4461 * @return 0 on success; nonzero on error.
4463 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4464 * @p ctype was not a supported compression type.
4465 * @retval ::WIMLIB_ERR_INVALID_PARAM
4466 * The decompression parameters were invalid.
4467 * @retval ::WIMLIB_ERR_NOMEM
4468 * Insufficient memory to allocate the decompressor.
4471 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4472 size_t max_block_size,
4473 const struct wimlib_decompressor_params_header *extra_params,
4474 struct wimlib_decompressor **decompressor_ret);
4477 * Decompress a block of data using a decompressor previously created with
4478 * wimlib_create_decompressor().
4480 * @param compressed_data
4481 * Buffer containing the data to decompress.
4482 * @param compressed_size
4483 * Size, in bytes, of the data to decompress.
4484 * @param uncompressed_data
4485 * Buffer into which to write the uncompressed data.
4486 * @param uncompressed_size
4487 * Size, in bytes, of the data when uncompressed.
4488 * @param decompressor
4489 * A decompressor previously allocated with wimlib_create_decompressor().
4491 * @return 0 on success; nonzero on error.
4494 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4495 void *uncompressed_data, size_t uncompressed_size,
4496 struct wimlib_decompressor *decompressor);
4499 * Free a decompressor previously allocated with wimlib_create_decompressor().
4501 * @param decompressor
4502 * The decompressor to free.
4505 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4517 #endif /* _WIMLIB_H */