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 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.0, a C
37 * library for creating, modifying, extracting, and mounting files in the
38 * Windows Imaging Format. This documentation is intended for developers only.
39 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
40 * program, please see the README file or manual pages.
42 * @section sec_installing_and_compiling Installing and Compiling
44 * wimlib uses the GNU autotools, so, on UNIX-like systems, it should be easy to
45 * install with <code>configure && make && sudo make install</code>; however,
46 * please see the README for more information about installing it.
48 * To use wimlib in your program after installing it, include wimlib.h and link
49 * your program with @c -lwim.
51 * As of wimlib 1.5.0, wimlib.h is also compatible with C++.
53 * Note: before calling any other function declared in wimlib.h,
54 * wimlib_global_init() can (and in some cases, must) be called. See its
55 * documentation for more details.
57 * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
59 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
60 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
61 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
62 * which creates a new ::WIMStruct that initially contains no images and does
63 * not yet have a backing on-disk file. See @ref G_creating_and_opening_wims
66 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
67 * Images can be extracted (or "applied") using wimlib_extract_image(), added
68 * (or "captured" or "appended") using wimlib_add_image(), deleted using
69 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
70 * modified using wimlib_update_image(). However, changes made to a WIM
71 * represented by a ::WIMStruct have no persistent effect until the WIM is
72 * actually written to an on-disk file. This can be done using wimlib_write(),
73 * but if the WIM was originally opened using wimlib_open_wim(), then
74 * wimlib_overwrite() can be used instead. See @ref G_extracting_wims, @ref
75 * G_modifying_wims, and @ref G_writing_and_overwriting_wims for more details.
77 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
78 * files is a multi-step process. For example, to add, or "append" an image to
79 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
80 * append</b>, you must call the following functions:
82 * 1. wimlib_open_wim()
83 * 2. wimlib_add_image()
84 * 3. wimlib_overwrite()
86 * This design is very much on purpose as it makes the library more useful in
87 * general by allowing functions to be composed in different ways. For example,
88 * you can make multiple changes to a WIM and commit them all to the underlying
89 * file in only one overwrite operation, which is more efficient.
91 * @section sec_cleaning_up Cleaning up
93 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
94 * all resources associated with it. Also, when you are completely done with
95 * using wimlib in your program, you can call wimlib_global_cleanup() to free
96 * any other resources allocated by the library.
98 * @section sec_error_handling Error Handling
100 * Most functions in wimlib return 0 on success and a positive error code on
101 * failure. Use wimlib_get_error_string() to get a string that describes an
102 * error code. wimlib also can print error messages to standard error itself
103 * when an error happens, and these may be more informative than the error code;
104 * to enable this, call wimlib_set_print_errors(). Please note that this is for
105 * convenience only, and some errors can occur without a message being printed.
106 * Currently, error messages and strings (as well as all documentation, for that
107 * matter) are only available in English.
109 * @section sec_encodings Locales and character encodings
111 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
112 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
115 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
116 * and the encoding is UTF-16LE.
118 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
119 * and the encoding is the locale-dependent multibyte encoding. I recommend you
120 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
121 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
122 * call wimlib_global_init() after having set your desired locale.
124 * @section sec_advanced Additional information and features
127 * @subsection subsec_mounting_wim_images Mounting WIM images
129 * See @ref G_mounting_wim_images.
131 * @subsection subsec_progress_functions Progress Messages
133 * See @ref G_progress.
135 * @subsection subsec_non_standalone_wims Non-standalone WIMs
137 * See @ref G_nonstandalone_wims.
139 * @subsection subsec_pipable_wims Pipable WIMs
141 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
142 * compatible with Microsoft's software. To create a pipable WIM, call
143 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
144 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
145 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
146 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
147 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
148 * s using a seekable file descriptor using the regular function calls (e.g.
149 * wimlib_open_wim(), wimlib_extract_image()).
151 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
152 * capture</b> for more information about pipable WIMs.
154 * @subsection subsec_thread_safety Thread Safety
156 * wimlib is thread-safe, with the following exceptions:
157 * - Different threads cannot operate on the same ::WIMStruct at the same time;
158 * they must use different ::WIMStruct's.
159 * - You must call wimlib_global_init() in one thread before calling any other
161 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
162 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
163 * concurrently in the same process, will daemonize the entire process when it
164 * does so for the first time. This includes changing the working directory
165 * to the root directory.
167 * @subsection subsec_limitations Limitations
169 * This section documents some technical limitations of wimlib not already
170 * documented in the man page for @b wimlib-imagex.
172 * - The old WIM format from Vista pre-releases is not supported.
173 * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
174 * functionality other than that already present in @b ImageX, that allows you
175 * to make certain Windows-specific modifications to a Windows PE image, such
176 * as adding a driver or Windows component. Such a tool could be implemented
179 * @subsection more_info More information
181 * You are advised to read the README as well as the manual pages for
182 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
183 * the API documentation.
186 /** @defgroup G_general General
188 * @brief Declarations and structures shared across the library.
191 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
193 * @brief Create new WIMs and open existing WIMs.
196 /** @defgroup G_wim_information Retrieving WIM information and directory listings
198 * @brief Retrieve information about a WIM or WIM image.
201 /** @defgroup G_modifying_wims Modifying WIMs
203 * @brief Make changes to a WIM.
205 * @section sec_adding_images Capturing and adding WIM images
207 * As described in @ref sec_basic_wim_handling_concepts, capturing a new WIM or
208 * appending an image to an existing WIM is a multi-step process, but at its
209 * core is wimlib_add_image() or an equivalent function. Normally,
210 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
211 * ::WIMStruct as a new image. However, when supported by the build of the
212 * library, there is also a special NTFS volume capture mode (entered when
213 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
214 * from an unmounted NTFS volume.
216 * Another function, wimlib_add_image_multisource() is also provided. It
217 * generalizes wimlib_add_image() to allow combining multiple files or directory
218 * trees into a single WIM image in a configurable way.
220 * For maximum customization of WIM image creation, it is also possible to add a
221 * completely empty WIM image with wimlib_add_empty_image(), then update it with
222 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
223 * wimlib_add_image_multisource() do internally.)
225 * Note that some details of how image addition/capture works are documented
226 * more fully in the manual page for <b>wimlib-imagex capture</b>.
228 * @section sec_deleting_images Deleting WIM images
230 * wimlib_delete_image() can delete an image from a ::WIMStruct. But as usual,
231 * wimlib_write() or wimlib_overwrite() must be called to cause the changes to
232 * be made persistent in an on-disk WIM file.
234 * @section sec_exporting_images Exporting WIM images
236 * wimlib_export_image() can copy, or "export", an image from one WIM to
239 * @section sec_other_modifications Other modifications
241 * wimlib_update_image() can add, delete, and rename files in a WIM image.
243 * wimlib_set_image_name(), wimlib_set_image_descripton(), and
244 * wimlib_set_image_flags() can change other image metadata.
246 * wimlib_set_wim_info() can change information about the WIM file itself, such
250 /** @defgroup G_extracting_wims Extracting WIMs
252 * @brief Extract files, directories, and images from a WIM.
254 * wimlib_extract_image() extracts, or "applies", an image from a WIM
255 * (represented, as usual, by a ::WIMStruct). This normally extracts the image
256 * to a directory, but when supported by the build of the library there is also
257 * a special NTFS volume extraction mode (entered when
258 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified) that allows extracting a WIM image
259 * directly to an unmounted NTFS volume. Various other flags allow further
260 * customization of image extraction.
262 * Another function, wimlib_extract_files(), is also provided. It can extract
263 * certain files or directories from a WIM image, instead of a full image.
265 * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a set
266 * of paths from a WIM image in a manner that may be easier to use than
267 * wimlib_extract_files(), and also can wildcard characters.
269 * wimlib_extract_image_from_pipe() allows an image to be extracted from a
270 * pipable WIM sent over a pipe; see @ref subsec_pipable_wims.
272 * Note that some details of how image extraction/application works are
273 * documented more fully in the manual pages for <b>wimlib-imagex apply</b> and
274 * <b>wimlib-imagex extract</b>.
277 /** @defgroup G_mounting_wim_images Mounting WIM images
279 * @brief Mount and unmount WIM images.
281 * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
282 * mounting images from WIM files either read-only or read-write. To mount an
283 * image, call wimlib_mount_image(). To unmount an image, call
284 * wimlib_unmount_image(). Mounting can be done without root privileges because
285 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
286 * compiled with the <code>--without-fuse</code> flag, these functions will be
287 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED. Note that mounting an
288 * image read-write is an alternative to calling wimlib_update_image().
291 /** @defgroup G_progress Progress Messages
293 * @brief Track the progress of long WIM operations.
295 * When operating on large archives, operations such as extraction will
296 * naturally take a while to complete. Because of this and to improve the
297 * potential user-friendliness of library clients, a number of functions take a
298 * pointer to a progress function of type ::wimlib_progress_func_t. This
299 * function will be called periodically during the WIM operation(s) to report on
300 * the progress of the operation (for example, how many bytes have been written
304 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
306 * @brief Write and overwrite on-disk WIM files.
308 * As described in @ref sec_basic_wim_handling_concepts, these functions are
309 * critical to the design of the library as they allow new or modified WIMs to
310 * actually be written to on-disk files. Generally, wimlib_write() is the
311 * function you need to call to write a new WIM file, and wimlib_overwrite() is
312 * the function you need to call to persistently update an existing WIM file.
315 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
317 * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
319 * Normally, ::WIMStruct represents a WIM file, but there's a bit more to it
320 * than that. Normally, WIM files are "standalone". However, WIM files can
321 * also be arranged in non-standalone ways, such as a set of on-disk files that
322 * together form a single "split WIM" or "delta WIM". Such arrangements are
323 * fully supported by wimlib. However, as a result, in such cases a ::WIMStruct
324 * created from one of these on-disk files initially only partially represents
325 * the full WIM and needs to, in effect, be logically combined with other
326 * ::WIMStruct's before performing certain operations, such as extracting files
327 * with wimlib_extract_image() or wimlib_extract_files(). This is done by
328 * calling wimlib_reference_resource_files() or wimlib_reference_resources().
330 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
331 * specialized function (wimlib_split()) is needed to create a split WIM.
340 #include <inttypes.h>
343 /** @ingroup G_general
346 /** Major version of the library (for example, the 1 in 1.2.5). */
347 #define WIMLIB_MAJOR_VERSION 1
349 /** Minor version of the library (for example, the 2 in 1.2.5). */
350 #define WIMLIB_MINOR_VERSION 6
352 /** Patch version of the library (for example, the 5 in 1.2.5). */
353 #define WIMLIB_PATCH_VERSION 0
360 /** @ingroup G_general
364 * Opaque structure that represents a WIM file. This is an in-memory structure
365 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
366 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
367 * continuing to exist so that data can be read from it as needed.
369 * Most functions in this library will work the same way regardless of whether a
370 * given ::WIMStruct was obtained through wimlib_open_wim() or
371 * wimlib_create_new_wim(). Exceptions are documented.
373 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
374 * file from a ::WIMStruct.
376 * See @ref sec_basic_wim_handling_concepts for more information.
378 #ifndef WIMLIB_WIMSTRUCT_DECLARED
379 typedef struct WIMStruct WIMStruct;
380 #define WIMLIB_WIMSTRUCT_DECLARED
384 typedef wchar_t wimlib_tchar;
386 /** See @ref sec_encodings */
387 typedef char wimlib_tchar;
391 /** Path separator for WIM paths passed back to progress callbacks. */
392 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
393 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
395 /** Path separator for WIM paths passed back to progress callbacks. */
396 # define WIMLIB_WIM_PATH_SEPARATOR '/'
397 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
401 # define _wimlib_deprecated __attribute__((deprecated))
403 # define _wimlib_deprecated
406 #define WIMLIB_GUID_LEN 16
409 * Specifies the compression type of a WIM file.
411 enum wimlib_compression_type {
412 /** An invalid compression type. */
413 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
415 /** The WIM does not include any compressed resources. */
416 WIMLIB_COMPRESSION_TYPE_NONE = 0,
418 /** Compressed resources in the WIM use LZX compression. */
419 WIMLIB_COMPRESSION_TYPE_LZX = 1,
421 /** Compressed resources in the WIM use XPRESS compression. */
422 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
424 /** Compressed resources in the WIM use LZMS compression. Note: LZMS
425 * compression is only compatible with wimlib v1.6.0 and later and with
426 * WIMGAPI Windows 8 and later (and some restrictions apply on the
428 WIMLIB_COMPRESSION_TYPE_LZMS = 3,
432 /** @ingroup G_progress
435 /** Possible values of the first parameter to the user-supplied
436 * ::wimlib_progress_func_t progress function */
437 enum wimlib_progress_msg {
439 /** A WIM image is about to be extracted. @p info will point to
440 * ::wimlib_progress_info.extract. */
441 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
443 /** One or more file or directory trees within a WIM image (not the full
444 * image) is about to be extracted. @p info will point to
445 * ::wimlib_progress_info.extract. */
446 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
448 /** The directory structure of the WIM image is about to be extracted.
449 * @p info will point to ::wimlib_progress_info.extract. */
450 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
452 /** The directory structure of the WIM image has been successfully
453 * extracted. @p info will point to ::wimlib_progress_info.extract. */
454 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
456 /** The WIM image's files resources are currently being extracted. @p
457 * info will point to ::wimlib_progress_info.extract. */
458 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
460 /** Starting to read a new part of a split pipable WIM over the pipe.
461 * @p info will point to ::wimlib_progress_info.extract. */
462 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
464 /** All the WIM files and directories have been extracted, and
465 * timestamps are about to be applied. @p info will point to
466 * ::wimlib_progress_info.extract. */
467 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
469 /** A WIM image has been successfully extracted. @p info will point to
470 * ::wimlib_progress_info.extract. */
471 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
473 /** A file or directory tree within a WIM image (not the full image) has
474 * been successfully extracted. @p info will point to
475 * ::wimlib_progress_info.extract. */
476 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
478 /** The directory or NTFS volume is about to be scanned to build a tree
479 * of WIM dentries in-memory. @p info will point to
480 * ::wimlib_progress_info.scan. */
481 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
483 /** A directory or file is being scanned. @p info will point to
484 * ::wimlib_progress_info.scan, and its @p cur_path member will be
485 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE
486 * is passed to wimlib_add_image(). */
487 WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
489 /** The directory or NTFS volume has been successfully scanned, and a
490 * tree of WIM dentries has been built in-memory. @p info will point to
491 * ::wimlib_progress_info.scan. */
492 WIMLIB_PROGRESS_MSG_SCAN_END,
495 * File resources are currently being written to the WIM.
496 * @p info will point to ::wimlib_progress_info.write_streams. */
497 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
500 * The metadata resource for each image is about to be written to the
501 * WIM. @p info will not be valid. */
502 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
505 * The metadata resource for each image has successfully been writen to
506 * the WIM. @p info will not be valid. */
507 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
510 * The temporary file has successfully been renamed to the original WIM
511 * file. Only happens when wimlib_overwrite() is called and the
512 * overwrite is not done in-place.
513 * @p info will point to ::wimlib_progress_info.rename. */
514 WIMLIB_PROGRESS_MSG_RENAME,
516 /** The contents of the WIM are being checked against the integrity
517 * table. Only happens when wimlib_open_wim() is called with the
518 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. @p info will point to
519 * ::wimlib_progress_info.integrity. */
520 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
522 /** An integrity table is being calculated for the WIM being written.
523 * Only happens when wimlib_write() or wimlib_overwrite() is called with
524 * the ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag. @p info will point to
525 * ::wimlib_progress_info.integrity. */
526 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
528 /** Reserved. (Previously used for WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
529 * but in wimlib v1.5.0 this was removed to simplify the code and now
530 * you'll get ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages instead.) */
531 WIMLIB_PROGRESS_MSG_RESERVED,
533 /** A wimlib_split() operation is in progress, and a new split part is
534 * about to be started. @p info will point to
535 * ::wimlib_progress_info.split. */
536 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
538 /** A wimlib_split() operation is in progress, and a split part has been
539 * finished. @p info will point to ::wimlib_progress_info.split. */
540 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
543 * A WIM update command is just about to be executed; @p info will point
544 * to ::wimlib_progress_info.update.
546 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
549 * A WIM update command has just been executed; @p info will point to
550 * ::wimlib_progress_info.update.
552 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
556 /** A pointer to this union is passed to the user-supplied
557 * ::wimlib_progress_func_t progress function. One (or none) of the structures
558 * contained in this union will be applicable for the operation
559 * (::wimlib_progress_msg) indicated in the first argument to the progress
561 union wimlib_progress_info {
563 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
564 * document them if they aren't given a name... */
566 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. */
567 struct wimlib_progress_info_write_streams {
568 /** Number of bytes that are going to be written for all the
569 * streams combined. This is the amount in uncompressed data.
570 * (The actual number of bytes will be less if the data is being
571 * written compressed.) */
572 uint64_t total_bytes;
574 /** Number of streams that are going to be written. */
575 uint64_t total_streams;
577 /** Number of uncompressed bytes that have been written so far.
578 * Will be 0 initially, and equal to @p total_bytes at the end.
580 uint64_t completed_bytes;
582 /** Number of streams that have been written. Will be 0
583 * initially, and equal to @p total_streams at the end. */
584 uint64_t completed_streams;
586 /** Number of threads that are being used to compress resources
587 * (if applicable). */
588 unsigned num_threads;
590 /** The compression type being used to write the streams; either
591 * ::WIMLIB_COMPRESSION_TYPE_NONE,
592 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or
593 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
594 int compression_type;
596 /** Number of split WIM parts from which streams are being
597 * written (may be 0 if irrelevant). */
598 unsigned total_parts;
600 /** Number of split WIM parts from which streams have been
601 * written (may be 0 if irrelevant). */
602 unsigned completed_parts;
605 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
606 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
607 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
608 struct wimlib_progress_info_scan {
609 /** Top-level directory being scanned; or, when capturing a NTFS
610 * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
611 * to the file or block device that contains the NTFS volume
613 const wimlib_tchar *source;
615 /** Path to the file (or directory) that has been scanned, valid
616 * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. When capturing a NTFS
617 * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
618 * relative to the root of the NTFS volume. */
619 const wimlib_tchar *cur_path;
621 /** Dentry scan status, valid on
622 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY. */
624 /** The file looks okay and will be captured. */
625 WIMLIB_SCAN_DENTRY_OK = 0,
627 /** File is being excluded from capture due to the
628 * capture configuration. */
629 WIMLIB_SCAN_DENTRY_EXCLUDED,
631 /** File is being excluded from capture due to being
632 * unsupported (e.g. an encrypted or device file). */
633 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
635 /** The file is an absolute symbolic link or junction
636 * point and it is being excluded from capture because
637 * it points outside of the capture directory and
638 * reparse-point fixups are enabled. (Reparse point
639 * fixups can be disabled by using the flag
640 * ::WIMLIB_ADD_FLAG_NORPFIX.) */
641 WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
645 /** Target path in the WIM image. Only valid on
646 * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
647 * ::WIMLIB_PROGRESS_MSG_SCAN_END. If capturing a full
648 * image, this will be the empty string; otherwise it
649 * will name the place in the WIM image at which the
650 * directory tree is being added. */
651 const wimlib_tchar *wim_target_path;
653 /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
654 * of ::WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK, this is the
655 * target of the absolute symbolic link or junction
657 const wimlib_tchar *symlink_target;
660 /** Number of directories scanned so far, including the root
661 * directory but excluding any unsupported/excluded directories.
663 * Details: On Windows and in NTFS capture mode, a reparse point
664 * counts as a directory if and only if it has
665 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
666 * counts as a directory if and only if when fully dereferenced
667 * it points to an accessible directory. If a file has multiple
668 * names (hard links), it is only counted one time. */
669 uint64_t num_dirs_scanned;
671 /** Number of non-directories scanned so far, excluding any
672 * unsupported/excluded files.
674 * Details: On Windows and in NTFS capture mode, a reparse point
675 * counts as a non-directory if and only if it does not have
676 * FILE_ATTRIBUTE_DIRECTORY set. Otherwise, a symbolic link
677 * counts as a non-directory if and only if when fully
678 * dereferenced it points to a non-directory or its target is
679 * inaccessible. If a file has multiple names (hard links), it
680 * is only counted one time. */
681 uint64_t num_nondirs_scanned;
683 /** Number of bytes of file data that have been detected so far.
685 * Details: This data may not actually have been read yet, and
686 * it will not actually be written to the WIM file until
687 * wimlib_write() or wimlib_overwrite() has been called. Data
688 * from excluded files is not counted. This number includes
689 * default file contents as well as named data streams and
690 * reparse point data. The size of reparse point data is
691 * tallied after any reparse-point fixups, and in the case of
692 * capturing a symbolic link on a UNIX-like system, the creation
693 * of the reparse point data itself. If a file has multiple
694 * names (hard links), its size(s) are only counted one time.
695 * On Windows, encrypted files have their encrypted size
696 * counted, not their unencrypted size; however, compressed
697 * files have their uncompressed size counted. */
698 uint64_t num_bytes_scanned;
701 /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
702 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
703 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
704 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
705 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
706 struct wimlib_progress_info_extract {
707 /** Number of the image being extracted (1-based). */
710 /** Flags passed to to wimlib_extract_image() */
713 /** Full path to the WIM file being extracted. */
714 const wimlib_tchar *wimfile_name;
716 /** Name of the image being extracted. */
717 const wimlib_tchar *image_name;
719 /** Directory or NTFS volume to which the image is being
721 const wimlib_tchar *target;
724 const wimlib_tchar *cur_path;
726 /** Number of bytes of uncompressed data that will be extracted.
727 * Takes into account hard links (they are not counted for each
729 uint64_t total_bytes;
731 /** Number of bytes that have been written so far. Will be 0
732 * initially, and equal to @p total_bytes at the end. */
733 uint64_t completed_bytes;
735 /** Number of streams that will be extracted. This may more or
736 * less than the number of "files" to be extracted due to
737 * special cases (hard links, symbolic links, and alternate data
739 uint64_t num_streams;
741 /** Path to the root dentry within the WIM for the tree that is
742 * being extracted. Will be the empty string when extracting a
743 * full image, or when extracting a set of paths using
744 * wimlib_extract_paths() or wimlib_extract_pathlist(). */
745 const wimlib_tchar *extract_root_wim_source_path;
747 /** Currently only used for
748 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
750 unsigned part_number;
752 /** Currently only used for
753 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
754 unsigned total_parts;
756 /** Currently only used for
757 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
758 uint8_t guid[WIMLIB_GUID_LEN];
761 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
762 struct wimlib_progress_info_rename {
763 /** Name of the temporary file that the WIM was written to. */
764 const wimlib_tchar *from;
766 /** Name of the original WIM file to which the temporary file is
768 const wimlib_tchar *to;
771 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
772 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
773 struct wimlib_progress_info_update {
774 /** Pointer to the update command that will be executed or has
775 * just been executed. */
776 const struct wimlib_update_command *command;
778 /** Number of update commands that have been completed so far.
780 size_t completed_commands;
782 /** Number of update commands that are being executed as part of
783 * this call to wimlib_update_image(). */
784 size_t total_commands;
787 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
788 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
789 struct wimlib_progress_info_integrity {
790 /** Number of bytes from the end of the WIM header to the end of
791 * the lookup table (the area that is covered by the SHA1
792 * integrity checks.) */
793 uint64_t total_bytes;
795 /** Number of bytes that have been SHA1-summed so far. Will be
796 * 0 initially, and equal @p total_bytes at the end. */
797 uint64_t completed_bytes;
799 /** Number of chunks that the checksummed region is divided
801 uint32_t total_chunks;
803 /** Number of chunks that have been SHA1-summed so far. Will
804 * be 0 initially, and equal to @p total_chunks at the end. */
805 uint32_t completed_chunks;
807 /** Size of the chunks used for the integrity calculation. */
810 /** Filename of the WIM (only valid if the message is
811 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
812 const wimlib_tchar *filename;
815 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
816 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
817 struct wimlib_progress_info_split {
818 /** Total size of the original WIM's file and metadata resources
820 uint64_t total_bytes;
822 /** Number of bytes of file and metadata resources that have
823 * been copied out of the original WIM so far. Will be 0
824 * initially, and equal to @p total_bytes at the end. */
825 uint64_t completed_bytes;
827 /** Number of the split WIM part that is about to be started
828 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
829 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
830 unsigned cur_part_number;
832 /** Total number of split WIM parts that are being written. */
833 unsigned total_parts;
835 /** Name of the split WIM part that is about to be started
836 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
837 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
838 const wimlib_tchar *part_name;
842 /** A user-supplied function that will be called periodically during certain WIM
843 * operations. The first argument will be the type of operation that is being
844 * performed or is about to be started or has been completed. The second
845 * argument will be a pointer to one of a number of structures depending on the
846 * first argument. It may be @c NULL for some message types.
848 * The return value of the progress function is currently ignored, but it may do
849 * something in the future. (Set it to 0 for now.)
851 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
852 const union wimlib_progress_info *info);
855 /** @ingroup G_modifying_wims
858 /** An array of these structures is passed to wimlib_add_image_multisource() to
859 * specify the sources from which to create a WIM image. */
860 struct wimlib_capture_source {
861 /** Absolute or relative path to a file or directory on the external
862 * filesystem to be included in the WIM image. */
863 wimlib_tchar *fs_source_path;
865 /** Destination path in the WIM image. Leading and trailing slashes are
866 * ignored. The empty string or @c NULL means the root directory of the
868 wimlib_tchar *wim_target_path;
870 /** Reserved; set to 0. */
874 /** Structure that specifies a list of path patterns. */
875 struct wimlib_pattern_list {
876 /** Array of patterns. The patterns may be modified by library code,
877 * but the @p pats pointer itself will not. See the man page for
878 * <b>wimlib-imagex capture</b> for more information about allowed
882 /** Number of patterns in the @p pats array. */
885 /** Ignored; may be used by the calling code. */
886 size_t num_allocated_pats;
889 /** A structure that contains lists of wildcards that match paths to treat
890 * specially when capturing a WIM image. */
891 struct wimlib_capture_config {
892 /** Paths matching any pattern this list are excluded from being
893 * captured, except if the same path appears in @p
894 * exclusion_exception_pats. */
895 struct wimlib_pattern_list exclusion_pats;
897 /** Paths matching any pattern in this list are never excluded from
899 struct wimlib_pattern_list exclusion_exception_pats;
901 /** Reserved for future capture configuration options. */
902 struct wimlib_pattern_list reserved1;
904 /** Reserved for future capture configuration options. */
905 struct wimlib_pattern_list reserved2;
907 /** Library internal use only. */
908 wimlib_tchar *_prefix;
910 /** Library internal use only. */
911 size_t _prefix_num_tchars;
914 /** Set or unset the WIM header flag that marks it read-only
915 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
916 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
917 * is distinct from basic file permissions; this flag can be set on a WIM file
918 * that is physically writable. If this flag is set, all further operations to
919 * modify the WIM will fail, except calling wimlib_overwrite() with
920 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
921 * allows you to set this flag persistently on the underlying WIM file.
923 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
925 /** Set the GUID (globally unique identifier) of the WIM file to the value
926 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
927 #define WIMLIB_CHANGE_GUID 0x00000002
929 /** Change the bootable image of the WIM to the value specified in
930 * ::wimlib_wim_info.boot_index of the @p info parameter. */
931 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
933 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
934 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
935 * indicates whether an image in the WIM has been captured with reparse-point
936 * fixups enabled. wimlib also treats this flag as specifying whether to do
937 * reparse-point fixups by default when capturing or applying WIM images. */
938 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
941 /** @ingroup G_wim_information
944 /** General information about a WIM file. */
945 struct wimlib_wim_info {
947 /** Globally unique identifier for the WIM file. Note: all parts of a
948 * split WIM should have an identical value in this field. */
949 uint8_t guid[WIMLIB_GUID_LEN];
951 /** Number of images in the WIM. */
952 uint32_t image_count;
954 /** 1-based index of the bootable image in the WIM, or 0 if no image is
958 /** Version of the WIM file. */
959 uint32_t wim_version;
961 /** Chunk size used for compression. */
964 /** For split WIMs, the 1-based index of this part within the split WIM;
966 uint16_t part_number;
968 /** For split WIMs, the total number of parts in the split WIM;
970 uint16_t total_parts;
972 /** One of the ::wimlib_compression_type values that specifies the
973 * method used to compress resources in the WIM. */
974 int32_t compression_type;
976 /** Size of the WIM file in bytes, excluding the XML data and integrity
978 uint64_t total_bytes;
980 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
981 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
982 * this will always be 0, even if the ::WIMStruct was written to
983 * somewhere by calling wimlib_write() with the
984 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
985 uint32_t has_integrity_table : 1;
987 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
988 * wimlib_create_new_wim(). */
989 uint32_t opened_from_file : 1;
991 /** 1 if the WIM is considered readonly for any reason. */
992 uint32_t is_readonly : 1;
994 /** 1 if reparse-point fixups are supposedly enabled for one or more
995 * images in the WIM. */
996 uint32_t has_rpfix : 1;
998 /** 1 if the WIM is marked as read-only. */
999 uint32_t is_marked_readonly : 1;
1001 /** 1 if the WIM is part of a spanned set. */
1002 uint32_t spanned : 1;
1004 uint32_t write_in_progress : 1;
1005 uint32_t metadata_only : 1;
1006 uint32_t resource_only : 1;
1008 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
1009 uint32_t pipable : 1;
1010 uint32_t reserved_flags : 22;
1011 uint32_t reserved[9];
1014 /** Information about a unique stream in the WIM file. (A stream is the same
1015 * thing as a "resource", except in the case of packed resources.) */
1016 struct wimlib_resource_entry {
1017 /** Uncompressed size of the stream in bytes. */
1018 uint64_t uncompressed_size;
1020 /** Compressed size of the stream in bytes. This will be the same as @p
1021 * uncompressed_size if the stream is uncompressed. Or, if @p
1022 * is_packed_streams is 1, this will be 0. */
1023 uint64_t compressed_size;
1025 /** Offset, in bytes, of this stream from the start of the WIM file. Or
1026 * if @p packed is 1, then this is actually the offset at which this
1027 * stream begins in the uncompressed contents of the packed resource.
1031 /** SHA1 message digest of the stream's uncompressed contents. */
1032 uint8_t sha1_hash[20];
1034 /** Which part number of the split WIM this stream is in. This should
1035 * be the same as the part number provided by wimlib_get_wim_info(). */
1036 uint32_t part_number;
1038 /** Number of times this stream is referenced over all WIM images. */
1039 uint32_t reference_count;
1041 /** 1 if this stream is compressed. */
1042 uint32_t is_compressed : 1;
1044 /** 1 if this stream is a metadata resource rather than a file resource.
1046 uint32_t is_metadata : 1;
1048 uint32_t is_free : 1;
1049 uint32_t is_spanned : 1;
1051 /** 1 if this stream was not found in the lookup table of the
1052 * ::WIMStruct. This normally implies a missing call to
1053 * wimlib_reference_resource_files() or wimlib_reference_resources().
1055 uint32_t is_missing : 1;
1057 /** 1 if this stream is located in a packed resource which may contain
1058 * other streams (all compressed together) as well. */
1059 uint32_t packed : 1;
1061 uint32_t reserved_flags : 26;
1063 /** If @p packed is 1, then this will specify the offset of the packed
1064 * resource in the WIM. */
1065 uint64_t raw_resource_offset_in_wim;
1067 /** If @p is_packed_streams is 1, then this will specify the compressed
1068 * size of the packed resource in the WIM. */
1069 uint64_t raw_resource_compressed_size;
1071 uint64_t reserved[2];
1074 /** A stream of a file in the WIM. */
1075 struct wimlib_stream_entry {
1076 /** Name of the stream, or NULL if the stream is unnamed. */
1077 const wimlib_tchar *stream_name;
1078 /** Location, size, etc. of the stream within the WIM file. */
1079 struct wimlib_resource_entry resource;
1080 uint64_t reserved[4];
1083 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1084 * Roughly, the information about a "file" in the WIM--- but really a directory
1085 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1086 * field can be used to distinguish actual file inodes. */
1087 struct wimlib_dir_entry {
1088 /** Name of the file, or NULL if this file is unnamed (only possible for
1089 * the root directory) */
1090 const wimlib_tchar *filename;
1092 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1094 const wimlib_tchar *dos_name;
1096 /** Full path to this file within the WIM image. */
1097 const wimlib_tchar *full_path;
1099 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1100 * children, ..., etc. */
1103 /** Pointer to the security descriptor for this file, in Windows
1104 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1105 * security descriptor. */
1106 const char *security_descriptor;
1108 /** Length of the above security descriptor. */
1109 size_t security_descriptor_size;
1111 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1112 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1113 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1114 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1115 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1116 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1117 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1118 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1119 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1120 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1121 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1122 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1123 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1124 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1125 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1126 /** File attributes, such as whether the file is a directory or not.
1127 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1128 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1129 * on other platforms. */
1130 uint32_t attributes;
1132 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1133 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1134 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1135 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1136 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1137 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1138 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1139 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1140 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1141 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1142 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1143 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1144 * attributes), this will give the reparse tag. This tells you whether
1145 * the reparse point is a symbolic link, junction point, or some other,
1146 * more unusual kind of reparse point. */
1147 uint32_t reparse_tag;
1149 /* Number of (hard) links to this file. */
1152 /** Number of named data streams that this file has. Normally 0. */
1153 uint32_t num_named_streams;
1155 /** Roughly, the inode number of this file. However, it may be 0 if
1156 * @p num_links == 1. */
1157 uint64_t hard_link_group_id;
1159 /** Time this file was created. */
1160 struct timespec creation_time;
1162 /** Time this file was last written to. */
1163 struct timespec last_write_time;
1165 /** Time this file was last accessed. */
1166 struct timespec last_access_time;
1167 uint64_t reserved[16];
1169 /** Array of streams that make up this file. The first entry will
1170 * always exist and will correspond to the unnamed data stream (default
1171 * file contents), so it will have @p stream_name == @c NULL. There
1172 * will then be @p num_named_streams additional entries that specify the
1173 * named data streams, if any, each of which will have @p stream_name !=
1175 struct wimlib_stream_entry streams[];
1179 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1182 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1186 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1189 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1192 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1193 * just on the specified path. */
1194 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1196 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1197 * itself; only its children (in the case of a non-empty directory) */
1198 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1200 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1201 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1202 * table of the ::WIMStruct. The default behavior without this flag is to fill
1203 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1204 * wimlib_resource_entry::is_missing "is_missing" flag. */
1205 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1209 /** @ingroup G_modifying_wims
1212 /** Directly capture a NTFS volume rather than a generic directory. This flag
1213 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1214 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1215 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1217 /** Follow symlinks; archive and dump the files they point to. Cannot be used
1218 * with ::WIMLIB_ADD_FLAG_NTFS. */
1219 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1221 /** Call the progress function with the message
1222 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1224 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1226 /** Mark the image being added as the bootable image of the WIM. */
1227 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1229 /** Store the UNIX owner, group, and mode. This is done by adding a special
1230 * alternate data stream to each regular file, symbolic link, and directory to
1231 * contain this information. Please note that this flag is for convenience
1232 * only; Microsoft's implementation will not understand this special
1233 * information. This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
1234 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1236 /** Do not capture security descriptors. Only has an effect in NTFS capture
1237 * mode, or in Windows native builds. */
1238 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1240 /** Fail immediately if the full security descriptor of any file or directory
1241 * cannot be accessed. Only has an effect in Windows native builds. The
1242 * default behavior without this flag is to first try omitting the SACL from the
1243 * security descriptor, then to try omitting the security descriptor entirely.
1245 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1247 /** Call the progress function with the message
1248 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1249 * capture. This is a subset of the messages provided by
1250 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1251 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1253 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1254 * in the case of Windows) that point inside the directory being captured to
1255 * instead be absolute relative to the directory being captured, rather than the
1256 * current root; also exclude absolute symbolic links that point outside the
1257 * directory tree being captured.
1259 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1260 * the WIM header or if this is the first image being added.
1261 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1262 * reparse point fixups enabled and currently cannot be unset. */
1263 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1265 /** Don't do reparse point fixups. The default behavior is described in the
1266 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1267 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1269 /** Do not automatically exclude unsupported files or directories from capture;
1270 * e.g. encrypted directories in NTFS-3g capture mode, or device files and FIFOs
1271 * on UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1272 * such a file is encountered. */
1273 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1275 /** Automatically select a capture configuration appropriate for capturing
1276 * filesystems containing Windows operating systems. When this flag is
1277 * specified, the corresponding @p config parameter or member must be @c NULL.
1279 * Currently, selecting this capture configuration will cause the following
1280 * files and directories to be excluded from capture:
1285 * - "\System Volume Information"
1289 * Note that the default behavior--- that is, when this flag is not specified
1290 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1291 * no files are excluded from capture.
1293 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1295 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1296 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1297 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1298 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1299 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1300 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1301 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1302 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1303 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1304 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1305 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1306 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1307 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1310 /** @ingroup G_modifying_wims
1313 /** Do not issue an error if the path to delete does not exist. */
1314 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1316 /** Delete the file or directory tree recursively; if not specified, an error is
1317 * issued if the path to delete is a directory. */
1318 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1321 /** @ingroup G_modifying_wims
1325 * If a single image is being exported, mark it bootable in the destination WIM.
1326 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1327 * the image in the source WIM (if any) that is marked as bootable is also
1328 * marked as bootable in the destination WIM.
1330 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1332 /** Give the exported image(s) no names. Avoids problems with image name
1335 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1337 /** Give the exported image(s) no descriptions. */
1338 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1341 /** @ingroup G_extracting_wims
1344 /** Extract the image directly to a NTFS volume rather than a generic directory.
1345 * This mode is only available if wimlib was compiled with libntfs-3g support;
1346 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1347 * extraction target will be interpreted as the path to a NTFS volume image (as
1348 * a regular file or block device) rather than a directory. It will be opened
1349 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1350 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1351 * is called with ::WIMLIB_ALL_IMAGES as the @p image. */
1352 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1354 /** When identical files are extracted from the WIM, always hard link them
1356 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
1358 /** When identical files are extracted from the WIM, always symlink them
1360 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
1362 /** This flag no longer does anything but is reserved for future use. */
1363 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
1365 /** Read the WIM file sequentially while extracting the image. As of wimlib
1366 * v1.6.0 this is the default behavior, and this flag no longer does anything.
1368 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
1370 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA. Only
1371 * valid on UNIX-like platforms, and when ::WIMLIB_EXTRACT_FLAG_NTFS was not
1373 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1375 /** Do not extract security descriptors. */
1376 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1378 /** Fail immediately if the full security descriptor of any file or directory
1379 * cannot be set exactly as specified in the WIM file. On Windows, the default
1380 * behavior without this flag is to fall back to setting the security descriptor
1381 * with the SACL omitted, then only the default inherited security descriptor,
1382 * if we do not have permission to set the desired one. */
1383 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1385 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1386 * reparse-point fixups on, so absolute symbolic links or junction points will
1387 * be fixed to be absolute relative to the actual extraction root. Reparse
1388 * point fixups are done by default if WIM_HDR_FLAG_RP_FIX is set in the WIM
1389 * header. This flag may only be specified when extracting a full image (not a
1390 * file or directory tree within one). */
1391 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1393 /** Force reparse-point fixups on extraction off, regardless of the state of the
1394 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. */
1395 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1397 /** Extract the specified file to standard output. This is only valid in an
1398 * extraction command that specifies the extraction of a regular file in the WIM
1400 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1402 /** Instead of ignoring files and directories with names that cannot be
1403 * represented on the current platform (note: Windows has more restrictions on
1404 * filenames than POSIX-compliant systems), try to replace characters or append
1405 * junk to the names so that they can be extracted in some form. */
1406 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1408 /** On Windows, when there exist two or more files with the same case
1409 * insensitive name but different case sensitive names, try to extract them all
1410 * by appending junk to the end of them, rather than arbitrarily extracting only
1412 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1414 /** Do not ignore failure to set timestamps on extracted files. */
1415 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1417 /** Do not ignore failure to set short names on extracted files. */
1418 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1420 /** Do not ignore failure to extract symbolic links (and junction points, on
1421 * Windows) due to permissions problems. By default, such failures are ignored
1422 * since the default configuration of Windows only allows the Administrator to
1423 * create symbolic links. */
1424 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1426 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1427 * behavior is currently less than satisfactory. Do not use (yet). */
1428 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1430 /** Perform the extraction ordered by the tree of files to extract rather than
1431 * how the underlying streams are arranged in the WIM file. For regular WIM
1432 * files this may decrease or increase performance, depending on various
1433 * factors. For WIM files containing packed streams this will decrease
1435 #define WIMLIB_EXTRACT_FLAG_FILE_ORDER 0x00020000
1437 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1438 * paths in the WIM as "glob" patterns which may contain the wildcard characters
1439 * '?' and '*'. The '?' character matches any character except a path
1440 * separator, whereas the '*' character matches zero or more non-path-separator
1441 * characters. Each glob pattern may match zero or more paths in the WIM file.
1442 * If a glob pattern ends in a path separator, it will only match directories
1443 * (including reparse points with FILE_ATTRIBUTE_DIRECTORY set). By default, if
1444 * a glob pattern does not match any files, a warning but not an error will be
1445 * issued, even if the glob pattern did not actually contain wildcard
1446 * characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error instead.
1448 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1450 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1451 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1452 * one of the provided globs did not match a file. */
1453 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1456 /** @ingroup G_mounting_wim_images
1459 /** Mount the WIM image read-write rather than the default of read-only. */
1460 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1462 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1463 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1465 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1466 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1468 /** Access alternate data streams in the mounted WIM image through extended file
1469 * attributes. This is the default mode. */
1470 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1472 /** Access alternate data streams in the mounted WIM image by specifying the
1473 * file name, a colon, then the alternate file stream name. */
1474 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1476 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1477 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1478 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1480 /** Allow other users to see the mounted filesystem. (this passes the @c
1481 * allow_other option to FUSE mount) */
1482 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1485 /** @ingroup G_creating_and_opening_wims
1488 /** Verify the WIM contents against the WIM's integrity table, if present. This
1489 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1490 * checksummed and checked against the SHA1 message digests specified in the
1491 * integrity table. ::WIMLIB_ERR_INTEGRITY is returned if there are any
1492 * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1493 * integrity table is invalid). */
1494 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1496 /** Issue an error if the WIM is part of a split WIM. Software can provide
1497 * this flag for convenience if it explicitly does not want to support split
1499 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1501 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1502 * is not. A WIM is considered writable only if it is writable at the
1503 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1504 * header, and is not part of a spanned set. It is not required to provide this
1505 * flag before attempting to make changes to the WIM, but with this flag you get
1506 * an error sooner rather than later. */
1507 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1510 /** @ingroup G_mounting_wim_images
1513 /** See ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
1514 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1516 /** Unless this flag is given, changes to a read-write mounted WIM are
1517 * discarded. Ignored for read-only mounts. */
1518 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1520 /** See ::WIMLIB_WRITE_FLAG_REBUILD. */
1521 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1523 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1524 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1526 /** Do a "lazy" unmount (detach filesystem immediately, even if busy). */
1527 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1530 /** @ingroup G_modifying_wims
1533 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1534 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1535 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1538 /** @ingroup G_writing_and_overwriting_wims
1541 /** Include an integrity table in the WIM.
1543 * For WIMs created with wimlib_open_wim(), the default behavior is to include
1544 * an integrity table if and only if one was present before. For WIMs created
1545 * with wimlib_create_new_wim(), the default behavior is to not include an
1546 * integrity table. */
1547 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1549 /** Do not include an integrity table in the new WIM file. This is the default
1550 * behavior, unless the WIM already included an integrity table. */
1551 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1553 /** Write the WIM as "pipable". After writing a WIM with this flag specified,
1554 * images from it can be applied directly from a pipe using
1555 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1556 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1557 * with this flag will not be compatible with Microsoft's software.
1559 * For WIMs created with wimlib_open_wim(), the default behavior is to write the
1560 * WIM as pipable if and only if it was pipable before. For WIMs created with
1561 * wimlib_create_new_wim(), the default behavior is to write the WIM as
1563 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1565 /** Do not write the WIM as "pipable". This is the default behavior, unless the
1566 * WIM was pipable already. */
1567 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1569 /** Recompress all resources, even if they could otherwise be copied from a
1570 * different WIM with the same compression type (in the case of
1571 * wimlib_export_image() being called previously). This flag is also valid in
1572 * the @p wim_write_flags of wimlib_join(), in which case all resources included
1573 * in the joined WIM file will be recompressed. */
1574 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1576 /** Call fsync() just before the WIM file is closed. */
1577 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1579 /** wimlib_overwrite() only: Re-build the entire WIM file rather than appending
1580 * data to it if possible. */
1581 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1583 /** wimlib_overwrite() only: Specifying this flag overrides the default
1584 * behavior of wimlib_overwrite() after one or more calls to
1585 * wimlib_delete_image(), which is to rebuild the entire WIM. With this flag,
1586 * only minimal changes to correctly remove the image from the WIM will be
1587 * taken. In particular, all streams will be left alone, even if they are no
1588 * longer referenced. This is probably not what you want, because almost no
1589 * space will be saved by deleting an image in this way. */
1590 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1592 /** wimlib_overwrite() only: Allow overwriting the WIM even if the readonly
1593 * flag is set in the WIM header. This can be used in combination with
1594 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1595 * set the readonly flag on the on-disk WIM file. */
1596 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1598 /** Do not include non-metadata resources already present in other WIMs. This
1599 * flag can be used to write a "delta" WIM after resources from the WIM on which
1600 * the delta is to be based were referenced with
1601 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1602 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1604 /** Asserts that for writes of all WIM images, all streams needed for the WIM
1605 * are already present (not in external resource WIMs) and their reference
1606 * counts are correct, so the code does not need to recalculate which streams
1607 * are referenced. This is for optimization purposes only, since with this flag
1608 * specified, the metadata resources may not need to be decompressed and parsed.
1610 * This flag can be passed to wimlib_write() and wimlib_write_to_fd(), but is
1611 * already implied for wimlib_overwrite(). */
1612 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1614 #define WIMLIB_WRITE_FLAG_RESERVED 0x00000800
1617 * When writing streams in the resulting WIM file, pack multiple streams into a
1618 * single WIM resource instead of compressing them independently. This tends to
1619 * produce a better compression ratio at the cost of less random access.
1620 * However, WIMs created with this flag are only compatible with wimlib v1.6.0
1621 * or later and WIMGAPI Windows 8 or later, seemingly for Windows Setup only and
1622 * <b>not including ImageX and Dism</b>. WIMs created with this flag must use
1623 * version number 3584 in their header instead of 68864.
1625 * If this flag is passed to wimlib_overwrite() and the WIM did not previously
1626 * contain packed streams, the WIM's version number will be changed to 3584 and
1627 * the new streams will be written packed. Use ::WIMLIB_WRITE_FLAG_REBUILD to
1628 * force the WIM to be fully rebuilt. */
1629 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
1632 /** @ingroup G_general
1635 /** Assume that strings are represented in UTF-8, even if this is not the
1636 * locale's character encoding. This flag is ignored on Windows, where wimlib
1637 * always uses UTF-16LE. */
1638 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1640 /** Windows-only: do not attempt to acquire additional privileges (currently
1641 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1642 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1643 * for the case where the calling program manages these privileges itself.
1644 * Note: no error is issued if privileges cannot be acquired, although related
1645 * errors may be reported later, depending on if the operations performed
1646 * actually require additional privileges or not. */
1647 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1649 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1650 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1651 * to read all possible data and metadata for a capture operation could not be
1652 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1654 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1656 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1657 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1658 * to restore all possible data and metadata for an apply operation could not be
1659 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1661 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1663 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1665 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
1667 /** Default to interpreting WIM paths case insensitively (default on Windows).
1668 * This does not apply to mounted images. */
1669 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
1672 /** @ingroup G_nonstandalone_wims
1675 /** wimlib_reference_resource_files() only: Enable shell-style filename
1677 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1679 /** wimlib_reference_resource_files() only: Issue an error
1680 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1681 * default behavior without this flag is to issue no error at that point, but
1682 * then attempt to open the glob as a literal path, which of course will fail
1683 * anyway if no file exists at that path. No effect if
1684 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. */
1685 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1688 /** @ingroup G_modifying_wims
1691 /** The specific type of update to perform. */
1692 enum wimlib_update_op {
1693 /** Add a new file or directory tree to the WIM image in a
1694 * certain location. */
1695 WIMLIB_UPDATE_OP_ADD = 0,
1697 /** Delete a file or directory tree from the WIM image. */
1698 WIMLIB_UPDATE_OP_DELETE,
1700 /** Rename a file or directory tree in the WIM image. */
1701 WIMLIB_UPDATE_OP_RENAME,
1704 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1705 struct wimlib_add_command {
1706 /** Filesystem path to the file or directory tree to
1708 wimlib_tchar *fs_source_path;
1709 /** Path, specified from the root of the WIM image, at
1710 * which to add the file or directory tree within the
1712 wimlib_tchar *wim_target_path;
1714 /** Configuration for excluded files. @c NULL means
1715 * exclude no files (use no configuration), unless
1716 * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
1718 struct wimlib_capture_config *config;
1720 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1724 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1725 struct wimlib_delete_command {
1726 /** Path, specified from the root of the WIM image, for
1727 * the file or directory tree within the WIM image to be
1729 wimlib_tchar *wim_path;
1730 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1734 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1735 struct wimlib_rename_command {
1736 /** Path, specified from the root of the WIM image, for
1737 * the source file or directory tree within the WIM
1739 wimlib_tchar *wim_source_path;
1740 /** Path, specified from the root of the WIM image, for
1741 * the destination file or directory tree within the WIM
1743 wimlib_tchar *wim_target_path;
1744 /** Reserved; set to 0. */
1748 /** Specification of an update to perform on a WIM image. */
1749 struct wimlib_update_command {
1751 enum wimlib_update_op op;
1754 struct wimlib_add_command add;
1755 struct wimlib_delete_command delete_; /* Underscore is for C++
1757 struct wimlib_rename_command rename;
1762 /** @ingroup G_extracting_wims
1765 /** Specification of a file or directory tree to extract from a WIM image. Used
1766 * in calls to wimlib_extract_files(). */
1767 struct wimlib_extract_command {
1768 /** Path to file or directory tree within the WIM image to extract. It
1769 * must be provided as an absolute path from the root of the WIM image.
1770 * The path separators may be either forward slashes or backslashes. */
1771 wimlib_tchar *wim_source_path;
1773 /** Filesystem path to extract the file or directory tree to. */
1774 wimlib_tchar *fs_dest_path;
1776 /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1782 /** @ingroup G_general
1786 * Possible values of the error code returned by many functions in wimlib.
1788 * See the documentation for each wimlib function to see specifically what error
1789 * codes can be returned by a given function, and what they mean.
1791 enum wimlib_error_code {
1792 WIMLIB_ERR_SUCCESS = 0,
1793 WIMLIB_ERR_ALREADY_LOCKED,
1794 WIMLIB_ERR_DECOMPRESSION,
1795 WIMLIB_ERR_DELETE_STAGING_DIR,
1796 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1799 WIMLIB_ERR_FUSERMOUNT,
1800 WIMLIB_ERR_GLOB_HAD_NO_MATCHES,
1801 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1802 WIMLIB_ERR_IMAGE_COUNT,
1803 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1804 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES,
1805 WIMLIB_ERR_INTEGRITY,
1806 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1807 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1808 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1809 WIMLIB_ERR_INVALID_HEADER,
1810 WIMLIB_ERR_INVALID_IMAGE,
1811 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1812 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1813 WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1814 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1815 WIMLIB_ERR_INVALID_OVERLAY,
1816 WIMLIB_ERR_INVALID_PARAM,
1817 WIMLIB_ERR_INVALID_PART_NUMBER,
1818 WIMLIB_ERR_INVALID_PIPABLE_WIM,
1819 WIMLIB_ERR_INVALID_REPARSE_DATA,
1820 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1821 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1822 WIMLIB_ERR_INVALID_UTF16_STRING,
1823 WIMLIB_ERR_INVALID_UTF8_STRING,
1824 WIMLIB_ERR_IS_DIRECTORY,
1825 WIMLIB_ERR_IS_SPLIT_WIM,
1826 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1828 WIMLIB_ERR_METADATA_NOT_FOUND,
1833 WIMLIB_ERR_NOTEMPTY,
1834 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1835 WIMLIB_ERR_NOT_A_WIM_FILE,
1836 WIMLIB_ERR_NOT_PIPABLE,
1837 WIMLIB_ERR_NO_FILENAME,
1841 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1843 WIMLIB_ERR_READLINK,
1846 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1847 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1848 WIMLIB_ERR_RESOURCE_ORDER,
1849 WIMLIB_ERR_SET_ATTRIBUTES,
1850 WIMLIB_ERR_SET_REPARSE_DATA,
1851 WIMLIB_ERR_SET_SECURITY,
1852 WIMLIB_ERR_SET_SHORT_NAME,
1853 WIMLIB_ERR_SET_TIMESTAMPS,
1854 WIMLIB_ERR_SPLIT_INVALID,
1857 WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
1858 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1859 WIMLIB_ERR_UNKNOWN_VERSION,
1860 WIMLIB_ERR_UNSUPPORTED,
1861 WIMLIB_ERR_UNSUPPORTED_FILE,
1862 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1863 WIMLIB_ERR_WIM_IS_READONLY,
1869 /** Used to indicate no WIM image or an invalid WIM image. */
1870 #define WIMLIB_NO_IMAGE 0
1872 /** Used to specify all images in the WIM. */
1873 #define WIMLIB_ALL_IMAGES (-1)
1876 * @ingroup G_modifying_wims
1878 * Appends an empty image to a WIM file. This empty image will initially
1879 * contain no files or directories, although if written without further
1880 * modifications, a root directory will be created automatically for it. After
1881 * calling this function, you can use wimlib_update_image() to add files to the
1882 * new WIM image. This gives you slightly more control over making the new
1883 * image compared to calling wimlib_add_image() or
1884 * wimlib_add_image_multisource() directly.
1887 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
1890 * Name to give the new image. If @c NULL or empty, the new image is given
1891 * no name. If nonempty, it must specify a name that does not already
1893 * @param new_idx_ret
1894 * If non-<code>NULL</code>, the index of the newly added image is returned
1897 * @return 0 on success; nonzero on failure. The possible error codes are:
1899 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1900 * There is already an image in @p wim named @p name.
1901 * @retval ::WIMLIB_ERR_NOMEM
1902 * Failed to allocate the memory needed to add the new image.
1903 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1904 * The WIM file is considered read-only because of any of the reasons
1905 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1909 wimlib_add_empty_image(WIMStruct *wim,
1910 const wimlib_tchar *name,
1914 * @ingroup G_modifying_wims
1916 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1918 * The directory tree or NTFS volume is scanned immediately to load the dentry
1919 * tree into memory, and file attributes and symbolic links are read. However,
1920 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1923 * See the manual page for the @b wimlib-imagex program for more information
1924 * about the "normal" capture mode versus the NTFS capture mode (entered by
1925 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1927 * Note that @b no changes are committed to the underlying WIM file (if
1928 * any) until wimlib_write() or wimlib_overwrite() is called.
1931 * Pointer to the ::WIMStruct for a WIM file to which the image will be
1934 * A path to a directory or unmounted NTFS volume that will be captured as
1937 * Name to give the new image. If @c NULL or empty, the new image is given
1938 * no name. If nonempty, it must specify a name that does not already
1941 * Capture configuration that specifies files, directories, or path globs
1942 * to exclude from being captured. If @c NULL, a dummy configuration where
1943 * no paths are treated specially is used.
1945 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1946 * @param progress_func
1947 * If non-NULL, a function that will be called periodically with the
1948 * progress of the current operation. The progress messages that will be
1949 * received are ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
1950 * ::WIMLIB_PROGRESS_MSG_SCAN_END, and, if ::WIMLIB_ADD_FLAG_VERBOSE was
1951 * included in @p add_flags, also ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
1953 * @return 0 on success; nonzero on error. On error, changes to @p wim are
1954 * discarded so that it appears to be in the same state as when this function
1957 * This function is implemented by calling wimlib_add_empty_image(), then
1958 * calling wimlib_update_image() with a single "add" command, so any error code
1959 * returned by wimlib_add_empty_image() may be returned, as well as any error
1960 * codes returned by wimlib_update_image() other than ones documented as only
1961 * being returned specifically by an update involving delete or rename commands.
1964 wimlib_add_image(WIMStruct *wim,
1965 const wimlib_tchar *source,
1966 const wimlib_tchar *name,
1967 const struct wimlib_capture_config *config,
1969 wimlib_progress_func_t progress_func);
1972 * @ingroup G_modifying_wims
1974 * This function is equivalent to wimlib_add_image() except it allows for
1975 * multiple sources to be combined into a single WIM image. This is done by
1976 * specifying the @p sources and @p num_sources parameters instead of the @p
1977 * source parameter of wimlib_add_image(). The rest of the parameters are the
1978 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
1979 * capture</b> for full details on how this mode works.
1981 * In addition to the error codes that wimlib_add_image() can return,
1982 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1983 * when trying to overlay a non-directory on a directory or when otherwise
1984 * trying to overlay multiple conflicting files to the same location in the WIM
1985 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
1986 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
1987 * was not exactly one capture source with the target being the root directory.
1988 * (In this respect, there is no advantage to using
1989 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1992 wimlib_add_image_multisource(WIMStruct *wim,
1993 const struct wimlib_capture_source *sources,
1995 const wimlib_tchar *name,
1996 const struct wimlib_capture_config *config,
1998 wimlib_progress_func_t progress_func);
2001 * @ingroup G_creating_and_opening_wims
2003 * Creates a ::WIMStruct for a new WIM file.
2005 * This only creates an in-memory structure for a WIM that initially contains no
2006 * images. No on-disk file is created until wimlib_write() is called.
2009 * The type of compression to be used in the new WIM file. Must be
2010 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
2011 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
2013 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2014 * written to the memory location pointed to by this paramater. The
2015 * ::WIMStruct must be freed using using wimlib_free() when finished with
2017 * @return 0 on success; nonzero on error.
2018 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2019 * @p ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
2020 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
2021 * @retval ::WIMLIB_ERR_NOMEM
2022 * Failed to allocate needed memory.
2025 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2028 * @ingroup G_modifying_wims
2030 * Deletes an image, or all images, from a WIM file.
2032 * All streams referenced by the image(s) being deleted are removed from the
2033 * lookup table of the WIM if they are not referenced by any other images in the
2036 * Please note that @b no changes are committed to the underlying WIM file (if
2037 * any) until wimlib_write() or wimlib_overwrite() is called.
2040 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2043 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2045 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
2046 * to be left unmodified only if @p image specified a single image. If instead
2047 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2048 * possible for some but not all of the images to have been deleted when a
2049 * failure status is returned.
2051 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2052 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2053 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2054 * The WIM file is considered read-only because of any of the reasons
2055 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2058 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2059 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2060 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2061 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2062 * different reasons) to read the metadata resource for an image that needed to
2066 wimlib_delete_image(WIMStruct *wim, int image);
2069 * @ingroup G_modifying_wims
2071 * Exports an image, or all the images, from a WIM file, into another WIM file.
2073 * The destination image is made to share the same dentry tree and security data
2074 * structure as the source image. This places some restrictions on additional
2075 * functions that may be called. wimlib_mount_image() may not be called on
2076 * either the source image or the destination image without an intervening call
2077 * to a function that un-shares the images, such as wimlib_free() on @p
2078 * dest_wim, or wimlib_delete_image() on either the source or destination image.
2079 * Furthermore, you may not call wimlib_free() on @p src_wim before calling
2080 * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
2081 * have references back to @p src_wim.
2083 * If this function fails, all changes to @p dest_wim are rolled back.
2085 * Please note that no changes are committed to the underlying WIM file of @p
2086 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2089 * The WIM from which to export the images, specified as a pointer to the
2090 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2091 * split WIM. In the case of a WIM file that is not standalone, this
2092 * ::WIMStruct must have had any needed external resources previously
2093 * referenced using wimlib_reference_resources() or
2094 * wimlib_reference_resource_files().
2096 * The image to export from @p src_wim, as either a 1-based image index to
2097 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2099 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2102 * For single-image exports, the name to give the exported image in @p
2103 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2104 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2105 * that case, the names are all taken from @p src_wim. This parameter is
2106 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2107 * @param dest_description
2108 * For single-image exports, the description to give the exported image in
2109 * the new WIM file. If left @c NULL, the description from @p src_wim is
2110 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2111 * NULL; in that case, the description are all taken from @p src_wim. This
2112 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2113 * @param export_flags
2114 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2115 * @param progress_func
2116 * Currently ignored, but reserved for a function that will be called with
2117 * information about the operation. Use NULL if no additional information
2120 * @return 0 on success; nonzero on error.
2121 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2122 * One or more of the names being given to an exported image was already in
2123 * use in the destination WIM.
2124 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2125 * @p src_image does not exist in @p src_wim and was not
2126 * ::WIMLIB_ALL_IMAGES.
2127 * @retval ::WIMLIB_ERR_INVALID_PARAM
2128 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2129 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2131 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2132 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2133 * example, one of them was a non-first part of a split WIM.
2134 * @retval ::WIMLIB_ERR_NOMEM
2135 * Failed to allocate needed memory.
2136 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2137 * A resource that needed to be exported could not be found in either the
2138 * source or destination WIMs. This error can occur if, for example, @p
2139 * src_wim is part of a split WIM but needed resources from the other split
2140 * WIM parts were not referenced with wimlib_reference_resources() or
2141 * wimlib_reference_resource_files() before the call to
2142 * wimlib_export_image().
2143 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2144 * @p dest_wim is considered read-only because of any of the reasons
2145 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2148 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2149 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2150 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2151 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2152 * different reasons) to read the metadata resource for an image in @p src_wim
2153 * that needed to be exported.
2156 wimlib_export_image(WIMStruct *src_wim, int src_image,
2157 WIMStruct *dest_wim,
2158 const wimlib_tchar *dest_name,
2159 const wimlib_tchar *dest_description,
2161 wimlib_progress_func_t progress_func);
2164 * @ingroup G_extracting_wims
2166 * Extract zero or more files or directory trees from a WIM image.
2168 * This generalizes the single-image extraction functionality of
2169 * wimlib_extract_image() to allow extracting only the specified subsets of the
2173 * The WIM from which to extract the files, specified as a pointer to the
2174 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2175 * split WIM. In the case of a WIM file that is not standalone, this
2176 * ::WIMStruct must have had any needed external resources previously
2177 * referenced using wimlib_reference_resources() or
2178 * wimlib_reference_resource_files().
2181 * The 1-based number of the image in @p wim from which the files or
2182 * directory trees are to be extracted. It cannot be ::WIMLIB_ALL_IMAGES.
2185 * An array of ::wimlib_extract_command structures that specifies the
2186 * extractions to perform.
2189 * Number of commands in the @p cmds array.
2191 * @param default_extract_flags
2192 * Default extraction flags; the behavior shall be as if these flags had
2193 * been specified in the ::wimlib_extract_command.extract_flags member in
2194 * each extraction command, in combination with any flags already present.
2196 * @param progress_func
2197 * If non-NULL, a function that will be called periodically with the
2198 * progress of the current operation.
2200 * @return 0 on success; nonzero on error. The possible error codes include
2201 * most of those documented as returned by wimlib_extract_image() as well as the
2202 * following additional error codes:
2204 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2205 * @p image was ::WIMLIB_ALL_IMAGES (or was not otherwise a valid image in
2207 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2208 * The ::wimlib_extract_command.wim_source_path member in one of the
2209 * extract commands did not exist in the WIM.
2210 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2211 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
2212 * in which ::wimlib_extract_command.wim_source_path existed but was not a
2213 * regular file or directory.
2214 * @retval ::WIMLIB_ERR_INVALID_PARAM
2215 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
2216 * specified for some commands but not all; or
2217 * ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
2218 * for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
2219 * for a command in which ::wimlib_extract_command.wim_source_path did not
2220 * specify the root directory of the WIM image.
2223 wimlib_extract_files(WIMStruct *wim,
2225 const struct wimlib_extract_command *cmds,
2227 int default_extract_flags,
2228 wimlib_progress_func_t progress_func);
2231 * @ingroup G_extracting_wims
2233 * Extracts an image, or all images, from a WIM to a directory or directly to a
2234 * NTFS volume image.
2236 * The exact behavior of how wimlib extracts files from a WIM image is
2237 * controllable by the @p extract_flags parameter, but there also are
2238 * differences depending on the platform (UNIX-like vs Windows). See the manual
2239 * page for <b>wimlib-imagex apply</b> for more information, including about the
2240 * special "NTFS volume extraction mode" entered by providing
2241 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2243 * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
2244 * returned if any resulting SHA1 message digests do not match the values
2245 * provided in the WIM file. Therefore, if this function is successful, you can
2246 * be fairly sure that any compressed data in the WIM was uncompressed
2250 * The WIM from which to extract the image(s), specified as a pointer to
2251 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2252 * of a split WIM. In the case of a WIM file that is not standalone, this
2253 * ::WIMStruct must have had any needed external resources previously
2254 * referenced using wimlib_reference_resources() or
2255 * wimlib_reference_resource_files().
2257 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
2258 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
2259 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2261 * Directory to extract the WIM image(s) to (created if it does not already
2262 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @p extract_flags, the
2263 * path to the unmounted NTFS volume to extract the image to.
2264 * @param extract_flags
2265 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
2266 * @param progress_func
2267 * If non-NULL, a function that will be called periodically with the
2268 * progress of the current operation.
2270 * @return 0 on success; nonzero on error.
2271 * @retval ::WIMLIB_ERR_DECOMPRESSION
2272 * Failed to decompress a resource to be extracted.
2273 * @retval ::WIMLIB_ERR_INVALID_PARAM
2274 * Both ::WIMLIB_EXTRACT_FLAG_HARDLINK and ::WIMLIB_EXTRACT_FLAG_SYMLINK
2275 * were specified in @p extract_flags; or both
2276 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS and ::WIMLIB_EXTRACT_FLAG_NO_ACLS were
2277 * specified in @p extract_flags; or both ::WIMLIB_EXTRACT_FLAG_RPFIX and
2278 * ::WIMLIB_EXTRACT_FLAG_NORPFIX were specified in @p extract_flags; or
2279 * ::WIMLIB_EXTRACT_FLAG_RESUME was specified in @p extract_flags; or if
2280 * ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @p extract_flags and
2281 * @p image was ::WIMLIB_ALL_IMAGES.
2282 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2283 * The SHA1 message digest of an extracted stream did not match the SHA1
2284 * message digest given in the WIM file.
2285 * @retval ::WIMLIB_ERR_LINK
2286 * Failed to create a symbolic link or a hard link.
2287 * @retval ::WIMLIB_ERR_MKDIR
2288 * Failed create a directory.
2289 * @retval ::WIMLIB_ERR_NOMEM
2290 * Failed to allocate needed memory.
2291 * @retval ::WIMLIB_ERR_OPEN
2292 * Could not create a file, or failed to open an already-extracted file.
2293 * @retval ::WIMLIB_ERR_READ
2294 * Failed to read data from the WIM file associated with @p wim.
2295 * @retval ::WIMLIB_ERR_READLINK
2296 * Failed to determine the target of a symbolic link in the WIM.
2297 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2298 * Failed to fix the target of an absolute symbolic link (e.g. if the
2299 * target would have exceeded the maximum allowed length). (Only if
2300 * reparse data was supported by the extraction mode and
2301 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p extract_flags.)
2302 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2303 * One of the files or directories that needed to be extracted referenced a
2304 * stream not present in the WIM's lookup table (or in any of the lookup
2305 * tables of the split WIM parts).
2306 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2307 * Failed to set attributes on a file.
2308 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2309 * Failed to set reparse data on a file (only if reparse data was supported
2310 * by the extraction mode).
2311 * @retval ::WIMLIB_ERR_SET_SECURITY
2312 * Failed to set security descriptor on a file
2313 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2315 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2316 * Failed to set the short name of a file (only if
2317 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2318 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2319 * Failed to set timestamps on a file (only if
2320 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2321 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2322 * Unexpected end-of-file occurred when reading data from the WIM file
2323 * associated with @p wim.
2324 * @retval ::WIMLIB_ERR_UNSUPPORTED
2325 * A requested extraction flag, or the data or metadata that must be
2326 * extracted to support it, is unsupported in the build and configuration
2327 * of wimlib, or on the current platform or extraction mode or target
2328 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2329 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2330 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2331 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS,
2332 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS, ::WIMLIB_EXTRACT_FLAG_SYMLINK,
2333 * and ::WIMLIB_EXTRACT_FLAG_HARDLINK. For example, if
2334 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2336 * ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM image contains one
2337 * or more files with short names, but extracting short names is not
2338 * supported --- on Windows, this occurs if the target volume does not
2339 * support short names, while on non-Windows, this occurs if
2340 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2341 * @retval ::WIMLIB_ERR_WRITE
2342 * Failed to write data to a file being extracted.
2344 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2345 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2346 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2347 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2348 * different reasons) to read the metadata resource for an image that needed to
2352 wimlib_extract_image(WIMStruct *wim, int image,
2353 const wimlib_tchar *target,
2355 wimlib_progress_func_t progress_func);
2358 * @ingroup G_extracting_wims
2360 * Since wimlib v1.5.0: Extract one or more images from a pipe on which a
2361 * pipable WIM is being sent.
2363 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2364 * about pipable WIMs.
2366 * This function operates in a special way to read the WIM fully sequentially.
2367 * As a result, there is no ::WIMStruct is made visible to library users, and
2368 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2369 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2370 * seekable file, not a pipe.)
2373 * File descriptor, which may be a pipe, opened for reading and positioned
2374 * at the start of the pipable WIM.
2375 * @param image_num_or_name
2376 * String that specifies the 1-based index or name of the image to extract.
2377 * It is translated to an image index using the same rules that
2378 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2379 * only a single image (not all images) can be specified. Alternatively,
2380 * specify @p NULL here to use the first image in the WIM if it contains
2381 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2383 * Same as the corresponding parameter to wimlib_extract_image().
2384 * @param extract_flags
2385 * Same as the corresponding parameter to wimlib_extract_image(), except
2386 * for the following exceptions: ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is
2387 * always implied, since data is always read from @p pipe_fd sequentially
2388 * in this mode; also, ::WIMLIB_EXTRACT_FLAG_TO_STDOUT is invalid and will
2389 * result in ::WIMLIB_ERR_INVALID_PARAM being returned.
2390 * @param progress_func
2391 * Same as the corresponding parameter to wimlib_extract_image(), except
2392 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
2395 * @return 0 on success; nonzero on error. The possible error codes include
2396 * those returned by wimlib_extract_image() as well as the following:
2398 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2399 * Data read from the pipable WIM was invalid.
2400 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2401 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2404 wimlib_extract_image_from_pipe(int pipe_fd,
2405 const wimlib_tchar *image_num_or_name,
2406 const wimlib_tchar *target, int extract_flags,
2407 wimlib_progress_func_t progress_func);
2410 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
2411 * image specified in the UTF-8 text file named by @p path_list_file which
2412 * itself contains the list of paths to use, one per line. Leading and trailing
2413 * whitespace, and otherwise empty lines and lines beginning with the ';'
2414 * character are ignored. No quotes are needed as paths are otherwise delimited
2415 * by the newline character.
2418 wimlib_extract_pathlist(WIMStruct *wim, int image,
2419 const wimlib_tchar *target,
2420 const wimlib_tchar *path_list_file,
2422 wimlib_progress_func_t progress_func);
2425 * Similar to wimlib_extract_files(), but the files or directories to extract
2426 * from the WIM image are specified as an array of paths.
2428 * Each path will be extracted to a corresponding subdirectory of the @p target
2429 * based on its location in the WIM image. For example, if one of the paths to
2430 * extract is "/Windows/explorer.exe" and the target is "outdir", the file will
2431 * be extracted to "outdir/Windows/explorer.exe". Each path to extract must be
2432 * specified as the absolute path to a directory within the WIM image.
2433 * Separators in the paths to extract may be either forwards or backwards
2434 * slashes, and leading path separators are optional. Symbolic links are not
2435 * dereferenced when interpreting paths to extract. Paths to extract will be
2436 * interpreted either case-sensitively (UNIX default) or case-insensitively
2437 * (Windows default); this can be changed by wimlib_global_init().
2439 * The @p target path, on the other hand, is expected to be a native path. On
2440 * UNIX-like systems it may not contain backslashes, for example.
2442 * By default, if any paths to extract do not exist,
2443 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is issued. This behavior changes if
2444 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified.
2446 * With ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS specified in @p extract_flags, this
2447 * function additionally allows paths to be globs using the wildcard characters
2451 wimlib_extract_paths(WIMStruct *wim,
2453 const wimlib_tchar *target,
2454 const wimlib_tchar * const *paths,
2457 wimlib_progress_func_t progress_func);
2460 * @ingroup G_wim_information
2462 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2463 * includes a string of XML that describes the images contained in the WIM.
2465 * See wimlib_get_xml_data() to read the XML data into memory instead.
2468 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2469 * have to be standalone (e.g. it could be part of a split WIM).
2471 * @c stdout, or a FILE* opened for writing, to extract the data to.
2473 * @return 0 on success; nonzero on error.
2474 * @retval ::WIMLIB_ERR_INVALID_PARAM
2475 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2476 * @retval ::WIMLIB_ERR_NOMEM
2477 * @retval ::WIMLIB_ERR_READ
2478 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2479 * Failed to read the XML data from the WIM.
2480 * @retval ::WIMLIB_ERR_WRITE
2481 * Failed to completely write the XML data to @p fp.
2484 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2487 * @ingroup G_general
2489 * Frees all memory allocated for a WIMStruct and closes all files associated
2493 * Pointer to the ::WIMStruct for a WIM file.
2495 * @return This function has no return value.
2498 wimlib_free(WIMStruct *wim);
2501 * @ingroup G_general
2503 * Converts a ::wimlib_compression_type value into a string.
2506 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
2507 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
2510 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
2513 extern const wimlib_tchar *
2514 wimlib_get_compression_type_string(int ctype);
2517 * @ingroup G_general
2519 * Converts an error code into a string describing it.
2522 * The error code returned by one of wimlib's functions.
2525 * Pointer to a statically allocated string describing the error code,
2526 * or @c NULL if the error code is not valid.
2528 extern const wimlib_tchar *
2529 wimlib_get_error_string(enum wimlib_error_code code);
2532 * @ingroup G_wim_information
2534 * Returns the description of the specified image.
2537 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2538 * to be standalone (e.g. it could be part of a split WIM).
2540 * The number of the image, numbered starting at 1.
2543 * The description of the image, or @c NULL if there is no such image, or
2544 * @c NULL if the specified image has no description. The description
2545 * string is in library-internal memory and may not be modified or freed;
2546 * in addition, the string will become invalid if the description of the
2547 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2549 extern const wimlib_tchar *
2550 wimlib_get_image_description(const WIMStruct *wim, int image);
2553 * @ingroup G_wim_information
2555 * Returns the name of the specified image.
2558 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2559 * to be standalone (e.g. it could be part of a split WIM).
2561 * The number of the image, numbered starting at 1.
2564 * The name of the image, or @c NULL if there is no such image, or an empty
2565 * string if the image is unnamed. The name string is in
2566 * library-internal memory and may not be modified or freed; in addition,
2567 * the string will become invalid if the name of the image is changed, the
2568 * image is deleted, or the ::WIMStruct is destroyed.
2570 extern const wimlib_tchar *
2571 wimlib_get_image_name(const WIMStruct *wim, int image);
2575 * @ingroup G_wim_information
2577 * Get basic information about a WIM file.
2580 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2581 * to be standalone (e.g. it could be part of a split WIM).
2583 * A ::wimlib_wim_info structure that will be filled in with information
2584 * about the WIM file.
2589 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2592 * @ingroup G_wim_information
2594 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
2595 * includes a string of XML that describes the images contained in the WIM.
2597 * See wimlib_extract_xml_data() to extract the XML data to a file stream
2601 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2602 * have to be standalone (e.g. it could be part of a split WIM).
2604 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
2605 * XML data is written to this location.
2606 * @param bufsize_ret
2607 * The size of the XML data in bytes is written to this location.
2609 * @return 0 on success; nonzero on error.
2610 * @retval ::WIMLIB_ERR_INVALID_PARAM
2611 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2612 * @p buf_ret or @p bufsize_ret was @c NULL.
2613 * @retval ::WIMLIB_ERR_NOMEM
2614 * @retval ::WIMLIB_ERR_READ
2615 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2616 * Failed to read the XML data from the WIM.
2619 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2622 * @ingroup G_general
2624 * Initialization function for wimlib. Call before using any other wimlib
2625 * function except wimlib_set_print_errors(). If not done manually, this
2626 * function will be called automatically with @p init_flags set to
2627 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
2628 * after it has already successfully run.
2631 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2633 * @return 0 on success; nonzero on failure. Currently, only the following
2634 * error code is defined:
2636 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2637 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2638 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2639 * init_flags, but the corresponding privileges could not be acquired.
2642 wimlib_global_init(int init_flags);
2645 * @ingroup G_general
2647 * Cleanup function for wimlib. You are not required to call this function, but
2648 * it will release any global resources allocated by the library.
2651 wimlib_global_cleanup(void);
2654 * @ingroup G_wim_information
2656 * Determines if an image name is already used by some image in the WIM.
2659 * Pointer to the ::WIMStruct for a WIM file.
2661 * The name to check.
2664 * @c true if there is already an image in @p wim named @p name; @c false
2665 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2666 * the empty string, @c false is returned.
2669 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2672 * @ingroup G_wim_information
2674 * Iterate through a file or directory tree in the WIM image. By specifying
2675 * appropriate flags and a callback function, you can get the attributes of a
2676 * file in the WIM, get a directory listing, or even get a listing of the entire
2680 * The WIM containing the image(s) over which to iterate, specified as a
2681 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2682 * or part 1 of a split WIM. In the case of a WIM file that is not
2683 * standalone, this ::WIMStruct should have had any needed external
2684 * resources previously referenced using wimlib_reference_resources() or
2685 * wimlib_reference_resource_files(). If not, see
2686 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2687 * the behavior when resources are missing.
2690 * The 1-based number of the image in @p wim that contains the files or
2691 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2692 * iteration on all images in the WIM.
2695 * Path in the WIM image at which to do the iteration.
2698 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2701 * A callback function that will receive each directory entry.
2704 * An extra parameter that will always be passed to the callback function
2707 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2708 * first nonzero value that was returned from @p cb. However, additional error
2709 * codes may be returned, including the following:
2711 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2712 * @p path did not exist in the WIM image.
2713 * @retval ::WIMLIB_ERR_NOMEM
2714 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2716 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2717 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2718 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2719 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2720 * different reasons) to read the metadata resource for an image over which
2721 * iteration needed to be done.
2724 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2726 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2729 * @ingroup G_wim_information
2731 * Iterate through the lookup table of a WIM file. This can be used to directly
2732 * get a listing of the unique resources contained in a WIM file over all
2733 * images. Both file resources and metadata resources are included. However,
2734 * only resources actually included in the file represented by @a wim, plus
2735 * explicitly referenced external resources (via wimlib_reference_resources() or
2736 * wimlib_reference_resource_files()) are included in the iteration. For
2737 * example, if @p wim represents just one part of a split WIM, then only
2738 * resources in that part will be included, unless other resources were
2739 * explicitly referenced.
2742 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2743 * to be standalone (e.g. it could be part of a split WIM).
2746 * Reserved; set to 0.
2749 * A callback function that will receive each resource.
2752 * An extra parameter that will always be passed to the callback function
2755 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
2756 * that was returned from @p cb.
2759 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2760 wimlib_iterate_lookup_table_callback_t cb,
2764 * @ingroup G_nonstandalone_wims
2766 * Joins a split WIM into a stand-alone one-part WIM.
2769 * An array of strings that gives the filenames of all parts of the split
2770 * WIM. No specific order is required, but all parts must be included with
2773 * Number of filenames in @p swms.
2774 * @param swm_open_flags
2775 * Open flags for the split WIM parts (e.g.
2776 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
2777 * @param wim_write_flags
2778 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
2779 * be used to write the joined WIM.
2780 * @param output_path
2781 * The path to write the joined WIM file to.
2782 * @param progress_func
2783 * If non-NULL, a function that will be called periodically with the
2784 * progress of the current operation.
2786 * @return 0 on success; nonzero on error. This function may return most error
2787 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
2788 * as the following error code:
2790 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2791 * The split WIMs do not form a valid WIM because they do not include all
2792 * the parts of the original WIM, there are duplicate parts, or not all the
2793 * parts have the same GUID and compression type.
2795 * Note: wimlib is generalized enough that this function is not actually needed
2796 * to join a split WIM; instead, you could open the first part of the split WIM,
2797 * then reference the other parts with wimlib_reference_resource_files(), then
2798 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
2799 * an easy-to-use wrapper around this that has some advantages (e.g. extra
2803 wimlib_join(const wimlib_tchar * const *swms,
2805 const wimlib_tchar *output_path,
2807 int wim_write_flags,
2808 wimlib_progress_func_t progress_func);
2812 * @ingroup G_mounting_wim_images
2814 * Mounts an image in a WIM file on a directory read-only or read-write.
2816 * As this is implemented using FUSE (Filesystme in UserSpacE), this is not
2817 * supported if wimlib was configured with @c --without-fuse. This includes
2818 * Windows builds of wimlib; ::WIMLIB_ERR_UNSUPPORTED will be returned in such
2821 * Calling this function daemonizes the process, unless
2822 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early occur occurs. If the
2823 * mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified), modifications
2824 * to the WIM are staged in a temporary directory.
2826 * It is safe to mount multiple images from the same underlying WIM file
2827 * read-only at the same time, but only if different ::WIMStruct's are used. It
2828 * is @b not safe to mount multiple images from the same WIM file read-write at
2831 * wimlib_mount_image() cannot be used on an image that was exported with
2832 * wimlib_export_image() while the dentry trees for both images are still in
2833 * memory. In addition, wimlib_mount_image() may not be used to mount an image
2834 * that already has modifications pending (e.g. an image added with
2835 * wimlib_add_image()).
2838 * Pointer to the ::WIMStruct containing the image to be mounted.
2840 * The number of the image to mount, indexed starting from it. It must be
2841 * an existing, single image.
2843 * The path to an existing empty directory to mount the image on.
2844 * @param mount_flags
2845 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
2846 * @param staging_dir
2847 * If non-NULL, the name of a directory in which the staging directory will
2848 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2849 * in @p mount_flags. If left @c NULL, the staging directory is created in
2850 * the same directory as the WIM file that @p wim was originally read from.
2852 * @return 0 on success; nonzero on error.
2854 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2855 * A read-write mount was requested, but an an exclusive advisory lock on
2856 * the on-disk WIM file could not be acquired because another thread or
2857 * process has mounted an image from the WIM read-write or is currently
2858 * modifying the WIM in-place.
2859 * @retval ::WIMLIB_ERR_FUSE
2860 * A non-zero status was returned by @c fuse_main().
2861 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2862 * @p image does not specify an existing, single image in @p wim.
2863 * @retval ::WIMLIB_ERR_INVALID_PARAM
2864 * @p image is shared among multiple ::WIMStruct's as a result of a call to
2865 * wimlib_export_image(), or @p image has been added with
2866 * wimlib_add_image().
2867 * @retval ::WIMLIB_ERR_MKDIR
2868 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
2869 * staging directory could not be created.
2870 * @retval ::WIMLIB_ERR_NOTDIR
2871 * Could not determine the current working directory.
2872 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2873 * One of the dentries in the image referenced a stream not present in the
2874 * WIM's lookup table (or in any of the lookup tables of the split WIM
2876 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2877 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but @p
2878 * wim is considered read-only because of any of the reasons mentioned in
2879 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2880 * @retval ::WIMLIB_ERR_UNSUPPORTED
2881 * Mounting is not supported, either because the platform is Windows, or
2882 * because the platform is UNIX-like and wimlib was compiled with @c
2885 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2886 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2887 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2888 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2889 * different reasons) to read the metadata resource for the image to mount.
2892 wimlib_mount_image(WIMStruct *wim,
2894 const wimlib_tchar *dir,
2896 const wimlib_tchar *staging_dir);
2899 * @ingroup G_creating_and_opening_wims
2901 * Opens a WIM file and creates a ::WIMStruct for it.
2904 * The path to the WIM file to open.
2907 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
2909 * @param progress_func
2910 * If non-NULL, a function that will be called periodically with the
2911 * progress of the current operation. Currently, the only messages sent
2912 * will be ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY, and only if
2913 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags.
2916 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2917 * is written to the memory location pointed to by this parameter. The
2918 * ::WIMStruct can be freed using using wimlib_free() when finished with
2921 * @return 0 on success; nonzero on error.
2922 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2923 * The WIM is not the non-first part of a split WIM, and the number of
2924 * metadata resources found in the WIM did not match the image count given
2925 * in the WIM header, or the number of <IMAGE> elements in the XML
2926 * data for the WIM did not match the image count given in the WIM header.
2927 * @retval ::WIMLIB_ERR_INTEGRITY
2928 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2929 * wim_file contains an integrity table, but the SHA1 message digest for a
2930 * chunk of the WIM does not match the corresponding message digest given
2931 * in the integrity table.
2932 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2933 * Resources in @p wim_file are compressed, but the chunk size was invalid
2934 * for the WIM's compression format.
2935 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2936 * The header of @p wim_file says that resources in the WIM are compressed,
2937 * but the header flag indicating LZX or XPRESS compression is not set.
2938 * @retval ::WIMLIB_ERR_INVALID_HEADER
2939 * The header of @p wim_file was otherwise invalid.
2940 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2941 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2942 * wim_file contains an integrity table, but the integrity table is
2944 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2945 * The lookup table for the WIM contained duplicate entries that are not
2946 * for metadata resources, or it contained an entry with a SHA1 message
2947 * digest of all 0's.
2948 * @retval ::WIMLIB_ERR_INVALID_PARAM
2949 * @p wim_ret was @c NULL.
2950 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
2951 * @p wim_file is a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
2952 * specified in @p open_flags.
2953 * @retval ::WIMLIB_ERR_NOMEM
2954 * Failed to allocated needed memory.
2955 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2956 * @p wim_file does not begin with the expected magic characters.
2957 * @retval ::WIMLIB_ERR_OPEN
2958 * Failed to open the file @p wim_file for reading.
2959 * @retval ::WIMLIB_ERR_READ
2960 * Failed to read data from @p wim_file.
2961 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2962 * Unexpected end-of-file while reading data from @p wim_file.
2963 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2964 * A number other than 0x10d00 is written in the version field of the WIM
2965 * header of @p wim_file. (May be a pre-Vista WIM.)
2966 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2967 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2968 * considered read-only because of any of the reasons mentioned in the
2969 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2970 * @retval ::WIMLIB_ERR_XML
2971 * The XML data for @p wim_file is invalid.
2974 wimlib_open_wim(const wimlib_tchar *wim_file,
2976 WIMStruct **wim_ret,
2977 wimlib_progress_func_t progress_func);
2980 * @ingroup G_writing_and_overwriting_wims
2982 * Overwrites the file that the WIM was originally read from, with changes made.
2983 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2984 * rather than wimlib_create_new_wim().
2986 * There are two ways that a WIM may be overwritten. The first is to do a full
2987 * rebuild. In this mode, the new WIM is written to a temporary file and then
2988 * renamed to the original file after it is has been completely written. The
2989 * temporary file is made in the same directory as the original WIM file. A
2990 * full rebuild may take a while, but can be used even if images have been
2991 * modified or deleted, will produce a WIM with no holes, and has little chance
2992 * of unintentional data loss because the temporary WIM is fsync()ed before
2993 * being renamed to the original WIM.
2995 * The second way to overwrite a WIM is by appending to the end of it and
2996 * overwriting the header. This can be much faster than a full rebuild, but the
2997 * disadvantage is that some space will be wasted. Writing a WIM in this mode
2998 * begins with writing any new file resources *after* everything in the old WIM,
2999 * even though this will leave a hole where the old lookup table, XML data, and
3000 * integrity were. This is done so that the WIM remains valid even if the
3001 * operation is aborted mid-write. The WIM header is only overwritten at the
3002 * very last moment, and up until that point the WIM will be seen as the old
3005 * By default, wimlib_overwrite() does the append-style overwrite described
3006 * above, unless resources in the WIM are arranged in an unusual way or if
3007 * images have been deleted from the WIM. Use the flag
3008 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3009 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3010 * images have been deleted from the WIM.
3012 * In the temporary-file overwrite mode, no changes are made to the WIM on
3013 * failure, and the temporary file is deleted if possible. Abnormal termination
3014 * of the program will result in the temporary file being orphaned. In the
3015 * direct append mode, the WIM is truncated to the original length on failure;
3016 * and while abnormal termination of the program will result in extra data
3017 * appended to the original WIM, it should still be a valid WIM.
3019 * If this function completes successfully, no more functions should be called
3020 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
3021 * the WIM file anew.
3024 * Pointer to the ::WIMStruct for the WIM file to write. There may have
3025 * been in-memory changes made to it, which are then reflected in the
3027 * @param write_flags
3028 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3029 * @param num_threads
3030 * Number of threads to use for compression (see wimlib_write()).
3031 * @param progress_func
3032 * If non-NULL, a function that will be called periodically with the
3033 * progress of the current operation.
3035 * @return 0 on success; nonzero on error. This function may return most error
3036 * codes returned by wimlib_write() as well as the following error codes:
3038 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3039 * The WIM was going to be modified in-place (with no temporary file), but
3040 * an exclusive advisory lock on the on-disk WIM file could not be acquired
3041 * because another thread or process has mounted an image from the WIM
3042 * read-write or is currently modifying the WIM in-place.
3043 * @retval ::WIMLIB_ERR_NO_FILENAME
3044 * @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
3045 * than a WIM read with wimlib_open_wim().
3046 * @retval ::WIMLIB_ERR_RENAME
3047 * The temporary file that the WIM was written to could not be renamed to
3048 * the original filename of @p wim.
3049 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3050 * The WIM file is considered read-only because of any of the reasons
3051 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3055 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
3056 wimlib_progress_func_t progress_func);
3059 * @ingroup G_wim_information
3061 * Prints information about one image, or all images, contained in a WIM.
3064 * Pointer to the ::WIMStruct for a WIM file.
3066 * The image about which to print information. Can be the number of an
3067 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3070 * @return This function has no return value. No error checking is done when
3071 * printing the information. If @p image is invalid, an error message is
3075 wimlib_print_available_images(const WIMStruct *wim, int image);
3078 * @ingroup G_wim_information
3080 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3081 * in a way that can be accessed programatically.
3084 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3087 * @ingroup G_wim_information
3089 * Deprecated in favor of wimlib_iterate_dir_tree(), which provides the
3090 * information in a way that can be accessed programatically.
3093 wimlib_print_metadata(WIMStruct *wim, int image) _wimlib_deprecated;
3096 * @ingroup G_nonstandalone_wims
3098 * Reference resources from other WIM files or split WIM parts. This function
3099 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3100 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3101 * from other files, before calling a function such as wimlib_extract_image()
3102 * that requires the resources to be present.
3105 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3106 * necessarily "standalone". In the case of split WIMs, this should be the
3107 * first part, since only the first part contains the metadata resources.
3108 * In the case of delta WIMs, this should be the delta WIM rather than the
3109 * WIM on which it is based.
3110 * @param resource_wimfiles_or_globs
3111 * Array of paths to WIM files and/or split WIM parts to reference.
3112 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3113 * ref_flags, these are treated as globs rather than literal paths. That
3114 * is, using this function you can specify zero or more globs, each of
3115 * which expands to one or more literal paths.
3117 * Number of entries in @p resource_wimfiles_or_globs.
3119 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3120 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3122 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3123 * pass to internal calls to wimlib_open_wim() on the reference files.
3124 * @param progress_func
3125 * Passed to internal calls to wimlib_open_wim() on the reference files.
3127 * @return 0 on success; nonzero on error.
3129 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3130 * One of the specified globs did not match any paths (only with both
3131 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3132 * specified in @p ref_flags).
3133 * @retval ::WIMLIB_ERR_NOMEM
3134 * Failed to allocate memory.
3135 * @retval ::WIMLIB_ERR_READ
3136 * I/O or permissions error while processing a file glob.
3138 * This function can additionally return most values that can be returned by
3139 * wimlib_open_wim().
3142 wimlib_reference_resource_files(WIMStruct *wim,
3143 const wimlib_tchar * const *resource_wimfiles_or_globs,
3147 wimlib_progress_func_t progress_func);
3150 * @ingroup G_nonstandalone_wims
3152 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3153 * where the caller must open the ::WIMStruct for each referenced file itself.
3156 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3157 * necessarily "standalone". In the case of split WIMs, this should be the
3158 * first part, since only the first part contains the metadata resources.
3159 * @param resource_wims
3160 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3161 * split WIM parts to reference.
3162 * @param num_resource_wims
3163 * Number of entries in @p resource_wims.
3165 * Currently ignored (set to 0).
3167 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3168 * @p resource_wims are referenced internally by @p wim and must not be freed
3169 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3170 * been freed with wimlib_free(), or immediately before freeing @p wim with
3173 * @retval ::WIMLIB_ERR_INVALID_PARAM
3174 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3175 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3176 * @retval ::WIMLIB_ERR_NOMEM
3177 * Failed to allocate memory.
3180 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3181 unsigned num_resource_wims, int ref_flags);
3184 * @ingroup G_modifying_wims
3186 * Declares that a newly added image is mostly the same as a prior image, but
3187 * captured at a later point in time, possibly with some modifications in the
3188 * intervening time. This is designed to be used in incremental backups of the
3189 * same filesystem or directory tree.
3191 * This function compares the metadata of the directory tree of the newly added
3192 * image against that of the old image. Any files that are present in both the
3193 * newly added image and the old image and have timestamps that indicate they
3194 * haven't been modified are deemed not to have been modified and have their
3195 * SHA1 message digest copied from the old image. Because of this and because
3196 * WIM uses single-instance streams, such files need not be read from the
3197 * filesystem when the WIM is being written or overwritten. Note that these
3198 * unchanged files will still be "archived" and will be logically present in the
3199 * new image; the optimization is that they don't need to actually be read from
3200 * the filesystem because the WIM already contains them.
3202 * This function is provided to optimize incremental backups. The resulting WIM
3203 * file will still be the same regardless of whether this function is called.
3204 * (This is, however, assuming that timestamps have not been manipulated or
3205 * unmaintained as to trick this function into thinking a file has not been
3206 * modified when really it has. To partly guard against such cases, other
3207 * metadata such as file sizes will be checked as well.)
3209 * This function must be called after adding the new image (e.g. with
3210 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3211 * wimlib_overwrite()).
3214 * Pointer to the ::WIMStruct for a WIM.
3216 * 1-based index in the WIM of the newly added image. This image can have
3217 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3218 * wimlib_add_empty_image() followed by wimlib_update_image().
3219 * @param template_wim
3220 * The ::WIMStruct for the WIM containing the template image. This can be
3221 * the same as @p wim, or it can be a different ::WIMStruct.
3222 * @param template_image
3223 * 1-based index in the WIM of a template image that reflects a prior state
3224 * of the directory tree being captured.
3226 * Reserved; must be 0.
3227 * @param progress_func
3228 * Currently ignored, but reserved for a function that will be called with
3229 * information about the operation. Use NULL if no additional information
3232 * @return 0 on success; nonzero on error.
3234 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3235 * @p new_image and/or @p template_image were not a valid image indices in
3237 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3238 * The specified ::WIMStruct did not actually contain the metadata resource
3239 * for the new or template image; for example, it was a non-first part of a
3241 * @retval ::WIMLIB_ERR_NOMEM
3242 * Failed to allocate needed memory.
3243 * @retval ::WIMLIB_ERR_INVALID_PARAM
3244 * @p new_image was equal to @p template_image, or @p new_image specified
3245 * an image that had not been modified since opening the WIM.
3247 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3248 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3249 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3250 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3251 * different reasons) to read the metadata resource for the template image.
3254 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3255 WIMStruct *template_wim, int template_image,
3256 int flags, wimlib_progress_func_t progress_func);
3259 * @ingroup G_wim_information
3261 * Translates a string specifying the name or number of an image in the WIM into
3262 * the number of the image. The images are numbered starting at 1.
3265 * Pointer to the ::WIMStruct for a WIM.
3266 * @param image_name_or_num
3267 * A string specifying the name or number of an image in the WIM. If it
3268 * parses to a positive integer, this integer is taken to specify the
3269 * number of the image, indexed starting at 1. Otherwise, it is taken to
3270 * be the name of an image, as given in the XML data for the WIM file. It
3271 * also may be the keyword "all" or the string "*", both of which will
3272 * resolve to ::WIMLIB_ALL_IMAGES.
3274 * There is no way to search for an image actually named "all", "*", or an
3275 * integer number, or an image that has no name. However, you can use
3276 * wimlib_get_image_name() to get the name of any image.
3279 * If the string resolved to a single existing image, the number of that
3280 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3281 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3282 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3283 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3284 * images in @p wim has no name.
3287 wimlib_resolve_image(WIMStruct *wim,
3288 const wimlib_tchar *image_name_or_num);
3291 * @ingroup G_modifying_wims
3293 * Changes the description of an image in the WIM.
3296 * Pointer to the ::WIMStruct for a WIM.
3298 * The number of the image for which to change the description.
3299 * @param description
3300 * The new description to give the image. It may be @c NULL, which
3301 * indicates that the image is to be given no description.
3303 * @return 0 on success; nonzero on error.
3304 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3305 * @p image does not specify a single existing image in @p wim.
3306 * @retval ::WIMLIB_ERR_NOMEM
3307 * Failed to allocate the memory needed to duplicate the @p description
3309 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3310 * @p wim is considered read-only because of any of the reasons mentioned
3311 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3314 wimlib_set_image_descripton(WIMStruct *wim, int image,
3315 const wimlib_tchar *description);
3318 * @ingroup G_writing_and_overwriting_wims
3320 * Set the compression chunk size of a WIM to use in subsequent calls to
3321 * wimlib_write() or wimlib_overwrite().
3323 * A compression chunk size will result in a greater compression ratio, but the
3324 * speed of random access to the WIM will be reduced, and the effect of an
3325 * increased compression chunk size is limited by the size of each file being
3328 * <b>WARNING: Microsoft's software is seemingly incompatible with LZX chunk
3329 * sizes other than 32768. Chunk sizes other than 32768 (for any format) are
3330 * also incompatible with wimlib v1.5.3 and earlier.</b>
3333 * ::WIMStruct for a WIM.
3334 * @param out_chunk_size
3335 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3336 * on the compression format. The XPRESS compression format supports chunk
3337 * sizes that are powers of 2 with exponents between 15 and 26 inclusively,
3338 * whereas the LZX compression format supports chunk sizes that are powers
3339 * of 2 with exponents between 15 and 21 inclusively. As a special case,
3340 * if @p out_chunk_size is specified as 0, the chunk size is set to the
3341 * default for the currently selected output compression type.
3343 * @return 0 on success; nonzero on error.
3345 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3346 * @p ctype is not a supported chunk size.
3349 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3352 * @ingroup G_writing_and_overwriting_wims
3354 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3358 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3361 * @ingroup G_writing_and_overwriting_wims
3363 * Set the compression type of a WIM to use in subsequent calls to
3364 * wimlib_write() or wimlib_overwrite().
3367 * ::WIMStruct for a WIM.
3369 * The compression type to set (one of ::wimlib_compression_type). If this
3370 * compression type is incompatible with the current output chunk size
3371 * (either the default or as set with wimlib_set_output_chunk_size()), the
3372 * output chunk size is reset to the default for that compression type.
3374 * @return 0 on success; nonzero on error.
3376 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3377 * @p ctype did not specify a valid compression type.
3380 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3383 * @ingroup G_writing_and_overwriting_wims
3385 * Similar to wimlib_set_output_compression_type(), but set the compression type
3386 * for writing packed streams.
3389 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3392 * @ingroup G_modifying_wims
3394 * Set basic information about a WIM.
3397 * Pointer to the ::WIMStruct for a WIM.
3399 * A struct ::wimlib_wim_info that contains the information to set. Only
3400 * the information explicitly specified in the @p which flags need be
3403 * Flags that specify which information to set. This is a bitwise OR of
3404 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3405 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3407 * @return 0 on success; nonzero on failure.
3408 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3409 * The WIM file is considered read-only because of any of the reasons
3410 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3411 * flag. However, as a special case, if you are using
3412 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3413 * function will not fail due to the readonly flag being previously set.
3414 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3415 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3416 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3420 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3424 * @ingroup G_modifying_wims
3426 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3427 * (something like "Core" or "Ultimate")
3430 * Pointer to the ::WIMStruct for a WIM.
3432 * The number of the image for which to change the description.
3434 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3435 * indicates that the image is to be given no \<FLAGS\> element.
3437 * @return 0 on success; nonzero on error.
3438 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3439 * @p image does not specify a single existing image in @p wim.
3440 * @retval ::WIMLIB_ERR_NOMEM
3441 * Failed to allocate the memory needed to duplicate the @p flags string.
3442 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3443 * @p wim is considered read-only because of any of the reasons mentioned
3444 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3447 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3450 * @ingroup G_modifying_wims
3452 * Changes the name of an image in the WIM.
3455 * Pointer to the ::WIMStruct for a WIM.
3457 * The number of the image for which to change the name.
3459 * New name to give the new image. If @c NULL or empty, the new image is
3460 * given no name. If nonempty, it must specify a name that does not
3461 * already exist in @p wim.
3463 * @return 0 on success; nonzero on error.
3464 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3465 * There is already an image named @p name in @p wim.
3466 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3467 * @p image does not specify a single existing image in @p wim.
3468 * @retval ::WIMLIB_ERR_NOMEM
3469 * Failed to allocate the memory needed to duplicate the @p name string.
3470 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3471 * @p wim is considered read-only because of any of the reasons mentioned
3472 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3475 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3478 * @ingroup G_general
3480 * Set the functions that wimlib uses to allocate and free memory.
3482 * These settings are global and not per-WIM.
3484 * The default is to use the default @c malloc() and @c free() from the C
3487 * Please note that some external functions, such as those in @c libntfs-3g, may
3488 * use the standard memory allocation functions.
3490 * @param malloc_func
3491 * A function equivalent to @c malloc() that wimlib will use to allocate
3492 * memory. If @c NULL, the allocator function is set back to the default
3493 * @c malloc() from the C library.
3495 * A function equivalent to @c free() that wimlib will use to free memory.
3496 * If @c NULL, the free function is set back to the default @c free() from
3498 * @param realloc_func
3499 * A function equivalent to @c realloc() that wimlib will use to reallocate
3500 * memory. If @c NULL, the free function is set back to the default @c
3501 * realloc() from the C library.
3505 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3506 void (*free_func)(void *),
3507 void *(*realloc_func)(void *, size_t));
3510 * @ingroup G_general
3512 * Sets whether wimlib is to print error messages to @c stderr when a function
3513 * fails. These error messages may provide information that cannot be
3514 * determined only from the error code that is returned. Not every error will
3515 * result in an error message being printed.
3517 * This setting is global and not per-WIM.
3519 * By default, error messages are not printed.
3521 * This can be called before wimlib_global_init().
3523 * @param show_messages
3524 * @c true if error messages are to be printed; @c false if error messages
3525 * are not to be printed.
3527 * @return 0 on success; nonzero on error.
3528 * @retval ::WIMLIB_ERR_UNSUPPORTED
3529 * @p show_messages was @c true, but wimlib was compiled with the @c
3530 * --without-error-messages option. Therefore, error messages cannot be
3534 wimlib_set_print_errors(bool show_messages);
3537 * @ingroup G_nonstandalone_wims
3539 * Splits a WIM into multiple parts.
3542 * The ::WIMStruct for the WIM to split.
3544 * Name of the SWM file to create. This will be the name of the first
3545 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3546 * appended before the suffix.
3548 * The maximum size per part, in bytes. Unfortunately, it is not
3549 * guaranteed that this will really be the maximum size per part, because
3550 * some file resources in the WIM may be larger than this size, and the WIM
3551 * file format provides no way to split up file resources among multiple
3553 * @param write_flags
3554 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3555 * flags will be used to write each split WIM part. Specify 0 here to get
3556 * the default behavior.
3557 * @param progress_func
3558 * If non-NULL, a function that will be called periodically with the
3559 * progress of the current operation
3560 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3561 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
3563 * @return 0 on success; nonzero on error. This function may return most error
3564 * codes that can be returned by wimlib_write() as well as the following error
3567 * @retval ::WIMLIB_ERR_INVALID_PARAM
3568 * @p swm_name was not a nonempty string, or @p part_size was 0.
3570 * Note: the WIM's uncompressed and compressed resources are not checksummed
3571 * when they are copied from the joined WIM to the split WIM parts, nor are
3572 * compressed resources re-compressed (unless explicitly requested with
3573 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
3576 wimlib_split(WIMStruct *wim,
3577 const wimlib_tchar *swm_name,
3580 wimlib_progress_func_t progress_func);
3583 * @ingroup G_mounting_wim_images
3585 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3587 * The image to unmount is specified by the path to the mountpoint, not the
3588 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
3589 * touched and also may have been allocated in a different process.
3591 * To unmount the image, the process calling this function communicates with the
3592 * process that is managing the mounted WIM image. This function blocks until it
3593 * is known whether the unmount succeeded or failed. In the case of a
3594 * read-write mounted WIM, the unmount is not considered to have succeeded until
3595 * all changes have been saved to the underlying WIM file.
3598 * The directory that the WIM image was mounted on.
3599 * @param unmount_flags
3600 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
3601 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
3602 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
3604 * @param progress_func
3605 * If non-NULL, a function that will be called periodically with the
3606 * progress of the current operation. Currently, only
3607 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS will be sent.
3609 * @return 0 on success; nonzero on error.
3611 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
3612 * The filesystem daemon was unable to remove the staging directory and the
3613 * temporary files that it contains.
3614 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
3615 * The filesystem daemon appears to have terminated before sending an exit
3617 * @retval ::WIMLIB_ERR_FORK
3618 * Could not @c fork() the process.
3619 * @retval ::WIMLIB_ERR_FUSERMOUNT
3620 * The @b fusermount program could not be executed or exited with a failure
3622 * @retval ::WIMLIB_ERR_MQUEUE
3623 * Could not open a POSIX message queue to communicate with the filesystem
3624 * daemon servicing the mounted filesystem, could not send a message
3625 * through the queue, or could not receive a message through the queue.
3626 * @retval ::WIMLIB_ERR_NOMEM
3627 * Failed to allocate needed memory.
3628 * @retval ::WIMLIB_ERR_OPEN
3629 * The filesystem daemon could not open a temporary file for writing the
3631 * @retval ::WIMLIB_ERR_READ
3632 * A read error occurred when the filesystem daemon tried to a file from
3633 * the staging directory
3634 * @retval ::WIMLIB_ERR_RENAME
3635 * The filesystem daemon failed to rename the newly written WIM file to the
3636 * original WIM file.
3637 * @retval ::WIMLIB_ERR_UNSUPPORTED
3638 * Mounting is not supported, either because the platform is Windows, or
3639 * because the platform is UNIX-like and wimlib was compiled with @c
3641 * @retval ::WIMLIB_ERR_WRITE
3642 * A write error occurred when the filesystem daemon was writing to the new
3643 * WIM file, or the filesystem daemon was unable to flush changes that had
3644 * been made to files in the staging directory.
3647 wimlib_unmount_image(const wimlib_tchar *dir,
3649 wimlib_progress_func_t progress_func);
3652 * @ingroup G_modifying_wims
3654 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3657 * Pointer to the ::WIMStruct for the WIM file to update.
3659 * The 1-based index of the image in the WIM to update. It cannot be
3660 * ::WIMLIB_ALL_IMAGES.
3662 * An array of ::wimlib_update_command's that specify the update operations
3665 * Number of commands in @p cmds.
3666 * @param update_flags
3667 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3668 * @param progress_func
3669 * If non-NULL, a function that will be called periodically with the
3670 * progress of the current operation.
3672 * @return 0 on success; nonzero on error. On failure, some but not all of the
3673 * update commands may have been executed. No individual update command will
3674 * have been partially executed. Possible error codes include:
3676 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3677 * The capture configuration structure specified for an add command was
3679 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3680 * @p image did not specify a single, existing image in @p wim.
3681 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3682 * Attempted to perform an add command that conflicted with previously
3683 * existing files in the WIM when an overlay was attempted.
3684 * @retval ::WIMLIB_ERR_INVALID_PARAM
3685 * An unknown operation type was specified in the update commands; or,
3686 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3687 * in the @p add_flags, but the same image had previously already been
3688 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3689 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3690 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3691 * specified in the @p add_flags for an add command in which @p
3692 * wim_target_path was not the root directory of the WIM image.
3693 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3694 * (Windows only): While executing an add command, tried to capture a
3695 * reparse point with invalid data.
3696 * @retval ::WIMLIB_ERR_IS_DIRECTORY
3697 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3698 * for a WIM path that corresponded to a directory; or, a rename command
3699 * attempted to rename a directory to a non-directory.
3700 * @retval ::WIMLIB_ERR_NOMEM
3701 * Failed to allocate needed memory.
3702 * @retval ::WIMLIB_ERR_NOTDIR
3703 * A rename command attempted to rename a directory to a non-directory; or,
3704 * an add command was executed that attempted to set the root of the WIM
3705 * image as a non-directory; or, a path component used as a directory in a
3706 * rename command was not, in fact, a directory.
3707 * @retval ::WIMLIB_ERR_NOTEMPTY
3708 * A rename command attempted to rename a directory to a non-empty
3710 * @retval ::WIMLIB_ERR_NTFS_3G
3711 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3712 * error occurred while reading data from the NTFS volume using libntfs-3g.
3713 * @retval ::WIMLIB_ERR_OPEN
3714 * Failed to open a file to be captured while executing an add command.
3715 * @retval ::WIMLIB_ERR_OPENDIR
3716 * Failed to open a directory to be captured while executing an add command.
3717 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3718 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3719 * WIM path that did not exist; or, a rename command attempted to rename a
3720 * file that does not exist.
3721 * @retval ::WIMLIB_ERR_READ
3722 * While executing an add command, failed to read data from a file or
3723 * directory to be captured.
3724 * @retval ::WIMLIB_ERR_READLINK
3725 * While executing an add command, failed to read the target of a symbolic
3726 * link or junction point.
3727 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3728 * (Windows only) Failed to perform a reparse point fixup because of
3729 * problems with the data of a reparse point.
3730 * @retval ::WIMLIB_ERR_STAT
3731 * While executing an add command, failed to get attributes for a file or
3733 * @retval ::WIMLIB_ERR_UNSUPPORTED
3734 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
3735 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
3736 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3737 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
3738 * add_flags for an update command.
3739 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
3740 * While executing an add command, attempted to capture a file that was not
3741 * a supported file type (e.g. a device file). Only if
3742 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
3743 * for an update command.
3744 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3745 * The WIM file is considered read-only because of any of the reasons
3746 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3749 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3750 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3751 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3752 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3753 * different reasons) to read the metadata resource for an image that needed to
3757 wimlib_update_image(WIMStruct *wim,
3759 const struct wimlib_update_command *cmds,
3762 wimlib_progress_func_t progress_func);
3765 * @ingroup G_writing_and_overwriting_wims
3767 * Writes a WIM to a file.
3769 * This brings in resources from any external locations, such as directory trees
3770 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3771 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3773 * By default, the new WIM file is written as stand-alone. Using the
3774 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
3775 * instead. However, this function cannot directly write a "split" WIM; use
3776 * wimlib_split() for that.
3779 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
3780 * changes made to it, which are then reflected in the output file.
3782 * The path to the file to write the WIM to.
3784 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
3785 * images are to be included in the new on-disk WIM file. If for some
3786 * reason you only want to include a single image, specify the index of
3787 * that image instead.
3788 * @param write_flags
3789 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3790 * @param num_threads
3791 * Number of threads to use for compressing data. If 0, the number of
3792 * threads is taken to be the number of online processors. Note: if no
3793 * data compression needs to be done, no additional threads will be created
3794 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
3795 * exporting an image from a compressed WIM to another WIM of the same
3796 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
3798 * @param progress_func
3799 * If non-NULL, a function that will be called periodically with the
3800 * progress of the current operation. The possible messages are
3801 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3802 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3803 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3805 * @return 0 on success; nonzero on error.
3807 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3808 * @p image does not specify a single existing image in @p wim, and is not
3809 * ::WIMLIB_ALL_IMAGES.
3810 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3811 * A file that had previously been scanned for inclusion in the WIM by
3812 * wimlib_add_image() was concurrently modified, so it failed the SHA1
3813 * message digest check.
3814 * @retval ::WIMLIB_ERR_INVALID_PARAM
3815 * @p path was @c NULL.
3816 * @retval ::WIMLIB_ERR_NOMEM
3817 * Failed to allocate needed memory.
3818 * @retval ::WIMLIB_ERR_OPEN
3819 * Failed to open @p path for writing, or some file resources in @p wim
3820 * refer to files in the outside filesystem, and one of these files could
3821 * not be opened for reading.
3822 * @retval ::WIMLIB_ERR_READ
3823 * An error occurred when trying to read data from the WIM file associated
3824 * with @p wim, or some file resources in @p wim refer to files in the
3825 * outside filesystem, and a read error occurred when reading one of these
3827 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3828 * A stream that needed to be written could not be found in the stream
3829 * lookup table of @p wim. This error can occur if, for example, @p wim is
3830 * part of a split WIM but needed resources from the other split WIM parts
3831 * were not referenced with wimlib_reference_resources() or
3832 * wimlib_reference_resource_files() before the call to wimlib_write().
3833 * @retval ::WIMLIB_ERR_WRITE
3834 * An error occurred when trying to write data to the new WIM file.
3836 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3837 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3838 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3839 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3840 * different reasons) to read the metadata resource for an image that needed to
3844 wimlib_write(WIMStruct *wim,
3845 const wimlib_tchar *path,
3848 unsigned num_threads,
3849 wimlib_progress_func_t progress_func);
3852 * @ingroup G_writing_and_overwriting_wims
3854 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
3855 * file descriptor, which need not be seekable if the write is done in a special
3856 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
3857 * write_flags. This can, for example, allow capturing a WIM image and
3858 * streaming it over the network. See the documentation for
3859 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
3861 * The file descriptor @p fd will @b not be closed when the write is complete;
3862 * the calling code is responsible for this.
3864 * Returns 0 on success; nonzero on failure. The possible error codes include
3865 * those that can be returned by wimlib_write() as well as the following:
3867 * @retval ::WIMLIB_ERR_INVALID_PARAM
3868 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
3869 * specified in @p write_flags.
3872 wimlib_write_to_fd(WIMStruct *wim,
3876 unsigned num_threads,
3877 wimlib_progress_func_t progress_func);
3880 * @defgroup G_compression Compression and decompression functions
3882 * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
3883 * exported for convenience only, as they are already used by wimlib internally
3886 * These functions can be used for general-purpose lossless data compression,
3887 * but some limitations apply; for example, none of the compressors or
3888 * decompressors currently support sliding windows, and there also exist
3889 * slightly different variants of these formats that are not supported
3894 * @ingroup G_compression
3898 /** Header for compression parameters to pass to wimlib_create_compressor() or
3899 * wimlib_set_default_compressor_params(). */
3900 struct wimlib_compressor_params_header {
3901 /** Size of the parameters, in bytes. */
3905 /** Header for decompression parameters to pass to wimlib_create_decompressor()
3906 * or wimlib_set_default_decompressor_params() */
3907 struct wimlib_decompressor_params_header {
3908 /** Size of the parameters, in bytes. */
3912 /** LZX compression parameters that can optionally be passed to
3913 * wimlib_create_compressor() with the compression type
3914 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
3915 struct wimlib_lzx_compressor_params {
3916 /** hdr.size Must be set to the size of this structure, in bytes. */
3917 struct wimlib_compressor_params_header hdr;
3919 /** Relatively fast LZX compression algorithm with a decent compression
3920 * ratio; the suggested default. */
3921 #define WIMLIB_LZX_ALGORITHM_FAST 0
3923 /** Slower LZX compression algorithm that provides a better compression
3925 #define WIMLIB_LZX_ALGORITHM_SLOW 1
3927 /** Algorithm to use to perform the compression: either
3928 * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW. The
3929 * format is still LZX; this refers to the method the code will use to
3930 * perform LZX-compatible compression. */
3931 uint32_t algorithm : 3;
3933 /** If set to 1, the default parameters for the specified algorithm are
3934 * used rather than the ones specified in the following union. */
3935 uint32_t use_defaults : 1;
3938 /** Parameters for the fast algorithm. */
3939 struct wimlib_lzx_fast_params {
3940 uint32_t fast_reserved1[10];
3943 /** Parameters for the slow algorithm. */
3944 struct wimlib_lzx_slow_params {
3945 /** If set to 1, the compressor can output length 2
3946 * matches. If set 0, the compressor only outputs
3947 * matches of length 3 or greater. Suggested value: 1
3949 uint32_t use_len2_matches : 1;
3951 uint32_t slow_reserved1 : 31;
3953 /** Matches with length (in bytes) longer than this
3954 * value are immediately taken without spending time on
3955 * minimum-cost measurements. Suggested value: 32. */
3956 uint32_t num_fast_bytes;
3958 /** Number of passes to compute a match/literal sequence
3959 * for each LZX block. This is for an iterative
3960 * algorithm that attempts to minimize the cost of the
3961 * match/literal sequence by using a cost model provided
3962 * by the previous iteration. Must be at least 1.
3963 * Suggested value: 2. */
3964 uint32_t num_optim_passes;
3966 /** Reserved; set to 0. */
3967 uint32_t slow_reserved_blocksplit;
3969 /** Maximum depth to search for matches at each
3970 * position. Suggested value: 50. */
3971 uint32_t max_search_depth;
3973 /** Maximum number of potentially good matches to
3974 * consider for each position. Suggested value: 3. */
3975 uint32_t max_matches_per_pos;
3977 uint32_t slow_reserved2[2];
3979 /** Assumed cost of a main symbol with zero frequency.
3980 * Must be at least 1 and no more than 16. Suggested
3982 uint8_t main_nostat_cost;
3984 /** Assumed cost of a length symbol with zero frequency.
3985 * Must be at least 1 and no more than 16. Suggested
3987 uint8_t len_nostat_cost;
3989 /** Assumed cost of an aligned symbol with zero
3990 * frequency. Must be at least 1 and no more than 8.
3991 * Suggested value: 7. */
3992 uint8_t aligned_nostat_cost;
3994 uint8_t slow_reserved3[5];
3999 /** Opaque compressor handle. */
4000 struct wimlib_compressor;
4002 /** Opaque decompressor handle. */
4003 struct wimlib_decompressor;
4006 * Set the default compression parameters for the specified compression type.
4007 * This will affect both explicit and wimlib-internal calls to
4008 * wimlib_create_compressor().
4011 * Compression type for which to set the default compression parameters.
4013 * Compression-type specific parameters. This may be @c NULL, in which
4014 * case the "default default" parameters are restored.
4016 * @return 0 on success; nonzero on error.
4018 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4019 * @p ctype was not a supported compression type.
4020 * @retval ::WIMLIB_ERR_NOMEM
4021 * Not enough memory to duplicate the parameters (perhaps @c params->size
4025 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
4026 const struct wimlib_compressor_params_header *params);
4029 * Allocate a compressor for the specified compression type using the specified
4033 * Compression type for which to create the compressor.
4034 * @param max_block_size
4035 * Maximum block size to support. The exact meaning and allowed values for
4036 * this parameter depend on the compression type, but it at least specifies
4037 * the maximum allowed value for @p uncompressed_size to wimlib_compress().
4038 * @param extra_params
4039 * An optional pointer to extra compressor parameters for the specified
4040 * compression type. For LZX, a pointer to ::wimlib_lzx_compressor_params
4041 * may be specified here. If left @c NULL, the default parameters are
4043 * @param compressor_ret
4044 * A location into which to return the pointer to the allocated compressor,
4045 * which can be used for any number of calls to wimlib_compress() before
4046 * being freed with wimlib_free_compressor().
4048 * @return 0 on success; nonzero on error.
4050 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4051 * @p ctype was not a supported compression type.
4052 * @retval ::WIMLIB_ERR_INVALID_PARAM
4053 * The compression parameters were invalid.
4054 * @retval ::WIMLIB_ERR_NOMEM
4055 * Insufficient memory to allocate the compressor.
4058 wimlib_create_compressor(enum wimlib_compression_type ctype,
4059 size_t max_block_size,
4060 const struct wimlib_compressor_params_header *extra_params,
4061 struct wimlib_compressor **compressor_ret);
4064 * Losslessly compress a block of data using a compressor previously created
4065 * with wimlib_create_compressor().
4067 * @param uncompressed_data
4068 * Buffer containing the data to compress.
4069 * @param uncompressed_size
4070 * Size, in bytes, of the data to compress.
4071 * @param compressed_data
4072 * Buffer into which to write the compressed data.
4073 * @param compressed_size_avail
4074 * Number of bytes available in @p compressed_data.
4076 * A compressor previously allocated with wimlib_create_compressor().
4079 * The size of the compressed data, in bytes, or 0 if the input data could
4080 * not be compressed to @p compressed_size_avail or fewer bytes.
4083 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4084 void *compressed_data, size_t compressed_size_avail,
4085 struct wimlib_compressor *compressor);
4088 * Free a compressor previously allocated with wimlib_create_compressor().
4091 * The compressor to free.
4094 wimlib_free_compressor(struct wimlib_compressor *compressor);
4097 * Set the default decompression parameters for the specified compression type.
4098 * This will affect both explicit and wimlib-internal calls to
4099 * wimlib_create_decompressor().
4102 * Compression type for which to set the default decompression parameters.
4104 * Compression-type specific parameters. This may be @c NULL, in which
4105 * case the "default default" parameters are restored.
4107 * @return 0 on success; nonzero on error.
4109 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4110 * @p ctype was not a supported compression type.
4111 * @retval ::WIMLIB_ERR_NOMEM
4112 * Not enough memory to duplicate the parameters (perhaps @c params->size
4116 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4117 const struct wimlib_decompressor_params_header *params);
4120 * Allocate a decompressor for the specified compression type using the
4121 * specified parameters.
4124 * Compression type for which to create the decompressor.
4125 * @param max_block_size
4126 * Maximum block size to support. The exact meaning and allowed values for
4127 * this parameter depend on the compression type, but it at least specifies
4128 * the maximum allowed value for @p uncompressed_size to
4129 * wimlib_decompress().
4130 * @param extra_params
4131 * An optional pointer to extra decompressor parameters for the specified
4132 * compression type. If @c NULL, the default parameters are used.
4133 * @param decompressor_ret
4134 * A location into which to return the pointer to the allocated
4135 * decompressor, which can be used for any number of calls to
4136 * wimlib_decompress() before being freed with wimlib_free_decompressor().
4138 * @return 0 on success; nonzero on error.
4140 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4141 * @p ctype was not a supported compression type.
4142 * @retval ::WIMLIB_ERR_INVALID_PARAM
4143 * The decompression parameters were invalid.
4144 * @retval ::WIMLIB_ERR_NOMEM
4145 * Insufficient memory to allocate the decompressor.
4148 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4149 size_t max_block_size,
4150 const struct wimlib_decompressor_params_header *extra_params,
4151 struct wimlib_decompressor **decompressor_ret);
4154 * Decompress a block of data using a decompressor previously created with
4155 * wimlib_create_decompressor().
4157 * @param compressed_data
4158 * Buffer containing the data to decompress.
4159 * @param compressed_size
4160 * Size, in bytes, of the data to decompress.
4161 * @param uncompressed_data
4162 * Buffer into which to write the uncompressed data.
4163 * @param uncompressed_size
4164 * Size, in bytes, of the data when uncompressed.
4165 * @param decompressor
4166 * A decompressor previously allocated with wimlib_create_decompressor().
4168 * @return 0 on success; nonzero on error.
4171 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4172 void *uncompressed_data, size_t uncompressed_size,
4173 struct wimlib_decompressor *decompressor);
4176 * Free a decompressor previously allocated with wimlib_create_decompressor().
4178 * @param decompressor
4179 * The decompressor to free.
4182 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4185 struct wimlib_lzx_params_old;
4186 struct wimlib_lzx_context_old;
4188 /** Deprecated; do not use. */
4190 wimlib_lzx_set_default_params(const struct wimlib_lzx_params_old *params)
4193 /** Deprecated; do not use. */
4195 wimlib_lzx_alloc_context(const struct wimlib_lzx_params_old *params,
4196 struct wimlib_lzx_context_old **ctx_pp)
4199 /** Deprecated; do not use. */
4201 wimlib_lzx_free_context(struct wimlib_lzx_context_old *ctx)
4204 /** Deprecated; do not use. */
4206 wimlib_lzx_compress2(const void *udata, unsigned ulen, void *cdata,
4207 struct wimlib_lzx_context_old *ctx)
4210 /** Deprecated; do not use. */
4212 wimlib_lzx_compress(const void *udata, unsigned ulen, void *cdata)
4215 /** Deprecated; do not use. */
4217 wimlib_xpress_compress(const void *udata, unsigned ulen, void *cdata)
4220 /** Deprecated; do not use. */
4222 wimlib_lzx_decompress(const void *cdata, unsigned clen,
4223 void *udata, unsigned ulen)
4226 /** Deprecated; do not use. */
4228 wimlib_xpress_decompress(const void *cdata, unsigned clen,
4229 void *udata, unsigned ulen)
4240 #endif /* _WIMLIB_H */