3 * @brief External header for wimlib.
5 * This file contains extensive comments for generating documentation with
6 * Doxygen. The built HTML documentation can be viewed at
7 * http://wimlib.sourceforge.net. Make sure to see the <a
8 * href="modules.html">Modules page</a> to make more sense of the declarations
13 * Copyright (C) 2012, 2013, 2014 Eric Biggers
15 * This file is part of wimlib, a library for working with WIM files.
17 * wimlib is free software; you can redistribute it and/or modify it under the
18 * terms of the GNU General Public License as published by the Free
19 * Software Foundation; either version 3 of the License, or (at your option)
22 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
23 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
24 * A PARTICULAR PURPOSE. See the GNU General Public License for more
27 * You should have received a copy of the GNU General Public License
28 * along with wimlib; if not, see http://www.gnu.org/licenses/.
34 * @section sec_intro Introduction
36 * This is the documentation for the library interface of wimlib 1.6.2, a C
37 * library for creating, modifying, extracting, and mounting files in the
38 * Windows Imaging Format. This documentation is intended for developers only.
39 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
40 * program, please see the README file or manual pages.
42 * @section sec_installing_and_compiling Installing and Compiling
44 * wimlib uses the GNU autotools, so, on UNIX-like systems, it should be easy to
45 * install with <code>configure && make && sudo make install</code>; however,
46 * please see the README for more information about installing it.
48 * To use wimlib in your program after installing it, include wimlib.h and link
49 * your program with @c -lwim.
51 * As of wimlib 1.5.0, wimlib.h is also compatible with C++.
53 * Note: before calling any other function declared in wimlib.h,
54 * wimlib_global_init() can (and in some cases, must) be called. See its
55 * documentation for more details.
57 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
59 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
60 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
61 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
62 * which creates a new ::WIMStruct that initially contains no images and does
63 * not yet have a backing on-disk file. See @ref G_creating_and_opening_wims
66 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
67 * Images can be extracted (or "applied") using wimlib_extract_image(), added
68 * (or "captured" or "appended") using wimlib_add_image(), deleted using
69 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
70 * modified using wimlib_update_image(). However, changes made to a WIM
71 * represented by a ::WIMStruct have no persistent effect until the WIM is
72 * actually written to an on-disk file. This can be done using wimlib_write(),
73 * but if the WIM was originally opened using wimlib_open_wim(), then
74 * wimlib_overwrite() can be used instead. See @ref G_extracting_wims, @ref
75 * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
77 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
78 * files is a multi-step process. For example, to add, or "append" an image to
79 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
80 * append</b>, you must call the following functions:
82 * 1. wimlib_open_wim()
83 * 2. wimlib_add_image()
84 * 3. wimlib_overwrite()
86 * This design is very much on purpose as it makes the library more useful in
87 * general by allowing functions to be composed in different ways. For example,
88 * you can make multiple changes to a WIM and commit them all to the underlying
89 * file in only one overwrite operation, which is more efficient.
91 * @section sec_cleaning_up Cleaning up
93 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
94 * all resources associated with it. Also, when you are completely done with
95 * using wimlib in your program, you can call wimlib_global_cleanup() to free
96 * any other resources allocated by the library.
98 * @section sec_error_handling Error Handling
100 * Most functions in wimlib return 0 on success and a positive error code on
101 * failure. Use wimlib_get_error_string() to get a string that describes an
102 * error code. wimlib also can print error messages to standard error itself
103 * when an error happens, and these may be more informative than the error code;
104 * to enable this, call wimlib_set_print_errors(). Please note that this is for
105 * convenience only, and some errors can occur without a message being printed.
106 * Currently, error messages and strings (as well as all documentation, for that
107 * matter) are only available in English.
109 * @section sec_encodings Locales and character encodings
111 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
112 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
115 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
116 * and the encoding is UTF-16LE.
118 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
119 * and the encoding is the locale-dependent multibyte encoding. I recommend you
120 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
121 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
122 * call wimlib_global_init() after having set your desired locale.
124 * @section sec_advanced Additional information and features
127 * @subsection subsec_mounting_wim_images Mounting WIM images
129 * See @ref G_mounting_wim_images.
131 * @subsection subsec_progress_functions Progress Messages
133 * See @ref G_progress.
135 * @subsection subsec_non_standalone_wims Non-standalone WIMs
137 * See @ref G_nonstandalone_wims.
139 * @subsection subsec_pipable_wims Pipable WIMs
141 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
142 * compatible with Microsoft's software. To create a pipable WIM, call
143 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
144 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
145 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
146 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
147 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
148 * s using a seekable file descriptor using the regular function calls (e.g.
149 * wimlib_open_wim(), wimlib_extract_image()).
151 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
152 * capture</b> for more information about pipable WIMs.
154 * @subsection subsec_thread_safety Thread Safety
156 * wimlib is thread-safe, with the following exceptions:
157 * - Different threads cannot operate on the same ::WIMStruct at the same time;
158 * they must use different ::WIMStruct's.
159 * - You must call wimlib_global_init() in one thread before calling any other
161 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
162 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
163 * concurrently in the same process, will daemonize the entire process when it
164 * does so for the first time. This includes changing the working directory
165 * to the root directory.
167 * @subsection subsec_limitations Limitations
169 * This section documents some technical limitations of wimlib not already
170 * documented in the man page for @b wimlib-imagex.
172 * - The old WIM format from Vista pre-releases is not supported.
173 * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
174 * functionality other than that already present in @b ImageX, that allows you
175 * to make certain Windows-specific modifications to a Windows PE image, such
176 * as adding a driver or Windows component. Such a tool could be implemented
179 * @subsection more_info More information
181 * You are advised to read the README as well as the manual pages for
182 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
183 * the API documentation.
186 /** @defgroup G_general General
188 * @brief Declarations and structures shared across the library.
191 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
193 * @brief Create new WIMs and open existing WIMs.
196 /** @defgroup G_wim_information Retrieving WIM information and directory listings
198 * @brief Retrieve information about a WIM or WIM image.
201 /** @defgroup G_modifying_wims Modifying WIMs
203 * @brief Make changes to a WIM.
205 * @section sec_adding_images Capturing and adding WIM images
207 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
208 * appending an image to an existing WIM is a multi-step process, but at its
209 * core is wimlib_add_image() or an equivalent function. Normally,
210 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
211 * ::WIMStruct as a new image. However, when supported by the build of the
212 * library, there is also a special NTFS volume capture mode (entered when
213 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
214 * from an unmounted NTFS volume.
216 * Another function, wimlib_add_image_multisource() is also provided. It
217 * generalizes wimlib_add_image() to allow combining multiple files or directory
218 * trees into a single WIM image in a configurable way.
220 * For maximum customization of WIM image creation, it is also possible to add a
221 * completely empty WIM image with wimlib_add_empty_image(), then update it with
222 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
223 * wimlib_add_image_multisource() do internally.)
225 * Note that some details of how image addition/capture works are documented
226 * more fully in the manual page for <b>wimlib-imagex capture</b>.
228 * @section sec_deleting_images Deleting WIM images
230 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
231 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
232 * be made persistent in an on-disk WIM file.
234 * @section sec_exporting_images Exporting WIM images
236 * wimlib_export_image() can copy, or "export", an image from one WIM to
239 * @section sec_other_modifications Other modifications
241 * wimlib_update_image() can add, delete, and rename files in a WIM image.
243 * wimlib_set_image_name(), wimlib_set_image_descripton(), and
244 * wimlib_set_image_flags() can change other image metadata.
246 * wimlib_set_wim_info() can change information about the WIM file itself, such
250 /** @defgroup G_extracting_wims Extracting WIMs
252 * @brief Extract files, directories, and images from a WIM.
254 * wimlib_extract_image() extracts, or "applies", an image from a WIM,
255 * represented by a ::WIMStruct. This normally extracts the image to a
256 * directory, but when supported by the build of the library there is also a
257 * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
258 * is specified) that allows extracting a WIM image directly to an unmounted
259 * NTFS volume. Various other flags allow further customization of image
262 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
263 * of (possibly wildcard) paths from a WIM image.
265 * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
266 * over a pipe; see @ref subsec_pipable_wims.
268 * Some details of how WIM extraction works are documented more fully in the
269 * manual pages for <b>wimlib-imagex apply</b> and <b>wimlib-imagex extract</b>.
272 /** @defgroup G_mounting_wim_images Mounting WIM images
274 * @brief Mount and unmount WIM images.
276 * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
277 * mounting images from WIM files either read-only or read-write. To mount an
278 * image, call wimlib_mount_image(). To unmount an image, call
279 * wimlib_unmount_image(). Mounting can be done without root privileges because
280 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
281 * compiled with the <code>--without-fuse</code> flag, these functions will be
282 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED. Note that mounting an
283 * image read-write is an alternative to calling wimlib_update_image().
286 /** @defgroup G_progress Progress Messages
288 * @brief Track the progress of long WIM operations.
290 * When operating on large archives, operations such as extraction will
291 * naturally take a while to complete. Because of this and to improve the
292 * potential user-friendliness of library clients, a number of functions take a
293 * pointer to a progress function of type ::wimlib_progress_func_t. This
294 * function will be called periodically during the WIM operation(s) to report on
295 * the progress of the operation (for example, how many bytes have been written
299 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
301 * @brief Write and overwrite on-disk WIM files.
303 * As described in @ref sec_basic_wim_handling_concepts, these functions are
304 * critical to the design of the library as they allow new or modified WIMs to
305 * actually be written to on-disk files. Generally, wimlib_write() is the
306 * function you need to call to write a new WIM file, and wimlib_overwrite() is
307 * the function you need to call to persistently update an existing WIM file.
310 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
312 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
314 * Normally, ::WIMStruct represents a WIM file, but there's a bit more to it
315 * than that. Normally, WIM files are "standalone". However, WIM files can
316 * also be arranged in non-standalone ways, such as a set of on-disk files that
317 * together form a single "split WIM" or "delta WIM". Such arrangements are
318 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
319 * created from one of these on-disk files initially only partially represents
320 * the full WIM and needs to, in effect, be logically combined with other
321 * ::WIMStruct's before performing certain operations, such as extracting files
322 * with wimlib_extract_image() or wimlib_extract_files(). This is done by
323 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
325 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
326 * specialized function (wimlib_split()) is needed to create a split WIM.
335 #include <inttypes.h>
338 /** @ingroup G_general
341 /** Major version of the library (for example, the 1 in 1.2.5). */
342 #define WIMLIB_MAJOR_VERSION 1
344 /** Minor version of the library (for example, the 2 in 1.2.5). */
345 #define WIMLIB_MINOR_VERSION 6
347 /** Patch version of the library (for example, the 5 in 1.2.5). */
348 #define WIMLIB_PATCH_VERSION 2
355 /** @ingroup G_general
359 * Opaque structure that represents a WIM file. This is an in-memory structure
360 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
361 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
362 * continuing to exist so that data can be read from it as needed.
364 * Most functions in this library will work the same way regardless of whether a
365 * given ::WIMStruct was obtained through wimlib_open_wim() or
366 * wimlib_create_new_wim(). Exceptions are documented.
368 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
369 * file from a ::WIMStruct.
371 * See @ref sec_basic_wim_handling_concepts for more information.
373 #ifndef WIMLIB_WIMSTRUCT_DECLARED
374 typedef struct WIMStruct WIMStruct;
375 #define WIMLIB_WIMSTRUCT_DECLARED
379 typedef wchar_t wimlib_tchar;
381 /** See @ref sec_encodings */
382 typedef char wimlib_tchar;
386 /** Path separator for WIM paths passed back to progress callbacks. */
387 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
388 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
390 /** Path separator for WIM paths passed back to progress callbacks. */
391 # define WIMLIB_WIM_PATH_SEPARATOR '/'
392 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
396 # define _wimlib_deprecated __attribute__((deprecated))
398 # define _wimlib_deprecated
401 #define WIMLIB_GUID_LEN 16
404 * Specifies the compression type of a WIM file.
406 enum wimlib_compression_type {
407 /** An invalid compression type. */
408 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
410 /** The WIM does not include any compressed resources. */
411 WIMLIB_COMPRESSION_TYPE_NONE = 0,
413 /** Compressed resources in the WIM use LZX compression. */
414 WIMLIB_COMPRESSION_TYPE_LZX = 1,
416 /** Compressed resources in the WIM use XPRESS compression. */
417 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
419 /** Compressed resources in the WIM use LZMS compression. Note: LZMS
420 * compression is only compatible with wimlib v1.6.0 and later and with
421 * WIMGAPI Windows 8 and later (and some restrictions apply on the
423 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
427 /** @ingroup G_progress
430 /** Possible values of the first parameter to the user-supplied
431 * ::wimlib_progress_func_t progress function */
432 enum wimlib_progress_msg {
434 /** A WIM image is about to be extracted. @p info will point to
435 * ::wimlib_progress_info.extract. This message is received once per
436 * image for calls to wimlib_extract_image() and
437 * wimlib_extract_image_from_pipe(). */
438 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
440 /** One or more file or directory trees within a WIM image is about to
441 * be extracted. @p info will point to ::wimlib_progress_info.extract.
442 * This message is received once per extraction command for
443 * wimlib_extract_files(), but only once for wimlib_extract_paths() and
444 * wimlib_extract_pathlist(). (In the latter cases, wimlib combines all
445 * paths into a single extraction operation for optimization purposes.)
447 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
449 /** The directory structure and other preliminary metadata is about to
450 * be extracted. @p info will point to ::wimlib_progress_info.extract.
451 * This message is received once after either
452 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN or
453 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
454 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
456 /** Confirms that the directory structure and other preliminary metadata
457 * has been successfully extracted. @p info will point to
458 * ::wimlib_progress_info.extract. This message is paired with a
459 * preceding ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN message.
461 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
463 /** File data is currently being extracted. @p info will point to
464 * ::wimlib_progress_info.extract. This is the main message to track
465 * the progress of an extraction operation. */
466 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
468 /** Starting to read a new part of a split pipable WIM over the pipe.
469 * @p info will point to ::wimlib_progress_info.extract. */
470 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
472 /** All data for WIM files and directories have been extracted, and
473 * final metadata such as timestamps is about to be extracted. @p info
474 * will point to ::wimlib_progress_info.extract. This message is
475 * received once before ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END or
476 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END. */
477 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
479 /** Confirms that the image has been successfully extracted. @p info
480 * will point to ::wimlib_progress_info.extract. This is paired with
481 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN. */
482 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
484 /** Confirms that the files or directory trees have been successfully
485 * extracted. @p info will point to ::wimlib_progress_info.extract.
486 * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN. */
487 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
489 /** The directory or NTFS volume is about to be scanned for metadata.
490 * @p info will point to ::wimlib_progress_info.scan. This message is
491 * received once per call to wimlib_add_image(), or once per capture
492 * source passed to wimlib_add_image_multisource(), or once per add
493 * command passed to wimlib_update_image(). */
494 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
496 /** A directory or file has been scanned. @p info will point to
497 * ::wimlib_progress_info.scan, and its @p cur_path member will be
498 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
500 WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
502 /** Confirms that the directory or NTFS volume has been successfully
503 * scanned. @p info will point to ::wimlib_progress_info.scan. This is
504 * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
505 * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
507 WIMLIB_PROGRESS_MSG_SCAN_END,
509 /** File resources ("streams") are currently being written to the WIM.
510 * @p info will point to ::wimlib_progress_info.write_streams. This
511 * message may be received many times while the WIM file is being
512 * written or appended to with wimlib_write(), wimlib_overwrite(), or
513 * wimlib_write_to_fd(). */
514 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
516 /** Per-image metadata is about to be written to the WIM file. @p info
517 * will not be valid. */
518 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
520 /** Confirms that per-image metadata has been successfully been written
521 * to the WIM file. @p info will not be valid. This message is paired
522 * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
524 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
526 /** wimlib_overwrite() has successfully renamed the temporary file to
527 * the original WIM file, thereby committing the update. @p info will
528 * point to ::wimlib_progress_info.rename. Note: this message is not
529 * received if wimlib_overwrite() chose to append to the WIM file
531 WIMLIB_PROGRESS_MSG_RENAME,
533 /** The contents of the WIM file are being checked against the integrity
534 * table. @p info will point to ::wimlib_progress_info.integrity. This
535 * message is only received (and may be received many times) when
536 * wimlib_open_wim() is called with the
537 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. */
538 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
540 /** An integrity table is being calculated for the WIM being written.
541 * @p info will point to ::wimlib_progress_info.integrity. This message
542 * is only received (and may be received many times) when a WIM file is
543 * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
544 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
547 WIMLIB_PROGRESS_MSG_RESERVED,
549 /** A wimlib_split() operation is in progress, and a new split part is
550 * about to be started. @p info will point to
551 * ::wimlib_progress_info.split. */
552 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
554 /** A wimlib_split() operation is in progress, and a split part has been
555 * finished. @p info will point to ::wimlib_progress_info.split. */
556 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
558 /** A WIM update command is just about to be executed. @p info will
559 * point to ::wimlib_progress_info.update. This message is received
560 * once per update command when wimlib_update_image() is called with the
561 * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
562 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
564 /** A WIM update command has just been executed. @p info will point to
565 * ::wimlib_progress_info.update. This message is received once per
566 * update command when wimlib_update_image() is called with the flag
567 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS. */
568 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
572 /** A pointer to this union is passed to the user-supplied
573 * ::wimlib_progress_func_t progress function. One (or none) of the structures
574 * contained in this union will be applicable for the operation
575 * (::wimlib_progress_msg) indicated in the first argument to the progress
577 union wimlib_progress_info {
579 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
580 * document them if they aren't given a name... */
582 /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. This is
583 * the primary message for tracking the progress of writing a WIM file.
585 struct wimlib_progress_info_write_streams {
586 /** Total number of uncompressed bytes of stream data being
587 * written. This can be thought of as the total uncompressed
588 * size of the files being archived, with some caveats. WIM
589 * files use single-instance streams, so the size provided here
590 * only counts distinct streams, except for the following
591 * exception: the size provided here may include the sizes of
592 * all newly added (e.g. with wimlib_add_image() streams,
593 * pending automatic de-duplication during the write operation
594 * itself. When each such stream de-duplication occurs, this
595 * number will be decreased by the size of the duplicate stream
596 * that need not be written.
598 * In the case of a wimlib_overwrite() that the library opted to
599 * perform in-place, both @p total_streams and @p total_bytes
600 * will only count the streams actually being written and not
601 * pre-existing streams in the WIM file. */
602 uint64_t total_bytes;
604 /** Total number of streams being written. This can be thought
605 * of as the total number of files being archived, with some
606 * caveats. In general, a single file or directory may contain
607 * multiple data streams, each of which will be represented
608 * separately in this number. Furthermore, WIM files use
609 * single-instance streams, so the stream count provided here
610 * only counts distinct streams, except for the following
611 * exception: the stream count provided here may include newly
612 * added (e.g. with wimlib_add_image() streams, pending
613 * automatic de-duplication during the write operation itself.
614 * When each such stream de-duplication occurs, this number will
615 * be decreased by 1 to account for the duplicate stream that
616 * need not be written. */
617 uint64_t total_streams;
619 /** Number of uncompressed bytes of stream data that have been
620 * written so far. This number be 0 initially, and will be
621 * equal to @p total_bytes at the end of the write operation.
622 * Note that @p total_bytes (but not @p completed_bytes) may
623 * decrease throughout the write operation due to the discovery
624 * of stream duplications. */
625 uint64_t completed_bytes;
627 /** Number of streams that have been written so far. This
628 * number will be 0 initially, and will be equal to @p
629 * total_streams at the end of the write operation. Note that
630 * @p total_streams (but not @p completed_streams) may decrease
631 * throughout the write operation due to the discovery of stream
634 * For applications that wish to calculate a simple "percent
635 * complete" for the write operation, it will likely be more
636 * accurate to calculate the percentage from @p completed_bytes
637 * and @p total_bytes rather than @p completed_streams and
638 * @p total_streams because the time for the operation to
639 * complete is mainly determined by the number of bytes that
640 * need to be read, compressed, and written, not just the number
641 * of files being archived. */
642 uint64_t completed_streams;
644 /** Number of threads that are being used to compress streams,
645 * or 1 if streams are being written uncompressed. */
646 uint32_t num_threads;
648 /** The compression type being used to write the streams, as one
649 * of the ::wimlib_compression_type constants. */
650 int32_t compression_type;
652 /** Number of split WIM parts from which streams are being
653 * written (may be 0 if irrelevant). */
654 uint32_t total_parts;
656 /** Number of split WIM parts from which streams have been
657 * written (may be 0 if irrelevant). */
658 uint32_t completed_parts;
661 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
662 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
663 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
664 struct wimlib_progress_info_scan {
665 /** Top-level directory being scanned; or, when capturing a NTFS
666 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
667 * to the file or block device that contains the NTFS volume
669 const wimlib_tchar *source;
671 /** Path to the file (or directory) that has been scanned, valid
672 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing a NTFS
673 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
674 * relative to the root of the NTFS volume. */
675 const wimlib_tchar *cur_path;
677 /** Dentry scan status, valid on
678 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
680 /** The file looks okay and will be captured. */
681 WIMLIB_SCAN_DENTRY_OK = 0,
683 /** File is being excluded from capture due to the
684 * capture configuration. */
685 WIMLIB_SCAN_DENTRY_EXCLUDED,
687 /** File is being excluded from capture due to being
688 * unsupported (e.g. an encrypted or device file). */
689 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
691 /** The file is an absolute symbolic link or junction
692 * point and it is being excluded from capture because
693 * it points outside of the capture directory and
694 * reparse-point fixups are enabled. (Reparse point
695 * fixups can be disabled by using the flag
696 * ::WIMLIB_ADD_FLAG_NORPFIX.) */
697 WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
701 /** Target path in the WIM image. Only valid on
702 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
703 * ::WIMLIB_PROGRESS_MSG_SCAN_END. If capturing a full
704 * image, this will be the empty string; otherwise it
705 * will name the place in the WIM image at which the
706 * directory tree is being added. */
707 const wimlib_tchar *wim_target_path;
709 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
710 * of @p WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK, this is
711 * the target of the absolute symbolic link or junction
713 const wimlib_tchar *symlink_target;
716 /** Number of directories scanned so far, including the root
717 * directory but excluding any unsupported/excluded directories.
719 * Details: On Windows and in NTFS capture mode, a reparse point
720 * counts as a directory if and only if it has
721 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
722 * counts as a directory if and only if when fully dereferenced
723 * it points to an accessible directory. If a file has multiple
724 * names (hard links), it is only counted one time. */
725 uint64_t num_dirs_scanned;
727 /** Number of non-directories scanned so far, excluding any
728 * unsupported/excluded files.
730 * Details: On Windows and in NTFS capture mode, a reparse point
731 * counts as a non-directory if and only if it does not have
732 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
733 * counts as a non-directory if and only if when fully
734 * dereferenced it points to a non-directory or its target is
735 * inaccessible. If a file has multiple names (hard links), it
736 * is only counted one time. */
737 uint64_t num_nondirs_scanned;
739 /** Number of bytes of file data that have been detected so far.
741 * Details: This data may not actually have been read yet, and
742 * it will not actually be written to the WIM file until
743 * wimlib_write() or wimlib_overwrite() has been called. Data
744 * from excluded files is not counted. This number includes
745 * default file contents as well as named data streams and
746 * reparse point data. The size of reparse point data is
747 * tallied after any reparse-point fixups, and in the case of
748 * capturing a symbolic link on a UNIX-like system, the creation
749 * of the reparse point data itself. If a file has multiple
750 * names (hard links), its size(s) are only counted one time.
751 * On Windows, encrypted files have their encrypted size
752 * counted, not their unencrypted size; however, compressed
753 * files have their uncompressed size counted. */
754 uint64_t num_bytes_scanned;
757 /** Valid on messages
758 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
759 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
760 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
761 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
762 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
763 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
764 * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
765 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END, and
766 * ::WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS.
768 * Note: most of the time of an extraction operation will be spent
769 * extracting streams, and the application will receive
770 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time. Using @p
771 * completed_bytes and @p total_bytes, the application can calculate a
772 * percentage complete. However, note that this message does not, in
773 * general, actually provide information about which "file" is currently
774 * being extracted. This is because wimlib, by default, extracts the
775 * individual data streams in whichever order it determines to be the
778 * An additional caveat: wimlib_extract_files() will perform a separate
779 * logical extraction operation, with separate byte counts, for each
780 * extraction command (file or directory tree). On the other hand,
781 * wimlib_extract_paths() and wimlib_extract_pathlist() combine all the
782 * paths to extract into a single logical extraction operation.
784 struct wimlib_progress_info_extract {
785 /** Number of the image from which files are being extracted
789 /** Extraction flags being used. */
790 uint32_t extract_flags;
792 /** Full path to the WIM file from which files are being
793 * extracted, or @c NULL if the WIMStruct has no associated
795 const wimlib_tchar *wimfile_name;
797 /** Name of the image from which files are being extracted, or
798 * the empty string if the image is unnamed. */
799 const wimlib_tchar *image_name;
801 /** Path to the directory or NTFS volume to which the files are
802 * being extracted. */
803 const wimlib_tchar *target;
806 const wimlib_tchar *reserved;
808 /** Number of bytes of uncompressed data that will be extracted.
809 * If a file has multiple names (hard links), its size (or
810 * sizes, in the case of named data streams) is only counted one
811 * time. For "reparse points" and symbolic links, the size to
812 * be extracted is the size of the reparse data buffer.
814 * This number will stay constant throughout the extraction. */
815 uint64_t total_bytes;
817 /** Number of bytes of uncompressed data that have been
818 * extracted so far. This initially be 0 and will equal to @p
819 * total_bytes at the end of the extraction. */
820 uint64_t completed_bytes;
822 /** Number of (not necessarily unique) streams that will be
823 * extracted. This may be more or less than the number of
824 * "files" to be extracted due to hard links as well as
825 * potentially multiple streams per file (named data streams).
826 * A "stream" may be the default contents of a file, a named
827 * data stream, or a reparse data buffer. */
828 uint64_t num_streams;
830 /** When extracting files using wimlib_extract_files(), this
831 * will be the path within the WIM image to the file or
832 * directory tree currently being extracted. Otherwise, this
833 * will be the empty string. */
834 const wimlib_tchar *extract_root_wim_source_path;
836 /** Currently only used for
837 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
838 uint32_t part_number;
840 /** Currently only used for
841 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
842 uint32_t total_parts;
844 /** Currently only used for
845 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
846 uint8_t guid[WIMLIB_GUID_LEN];
849 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
850 struct wimlib_progress_info_rename {
851 /** Name of the temporary file that the WIM was written to. */
852 const wimlib_tchar *from;
854 /** Name of the original WIM file to which the temporary file is
856 const wimlib_tchar *to;
859 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
860 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
861 struct wimlib_progress_info_update {
862 /** Pointer to the update command that will be executed or has
863 * just been executed. */
864 const struct wimlib_update_command *command;
866 /** Number of update commands that have been completed so far.
868 size_t completed_commands;
870 /** Number of update commands that are being executed as part of
871 * this call to wimlib_update_image(). */
872 size_t total_commands;
875 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
876 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
877 struct wimlib_progress_info_integrity {
878 /** Number of bytes from the end of the WIM header to the end of
879 * the lookup table (the area that is covered by the SHA1
880 * integrity checks.) */
881 uint64_t total_bytes;
883 /** Number of bytes that have been SHA1-summed so far. Will be
884 * 0 initially, and equal @p total_bytes at the end. */
885 uint64_t completed_bytes;
887 /** Number of chunks that the checksummed region is divided
889 uint32_t total_chunks;
891 /** Number of chunks that have been SHA1-summed so far. Will
892 * be 0 initially, and equal to @p total_chunks at the end. */
893 uint32_t completed_chunks;
895 /** Size of the chunks used for the integrity calculation. */
898 /** Filename of the WIM (only valid if the message is
899 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
900 const wimlib_tchar *filename;
903 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
904 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
905 struct wimlib_progress_info_split {
906 /** Total size of the original WIM's file and metadata resources
908 uint64_t total_bytes;
910 /** Number of bytes of file and metadata resources that have
911 * been copied out of the original WIM so far. Will be 0
912 * initially, and equal to @p total_bytes at the end. */
913 uint64_t completed_bytes;
915 /** Number of the split WIM part that is about to be started
916 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
917 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
918 unsigned cur_part_number;
920 /** Total number of split WIM parts that are being written. */
921 unsigned total_parts;
923 /** Name of the split WIM part that is about to be started
924 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
925 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
926 const wimlib_tchar *part_name;
930 /** A user-supplied function that will be called periodically during certain WIM
931 * operations. The first argument will be the type of operation that is being
932 * performed or is about to be started or has been completed. The second
933 * argument will be a pointer to one of a number of structures depending on the
934 * first argument. It may be @c NULL for some message types.
936 * The return value of the progress function is currently ignored, but it may do
937 * something in the future. (Set it to 0 for now.)
939 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
940 const union wimlib_progress_info *info);
943 /** @ingroup G_modifying_wims
946 /** An array of these structures is passed to wimlib_add_image_multisource() to
947 * specify the sources from which to create a WIM image. */
948 struct wimlib_capture_source {
949 /** Absolute or relative path to a file or directory on the external
950 * filesystem to be included in the WIM image. */
951 wimlib_tchar *fs_source_path;
953 /** Destination path in the WIM image. Leading and trailing slashes are
954 * ignored. The empty string or @c NULL means the root directory of the
956 wimlib_tchar *wim_target_path;
958 /** Reserved; set to 0. */
962 /** Structure that specifies a list of path patterns. */
963 struct wimlib_pattern_list {
964 /** Array of patterns. The patterns may be modified by library code,
965 * but the @p pats pointer itself will not. See the man page for
966 * <b>wimlib-imagex capture</b> for more information about allowed
970 /** Number of patterns in the @p pats array. */
973 /** Ignored; may be used by the calling code. */
974 size_t num_allocated_pats;
977 /** A structure that contains lists of wildcards that match paths to treat
978 * specially when capturing a WIM image. */
979 struct wimlib_capture_config {
980 /** Paths matching any pattern this list are excluded from being
981 * captured, except if the same path appears in @p
982 * exclusion_exception_pats. */
983 struct wimlib_pattern_list exclusion_pats;
985 /** Paths matching any pattern in this list are never excluded from
987 struct wimlib_pattern_list exclusion_exception_pats;
989 /** Reserved for future capture configuration options. */
990 struct wimlib_pattern_list reserved1;
992 /** Reserved for future capture configuration options. */
993 struct wimlib_pattern_list reserved2;
995 /** Library internal use only. */
996 wimlib_tchar *_prefix;
998 /** Library internal use only. */
999 size_t _prefix_num_tchars;
1002 /** Set or unset the WIM header flag that marks it read-only
1003 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
1004 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
1005 * is distinct from basic file permissions; this flag can be set on a WIM file
1006 * that is physically writable. If this flag is set, all further operations to
1007 * modify the WIM will fail, except calling wimlib_overwrite() with
1008 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
1009 * allows you to set this flag persistently on the underlying WIM file.
1011 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
1013 /** Set the GUID (globally unique identifier) of the WIM file to the value
1014 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1015 #define WIMLIB_CHANGE_GUID 0x00000002
1017 /** Change the bootable image of the WIM to the value specified in
1018 * ::wimlib_wim_info.boot_index of the @p info parameter. */
1019 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
1021 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1022 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
1023 * indicates whether an image in the WIM has been captured with reparse-point
1024 * fixups enabled. wimlib also treats this flag as specifying whether to do
1025 * reparse-point fixups by default when capturing or applying WIM images. */
1026 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
1029 /** @ingroup G_wim_information
1032 /** General information about a WIM file. */
1033 struct wimlib_wim_info {
1035 /** Globally unique identifier for the WIM file. Note: all parts of a
1036 * split WIM should have an identical value in this field. */
1037 uint8_t guid[WIMLIB_GUID_LEN];
1039 /** Number of images in the WIM. */
1040 uint32_t image_count;
1042 /** 1-based index of the bootable image in the WIM, or 0 if no image is
1044 uint32_t boot_index;
1046 /** Version of the WIM file. */
1047 uint32_t wim_version;
1049 /** Chunk size used for compression. */
1050 uint32_t chunk_size;
1052 /** For split WIMs, the 1-based index of this part within the split WIM;
1054 uint16_t part_number;
1056 /** For split WIMs, the total number of parts in the split WIM;
1058 uint16_t total_parts;
1060 /** One of the ::wimlib_compression_type values that specifies the
1061 * method used to compress resources in the WIM. */
1062 int32_t compression_type;
1064 /** Size of the WIM file in bytes, excluding the XML data and integrity
1066 uint64_t total_bytes;
1068 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
1069 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1070 * this will always be 0, even if the ::WIMStruct was written to
1071 * somewhere by calling wimlib_write() with the
1072 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1073 uint32_t has_integrity_table : 1;
1075 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1076 * wimlib_create_new_wim(). */
1077 uint32_t opened_from_file : 1;
1079 /** 1 if the WIM is considered readonly for any reason. */
1080 uint32_t is_readonly : 1;
1082 /** 1 if reparse-point fixups are supposedly enabled for one or more
1083 * images in the WIM. */
1084 uint32_t has_rpfix : 1;
1086 /** 1 if the WIM is marked as read-only. */
1087 uint32_t is_marked_readonly : 1;
1089 /** 1 if the WIM is part of a spanned set. */
1090 uint32_t spanned : 1;
1092 uint32_t write_in_progress : 1;
1093 uint32_t metadata_only : 1;
1094 uint32_t resource_only : 1;
1096 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1097 uint32_t pipable : 1;
1098 uint32_t reserved_flags : 22;
1099 uint32_t reserved[9];
1102 /** Information about a unique stream in the WIM file. (A stream is the same
1103 * thing as a "resource", except in the case of packed resources.) */
1104 struct wimlib_resource_entry {
1105 /** Uncompressed size of the stream in bytes. */
1106 uint64_t uncompressed_size;
1108 /** Compressed size of the stream in bytes. This will be the same as @p
1109 * uncompressed_size if the stream is uncompressed. Or, if @p
1110 * is_packed_streams is 1, this will be 0. */
1111 uint64_t compressed_size;
1113 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1114 * if @p packed is 1, then this is actually the offset at which this
1115 * stream begins in the uncompressed contents of the packed resource.
1119 /** SHA1 message digest of the stream's uncompressed contents. */
1120 uint8_t sha1_hash[20];
1122 /** Which part number of the split WIM this stream is in. This should
1123 * be the same as the part number provided by wimlib_get_wim_info(). */
1124 uint32_t part_number;
1126 /** Number of times this stream is referenced over all WIM images. */
1127 uint32_t reference_count;
1129 /** 1 if this stream is compressed. */
1130 uint32_t is_compressed : 1;
1132 /** 1 if this stream is a metadata resource rather than a file resource.
1134 uint32_t is_metadata : 1;
1136 uint32_t is_free : 1;
1137 uint32_t is_spanned : 1;
1139 /** 1 if this stream was not found in the lookup table of the
1140 * ::WIMStruct. This normally implies a missing call to
1141 * wimlib_reference_resource_files() or wimlib_reference_resources().
1143 uint32_t is_missing : 1;
1145 /** 1 if this stream is located in a packed resource which may contain
1146 * other streams (all compressed together) as well. */
1147 uint32_t packed : 1;
1149 uint32_t reserved_flags : 26;
1151 /** If @p packed is 1, then this will specify the offset of the packed
1152 * resource in the WIM. */
1153 uint64_t raw_resource_offset_in_wim;
1155 /** If @p is_packed_streams is 1, then this will specify the compressed
1156 * size of the packed resource in the WIM. */
1157 uint64_t raw_resource_compressed_size;
1159 uint64_t reserved[2];
1162 /** A stream of a file in the WIM. */
1163 struct wimlib_stream_entry {
1164 /** Name of the stream, or NULL if the stream is unnamed. */
1165 const wimlib_tchar *stream_name;
1166 /** Location, size, etc. of the stream within the WIM file. */
1167 struct wimlib_resource_entry resource;
1168 uint64_t reserved[4];
1171 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1172 * Roughly, the information about a "file" in the WIM--- but really a directory
1173 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1174 * field can be used to distinguish actual file inodes. */
1175 struct wimlib_dir_entry {
1176 /** Name of the file, or NULL if this file is unnamed (only possible for
1177 * the root directory) */
1178 const wimlib_tchar *filename;
1180 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1182 const wimlib_tchar *dos_name;
1184 /** Full path to this file within the WIM image. */
1185 const wimlib_tchar *full_path;
1187 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1188 * children, ..., etc. */
1191 /** Pointer to the security descriptor for this file, in Windows
1192 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1193 * security descriptor. */
1194 const char *security_descriptor;
1196 /** Length of the above security descriptor. */
1197 size_t security_descriptor_size;
1199 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1200 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1201 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1202 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1203 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1204 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1205 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1206 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1207 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1208 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1209 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1210 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1211 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1212 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1213 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1214 /** File attributes, such as whether the file is a directory or not.
1215 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1216 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1217 * on other platforms. */
1218 uint32_t attributes;
1220 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1221 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1222 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1223 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1224 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1225 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1226 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1227 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1228 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1229 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1230 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1231 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1232 * attributes), this will give the reparse tag. This tells you whether
1233 * the reparse point is a symbolic link, junction point, or some other,
1234 * more unusual kind of reparse point. */
1235 uint32_t reparse_tag;
1237 /* Number of (hard) links to this file. */
1240 /** Number of named data streams that this file has. Normally 0. */
1241 uint32_t num_named_streams;
1243 /** Roughly, the inode number of this file. However, it may be 0 if
1244 * @p num_links == 1. */
1245 uint64_t hard_link_group_id;
1247 /** Time this file was created. */
1248 struct timespec creation_time;
1250 /** Time this file was last written to. */
1251 struct timespec last_write_time;
1253 /** Time this file was last accessed. */
1254 struct timespec last_access_time;
1255 uint64_t reserved[16];
1257 /** Array of streams that make up this file. The first entry will
1258 * always exist and will correspond to the unnamed data stream (default
1259 * file contents), so it will have @p stream_name == @c NULL. There
1260 * will then be @p num_named_streams additional entries that specify the
1261 * named data streams, if any, each of which will have @p stream_name !=
1263 struct wimlib_stream_entry streams[];
1267 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1270 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1274 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1277 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1280 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1281 * just on the specified path. */
1282 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1284 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1285 * itself; only its children (in the case of a non-empty directory) */
1286 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1288 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1289 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1290 * table of the ::WIMStruct. The default behavior without this flag is to fill
1291 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1292 * wimlib_resource_entry::is_missing "is_missing" flag. */
1293 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1297 /** @ingroup G_modifying_wims
1300 /** Directly capture a NTFS volume rather than a generic directory. This flag
1301 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1302 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1303 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1305 /** Follow symlinks; archive and dump the files they point to. Cannot be used
1306 * with ::WIMLIB_ADD_FLAG_NTFS. */
1307 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1309 /** Call the progress function with the message
1310 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1312 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1314 /** Mark the image being added as the bootable image of the WIM. Not valid for
1315 * wimlib_update_image(). */
1316 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1318 /** Store the UNIX owner, group, and mode. This is done by adding a special
1319 * alternate data stream to each regular file, symbolic link, and directory to
1320 * contain this information. Please note that this flag is for convenience
1321 * only; Microsoft's implementation will not understand this special
1322 * information. This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
1323 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1325 /** Do not capture security descriptors. Only has an effect in NTFS capture
1326 * mode, or in Windows native builds. */
1327 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1329 /** Fail immediately if the full security descriptor of any file or directory
1330 * cannot be accessed. Only has an effect in Windows native builds. The
1331 * default behavior without this flag is to first try omitting the SACL from the
1332 * security descriptor, then to try omitting the security descriptor entirely.
1334 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1336 /** Call the progress function with the message
1337 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1338 * capture. This is a subset of the messages provided by
1339 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1340 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1342 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1343 * in the case of Windows) that point inside the directory being captured to
1344 * instead be absolute relative to the directory being captured, rather than the
1345 * current root; also exclude absolute symbolic links that point outside the
1346 * directory tree being captured.
1348 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1349 * the WIM header or if this is the first image being added.
1350 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1351 * reparse point fixups enabled and currently cannot be unset. */
1352 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1354 /** Don't do reparse point fixups. The default behavior is described in the
1355 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1356 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1358 /** Do not automatically exclude unsupported files or directories from capture;
1359 * e.g. encrypted directories in NTFS-3g capture mode, or device files and FIFOs
1360 * on UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1361 * such a file is encountered. */
1362 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1364 /** Automatically select a capture configuration appropriate for capturing
1365 * filesystems containing Windows operating systems. When this flag is
1366 * specified, the corresponding @p config parameter or member must be @c NULL.
1368 * Currently, selecting this capture configuration will cause the following
1369 * files and directories to be excluded from capture:
1374 * - "\System Volume Information"
1378 * Note that the default behavior--- that is, when this flag is not specified
1379 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1380 * no files are excluded from capture.
1382 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1384 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1385 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1386 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1387 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1388 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1389 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1390 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1391 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1392 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1393 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1394 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1395 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1396 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1399 /** @ingroup G_modifying_wims
1402 /** Do not issue an error if the path to delete does not exist. */
1403 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1405 /** Delete the file or directory tree recursively; if not specified, an error is
1406 * issued if the path to delete is a directory. */
1407 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1410 /** @ingroup G_modifying_wims
1414 * If a single image is being exported, mark it bootable in the destination WIM.
1415 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1416 * the image in the source WIM (if any) that is marked as bootable is also
1417 * marked as bootable in the destination WIM.
1419 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1421 /** Give the exported image(s) no names. Avoids problems with image name
1424 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1426 /** Give the exported image(s) no descriptions. */
1427 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1430 /** @ingroup G_extracting_wims
1433 /** Extract the image directly to a NTFS volume rather than a generic directory.
1434 * This mode is only available if wimlib was compiled with libntfs-3g support;
1435 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1436 * extraction target will be interpreted as the path to a NTFS volume image (as
1437 * a regular file or block device) rather than a directory. It will be opened
1438 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1439 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1440 * is called with ::WIMLIB_ALL_IMAGES as the @p image. */
1441 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1443 /** When identical files are extracted from the WIM, always hard link them
1444 * together. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_SYMLINK.
1446 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
1448 /** When identical files are extracted from the WIM, always symlink them
1449 * together. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_HARDLINK.
1451 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
1453 /** This flag no longer does anything but is reserved for future use. */
1454 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
1456 /** Read the WIM file sequentially while extracting the image. As of wimlib
1457 * v1.6.0 this is the default behavior, and this flag no longer does anything.
1459 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
1461 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA. Only
1462 * valid on UNIX-like platforms, and when ::WIMLIB_EXTRACT_FLAG_NTFS was not
1464 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1466 /** Do not extract security descriptors. This flag cannot be combined with
1467 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS. */
1468 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1470 /** Fail immediately if the full security descriptor of any file or directory
1471 * cannot be set exactly as specified in the WIM file. On Windows, the default
1472 * behavior without this flag when wimlib does not have permission to set the
1473 * correct security descriptor is to fall back to setting the security
1474 * descriptor with the SACL omitted, then with the DACL omitted, then with the
1475 * owner omitted, then not at all. This flag cannot be combined with
1476 * ::WIMLIB_EXTRACT_FLAG_NO_ACLS. */
1477 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1479 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1480 * reparse-point fixups on, so absolute symbolic links or junction points will
1481 * be fixed to be absolute relative to the actual extraction root. Reparse-
1482 * point fixups are done by default for wimlib_extract_image() and
1483 * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1484 * header. This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX. */
1485 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1487 /** Force reparse-point fixups on extraction off, regardless of the state of the
1488 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. This flag cannot be combined
1489 * with ::WIMLIB_EXTRACT_FLAG_RPFIX. */
1490 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1492 /** Extract the paths, each of which must name a regular file, to standard
1493 * output. Not valid for wimlib_extract_image() and
1494 * wimlib_extract_image_from_pipe(). */
1495 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1497 /** Instead of ignoring files and directories with names that cannot be
1498 * represented on the current platform (note: Windows has more restrictions on
1499 * filenames than POSIX-compliant systems), try to replace characters or append
1500 * junk to the names so that they can be extracted in some form. */
1501 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1503 /** On Windows, when there exist two or more files with the same case
1504 * insensitive name but different case sensitive names, try to extract them all
1505 * by appending junk to the end of them, rather than arbitrarily extracting only
1507 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1509 /** Do not ignore failure to set timestamps on extracted files. */
1510 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1512 /** Do not ignore failure to set short names on extracted files. */
1513 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1515 /** Do not ignore failure to extract symbolic links (and junction points, on
1516 * Windows) due to permissions problems. By default, such failures are ignored
1517 * since the default configuration of Windows only allows the Administrator to
1518 * create symbolic links. */
1519 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1521 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1522 * behavior is currently less than satisfactory. Do not use (yet). */
1523 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1525 /** Perform the extraction ordered by the tree of files to extract rather than
1526 * how the underlying streams are arranged in the WIM file. For regular WIM
1527 * files this may decrease or increase performance, depending on various
1528 * factors. For WIM files containing packed streams this will decrease
1530 #define WIMLIB_EXTRACT_FLAG_FILE_ORDER 0x00020000
1532 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1533 * paths to extract as wildcard patterns ("globs") which may contain the
1534 * wildcard characters @c ? and @c *. The @c ? character matches any
1535 * non-path-separator character, whereas the @c * character matches zero or more
1536 * non-path-separator characters. Consequently, each glob may match zero or
1537 * more actual paths in the WIM image. By default, if a glob does not match any
1538 * files, a warning but not an error will be issued, even if the glob did not
1539 * actually contain wildcard characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
1540 * to get an error instead. */
1541 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1543 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1544 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1545 * one of the provided globs did not match a file. */
1546 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1548 /** Do not extract Windows file attributes such as readonly, hidden, etc. */
1549 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000
1551 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Do not
1552 * preserve the directory structure of the archive when extracting --- that is,
1553 * place each extracted file or directory tree directly in the target directory.
1555 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE 0x00200000
1558 /** @ingroup G_mounting_wim_images
1561 /** Mount the WIM image read-write rather than the default of read-only. */
1562 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1564 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1565 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1567 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1568 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1570 /** Access alternate data streams in the mounted WIM image through extended file
1571 * attributes. This is the default mode. */
1572 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1574 /** Access alternate data streams in the mounted WIM image by specifying the
1575 * file name, a colon, then the alternate file stream name. */
1576 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1578 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1579 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1580 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1582 /** Allow other users to see the mounted filesystem. (this passes the @c
1583 * allow_other option to FUSE mount) */
1584 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1587 /** @ingroup G_creating_and_opening_wims
1590 /** Verify the WIM contents against the WIM's integrity table, if present. This
1591 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1592 * checksummed and checked against the SHA1 message digests specified in the
1593 * integrity table. ::WIMLIB_ERR_INTEGRITY is returned if there are any
1594 * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1595 * integrity table is invalid). */
1596 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1598 /** Issue an error if the WIM is part of a split WIM. Software can provide
1599 * this flag for convenience if it explicitly does not want to support split
1601 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1603 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1604 * is not. A WIM is considered writable only if it is writable at the
1605 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1606 * header, and is not part of a spanned set. It is not required to provide this
1607 * flag before attempting to make changes to the WIM, but with this flag you get
1608 * an error sooner rather than later. */
1609 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1612 /** @ingroup G_mounting_wim_images
1615 /** See ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
1616 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1618 /** Unless this flag is given, changes to a read-write mounted WIM are
1619 * discarded. Ignored for read-only mounts. */
1620 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1622 /** See ::WIMLIB_WRITE_FLAG_REBUILD. */
1623 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1625 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1626 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1628 /** Do a "lazy" unmount (detach filesystem immediately, even if busy). */
1629 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1631 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1632 * image, causes the modified image to be committed as a new, unnamed image
1633 * appended to the archive. The original image will be unmodified. */
1634 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE 0x00000020
1637 /** @ingroup G_modifying_wims
1640 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1641 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1642 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1645 /** @ingroup G_writing_and_overwriting_wims
1648 /** Include an integrity table in the WIM.
1650 * For WIMs created with wimlib_open_wim(), the default behavior is to include
1651 * an integrity table if and only if one was present before. For WIMs created
1652 * with wimlib_create_new_wim(), the default behavior is to not include an
1653 * integrity table. */
1654 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1656 /** Do not include an integrity table in the new WIM file. This is the default
1657 * behavior, unless the WIM already included an integrity table. */
1658 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1660 /** Write the WIM as "pipable". After writing a WIM with this flag specified,
1661 * images from it can be applied directly from a pipe using
1662 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1663 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1664 * with this flag will not be compatible with Microsoft's software.
1666 * For WIMs created with wimlib_open_wim(), the default behavior is to write the
1667 * WIM as pipable if and only if it was pipable before. For WIMs created with
1668 * wimlib_create_new_wim(), the default behavior is to write the WIM as
1670 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1672 /** Do not write the WIM as "pipable". This is the default behavior, unless the
1673 * WIM was pipable already. */
1674 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1676 /** Recompress all resources, even if they could otherwise be copied from a
1677 * different WIM with the same compression type (in the case of
1678 * wimlib_export_image() being called previously). This flag is also valid in
1679 * the @p wim_write_flags of wimlib_join(), in which case all resources included
1680 * in the joined WIM file will be recompressed. */
1681 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1683 /** Call fsync() just before the WIM file is closed. */
1684 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1686 /** wimlib_overwrite() only: Re-build the entire WIM file rather than appending
1687 * data to it if possible. */
1688 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1690 /** wimlib_overwrite() only: Specifying this flag overrides the default
1691 * behavior of wimlib_overwrite() after one or more calls to
1692 * wimlib_delete_image(), which is to rebuild the entire WIM. With this flag,
1693 * only minimal changes to correctly remove the image from the WIM will be
1694 * taken. In particular, all streams will be left alone, even if they are no
1695 * longer referenced. This is probably not what you want, because almost no
1696 * space will be saved by deleting an image in this way. */
1697 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1699 /** wimlib_overwrite() only: Allow overwriting the WIM even if the readonly
1700 * flag is set in the WIM header. This can be used in combination with
1701 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1702 * set the readonly flag on the on-disk WIM file. */
1703 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1705 /** Do not include non-metadata resources already present in other WIMs. This
1706 * flag can be used to write a "delta" WIM after resources from the WIM on which
1707 * the delta is to be based were referenced with
1708 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1709 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1711 /** Asserts that for writes of all WIM images, all streams needed for the WIM
1712 * are already present (not in external resource WIMs) and their reference
1713 * counts are correct, so the code does not need to recalculate which streams
1714 * are referenced. This is for optimization purposes only, since with this flag
1715 * specified, the metadata resources may not need to be decompressed and parsed.
1717 * This flag can be passed to wimlib_write() and wimlib_write_to_fd(), but is
1718 * already implied for wimlib_overwrite(). */
1719 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1721 #define WIMLIB_WRITE_FLAG_RESERVED 0x00000800
1724 * When writing streams in the resulting WIM file, pack multiple streams into a
1725 * single WIM resource instead of compressing them independently. This tends to
1726 * produce a better compression ratio at the cost of less random access.
1727 * However, WIMs created with this flag are only compatible with wimlib v1.6.0
1728 * or later and WIMGAPI Windows 8 or later, seemingly for Windows Setup only and
1729 * <b>not including ImageX and Dism</b>. WIMs created with this flag must use
1730 * version number 3584 in their header instead of 68864.
1732 * If this flag is passed to wimlib_overwrite() and the WIM did not previously
1733 * contain packed streams, the WIM's version number will be changed to 3584 and
1734 * the new streams will be written packed. Use ::WIMLIB_WRITE_FLAG_REBUILD to
1735 * force the WIM to be fully rebuilt. */
1736 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
1739 /** @ingroup G_general
1742 /** Assume that strings are represented in UTF-8, even if this is not the
1743 * locale's character encoding. This flag is ignored on Windows, where wimlib
1744 * always uses UTF-16LE. */
1745 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1747 /** Windows-only: do not attempt to acquire additional privileges (currently
1748 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1749 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1750 * for the case where the calling program manages these privileges itself.
1751 * Note: no error is issued if privileges cannot be acquired, although related
1752 * errors may be reported later, depending on if the operations performed
1753 * actually require additional privileges or not. */
1754 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1756 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1757 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1758 * to read all possible data and metadata for a capture operation could not be
1759 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1761 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1763 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1764 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1765 * to restore all possible data and metadata for an apply operation could not be
1766 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1768 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1770 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1772 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
1774 /** Default to interpreting WIM paths case insensitively (default on Windows).
1775 * This does not apply to mounted images. */
1776 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
1779 /** @ingroup G_nonstandalone_wims
1782 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
1783 * Ignored by wimlib_reference_resources(). */
1784 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1786 /** For wimlib_reference_resource_files(), issue an error
1787 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1788 * default behavior without this flag is to issue no error at that point, but
1789 * then attempt to open the glob as a literal path, which of course will fail
1790 * anyway if no file exists at that path. No effect if
1791 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. Ignored by
1792 * wimlib_reference_resources(). */
1793 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1796 /** @ingroup G_modifying_wims
1799 /** The specific type of update to perform. */
1800 enum wimlib_update_op {
1801 /** Add a new file or directory tree to the WIM image in a
1802 * certain location. */
1803 WIMLIB_UPDATE_OP_ADD = 0,
1805 /** Delete a file or directory tree from the WIM image. */
1806 WIMLIB_UPDATE_OP_DELETE,
1808 /** Rename a file or directory tree in the WIM image. */
1809 WIMLIB_UPDATE_OP_RENAME,
1812 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1813 struct wimlib_add_command {
1814 /** Filesystem path to the file or directory tree to
1816 wimlib_tchar *fs_source_path;
1817 /** Path, specified from the root of the WIM image, at
1818 * which to add the file or directory tree within the
1820 wimlib_tchar *wim_target_path;
1822 /** Configuration for excluded files. @c NULL means
1823 * exclude no files (use no configuration), unless
1824 * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
1826 struct wimlib_capture_config *config;
1828 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1832 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1833 struct wimlib_delete_command {
1834 /** Path, specified from the root of the WIM image, for
1835 * the file or directory tree within the WIM image to be
1837 wimlib_tchar *wim_path;
1838 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1842 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1843 struct wimlib_rename_command {
1844 /** Path, specified from the root of the WIM image, for
1845 * the source file or directory tree within the WIM
1847 wimlib_tchar *wim_source_path;
1848 /** Path, specified from the root of the WIM image, for
1849 * the destination file or directory tree within the WIM
1851 wimlib_tchar *wim_target_path;
1852 /** Reserved; set to 0. */
1856 /** Specification of an update to perform on a WIM image. */
1857 struct wimlib_update_command {
1859 enum wimlib_update_op op;
1862 struct wimlib_add_command add;
1863 struct wimlib_delete_command delete_; /* Underscore is for C++
1865 struct wimlib_rename_command rename;
1870 /** @ingroup G_extracting_wims
1873 /** DEPRECATED: Specification of extracting a file or directory tree from a WIM
1874 * image. This is only used for calls to wimlib_extract_files(), which has been
1875 * deprecated in favor of the easier-to-use wimlib_extract_paths(). */
1876 struct wimlib_extract_command {
1877 /** Path to file or directory tree within the WIM image to extract. It
1878 * must be provided as an absolute path from the root of the WIM image.
1879 * The path separators may be either forward slashes or backslashes. */
1880 wimlib_tchar *wim_source_path;
1882 /** Filesystem path to extract the file or directory tree to. */
1883 wimlib_tchar *fs_dest_path;
1885 /** Bitwise OR of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1891 /** @ingroup G_general
1895 * Possible values of the error code returned by many functions in wimlib.
1897 * See the documentation for each wimlib function to see specifically what error
1898 * codes can be returned by a given function, and what they mean.
1900 enum wimlib_error_code {
1901 WIMLIB_ERR_SUCCESS = 0,
1902 WIMLIB_ERR_ALREADY_LOCKED,
1903 WIMLIB_ERR_DECOMPRESSION,
1904 WIMLIB_ERR_DELETE_STAGING_DIR,
1905 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1908 WIMLIB_ERR_FUSERMOUNT,
1909 WIMLIB_ERR_GLOB_HAD_NO_MATCHES,
1910 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1911 WIMLIB_ERR_IMAGE_COUNT,
1912 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1913 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES,
1914 WIMLIB_ERR_INTEGRITY,
1915 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1916 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1917 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1918 WIMLIB_ERR_INVALID_HEADER,
1919 WIMLIB_ERR_INVALID_IMAGE,
1920 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1921 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1922 WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1923 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1924 WIMLIB_ERR_INVALID_OVERLAY,
1925 WIMLIB_ERR_INVALID_PARAM,
1926 WIMLIB_ERR_INVALID_PART_NUMBER,
1927 WIMLIB_ERR_INVALID_PIPABLE_WIM,
1928 WIMLIB_ERR_INVALID_REPARSE_DATA,
1929 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1930 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1931 WIMLIB_ERR_INVALID_UTF16_STRING,
1932 WIMLIB_ERR_INVALID_UTF8_STRING,
1933 WIMLIB_ERR_IS_DIRECTORY,
1934 WIMLIB_ERR_IS_SPLIT_WIM,
1935 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1937 WIMLIB_ERR_METADATA_NOT_FOUND,
1942 WIMLIB_ERR_NOTEMPTY,
1943 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1944 WIMLIB_ERR_NOT_A_WIM_FILE,
1945 WIMLIB_ERR_NOT_PIPABLE,
1946 WIMLIB_ERR_NO_FILENAME,
1950 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1952 WIMLIB_ERR_READLINK,
1955 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1956 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1957 WIMLIB_ERR_RESOURCE_ORDER,
1958 WIMLIB_ERR_SET_ATTRIBUTES,
1959 WIMLIB_ERR_SET_REPARSE_DATA,
1960 WIMLIB_ERR_SET_SECURITY,
1961 WIMLIB_ERR_SET_SHORT_NAME,
1962 WIMLIB_ERR_SET_TIMESTAMPS,
1963 WIMLIB_ERR_SPLIT_INVALID,
1966 WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
1967 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1968 WIMLIB_ERR_UNKNOWN_VERSION,
1969 WIMLIB_ERR_UNSUPPORTED,
1970 WIMLIB_ERR_UNSUPPORTED_FILE,
1971 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1972 WIMLIB_ERR_WIM_IS_READONLY,
1975 WIMLIB_ERR_WIM_IS_ENCRYPTED,
1979 /** Used to indicate no WIM image or an invalid WIM image. */
1980 #define WIMLIB_NO_IMAGE 0
1982 /** Used to specify all images in the WIM. */
1983 #define WIMLIB_ALL_IMAGES (-1)
1988 * @ingroup G_modifying_wims
1990 * Appends an empty image to a WIM file. This empty image will initially
1991 * contain no files or directories, although if written without further
1992 * modifications, a root directory will be created automatically for it. After
1993 * calling this function, you can use wimlib_update_image() to add files to the
1994 * new WIM image. This gives you slightly more control over making the new
1995 * image compared to calling wimlib_add_image() or
1996 * wimlib_add_image_multisource() directly.
1999 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
2002 * Name to give the new image. If @c NULL or empty, the new image is given
2003 * no name. If nonempty, it must specify a name that does not already
2005 * @param new_idx_ret
2006 * If non-<code>NULL</code>, the index of the newly added image is returned
2009 * @return 0 on success; nonzero on failure. The possible error codes are:
2011 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2012 * There is already an image in @p wim named @p name.
2013 * @retval ::WIMLIB_ERR_NOMEM
2014 * Failed to allocate the memory needed to add the new image.
2015 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2016 * The WIM file is considered read-only because of any of the reasons
2017 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2021 wimlib_add_empty_image(WIMStruct *wim,
2022 const wimlib_tchar *name,
2026 * @ingroup G_modifying_wims
2028 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2030 * The directory tree or NTFS volume is scanned immediately to load the dentry
2031 * tree into memory, and file attributes and symbolic links are read. However,
2032 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2035 * See the manual page for the @b wimlib-imagex program for more information
2036 * about the "normal" capture mode versus the NTFS capture mode (entered by
2037 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2039 * Note that @b no changes are committed to the underlying WIM file (if
2040 * any) until wimlib_write() or wimlib_overwrite() is called.
2043 * Pointer to the ::WIMStruct for a WIM file to which the image will be
2046 * A path to a directory or unmounted NTFS volume that will be captured as
2049 * Name to give the new image. If @c NULL or empty, the new image is given
2050 * no name. If nonempty, it must specify a name that does not already
2053 * Capture configuration that specifies files, directories, or path globs
2054 * to exclude from being captured. If @c NULL, a dummy configuration where
2055 * no paths are treated specially is used.
2057 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2058 * @param progress_func
2059 * If non-NULL, a function that will be called periodically with the
2060 * progress of the current operation. The progress messages that will be
2061 * received are ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
2062 * ::WIMLIB_PROGRESS_MSG_SCAN_END, and, if ::WIMLIB_ADD_FLAG_VERBOSE was
2063 * included in @p add_flags, also ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2065 * @return 0 on success; nonzero on error. On error, changes to @p wim are
2066 * discarded so that it appears to be in the same state as when this function
2069 * This function is implemented by calling wimlib_add_empty_image(), then
2070 * calling wimlib_update_image() with a single "add" command, so any error code
2071 * returned by wimlib_add_empty_image() may be returned, as well as any error
2072 * codes returned by wimlib_update_image() other than ones documented as only
2073 * being returned specifically by an update involving delete or rename commands.
2076 wimlib_add_image(WIMStruct *wim,
2077 const wimlib_tchar *source,
2078 const wimlib_tchar *name,
2079 const struct wimlib_capture_config *config,
2081 wimlib_progress_func_t progress_func);
2084 * @ingroup G_modifying_wims
2086 * This function is equivalent to wimlib_add_image() except it allows for
2087 * multiple sources to be combined into a single WIM image. This is done by
2088 * specifying the @p sources and @p num_sources parameters instead of the @p
2089 * source parameter of wimlib_add_image(). The rest of the parameters are the
2090 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
2091 * capture</b> for full details on how this mode works.
2093 * In addition to the error codes that wimlib_add_image() can return,
2094 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2095 * when trying to overlay a non-directory on a directory or when otherwise
2096 * trying to overlay multiple conflicting files to the same location in the WIM
2097 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
2098 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2099 * was not exactly one capture source with the target being the root directory.
2100 * (In this respect, there is no advantage to using
2101 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2104 wimlib_add_image_multisource(WIMStruct *wim,
2105 const struct wimlib_capture_source *sources,
2107 const wimlib_tchar *name,
2108 const struct wimlib_capture_config *config,
2110 wimlib_progress_func_t progress_func);
2113 * @ingroup G_creating_and_opening_wims
2115 * Creates a ::WIMStruct for a new WIM file.
2117 * This only creates an in-memory structure for a WIM that initially contains no
2118 * images. No on-disk file is created until wimlib_write() is called.
2121 * The type of compression to be used in the new WIM file, as one of the
2122 * ::wimlib_compression_type constants.
2124 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2125 * written to the memory location pointed to by this paramater. The
2126 * ::WIMStruct must be freed using using wimlib_free() when finished with
2128 * @return 0 on success; nonzero on error.
2129 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2130 * @p ctype was not a supported compression type.
2131 * @retval ::WIMLIB_ERR_NOMEM
2132 * Failed to allocate needed memory.
2135 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2138 * @ingroup G_modifying_wims
2140 * Deletes an image, or all images, from a WIM file.
2142 * All streams referenced by the image(s) being deleted are removed from the
2143 * lookup table of the WIM if they are not referenced by any other images in the
2146 * Please note that @b no changes are committed to the underlying WIM file (if
2147 * any) until wimlib_write() or wimlib_overwrite() is called.
2150 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2153 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2155 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2156 * to be left unmodified only if @p image specified a single image. If instead
2157 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2158 * possible for some but not all of the images to have been deleted when a
2159 * failure status is returned.
2161 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2162 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2163 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2164 * The WIM file is considered read-only because of any of the reasons
2165 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2168 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2169 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2170 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2171 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2172 * different reasons) to read the metadata resource for an image that needed to
2176 wimlib_delete_image(WIMStruct *wim, int image);
2179 * @ingroup G_modifying_wims
2181 * Exports an image, or all the images, from a WIM file, into another WIM file.
2183 * The destination image is made to share the same dentry tree and security data
2184 * structure as the source image. This places some restrictions on additional
2185 * functions that may be called. wimlib_mount_image() may not be called on
2186 * either the source image or the destination image without an intervening call
2187 * to a function that un-shares the images, such as wimlib_free() on @p
2188 * dest_wim, or wimlib_delete_image() on either the source or destination image.
2189 * Furthermore, you may not call wimlib_free() on @p src_wim before calling
2190 * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
2191 * have references back to @p src_wim.
2193 * If this function fails, all changes to @p dest_wim are rolled back.
2195 * Please note that no changes are committed to the underlying WIM file of @p
2196 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2199 * The WIM from which to export the images, specified as a pointer to the
2200 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2201 * split WIM. In the case of a WIM file that is not standalone, this
2202 * ::WIMStruct must have had any needed external resources previously
2203 * referenced using wimlib_reference_resources() or
2204 * wimlib_reference_resource_files().
2206 * The image to export from @p src_wim, as either a 1-based image index to
2207 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2209 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2212 * For single-image exports, the name to give the exported image in @p
2213 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2214 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2215 * that case, the names are all taken from @p src_wim. This parameter is
2216 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2217 * @param dest_description
2218 * For single-image exports, the description to give the exported image in
2219 * the new WIM file. If left @c NULL, the description from @p src_wim is
2220 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2221 * NULL; in that case, the description are all taken from @p src_wim. This
2222 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2223 * @param export_flags
2224 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2225 * @param progress_func
2226 * Currently ignored, but reserved for a function that will be called with
2227 * information about the operation. Use NULL if no additional information
2230 * @return 0 on success; nonzero on error.
2231 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2232 * One or more of the names being given to an exported image was already in
2233 * use in the destination WIM.
2234 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2235 * @p src_image does not exist in @p src_wim and was not
2236 * ::WIMLIB_ALL_IMAGES.
2237 * @retval ::WIMLIB_ERR_INVALID_PARAM
2238 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2239 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2241 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2242 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2243 * example, one of them was a non-first part of a split WIM.
2244 * @retval ::WIMLIB_ERR_NOMEM
2245 * Failed to allocate needed memory.
2246 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2247 * A resource that needed to be exported could not be found in either the
2248 * source or destination WIMs. This error can occur if, for example, @p
2249 * src_wim is part of a split WIM but needed resources from the other split
2250 * WIM parts were not referenced with wimlib_reference_resources() or
2251 * wimlib_reference_resource_files() before the call to
2252 * wimlib_export_image().
2253 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2254 * @p dest_wim is considered read-only because of any of the reasons
2255 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2258 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2259 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2260 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2261 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2262 * different reasons) to read the metadata resource for an image in @p src_wim
2263 * that needed to be exported.
2266 wimlib_export_image(WIMStruct *src_wim, int src_image,
2267 WIMStruct *dest_wim,
2268 const wimlib_tchar *dest_name,
2269 const wimlib_tchar *dest_description,
2271 wimlib_progress_func_t progress_func);
2274 * @ingroup G_extracting_wims
2276 * Extract zero or more files or directory trees from a WIM image.
2278 * As of wimlib v1.6.1, this function is deprecated in favor of
2279 * wimlib_extract_paths() because wimlib_extract_paths() is easier to use and
2282 * Notes: wimlib_extract_files() does not support the
2283 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS flag, and
2284 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE is always implied. The same
2285 * hardlink/symlink extraction mode must be set on all extraction commands. An
2286 * independent extraction operation (like a separate call to
2287 * wimlib_extract_paths()) is done for each extraction command. Otherwise, the
2288 * documentation for wimlib_extract_paths() applies.
2291 wimlib_extract_files(WIMStruct *wim,
2293 const struct wimlib_extract_command *cmds,
2295 int default_extract_flags,
2296 wimlib_progress_func_t progress_func) _wimlib_deprecated;
2299 * @ingroup G_extracting_wims
2301 * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2304 * The exact behavior of how wimlib extracts files from a WIM image is
2305 * controllable by the @p extract_flags parameter, but there also are
2306 * differences depending on the platform (UNIX-like vs Windows). See the manual
2307 * page for <b>wimlib-imagex apply</b> for more information, including about the
2308 * special "NTFS volume extraction mode" entered by providing
2309 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2312 * The WIM from which to extract the image(s), specified as a pointer to
2313 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2314 * of a split WIM. In the case of a WIM file that is not standalone, this
2315 * ::WIMStruct must have had any needed external resources previously
2316 * referenced using wimlib_reference_resources() or
2317 * wimlib_reference_resource_files().
2319 * The image to extract, specified as either the 1-based index of a single
2320 * image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2321 * to be extracted. ::WIMLIB_ALL_IMAGES cannot be used if
2322 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2324 * Directory to extract the WIM image(s) to; or, with
2325 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2326 * the unmounted NTFS volume to which to extract the image.
2327 * @param extract_flags
2328 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2329 * @param progress_func
2330 * If non-NULL, a function that will be called periodically with the
2331 * progress of the current operation. The main message to look for is
2332 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS; however, there are others as
2335 * @return 0 on success; nonzero on error.
2336 * @retval ::WIMLIB_ERR_DECOMPRESSION
2337 * Failed to decompress data contained in the WIM.
2338 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2339 * The metadata for one of the images to extract was invalid.
2340 * @retval ::WIMLIB_ERR_INVALID_PARAM
2341 * The extraction flags were invalid; more details may be found in the
2342 * documentation for the specific extraction flags that were specified. Or
2343 * @p target was @c NULL or the empty string, or @p wim was @c NULL.
2344 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2345 * The SHA1 message digest of an extracted stream did not match the SHA1
2346 * message digest given in the WIM.
2347 * @retval ::WIMLIB_ERR_LINK
2348 * Failed to create a symbolic link or a hard link.
2349 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2350 * The metadata resource for one of the images to extract was not found.
2351 * This can happen if @p wim represents a non-first part of a split WIM.
2352 * @retval ::WIMLIB_ERR_MKDIR
2353 * Failed create a directory.
2354 * @retval ::WIMLIB_ERR_NOMEM
2355 * Failed to allocate needed memory.
2356 * @retval ::WIMLIB_ERR_OPEN
2357 * Could not create a file, or failed to open an already-extracted file.
2358 * @retval ::WIMLIB_ERR_READ
2359 * Failed to read data from the WIM.
2360 * @retval ::WIMLIB_ERR_READLINK
2361 * Failed to determine the target of a symbolic link in the WIM.
2362 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2363 * Failed to fix the target of an absolute symbolic link (e.g. if the
2364 * target would have exceeded the maximum allowed length). (Only if
2365 * reparse data was supported by the extraction mode and
2366 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2368 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2369 * One of the files or directories that needed to be extracted referenced a
2370 * stream not present in the WIM's lookup table (or in any of the lookup
2371 * tables of the split WIM parts).
2372 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2373 * Failed to set attributes on a file.
2374 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2375 * Failed to set reparse data on a file (only if reparse data was supported
2376 * by the extraction mode).
2377 * @retval ::WIMLIB_ERR_SET_SECURITY
2378 * Failed to set security descriptor on a file
2379 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2381 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2382 * Failed to set the short name of a file (only if
2383 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2384 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2385 * Failed to set timestamps on a file (only if
2386 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2387 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2388 * Unexpected end-of-file occurred when reading data from the WIM.
2389 * @retval ::WIMLIB_ERR_UNSUPPORTED
2390 * A requested extraction flag, or the data or metadata that must be
2391 * extracted to support it, is unsupported in the build and configuration
2392 * of wimlib, or on the current platform or extraction mode or target
2393 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2394 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2395 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2396 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS,
2397 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS, ::WIMLIB_EXTRACT_FLAG_SYMLINK,
2398 * and ::WIMLIB_EXTRACT_FLAG_HARDLINK. For example, if
2399 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2400 * extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2401 * image contains one or more files with short names, but extracting short
2402 * names is not supported --- on Windows, this occurs if the target volume
2403 * does not support short names, while on non-Windows, this occurs if
2404 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2405 * @retval ::WIMLIB_ERR_WRITE
2406 * Failed to write data to a file being extracted.
2409 wimlib_extract_image(WIMStruct *wim, int image,
2410 const wimlib_tchar *target,
2412 wimlib_progress_func_t progress_func);
2415 * @ingroup G_extracting_wims
2417 * Since wimlib v1.5.0: Extract one image from a pipe on which a pipable WIM is
2420 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2421 * about pipable WIMs.
2423 * This function operates in a special way to read the WIM fully sequentially.
2424 * As a result, there is no ::WIMStruct is made visible to library users, and
2425 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2426 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2427 * seekable file, not a pipe.)
2430 * File descriptor, which may be a pipe, opened for reading and positioned
2431 * at the start of the pipable WIM.
2432 * @param image_num_or_name
2433 * String that specifies the 1-based index or name of the image to extract.
2434 * It is translated to an image index using the same rules that
2435 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2436 * only a single image (not all images) can be specified. Alternatively,
2437 * specify @p NULL here to use the first image in the WIM if it contains
2438 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2440 * Same as the corresponding parameter to wimlib_extract_image().
2441 * @param extract_flags
2442 * Same as the corresponding parameter to wimlib_extract_image(), except
2443 * that ::WIMLIB_EXTRACT_FLAG_FILE_ORDER cannot be specified and will
2444 * result in ::WIMLIB_ERR_INVALID_PARAM being returned.
2445 * @param progress_func
2446 * Same as the corresponding parameter to wimlib_extract_image(), except
2447 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
2448 * received by the progress function.
2450 * @return 0 on success; nonzero on error. The possible error codes include
2451 * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2454 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2455 * Data read from the pipable WIM was invalid.
2456 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2457 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2460 wimlib_extract_image_from_pipe(int pipe_fd,
2461 const wimlib_tchar *image_num_or_name,
2462 const wimlib_tchar *target, int extract_flags,
2463 wimlib_progress_func_t progress_func);
2466 * @ingroup G_extracting_wims
2468 * Since wimlib v1.6.0: Similar to wimlib_extract_paths(), but the paths to
2469 * extract from the WIM image are specified in the UTF-8 text file named by @p
2470 * path_list_file which itself contains the list of paths to use, one per line.
2471 * Leading and trailing whitespace, and otherwise empty lines and lines
2472 * beginning with the ';' character are ignored. No quotes are needed as paths
2473 * are otherwise delimited by the newline character.
2475 * The error codes are the same as those returned by wimlib_extract_paths(),
2476 * except that wimlib_extract_pathlist() returns an appropriate error code if it
2477 * cannot read the path list file (::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2478 * ::WIMLIB_ERR_READ, ::WIMLIB_ERR_NOMEM, or ::WIMLIB_ERR_INVALID_UTF8_STRING).
2481 wimlib_extract_pathlist(WIMStruct *wim, int image,
2482 const wimlib_tchar *target,
2483 const wimlib_tchar *path_list_file,
2485 wimlib_progress_func_t progress_func);
2488 * @ingroup G_extracting_wims
2490 * Since wimlib v1.6.0: Extract zero or more paths (files or directory trees)
2491 * from the specified WIM image.
2493 * By default, each path will be extracted to a corresponding subdirectory of
2494 * the target based on its location in the WIM image. For example, if one of
2495 * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2496 * the file will be extracted to "outdir/Windows/explorer.exe". This behavior
2497 * can be changed by providing the flag
2498 * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2499 * or directory tree to be placed directly in the target directory --- so the
2500 * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2502 * Symbolic links will not be dereferenced when paths in the WIM image are
2506 * WIM from which to extract the paths, specified as a pointer to the
2507 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2508 * split WIM. In the case of a WIM file that is not standalone, this
2509 * ::WIMStruct must have had any needed external resources previously
2510 * referenced using wimlib_reference_resources() or
2511 * wimlib_reference_resource_files().
2513 * 1-based index of the WIM image from which to extract the paths.
2515 * Array of paths to extract. Each element must be the absolute path to a
2516 * file or directory within the WIM image. Separators may be either
2517 * forwards or backwards slashes, and leading path separators are optional.
2518 * The paths will be interpreted either case-sensitively (UNIX default) or
2519 * case-insensitively (Windows default); this can be changed by
2520 * wimlib_global_init().
2522 * By default, the characters @c * and @c ? are interpreted literally.
2523 * This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2526 * By default, if any paths to extract do not exist, the error code
2527 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned. This behavior changes if
2528 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2530 * Number of paths specified in @p paths.
2532 * Directory to which to extract the paths; or with
2533 * ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2534 * unmounted NTFS volume to which to extract the paths. Unlike the @p
2535 * paths being extracted, the @p target must be native path. On UNIX-like
2536 * systems it may not contain backslashes, for example.
2537 * @param extract_flags
2538 * Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2539 * @param progress_func
2540 * If non-NULL, a function that will be called periodically with the
2541 * progress of the current operation. The main message to look for is
2542 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS; however, there are others as
2543 * well. Note: because the extraction code is stream-based and not
2544 * file-based, there is no way to get information about which path is
2545 * currently being extracted, but based on byte count you can still
2546 * calculate an approximate percentage complete for the extraction overall
2547 * which may be all you really need anyway.
2549 * @return 0 on success; nonzero on error. Most of the error codes are the same
2550 * as those returned by wimlib_extract_image(). Below, some of the error codes
2551 * returned in situations specific to path-mode extraction are documented:
2553 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2554 * @p image was ::WIMLIB_ALL_IMAGES or was otherwise not a valid single
2556 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2557 * One of the paths to extract did not exist in the WIM image. This error
2558 * code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2559 * specified in @p extract_flags, or if both
2560 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2561 * were specified in @p extract_flags.
2562 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2563 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2564 * one of the paths to extract did not name a regular file.
2567 wimlib_extract_paths(WIMStruct *wim,
2569 const wimlib_tchar *target,
2570 const wimlib_tchar * const *paths,
2573 wimlib_progress_func_t progress_func);
2576 * @ingroup G_wim_information
2578 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2579 * includes a string of XML that describes the images contained in the WIM.
2581 * See wimlib_get_xml_data() to read the XML data into memory instead.
2584 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2585 * have to be standalone (e.g. it could be part of a split WIM).
2587 * @c stdout, or a FILE* opened for writing, to extract the data to.
2589 * @return 0 on success; nonzero on error.
2590 * @retval ::WIMLIB_ERR_INVALID_PARAM
2591 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2592 * @retval ::WIMLIB_ERR_NOMEM
2593 * @retval ::WIMLIB_ERR_READ
2594 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2595 * Failed to read the XML data from the WIM.
2596 * @retval ::WIMLIB_ERR_WRITE
2597 * Failed to completely write the XML data to @p fp.
2600 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2603 * @ingroup G_general
2605 * Frees all memory allocated for a WIMStruct and closes all files associated
2609 * Pointer to the ::WIMStruct for a WIM file.
2611 * @return This function has no return value.
2614 wimlib_free(WIMStruct *wim);
2617 * @ingroup G_general
2619 * Converts a ::wimlib_compression_type value into a string.
2622 * The ::wimlib_compression_type value to convert.
2625 * A statically allocated string naming the compression algorithm,
2626 * such as "None", "LZX", "XPRESS", or "Invalid".
2628 extern const wimlib_tchar *
2629 wimlib_get_compression_type_string(int ctype);
2632 * @ingroup G_general
2634 * Converts an error code into a string describing it.
2637 * The error code returned by one of wimlib's functions.
2640 * Pointer to a statically allocated string describing the error code,
2641 * or @c NULL if the error code is not valid.
2643 extern const wimlib_tchar *
2644 wimlib_get_error_string(enum wimlib_error_code code);
2647 * @ingroup G_wim_information
2649 * Returns the description of the specified image.
2652 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2653 * to be standalone (e.g. it could be part of a split WIM).
2655 * The number of the image, numbered starting at 1.
2658 * The description of the image, or @c NULL if there is no such image, or
2659 * @c NULL if the specified image has no description. The description
2660 * string is in library-internal memory and may not be modified or freed;
2661 * in addition, the string will become invalid if the description of the
2662 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2664 extern const wimlib_tchar *
2665 wimlib_get_image_description(const WIMStruct *wim, int image);
2668 * @ingroup G_wim_information
2670 * Returns the name of the specified image.
2673 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2674 * to be standalone (e.g. it could be part of a split WIM).
2676 * The number of the image, numbered starting at 1.
2679 * The name of the image, or @c NULL if there is no such image, or an empty
2680 * string if the image is unnamed. The name string is in
2681 * library-internal memory and may not be modified or freed; in addition,
2682 * the string will become invalid if the name of the image is changed, the
2683 * image is deleted, or the ::WIMStruct is destroyed.
2685 extern const wimlib_tchar *
2686 wimlib_get_image_name(const WIMStruct *wim, int image);
2689 * @ingroup G_general
2691 * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
2692 * the major version, the next 10 bits contain the minor version, and the low 10
2693 * bits contain the patch version.
2695 * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
2696 * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
2697 * corresponding header file.
2700 wimlib_get_version(void);
2703 * @ingroup G_wim_information
2705 * Get basic information about a WIM file.
2708 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2709 * to be standalone (e.g. it could be part of a split WIM).
2711 * A ::wimlib_wim_info structure that will be filled in with information
2712 * about the WIM file.
2717 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2720 * @ingroup G_wim_information
2722 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
2723 * includes a string of XML that describes the images contained in the WIM.
2725 * See wimlib_extract_xml_data() to extract the XML data to a file stream
2729 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2730 * have to be standalone (e.g. it could be part of a split WIM).
2732 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
2733 * XML data is written to this location.
2734 * @param bufsize_ret
2735 * The size of the XML data in bytes is written to this location.
2737 * @return 0 on success; nonzero on error.
2738 * @retval ::WIMLIB_ERR_INVALID_PARAM
2739 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2740 * @p buf_ret or @p bufsize_ret was @c NULL.
2741 * @retval ::WIMLIB_ERR_NOMEM
2742 * @retval ::WIMLIB_ERR_READ
2743 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2744 * Failed to read the XML data from the WIM.
2747 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2750 * @ingroup G_general
2752 * Initialization function for wimlib. Call before using any other wimlib
2753 * function except wimlib_set_print_errors(). If not done manually, this
2754 * function will be called automatically with @p init_flags set to
2755 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
2756 * after it has already successfully run.
2759 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2761 * @return 0 on success; nonzero on failure. Currently, only the following
2762 * error code is defined:
2764 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2765 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2766 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2767 * init_flags, but the corresponding privileges could not be acquired.
2770 wimlib_global_init(int init_flags);
2773 * @ingroup G_general
2775 * Cleanup function for wimlib. You are not required to call this function, but
2776 * it will release any global resources allocated by the library.
2779 wimlib_global_cleanup(void);
2782 * @ingroup G_wim_information
2784 * Determines if an image name is already used by some image in the WIM.
2787 * Pointer to the ::WIMStruct for a WIM file.
2789 * The name to check.
2792 * @c true if there is already an image in @p wim named @p name; @c false
2793 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2794 * the empty string, @c false is returned.
2797 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2800 * @ingroup G_wim_information
2802 * Iterate through a file or directory tree in the WIM image. By specifying
2803 * appropriate flags and a callback function, you can get the attributes of a
2804 * file in the WIM, get a directory listing, or even get a listing of the entire
2808 * The WIM containing the image(s) over which to iterate, specified as a
2809 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2810 * or part 1 of a split WIM. In the case of a WIM file that is not
2811 * standalone, this ::WIMStruct should have had any needed external
2812 * resources previously referenced using wimlib_reference_resources() or
2813 * wimlib_reference_resource_files(). If not, see
2814 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2815 * the behavior when resources are missing.
2818 * The 1-based number of the image in @p wim that contains the files or
2819 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2820 * iteration on all images in the WIM.
2823 * Path in the WIM image at which to do the iteration.
2826 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2829 * A callback function that will receive each directory entry.
2832 * An extra parameter that will always be passed to the callback function
2835 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2836 * first nonzero value that was returned from @p cb. However, additional error
2837 * codes may be returned, including the following:
2839 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2840 * @p path did not exist in the WIM image.
2841 * @retval ::WIMLIB_ERR_NOMEM
2842 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2844 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2845 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2846 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2847 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2848 * different reasons) to read the metadata resource for an image over which
2849 * iteration needed to be done.
2852 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2854 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2857 * @ingroup G_wim_information
2859 * Iterate through the lookup table of a WIM file. This can be used to directly
2860 * get a listing of the unique resources contained in a WIM file over all
2861 * images. Both file resources and metadata resources are included. However,
2862 * only resources actually included in the file represented by @a wim, plus
2863 * explicitly referenced external resources (via wimlib_reference_resources() or
2864 * wimlib_reference_resource_files()) are included in the iteration. For
2865 * example, if @p wim represents just one part of a split WIM, then only
2866 * resources in that part will be included, unless other resources were
2867 * explicitly referenced.
2870 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2871 * to be standalone (e.g. it could be part of a split WIM).
2874 * Reserved; set to 0.
2877 * A callback function that will receive each resource.
2880 * An extra parameter that will always be passed to the callback function
2883 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
2884 * that was returned from @p cb.
2887 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2888 wimlib_iterate_lookup_table_callback_t cb,
2892 * @ingroup G_nonstandalone_wims
2894 * Joins a split WIM into a stand-alone one-part WIM.
2897 * An array of strings that gives the filenames of all parts of the split
2898 * WIM. No specific order is required, but all parts must be included with
2901 * Number of filenames in @p swms.
2902 * @param swm_open_flags
2903 * Open flags for the split WIM parts (e.g.
2904 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
2905 * @param wim_write_flags
2906 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
2907 * be used to write the joined WIM.
2908 * @param output_path
2909 * The path to write the joined WIM file to.
2910 * @param progress_func
2911 * If non-NULL, a function that will be called periodically with the
2912 * progress of the current operation.
2914 * @return 0 on success; nonzero on error. This function may return most error
2915 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
2916 * as the following error code:
2918 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2919 * The split WIMs do not form a valid WIM because they do not include all
2920 * the parts of the original WIM, there are duplicate parts, or not all the
2921 * parts have the same GUID and compression type.
2923 * Note: wimlib is generalized enough that this function is not actually needed
2924 * to join a split WIM; instead, you could open the first part of the split WIM,
2925 * then reference the other parts with wimlib_reference_resource_files(), then
2926 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
2927 * an easy-to-use wrapper around this that has some advantages (e.g. extra
2931 wimlib_join(const wimlib_tchar * const *swms,
2933 const wimlib_tchar *output_path,
2935 int wim_write_flags,
2936 wimlib_progress_func_t progress_func);
2940 * @ingroup G_mounting_wim_images
2942 * Mounts an image in a WIM file on a directory read-only or read-write.
2944 * As this is implemented using FUSE (Filesystme in UserSpacE), this is not
2945 * supported if wimlib was configured with @c --without-fuse. This includes
2946 * Windows builds of wimlib; ::WIMLIB_ERR_UNSUPPORTED will be returned in such
2949 * Calling this function daemonizes the process, unless
2950 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early occur occurs. If the
2951 * mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified), modifications
2952 * to the WIM are staged in a temporary directory.
2954 * It is safe to mount multiple images from the same underlying WIM file
2955 * read-only at the same time, but only if different ::WIMStruct's are used. It
2956 * is @b not safe to mount multiple images from the same WIM file read-write at
2959 * wimlib_mount_image() cannot be used on an image that was exported with
2960 * wimlib_export_image() while the dentry trees for both images are still in
2961 * memory. In addition, wimlib_mount_image() may not be used to mount an image
2962 * that already has modifications pending (e.g. an image added with
2963 * wimlib_add_image()).
2966 * Pointer to the ::WIMStruct containing the image to be mounted.
2968 * The number of the image to mount, indexed starting from it. It must be
2969 * an existing, single image.
2971 * The path to an existing empty directory to mount the image on.
2972 * @param mount_flags
2973 * Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG.
2974 * @param staging_dir
2975 * If non-NULL, the name of a directory in which the staging directory will
2976 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2977 * in @p mount_flags. If left @c NULL, the staging directory is created in
2978 * the same directory as the WIM file that @p wim was originally read from.
2980 * @return 0 on success; nonzero on error.
2982 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2983 * A read-write mount was requested, but an an exclusive advisory lock on
2984 * the on-disk WIM file could not be acquired because another thread or
2985 * process has mounted an image from the WIM read-write or is currently
2986 * modifying the WIM in-place.
2987 * @retval ::WIMLIB_ERR_FUSE
2988 * A non-zero status was returned by @c fuse_main().
2989 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2990 * @p image does not specify an existing, single image in @p wim.
2991 * @retval ::WIMLIB_ERR_INVALID_PARAM
2992 * @p image is shared among multiple ::WIMStruct's as a result of a call to
2993 * wimlib_export_image(), or @p image has been added with
2994 * wimlib_add_image().
2995 * @retval ::WIMLIB_ERR_MKDIR
2996 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
2997 * staging directory could not be created.
2998 * @retval ::WIMLIB_ERR_NOTDIR
2999 * Could not determine the current working directory.
3000 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3001 * One of the dentries in the image referenced a stream not present in the
3002 * WIM's lookup table (or in any of the lookup tables of the split WIM
3004 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3005 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but @p
3006 * wim is considered read-only because of any of the reasons mentioned in
3007 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3008 * @retval ::WIMLIB_ERR_UNSUPPORTED
3009 * Mounting is not supported, either because the platform is Windows, or
3010 * because the platform is UNIX-like and wimlib was compiled with @c
3013 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3014 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3015 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3016 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3017 * different reasons) to read the metadata resource for the image to mount.
3020 wimlib_mount_image(WIMStruct *wim,
3022 const wimlib_tchar *dir,
3024 const wimlib_tchar *staging_dir);
3027 * @ingroup G_creating_and_opening_wims
3029 * Opens a WIM file and creates a ::WIMStruct for it.
3032 * The path to the WIM file to open.
3035 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3037 * @param progress_func
3038 * If non-NULL, a function that will be called periodically with the
3039 * progress of the current operation. Currently, the only messages sent
3040 * will be ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY, and only if
3041 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags.
3044 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3045 * is written to the memory location pointed to by this parameter. The
3046 * ::WIMStruct can be freed using using wimlib_free() when finished with
3049 * @return 0 on success; nonzero on error.
3050 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3051 * The WIM is not the non-first part of a split WIM, and the number of
3052 * metadata resources found in the WIM did not match the image count given
3053 * in the WIM header, or the number of <IMAGE> elements in the XML
3054 * data for the WIM did not match the image count given in the WIM header.
3055 * @retval ::WIMLIB_ERR_INTEGRITY
3056 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
3057 * wim_file contains an integrity table, but the SHA1 message digest for a
3058 * chunk of the WIM does not match the corresponding message digest given
3059 * in the integrity table.
3060 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3061 * Resources in @p wim_file are compressed, but the chunk size was invalid
3062 * for the WIM's compression type.
3063 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3064 * The header of @p wim_file says that resources in the WIM are compressed,
3065 * but the header flag for a recognized compression type is not set.
3066 * @retval ::WIMLIB_ERR_INVALID_HEADER
3067 * The header of @p wim_file was otherwise invalid.
3068 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3069 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
3070 * wim_file contains an integrity table, but the integrity table is
3072 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3073 * The lookup table for the WIM was invalid.
3074 * @retval ::WIMLIB_ERR_INVALID_PARAM
3075 * @p wim_ret was @c NULL.
3076 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3077 * @p wim_file is a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3078 * specified in @p open_flags.
3079 * @retval ::WIMLIB_ERR_NOMEM
3080 * Failed to allocated needed memory.
3081 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3082 * @p wim_file does not begin with the expected magic characters.
3083 * @retval ::WIMLIB_ERR_OPEN
3084 * Failed to open the file @p wim_file for reading.
3085 * @retval ::WIMLIB_ERR_READ
3086 * Failed to read data from @p wim_file.
3087 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3088 * Unexpected end-of-file while reading data from @p wim_file.
3089 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3090 * The WIM version number was not recognized. (May be a pre-Vista WIM.)
3091 * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3092 * The WIM cannot be opened because it contains encrypted segments. (It
3093 * may be a Windows 8 "ESD" file).
3094 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3095 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3096 * considered read-only because of any of the reasons mentioned in the
3097 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3098 * @retval ::WIMLIB_ERR_XML
3099 * The XML data for @p wim_file is invalid.
3102 wimlib_open_wim(const wimlib_tchar *wim_file,
3104 WIMStruct **wim_ret,
3105 wimlib_progress_func_t progress_func);
3108 * @ingroup G_writing_and_overwriting_wims
3110 * Overwrites the file that the WIM was originally read from, with changes made.
3111 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3112 * rather than wimlib_create_new_wim().
3114 * There are two ways that a WIM may be overwritten. The first is to do a full
3115 * rebuild. In this mode, the new WIM is written to a temporary file and then
3116 * renamed to the original file after it is has been completely written. The
3117 * temporary file is made in the same directory as the original WIM file. A
3118 * full rebuild may take a while, but can be used even if images have been
3119 * modified or deleted, will produce a WIM with no holes, and has little chance
3120 * of unintentional data loss because the temporary WIM is fsync()ed before
3121 * being renamed to the original WIM.
3123 * The second way to overwrite a WIM is by appending to the end of it and
3124 * overwriting the header. This can be much faster than a full rebuild, but the
3125 * disadvantage is that some space will be wasted. Writing a WIM in this mode
3126 * begins with writing any new file resources *after* everything in the old WIM,
3127 * even though this will leave a hole where the old lookup table, XML data, and
3128 * integrity were. This is done so that the WIM remains valid even if the
3129 * operation is aborted mid-write. The WIM header is only overwritten at the
3130 * very last moment, and up until that point the WIM will be seen as the old
3133 * By default, wimlib_overwrite() does the append-style overwrite described
3134 * above, unless resources in the WIM are arranged in an unusual way or if
3135 * images have been deleted from the WIM. Use the flag
3136 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3137 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3138 * images have been deleted from the WIM.
3140 * In the temporary-file overwrite mode, no changes are made to the WIM on
3141 * failure, and the temporary file is deleted if possible. Abnormal termination
3142 * of the program will result in the temporary file being orphaned. In the
3143 * direct append mode, the WIM is truncated to the original length on failure;
3144 * and while abnormal termination of the program will result in extra data
3145 * appended to the original WIM, it should still be a valid WIM.
3147 * If this function completes successfully, no more functions should be called
3148 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
3149 * the WIM file anew.
3152 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3153 * been in-memory changes made to it, which are then reflected in the
3155 * @param write_flags
3156 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3157 * @param num_threads
3158 * Number of threads to use for compression (see wimlib_write()).
3159 * @param progress_func
3160 * If non-NULL, a function that will be called periodically with the
3161 * progress of the current operation.
3163 * @return 0 on success; nonzero on error. This function may return most error
3164 * codes returned by wimlib_write() as well as the following error codes:
3166 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3167 * The WIM was going to be modified in-place (with no temporary file), but
3168 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3169 * because another thread or process has mounted an image from the WIM
3170 * read-write or is currently modifying the WIM in-place.
3171 * @retval ::WIMLIB_ERR_NO_FILENAME
3172 * @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
3173 * than a WIM read with wimlib_open_wim().
3174 * @retval ::WIMLIB_ERR_RENAME
3175 * The temporary file that the WIM was written to could not be renamed to
3176 * the original filename of @p wim.
3177 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3178 * The WIM file is considered read-only because of any of the reasons
3179 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3183 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
3184 wimlib_progress_func_t progress_func);
3187 * @ingroup G_wim_information
3189 * Prints information about one image, or all images, contained in a WIM.
3192 * Pointer to the ::WIMStruct for a WIM file.
3194 * The image about which to print information. Can be the number of an
3195 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3198 * @return This function has no return value. No error checking is done when
3199 * printing the information. If @p image is invalid, an error message is
3203 wimlib_print_available_images(const WIMStruct *wim, int image);
3206 * @ingroup G_wim_information
3208 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3209 * in a way that can be accessed programatically.
3212 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3215 * @ingroup G_nonstandalone_wims
3217 * Reference resources from other WIM files or split WIM parts. This function
3218 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3219 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3220 * from other files, before calling a function such as wimlib_extract_image()
3221 * that requires the resources to be present.
3224 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3225 * necessarily "standalone". In the case of split WIMs, this should be the
3226 * first part, since only the first part contains the metadata resources.
3227 * In the case of delta WIMs, this should be the delta WIM rather than the
3228 * WIM on which it is based.
3229 * @param resource_wimfiles_or_globs
3230 * Array of paths to WIM files and/or split WIM parts to reference.
3231 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3232 * ref_flags, these are treated as globs rather than literal paths. That
3233 * is, using this function you can specify zero or more globs, each of
3234 * which expands to one or more literal paths.
3236 * Number of entries in @p resource_wimfiles_or_globs.
3238 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3239 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3241 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3242 * pass to internal calls to wimlib_open_wim() on the reference files.
3243 * @param progress_func
3244 * Passed to internal calls to wimlib_open_wim() on the reference files.
3246 * @return 0 on success; nonzero on error.
3248 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3249 * One of the specified globs did not match any paths (only with both
3250 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3251 * specified in @p ref_flags).
3252 * @retval ::WIMLIB_ERR_NOMEM
3253 * Failed to allocate memory.
3254 * @retval ::WIMLIB_ERR_READ
3255 * I/O or permissions error while processing a file glob.
3257 * This function can additionally return most values that can be returned by
3258 * wimlib_open_wim().
3261 wimlib_reference_resource_files(WIMStruct *wim,
3262 const wimlib_tchar * const *resource_wimfiles_or_globs,
3266 wimlib_progress_func_t progress_func);
3269 * @ingroup G_nonstandalone_wims
3271 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3272 * where the caller must open the ::WIMStruct for each referenced file itself.
3275 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3276 * necessarily "standalone". In the case of split WIMs, this should be the
3277 * first part, since only the first part contains the metadata resources.
3278 * @param resource_wims
3279 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3280 * split WIM parts to reference.
3281 * @param num_resource_wims
3282 * Number of entries in @p resource_wims.
3284 * Currently ignored (set to 0).
3286 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3287 * @p resource_wims are referenced internally by @p wim and must not be freed
3288 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3289 * been freed with wimlib_free(), or immediately before freeing @p wim with
3292 * @retval ::WIMLIB_ERR_INVALID_PARAM
3293 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3294 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3295 * @retval ::WIMLIB_ERR_NOMEM
3296 * Failed to allocate memory.
3299 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3300 unsigned num_resource_wims, int ref_flags);
3303 * @ingroup G_modifying_wims
3305 * Declares that a newly added image is mostly the same as a prior image, but
3306 * captured at a later point in time, possibly with some modifications in the
3307 * intervening time. This is designed to be used in incremental backups of the
3308 * same filesystem or directory tree.
3310 * This function compares the metadata of the directory tree of the newly added
3311 * image against that of the old image. Any files that are present in both the
3312 * newly added image and the old image and have timestamps that indicate they
3313 * haven't been modified are deemed not to have been modified and have their
3314 * SHA1 message digest copied from the old image. Because of this and because
3315 * WIM uses single-instance streams, such files need not be read from the
3316 * filesystem when the WIM is being written or overwritten. Note that these
3317 * unchanged files will still be "archived" and will be logically present in the
3318 * new image; the optimization is that they don't need to actually be read from
3319 * the filesystem because the WIM already contains them.
3321 * This function is provided to optimize incremental backups. The resulting WIM
3322 * file will still be the same regardless of whether this function is called.
3323 * (This is, however, assuming that timestamps have not been manipulated or
3324 * unmaintained as to trick this function into thinking a file has not been
3325 * modified when really it has. To partly guard against such cases, other
3326 * metadata such as file sizes will be checked as well.)
3328 * This function must be called after adding the new image (e.g. with
3329 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3330 * wimlib_overwrite()).
3333 * Pointer to the ::WIMStruct for a WIM.
3335 * 1-based index in the WIM of the newly added image. This image can have
3336 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3337 * wimlib_add_empty_image() followed by wimlib_update_image().
3338 * @param template_wim
3339 * The ::WIMStruct for the WIM containing the template image. This can be
3340 * the same as @p wim, or it can be a different ::WIMStruct.
3341 * @param template_image
3342 * 1-based index in the WIM of a template image that reflects a prior state
3343 * of the directory tree being captured.
3345 * Reserved; must be 0.
3346 * @param progress_func
3347 * Currently ignored, but reserved for a function that will be called with
3348 * information about the operation. Use NULL if no additional information
3351 * @return 0 on success; nonzero on error.
3353 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3354 * @p new_image and/or @p template_image were not a valid image indices in
3356 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3357 * The specified ::WIMStruct did not actually contain the metadata resource
3358 * for the new or template image; for example, it was a non-first part of a
3360 * @retval ::WIMLIB_ERR_NOMEM
3361 * Failed to allocate needed memory.
3362 * @retval ::WIMLIB_ERR_INVALID_PARAM
3363 * @p new_image was equal to @p template_image, or @p new_image specified
3364 * an image that had not been modified since opening the WIM.
3366 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3367 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3368 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3369 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3370 * different reasons) to read the metadata resource for the template image.
3373 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3374 WIMStruct *template_wim, int template_image,
3375 int flags, wimlib_progress_func_t progress_func);
3378 * @ingroup G_wim_information
3380 * Translates a string specifying the name or number of an image in the WIM into
3381 * the number of the image. The images are numbered starting at 1.
3384 * Pointer to the ::WIMStruct for a WIM.
3385 * @param image_name_or_num
3386 * A string specifying the name or number of an image in the WIM. If it
3387 * parses to a positive integer, this integer is taken to specify the
3388 * number of the image, indexed starting at 1. Otherwise, it is taken to
3389 * be the name of an image, as given in the XML data for the WIM file. It
3390 * also may be the keyword "all" or the string "*", both of which will
3391 * resolve to ::WIMLIB_ALL_IMAGES.
3393 * There is no way to search for an image actually named "all", "*", or an
3394 * integer number, or an image that has no name. However, you can use
3395 * wimlib_get_image_name() to get the name of any image.
3398 * If the string resolved to a single existing image, the number of that
3399 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3400 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3401 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3402 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3403 * images in @p wim has no name.
3406 wimlib_resolve_image(WIMStruct *wim,
3407 const wimlib_tchar *image_name_or_num);
3410 * @ingroup G_modifying_wims
3412 * Changes the description of an image in the WIM.
3415 * Pointer to the ::WIMStruct for a WIM.
3417 * The number of the image for which to change the description.
3418 * @param description
3419 * The new description to give the image. It may be @c NULL, which
3420 * indicates that the image is to be given no description.
3422 * @return 0 on success; nonzero on error.
3423 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3424 * @p image does not specify a single existing image in @p wim.
3425 * @retval ::WIMLIB_ERR_NOMEM
3426 * Failed to allocate the memory needed to duplicate the @p description
3428 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3429 * @p wim is considered read-only because of any of the reasons mentioned
3430 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3433 wimlib_set_image_descripton(WIMStruct *wim, int image,
3434 const wimlib_tchar *description);
3437 * @ingroup G_writing_and_overwriting_wims
3439 * Set the compression chunk size of a WIM to use in subsequent calls to
3440 * wimlib_write() or wimlib_overwrite().
3442 * For compatibility reasons, using this function is not generally recommended.
3443 * See the documentation for the @c --chunk-size option of <b>wimlib-imagex
3444 * capture</b> for more information.
3446 * A larger compression chunk size will likely result in a better compression
3447 * ratio, but the speed of random access to the WIM will be reduced.
3448 * Furthermore, the effect of a larger compression chunk size is limited by the
3449 * size of each stream ("file") being compressed.
3452 * ::WIMStruct for a WIM.
3454 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3455 * on the compression format; see the documentation for the @c --chunk-size
3456 * option of <b>wimlib-imagex capture</b> for more information. As a
3457 * special case, if @p chunk_size is specified as 0, the chunk size is set
3458 * to the default for the currently selected output compression type.
3460 * @return 0 on success; nonzero on error.
3462 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3463 * @p chunk_size is not a supported chunk size for the currently selected
3464 * output compression type.
3467 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3470 * @ingroup G_writing_and_overwriting_wims
3472 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3476 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3479 * @ingroup G_writing_and_overwriting_wims
3481 * Set the compression type of a WIM to use in subsequent calls to
3482 * wimlib_write() or wimlib_overwrite().
3485 * ::WIMStruct for a WIM.
3487 * The compression type to set (one of ::wimlib_compression_type). If this
3488 * compression type is incompatible with the current output chunk size
3489 * (either the default or as set with wimlib_set_output_chunk_size()), the
3490 * output chunk size is reset to the default for that compression type.
3492 * @return 0 on success; nonzero on error.
3494 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3495 * @p ctype did not specify a valid compression type.
3498 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3501 * @ingroup G_writing_and_overwriting_wims
3503 * Similar to wimlib_set_output_compression_type(), but set the compression type
3504 * for writing packed streams (solid blocks).
3506 * Note: based on testing, WIMGAPI is seemingly only compatible with LZMS
3507 * compression in packed streams. Therefore the use of this function is not
3508 * recommended. Also, with large chunk sizes, LZMS gives the best compression
3509 * ratio among the alternatives anyway.
3512 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3515 * @ingroup G_modifying_wims
3517 * Set basic information about a WIM.
3520 * Pointer to the ::WIMStruct for a WIM.
3522 * A struct ::wimlib_wim_info that contains the information to set. Only
3523 * the information explicitly specified in the @p which flags need be
3526 * Flags that specify which information to set. This is a bitwise OR of
3527 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3528 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3530 * @return 0 on success; nonzero on failure.
3531 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3532 * The WIM file is considered read-only because of any of the reasons
3533 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3534 * flag. However, as a special case, if you are using
3535 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3536 * function will not fail due to the readonly flag being previously set.
3537 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3538 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3539 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3543 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3547 * @ingroup G_modifying_wims
3549 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3550 * (something like "Core" or "Ultimate")
3553 * Pointer to the ::WIMStruct for a WIM.
3555 * The number of the image for which to change the description.
3557 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3558 * indicates that the image is to be given no \<FLAGS\> element.
3560 * @return 0 on success; nonzero on error.
3561 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3562 * @p image does not specify a single existing image in @p wim.
3563 * @retval ::WIMLIB_ERR_NOMEM
3564 * Failed to allocate the memory needed to duplicate the @p flags string.
3565 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3566 * @p wim is considered read-only because of any of the reasons mentioned
3567 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3570 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3573 * @ingroup G_modifying_wims
3575 * Changes the name of an image in the WIM.
3578 * Pointer to the ::WIMStruct for a WIM.
3580 * The number of the image for which to change the name.
3582 * New name to give the new image. If @c NULL or empty, the new image is
3583 * given no name. If nonempty, it must specify a name that does not
3584 * already exist in @p wim.
3586 * @return 0 on success; nonzero on error.
3587 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3588 * There is already an image named @p name in @p wim.
3589 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3590 * @p image does not specify a single existing image in @p wim.
3591 * @retval ::WIMLIB_ERR_NOMEM
3592 * Failed to allocate the memory needed to duplicate the @p name string.
3593 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3594 * @p wim is considered read-only because of any of the reasons mentioned
3595 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3598 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3601 * @ingroup G_general
3603 * Set the functions that wimlib uses to allocate and free memory.
3605 * These settings are global and not per-WIM.
3607 * The default is to use the default @c malloc() and @c free() from the C
3610 * Please note that some external functions, such as those in @c libntfs-3g, may
3611 * use the standard memory allocation functions.
3613 * @param malloc_func
3614 * A function equivalent to @c malloc() that wimlib will use to allocate
3615 * memory. If @c NULL, the allocator function is set back to the default
3616 * @c malloc() from the C library.
3618 * A function equivalent to @c free() that wimlib will use to free memory.
3619 * If @c NULL, the free function is set back to the default @c free() from
3621 * @param realloc_func
3622 * A function equivalent to @c realloc() that wimlib will use to reallocate
3623 * memory. If @c NULL, the free function is set back to the default @c
3624 * realloc() from the C library.
3628 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3629 void (*free_func)(void *),
3630 void *(*realloc_func)(void *, size_t));
3633 * @ingroup G_general
3635 * Sets whether wimlib is to print error messages to @c stderr when a function
3636 * fails. These error messages may provide information that cannot be
3637 * determined only from the error code that is returned. Not every error will
3638 * result in an error message being printed.
3640 * This setting is global and not per-WIM.
3642 * By default, error messages are not printed.
3644 * This can be called before wimlib_global_init().
3646 * @param show_messages
3647 * @c true if error messages are to be printed; @c false if error messages
3648 * are not to be printed.
3650 * @return 0 on success; nonzero on error.
3651 * @retval ::WIMLIB_ERR_UNSUPPORTED
3652 * @p show_messages was @c true, but wimlib was compiled with the @c
3653 * --without-error-messages option. Therefore, error messages cannot be
3657 wimlib_set_print_errors(bool show_messages);
3660 * @ingroup G_nonstandalone_wims
3662 * Splits a WIM into multiple parts.
3665 * The ::WIMStruct for the WIM to split.
3667 * Name of the SWM file to create. This will be the name of the first
3668 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3669 * appended before the suffix.
3671 * The maximum size per part, in bytes. Unfortunately, it is not
3672 * guaranteed that this will really be the maximum size per part, because
3673 * some file resources in the WIM may be larger than this size, and the WIM
3674 * file format provides no way to split up file resources among multiple
3676 * @param write_flags
3677 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3678 * flags will be used to write each split WIM part. Specify 0 here to get
3679 * the default behavior.
3680 * @param progress_func
3681 * If non-NULL, a function that will be called periodically with the
3682 * progress of the current operation
3683 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3684 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
3686 * @return 0 on success; nonzero on error. This function may return most error
3687 * codes that can be returned by wimlib_write() as well as the following error
3690 * @retval ::WIMLIB_ERR_INVALID_PARAM
3691 * @p swm_name was not a nonempty string, or @p part_size was 0.
3693 * Note: the WIM's uncompressed and compressed resources are not checksummed
3694 * when they are copied from the joined WIM to the split WIM parts, nor are
3695 * compressed resources re-compressed (unless explicitly requested with
3696 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
3699 wimlib_split(WIMStruct *wim,
3700 const wimlib_tchar *swm_name,
3703 wimlib_progress_func_t progress_func);
3706 * @ingroup G_mounting_wim_images
3708 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3710 * The image to unmount is specified by the path to the mountpoint, not the
3711 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
3712 * touched and also may have been allocated in a different process.
3714 * To unmount the image, the process calling this function communicates with the
3715 * process that is managing the mounted WIM image. This function blocks until it
3716 * is known whether the unmount succeeded or failed. In the case of a
3717 * read-write mounted WIM, the unmount is not considered to have succeeded until
3718 * all changes have been saved to the underlying WIM file.
3721 * The directory that the WIM image was mounted on.
3722 * @param unmount_flags
3723 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
3724 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
3725 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
3727 * @param progress_func
3728 * If non-NULL, a function that will be called periodically with the
3729 * progress of the current operation. Currently, only
3730 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS will be sent.
3732 * @return 0 on success; nonzero on error.
3734 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
3735 * The filesystem daemon was unable to remove the staging directory and the
3736 * temporary files that it contains.
3737 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
3738 * The filesystem daemon appears to have terminated before sending an exit
3740 * @retval ::WIMLIB_ERR_FORK
3741 * Could not @c fork() the process.
3742 * @retval ::WIMLIB_ERR_FUSERMOUNT
3743 * The @b fusermount program could not be executed or exited with a failure
3745 * @retval ::WIMLIB_ERR_MQUEUE
3746 * Could not open a POSIX message queue to communicate with the filesystem
3747 * daemon servicing the mounted filesystem, could not send a message
3748 * through the queue, or could not receive a message through the queue.
3749 * @retval ::WIMLIB_ERR_NOMEM
3750 * Failed to allocate needed memory.
3751 * @retval ::WIMLIB_ERR_OPEN
3752 * The filesystem daemon could not open a temporary file for writing the
3754 * @retval ::WIMLIB_ERR_READ
3755 * A read error occurred when the filesystem daemon tried to a file from
3756 * the staging directory
3757 * @retval ::WIMLIB_ERR_RENAME
3758 * The filesystem daemon failed to rename the newly written WIM file to the
3759 * original WIM file.
3760 * @retval ::WIMLIB_ERR_UNSUPPORTED
3761 * Mounting is not supported, either because the platform is Windows, or
3762 * because the platform is UNIX-like and wimlib was compiled with @c
3764 * @retval ::WIMLIB_ERR_WRITE
3765 * A write error occurred when the filesystem daemon was writing to the new
3766 * WIM file, or the filesystem daemon was unable to flush changes that had
3767 * been made to files in the staging directory.
3770 wimlib_unmount_image(const wimlib_tchar *dir,
3772 wimlib_progress_func_t progress_func);
3775 * @ingroup G_modifying_wims
3777 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3780 * Pointer to the ::WIMStruct for the WIM file to update.
3782 * The 1-based index of the image in the WIM to update. It cannot be
3783 * ::WIMLIB_ALL_IMAGES.
3785 * An array of ::wimlib_update_command's that specify the update operations
3788 * Number of commands in @p cmds.
3789 * @param update_flags
3790 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3791 * @param progress_func
3792 * If non-NULL, a function that will be called periodically with the
3793 * progress of the current operation.
3795 * @return 0 on success; nonzero on error. On failure, some but not all of the
3796 * update commands may have been executed. No individual update command will
3797 * have been partially executed. Possible error codes include:
3799 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3800 * The capture configuration structure specified for an add command was
3802 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3803 * @p image did not specify a single, existing image in @p wim.
3804 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3805 * Attempted to perform an add command that conflicted with previously
3806 * existing files in the WIM when an overlay was attempted.
3807 * @retval ::WIMLIB_ERR_INVALID_PARAM
3808 * An unknown operation type was specified in the update commands; or,
3809 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3810 * in the @p add_flags, but the same image had previously already been
3811 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3812 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3813 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3814 * specified in the @p add_flags for an add command in which @p
3815 * wim_target_path was not the root directory of the WIM image.
3816 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3817 * (Windows only): While executing an add command, tried to capture a
3818 * reparse point with invalid data.
3819 * @retval ::WIMLIB_ERR_IS_DIRECTORY
3820 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3821 * for a WIM path that corresponded to a directory; or, a rename command
3822 * attempted to rename a directory to a non-directory.
3823 * @retval ::WIMLIB_ERR_NOMEM
3824 * Failed to allocate needed memory.
3825 * @retval ::WIMLIB_ERR_NOTDIR
3826 * A rename command attempted to rename a directory to a non-directory; or,
3827 * an add command was executed that attempted to set the root of the WIM
3828 * image as a non-directory; or, a path component used as a directory in a
3829 * rename command was not, in fact, a directory.
3830 * @retval ::WIMLIB_ERR_NOTEMPTY
3831 * A rename command attempted to rename a directory to a non-empty
3833 * @retval ::WIMLIB_ERR_NTFS_3G
3834 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3835 * error occurred while reading data from the NTFS volume using libntfs-3g.
3836 * @retval ::WIMLIB_ERR_OPEN
3837 * Failed to open a file to be captured while executing an add command.
3838 * @retval ::WIMLIB_ERR_OPENDIR
3839 * Failed to open a directory to be captured while executing an add command.
3840 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3841 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3842 * WIM path that did not exist; or, a rename command attempted to rename a
3843 * file that does not exist.
3844 * @retval ::WIMLIB_ERR_READ
3845 * While executing an add command, failed to read data from a file or
3846 * directory to be captured.
3847 * @retval ::WIMLIB_ERR_READLINK
3848 * While executing an add command, failed to read the target of a symbolic
3849 * link or junction point.
3850 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3851 * (Windows only) Failed to perform a reparse point fixup because of
3852 * problems with the data of a reparse point.
3853 * @retval ::WIMLIB_ERR_STAT
3854 * While executing an add command, failed to get attributes for a file or
3856 * @retval ::WIMLIB_ERR_UNSUPPORTED
3857 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
3858 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
3859 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3860 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
3861 * add_flags for an update command.
3862 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
3863 * While executing an add command, attempted to capture a file that was not
3864 * a supported file type (e.g. a device file). Only if
3865 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
3866 * for an update command.
3867 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3868 * The WIM file is considered read-only because of any of the reasons
3869 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3872 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3873 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3874 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3875 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3876 * different reasons) to read the metadata resource for an image that needed to
3880 wimlib_update_image(WIMStruct *wim,
3882 const struct wimlib_update_command *cmds,
3885 wimlib_progress_func_t progress_func);
3888 * @ingroup G_writing_and_overwriting_wims
3890 * Writes a WIM to a file.
3892 * This brings in resources from any external locations, such as directory trees
3893 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3894 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3896 * By default, the new WIM file is written as stand-alone. Using the
3897 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
3898 * instead. However, this function cannot directly write a "split" WIM; use
3899 * wimlib_split() for that.
3902 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
3903 * changes made to it, which are then reflected in the output file.
3905 * The path to the file to write the WIM to.
3907 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
3908 * images are to be included in the new on-disk WIM file. If for some
3909 * reason you only want to include a single image, specify the index of
3910 * that image instead.
3911 * @param write_flags
3912 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3913 * @param num_threads
3914 * Number of threads to use for compressing data. If 0, the number of
3915 * threads is taken to be the number of online processors. Note: if no
3916 * data compression needs to be done, no additional threads will be created
3917 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
3918 * exporting an image from a compressed WIM to another WIM of the same
3919 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
3921 * @param progress_func
3922 * If non-NULL, a function that will be called periodically with the
3923 * progress of the current operation. The possible messages are
3924 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3925 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3926 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3928 * @return 0 on success; nonzero on error.
3930 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3931 * @p image does not specify a single existing image in @p wim, and is not
3932 * ::WIMLIB_ALL_IMAGES.
3933 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3934 * A file that had previously been scanned for inclusion in the WIM by
3935 * wimlib_add_image() was concurrently modified, so it failed the SHA1
3936 * message digest check.
3937 * @retval ::WIMLIB_ERR_INVALID_PARAM
3938 * @p path was @c NULL.
3939 * @retval ::WIMLIB_ERR_NOMEM
3940 * Failed to allocate needed memory.
3941 * @retval ::WIMLIB_ERR_OPEN
3942 * Failed to open @p path for writing, or some file resources in @p wim
3943 * refer to files in the outside filesystem, and one of these files could
3944 * not be opened for reading.
3945 * @retval ::WIMLIB_ERR_READ
3946 * An error occurred when trying to read data from the WIM file associated
3947 * with @p wim, or some file resources in @p wim refer to files in the
3948 * outside filesystem, and a read error occurred when reading one of these
3950 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3951 * A stream that needed to be written could not be found in the stream
3952 * lookup table of @p wim. This error can occur if, for example, @p wim is
3953 * part of a split WIM but needed resources from the other split WIM parts
3954 * were not referenced with wimlib_reference_resources() or
3955 * wimlib_reference_resource_files() before the call to wimlib_write().
3956 * @retval ::WIMLIB_ERR_WRITE
3957 * An error occurred when trying to write data to the new WIM file.
3959 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3960 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3961 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3962 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3963 * different reasons) to read the metadata resource for an image that needed to
3967 wimlib_write(WIMStruct *wim,
3968 const wimlib_tchar *path,
3971 unsigned num_threads,
3972 wimlib_progress_func_t progress_func);
3975 * @ingroup G_writing_and_overwriting_wims
3977 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
3978 * file descriptor, which need not be seekable if the write is done in a special
3979 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
3980 * write_flags. This can, for example, allow capturing a WIM image and
3981 * streaming it over the network. See the documentation for
3982 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
3984 * The file descriptor @p fd will @b not be closed when the write is complete;
3985 * the calling code is responsible for this.
3987 * Returns 0 on success; nonzero on failure. The possible error codes include
3988 * those that can be returned by wimlib_write() as well as the following:
3990 * @retval ::WIMLIB_ERR_INVALID_PARAM
3991 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
3992 * specified in @p write_flags.
3995 wimlib_write_to_fd(WIMStruct *wim,
3999 unsigned num_threads,
4000 wimlib_progress_func_t progress_func);
4003 * @defgroup G_compression Compression and decompression functions
4005 * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
4006 * exported for convenience only, as they are already used by wimlib internally
4009 * These functions can be used for general-purpose lossless data compression,
4010 * but some limitations apply; for example, none of the compressors or
4011 * decompressors currently support sliding windows, and there also exist
4012 * slightly different variants of these formats that are not supported
4018 /** Header for compression parameters to pass to wimlib_create_compressor() or
4019 * wimlib_set_default_compressor_params(). */
4020 struct wimlib_compressor_params_header {
4021 /** Size of the parameters, in bytes. */
4025 /** Header for decompression parameters to pass to wimlib_create_decompressor()
4026 * or wimlib_set_default_decompressor_params() */
4027 struct wimlib_decompressor_params_header {
4028 /** Size of the parameters, in bytes. */
4032 /** LZX compression parameters that can optionally be passed to
4033 * wimlib_create_compressor() with the compression type
4034 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
4035 struct wimlib_lzx_compressor_params {
4036 /** hdr.size Must be set to the size of this structure, in bytes. */
4037 struct wimlib_compressor_params_header hdr;
4039 /** Relatively fast LZX compression algorithm with a decent compression
4040 * ratio; the suggested default. */
4041 #define WIMLIB_LZX_ALGORITHM_FAST 0
4043 /** Slower LZX compression algorithm that provides a better compression
4045 #define WIMLIB_LZX_ALGORITHM_SLOW 1
4047 /** Algorithm to use to perform the compression: either
4048 * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW. The
4049 * format is still LZX; this refers to the method the code will use to
4050 * perform LZX-compatible compression. */
4051 uint32_t algorithm : 3;
4053 /** If set to 1, the default parameters for the specified algorithm are
4054 * used rather than the ones specified in the following union. */
4055 uint32_t use_defaults : 1;
4058 /** Parameters for the fast algorithm. */
4059 struct wimlib_lzx_fast_params {
4060 uint32_t fast_reserved1[10];
4063 /** Parameters for the slow algorithm. */
4064 struct wimlib_lzx_slow_params {
4065 /** If set to 1, the compressor can output length 2
4066 * matches. If set 0, the compressor only outputs
4067 * matches of length 3 or greater. Suggested value: 1
4069 uint32_t use_len2_matches : 1;
4071 uint32_t slow_reserved1 : 31;
4073 /** Matches with length (in bytes) greater than or equal
4074 * to this value are immediately taken without spending
4075 * time on minimum-cost measurements. Suggested value:
4077 uint32_t nice_match_length;
4079 /** Number of passes to compute a match/literal sequence
4080 * for each LZX block. This is for an iterative
4081 * algorithm that attempts to minimize the cost of the
4082 * match/literal sequence by using a cost model provided
4083 * by the previous iteration. Must be at least 1.
4084 * Suggested value: 2. */
4085 uint32_t num_optim_passes;
4087 /** Reserved; set to 0. */
4088 uint32_t slow_reserved_blocksplit;
4090 /** Maximum depth to search for matches at each
4091 * position. Suggested value: 50. */
4092 uint32_t max_search_depth;
4094 /** Maximum number of potentially good matches to
4095 * consider for each position. Suggested value: 3. */
4096 uint32_t max_matches_per_pos;
4098 uint32_t slow_reserved2[2];
4100 /** Assumed cost of a main symbol with zero frequency.
4101 * Must be at least 1 and no more than 16. Suggested
4103 uint8_t main_nostat_cost;
4105 /** Assumed cost of a length symbol with zero frequency.
4106 * Must be at least 1 and no more than 16. Suggested
4108 uint8_t len_nostat_cost;
4110 /** Assumed cost of an aligned symbol with zero
4111 * frequency. Must be at least 1 and no more than 8.
4112 * Suggested value: 7. */
4113 uint8_t aligned_nostat_cost;
4115 uint8_t slow_reserved3[5];
4120 /** LZMS compression parameters that can optionally be passed to
4121 * wimlib_create_compressor() with the compression type
4122 * ::WIMLIB_COMPRESSION_TYPE_LZMS. */
4123 struct wimlib_lzms_compressor_params {
4124 /** hdr.size Must be set to the size of this structure, in bytes. */
4125 struct wimlib_compressor_params_header hdr;
4127 /** Minimum match length to output. This must be at least 2. Suggested
4129 uint32_t min_match_length;
4131 /** Maximum match length to output. This must be at least @p
4132 * min_match_length. Suggested value: @p UINT32_MAX. */
4133 uint32_t max_match_length;
4135 /** Matches with length (in bytes) greater than or equal to this value
4136 * are immediately taken without spending time on minimum-cost
4137 * measurements. The minimum of @p max_match_length and @p
4138 * nice_match_length may not exceed 65536. Suggested value: 32. */
4139 uint32_t nice_match_length;
4141 /** Maximum depth to search for matches at each position. Suggested
4143 uint32_t max_search_depth;
4145 /** Maximum number of potentially good matches to consider at each
4146 * position. Suggested value: 3. */
4147 uint32_t max_matches_per_pos;
4149 /** Length of the array for the near-optimal LZ parsing algorithm. This
4150 * must be at least 1. Suggested value: 1024. */
4151 uint32_t optim_array_length;
4153 uint64_t reserved2[4];
4156 /** Opaque compressor handle. */
4157 struct wimlib_compressor;
4159 /** Opaque decompressor handle. */
4160 struct wimlib_decompressor;
4163 * Set the default compression parameters for the specified compression type.
4164 * This will affect both explicit and wimlib-internal calls to
4165 * wimlib_create_compressor().
4168 * Compression type for which to set the default compression parameters.
4170 * Compression-type specific parameters. This may be @c NULL, in which
4171 * case the "default default" parameters are restored.
4173 * @return 0 on success; nonzero on error.
4175 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4176 * @p ctype was not a supported compression type.
4177 * @retval ::WIMLIB_ERR_INVALID_PARAM
4178 * @p params were invalid.
4179 * @retval ::WIMLIB_ERR_NOMEM
4180 * Not enough memory to duplicate the parameters (perhaps @c params->size
4184 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
4185 const struct wimlib_compressor_params_header *params);
4188 * Returns the approximate number of bytes needed to allocate a compressor with
4189 * wimlib_create_compressor() for the specified compression type, block size,
4190 * and parameters. @p params may be @c NULL, in which case the current default
4191 * parameters for @p ctype are used. Returns 0 if the compression type or
4192 * parameters are invalid.
4195 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4196 size_t max_block_size,
4197 const struct wimlib_compressor_params_header *params);
4200 * Allocate a compressor for the specified compression type using the specified
4204 * Compression type for which to create the compressor.
4205 * @param max_block_size
4206 * Maximum block size to support. The exact meaning and allowed values for
4207 * this parameter depend on the compression type, but it at least specifies
4208 * the maximum allowed value for @p uncompressed_size to wimlib_compress().
4209 * @param extra_params
4210 * An optional pointer to extra compressor parameters for the specified
4211 * compression type. For LZX, a pointer to ::wimlib_lzx_compressor_params
4212 * may be specified here. If left @c NULL, the default parameters are
4214 * @param compressor_ret
4215 * A location into which to return the pointer to the allocated compressor,
4216 * which can be used for any number of calls to wimlib_compress() before
4217 * being freed with wimlib_free_compressor().
4219 * @return 0 on success; nonzero on error.
4221 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4222 * @p ctype was not a supported compression type.
4223 * @retval ::WIMLIB_ERR_INVALID_PARAM
4224 * The compression parameters were invalid.
4225 * @retval ::WIMLIB_ERR_NOMEM
4226 * Insufficient memory to allocate the compressor.
4229 wimlib_create_compressor(enum wimlib_compression_type ctype,
4230 size_t max_block_size,
4231 const struct wimlib_compressor_params_header *extra_params,
4232 struct wimlib_compressor **compressor_ret);
4235 * Losslessly compress a block of data using a compressor previously created
4236 * with wimlib_create_compressor().
4238 * @param uncompressed_data
4239 * Buffer containing the data to compress.
4240 * @param uncompressed_size
4241 * Size, in bytes, of the data to compress.
4242 * @param compressed_data
4243 * Buffer into which to write the compressed data.
4244 * @param compressed_size_avail
4245 * Number of bytes available in @p compressed_data.
4247 * A compressor previously allocated with wimlib_create_compressor().
4250 * The size of the compressed data, in bytes, or 0 if the input data could
4251 * not be compressed to @p compressed_size_avail or fewer bytes.
4254 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4255 void *compressed_data, size_t compressed_size_avail,
4256 struct wimlib_compressor *compressor);
4259 * Free a compressor previously allocated with wimlib_create_compressor().
4262 * The compressor to free.
4265 wimlib_free_compressor(struct wimlib_compressor *compressor);
4268 * Set the default decompression parameters for the specified compression type.
4269 * This will affect both explicit and wimlib-internal calls to
4270 * wimlib_create_decompressor().
4273 * Compression type for which to set the default decompression parameters.
4275 * Compression-type specific parameters. This may be @c NULL, in which
4276 * case the "default default" parameters are restored.
4278 * @return 0 on success; nonzero on error.
4280 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4281 * @p ctype was not a supported compression type.
4282 * @retval ::WIMLIB_ERR_NOMEM
4283 * Not enough memory to duplicate the parameters (perhaps @c params->size
4287 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4288 const struct wimlib_decompressor_params_header *params);
4291 * Allocate a decompressor for the specified compression type using the
4292 * specified parameters.
4295 * Compression type for which to create the decompressor.
4296 * @param max_block_size
4297 * Maximum block size to support. The exact meaning and allowed values for
4298 * this parameter depend on the compression type, but it at least specifies
4299 * the maximum allowed value for @p uncompressed_size to
4300 * wimlib_decompress().
4301 * @param extra_params
4302 * An optional pointer to extra decompressor parameters for the specified
4303 * compression type. If @c NULL, the default parameters are used.
4304 * @param decompressor_ret
4305 * A location into which to return the pointer to the allocated
4306 * decompressor, which can be used for any number of calls to
4307 * wimlib_decompress() before being freed with wimlib_free_decompressor().
4309 * @return 0 on success; nonzero on error.
4311 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4312 * @p ctype was not a supported compression type.
4313 * @retval ::WIMLIB_ERR_INVALID_PARAM
4314 * The decompression parameters were invalid.
4315 * @retval ::WIMLIB_ERR_NOMEM
4316 * Insufficient memory to allocate the decompressor.
4319 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4320 size_t max_block_size,
4321 const struct wimlib_decompressor_params_header *extra_params,
4322 struct wimlib_decompressor **decompressor_ret);
4325 * Decompress a block of data using a decompressor previously created with
4326 * wimlib_create_decompressor().
4328 * @param compressed_data
4329 * Buffer containing the data to decompress.
4330 * @param compressed_size
4331 * Size, in bytes, of the data to decompress.
4332 * @param uncompressed_data
4333 * Buffer into which to write the uncompressed data.
4334 * @param uncompressed_size
4335 * Size, in bytes, of the data when uncompressed.
4336 * @param decompressor
4337 * A decompressor previously allocated with wimlib_create_decompressor().
4339 * @return 0 on success; nonzero on error.
4342 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4343 void *uncompressed_data, size_t uncompressed_size,
4344 struct wimlib_decompressor *decompressor);
4347 * Free a decompressor previously allocated with wimlib_create_decompressor().
4349 * @param decompressor
4350 * The decompressor to free.
4353 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4356 struct wimlib_lzx_params_old;
4357 struct wimlib_lzx_context_old;
4359 /** Deprecated; do not use. */
4361 wimlib_lzx_set_default_params(const struct wimlib_lzx_params_old *params)
4364 /** Deprecated; do not use. */
4366 wimlib_lzx_alloc_context(const struct wimlib_lzx_params_old *params,
4367 struct wimlib_lzx_context_old **ctx_pp)
4370 /** Deprecated; do not use. */
4372 wimlib_lzx_free_context(struct wimlib_lzx_context_old *ctx)
4375 /** Deprecated; do not use. */
4377 wimlib_lzx_compress2(const void *udata, unsigned ulen, void *cdata,
4378 struct wimlib_lzx_context_old *ctx)
4381 /** Deprecated; do not use. */
4383 wimlib_lzx_compress(const void *udata, unsigned ulen, void *cdata)
4386 /** Deprecated; do not use. */
4388 wimlib_xpress_compress(const void *udata, unsigned ulen, void *cdata)
4391 /** Deprecated; do not use. */
4393 wimlib_lzx_decompress(const void *cdata, unsigned clen,
4394 void *udata, unsigned ulen)
4397 /** Deprecated; do not use. */
4399 wimlib_xpress_decompress(const void *cdata, unsigned clen,
4400 void *udata, unsigned ulen)
4408 /** @ingroup G_wim_information
4410 * Deprecated and will return ::WIMLIB_ERR_UNSUPPORTED. Use
4411 * wimlib_iterate_dir_tree() instead. */
4413 wimlib_print_metadata(WIMStruct *wim, int image)
4421 #endif /* _WIMLIB_H */