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 and
606 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
607 struct wimlib_progress_info_scan {
608 /** Directory or NTFS volume that is being scanned. */
609 const wimlib_tchar *source;
611 /** Path to the file or directory that is about to be scanned,
612 * relative to the root of the image capture or the NTFS volume.
614 const wimlib_tchar *cur_path;
617 /** File or directory looks okay and will be captured. */
618 WIMLIB_SCAN_DENTRY_OK = 0,
620 /** File or directory is being excluded from capture due
621 * to the capture configuration file, or being an
622 * absolute symbolic link that points outside of the
623 * capture directory without ::WIMLIB_ADD_FLAG_NORPFIX.
625 WIMLIB_SCAN_DENTRY_EXCLUDED,
627 /** File or directory is being excluded from capture due
628 * to being unsupported (e.g. an encrypted or device
630 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
633 /** Target path in the WIM. Only valid on messages
634 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
635 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
636 const wimlib_tchar *wim_target_path;
638 /** Number of directories scanned so far, including the root
639 * directory but excluding any unsupported/excluded directories.
641 uint64_t num_dirs_scanned;
643 /** Number of non-directories scanned so far, excluding any
644 * unsupported/excluded files. */
645 uint64_t num_nondirs_scanned;
647 /** Number of bytes of file data that have been detected so far.
648 * This data may not actually have been read yet, and it will
649 * not actually be written to the WIM file until wimlib_write()
650 * or wimlib_overwrite() has been called. */
651 uint64_t num_bytes_scanned;
654 /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
655 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
656 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
657 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
658 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
659 struct wimlib_progress_info_extract {
660 /** Number of the image being extracted (1-based). */
663 /** Flags passed to to wimlib_extract_image() */
666 /** Full path to the WIM file being extracted. */
667 const wimlib_tchar *wimfile_name;
669 /** Name of the image being extracted. */
670 const wimlib_tchar *image_name;
672 /** Directory or NTFS volume to which the image is being
674 const wimlib_tchar *target;
677 const wimlib_tchar *cur_path;
679 /** Number of bytes of uncompressed data that will be extracted.
680 * Takes into account hard links (they are not counted for each
682 uint64_t total_bytes;
684 /** Number of bytes that have been written so far. Will be 0
685 * initially, and equal to @p total_bytes at the end. */
686 uint64_t completed_bytes;
688 /** Number of streams that will be extracted. This may more or
689 * less than the number of "files" to be extracted due to
690 * special cases (hard links, symbolic links, and alternate data
692 uint64_t num_streams;
694 /** Path to the root dentry within the WIM for the tree that is
695 * being extracted. Will be the empty string when extracting a
696 * full image, or when extracting a set of paths using
697 * wimlib_extract_paths() or wimlib_extract_pathlist(). */
698 const wimlib_tchar *extract_root_wim_source_path;
700 /** Currently only used for
701 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
703 unsigned part_number;
705 /** Currently only used for
706 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
707 unsigned total_parts;
709 /** Currently only used for
710 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
711 uint8_t guid[WIMLIB_GUID_LEN];
714 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
715 struct wimlib_progress_info_rename {
716 /** Name of the temporary file that the WIM was written to. */
717 const wimlib_tchar *from;
719 /** Name of the original WIM file to which the temporary file is
721 const wimlib_tchar *to;
724 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
725 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
726 struct wimlib_progress_info_update {
727 /** Pointer to the update command that will be executed or has
728 * just been executed. */
729 const struct wimlib_update_command *command;
731 /** Number of update commands that have been completed so far.
733 size_t completed_commands;
735 /** Number of update commands that are being executed as part of
736 * this call to wimlib_update_image(). */
737 size_t total_commands;
740 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
741 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
742 struct wimlib_progress_info_integrity {
743 /** Number of bytes from the end of the WIM header to the end of
744 * the lookup table (the area that is covered by the SHA1
745 * integrity checks.) */
746 uint64_t total_bytes;
748 /** Number of bytes that have been SHA1-summed so far. Will be
749 * 0 initially, and equal @p total_bytes at the end. */
750 uint64_t completed_bytes;
752 /** Number of chunks that the checksummed region is divided
754 uint32_t total_chunks;
756 /** Number of chunks that have been SHA1-summed so far. Will
757 * be 0 initially, and equal to @p total_chunks at the end. */
758 uint32_t completed_chunks;
760 /** Size of the chunks used for the integrity calculation. */
763 /** Filename of the WIM (only valid if the message is
764 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
765 const wimlib_tchar *filename;
768 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
769 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
770 struct wimlib_progress_info_split {
771 /** Total size of the original WIM's file and metadata resources
773 uint64_t total_bytes;
775 /** Number of bytes of file and metadata resources that have
776 * been copied out of the original WIM so far. Will be 0
777 * initially, and equal to @p total_bytes at the end. */
778 uint64_t completed_bytes;
780 /** Number of the split WIM part that is about to be started
781 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
782 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
783 unsigned cur_part_number;
785 /** Total number of split WIM parts that are being written. */
786 unsigned total_parts;
788 /** Name of the split WIM part that is about to be started
789 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
790 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
791 const wimlib_tchar *part_name;
795 /** A user-supplied function that will be called periodically during certain WIM
796 * operations. The first argument will be the type of operation that is being
797 * performed or is about to be started or has been completed. The second
798 * argument will be a pointer to one of a number of structures depending on the
799 * first argument. It may be @c NULL for some message types.
801 * The return value of the progress function is currently ignored, but it may do
802 * something in the future. (Set it to 0 for now.)
804 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
805 const union wimlib_progress_info *info);
808 /** @ingroup G_modifying_wims
811 /** An array of these structures is passed to wimlib_add_image_multisource() to
812 * specify the sources from which to create a WIM image. */
813 struct wimlib_capture_source {
814 /** Absolute or relative path to a file or directory on the external
815 * filesystem to be included in the WIM image. */
816 wimlib_tchar *fs_source_path;
818 /** Destination path in the WIM image. Leading and trailing slashes are
819 * ignored. The empty string or @c NULL means the root directory of the
821 wimlib_tchar *wim_target_path;
823 /** Reserved; set to 0. */
827 /** Structure that specifies a list of path patterns. */
828 struct wimlib_pattern_list {
829 /** Array of patterns. The patterns may be modified by library code,
830 * but the @p pats pointer itself will not. See the man page for
831 * <b>wimlib-imagex capture</b> for more information about allowed
835 /** Number of patterns in the @p pats array. */
838 /** Ignored; may be used by the calling code. */
839 size_t num_allocated_pats;
842 /** A structure that contains lists of wildcards that match paths to treat
843 * specially when capturing a WIM image. */
844 struct wimlib_capture_config {
845 /** Paths matching any pattern this list are excluded from being
846 * captured, except if the same path appears in @p
847 * exclusion_exception_pats. */
848 struct wimlib_pattern_list exclusion_pats;
850 /** Paths matching any pattern in this list are never excluded from
852 struct wimlib_pattern_list exclusion_exception_pats;
854 /** Reserved for future capture configuration options. */
855 struct wimlib_pattern_list reserved1;
857 /** Reserved for future capture configuration options. */
858 struct wimlib_pattern_list reserved2;
860 /** Library internal use only. */
861 wimlib_tchar *_prefix;
863 /** Library internal use only. */
864 size_t _prefix_num_tchars;
867 /** Set or unset the WIM header flag that marks it read-only
868 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
869 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
870 * is distinct from basic file permissions; this flag can be set on a WIM file
871 * that is physically writable. If this flag is set, all further operations to
872 * modify the WIM will fail, except calling wimlib_overwrite() with
873 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
874 * allows you to set this flag persistently on the underlying WIM file.
876 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
878 /** Set the GUID (globally unique identifier) of the WIM file to the value
879 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
880 #define WIMLIB_CHANGE_GUID 0x00000002
882 /** Change the bootable image of the WIM to the value specified in
883 * ::wimlib_wim_info.boot_index of the @p info parameter. */
884 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
886 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
887 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
888 * indicates whether an image in the WIM has been captured with reparse-point
889 * fixups enabled. wimlib also treats this flag as specifying whether to do
890 * reparse-point fixups by default when capturing or applying WIM images. */
891 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
894 /** @ingroup G_wim_information
897 /** General information about a WIM file. */
898 struct wimlib_wim_info {
900 /** Globally unique identifier for the WIM file. Note: all parts of a
901 * split WIM should have an identical value in this field. */
902 uint8_t guid[WIMLIB_GUID_LEN];
904 /** Number of images in the WIM. */
905 uint32_t image_count;
907 /** 1-based index of the bootable image in the WIM, or 0 if no image is
911 /** Version of the WIM file. */
912 uint32_t wim_version;
914 /** Chunk size used for compression. */
917 /** For split WIMs, the 1-based index of this part within the split WIM;
919 uint16_t part_number;
921 /** For split WIMs, the total number of parts in the split WIM;
923 uint16_t total_parts;
925 /** One of the ::wimlib_compression_type values that specifies the
926 * method used to compress resources in the WIM. */
927 int32_t compression_type;
929 /** Size of the WIM file in bytes, excluding the XML data and integrity
931 uint64_t total_bytes;
933 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
934 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
935 * this will always be 0, even if the ::WIMStruct was written to
936 * somewhere by calling wimlib_write() with the
937 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
938 uint32_t has_integrity_table : 1;
940 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
941 * wimlib_create_new_wim(). */
942 uint32_t opened_from_file : 1;
944 /** 1 if the WIM is considered readonly for any reason. */
945 uint32_t is_readonly : 1;
947 /** 1 if reparse-point fixups are supposedly enabled for one or more
948 * images in the WIM. */
949 uint32_t has_rpfix : 1;
951 /** 1 if the WIM is marked as read-only. */
952 uint32_t is_marked_readonly : 1;
954 /** 1 if the WIM is part of a spanned set. */
955 uint32_t spanned : 1;
957 uint32_t write_in_progress : 1;
958 uint32_t metadata_only : 1;
959 uint32_t resource_only : 1;
961 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
962 uint32_t pipable : 1;
963 uint32_t reserved_flags : 22;
964 uint32_t reserved[9];
967 /** Information about a unique stream in the WIM file. (A stream is the same
968 * thing as a "resource", except in the case of packed resources.) */
969 struct wimlib_resource_entry {
970 /** Uncompressed size of the stream in bytes. */
971 uint64_t uncompressed_size;
973 /** Compressed size of the stream in bytes. This will be the same as @p
974 * uncompressed_size if the stream is uncompressed. Or, if @p
975 * is_packed_streams is 1, this will be 0. */
976 uint64_t compressed_size;
978 /** Offset, in bytes, of this stream from the start of the WIM file. Or
979 * if @p packed is 1, then this is actually the offset at which this
980 * stream begins in the uncompressed contents of the packed resource.
984 /** SHA1 message digest of the stream's uncompressed contents. */
985 uint8_t sha1_hash[20];
987 /** Which part number of the split WIM this stream is in. This should
988 * be the same as the part number provided by wimlib_get_wim_info(). */
989 uint32_t part_number;
991 /** Number of times this stream is referenced over all WIM images. */
992 uint32_t reference_count;
994 /** 1 if this stream is compressed. */
995 uint32_t is_compressed : 1;
997 /** 1 if this stream is a metadata resource rather than a file resource.
999 uint32_t is_metadata : 1;
1001 uint32_t is_free : 1;
1002 uint32_t is_spanned : 1;
1004 /** 1 if this stream was not found in the lookup table of the
1005 * ::WIMStruct. This normally implies a missing call to
1006 * wimlib_reference_resource_files() or wimlib_reference_resources().
1008 uint32_t is_missing : 1;
1010 /** 1 if this stream is located in a packed resource which may contain
1011 * other streams (all compressed together) as well. */
1012 uint32_t packed : 1;
1014 uint32_t reserved_flags : 26;
1016 /** If @p packed is 1, then this will specify the offset of the packed
1017 * resource in the WIM. */
1018 uint64_t raw_resource_offset_in_wim;
1020 /** If @p is_packed_streams is 1, then this will specify the compressed
1021 * size of the packed resource in the WIM. */
1022 uint64_t raw_resource_compressed_size;
1024 uint64_t reserved[2];
1027 /** A stream of a file in the WIM. */
1028 struct wimlib_stream_entry {
1029 /** Name of the stream, or NULL if the stream is unnamed. */
1030 const wimlib_tchar *stream_name;
1031 /** Location, size, etc. of the stream within the WIM file. */
1032 struct wimlib_resource_entry resource;
1033 uint64_t reserved[4];
1036 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1037 * Roughly, the information about a "file" in the WIM--- but really a directory
1038 * entry ("dentry") because hard links are allowed. The hard_link_group_id
1039 * field can be used to distinguish actual file inodes. */
1040 struct wimlib_dir_entry {
1041 /** Name of the file, or NULL if this file is unnamed (only possible for
1042 * the root directory) */
1043 const wimlib_tchar *filename;
1045 /** 8.3 DOS name of this file, or NULL if this file has no such name.
1047 const wimlib_tchar *dos_name;
1049 /** Full path to this file within the WIM image. */
1050 const wimlib_tchar *full_path;
1052 /** Depth of this directory entry, where 0 is the root, 1 is the root's
1053 * children, ..., etc. */
1056 /** Pointer to the security descriptor for this file, in Windows
1057 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1058 * security descriptor. */
1059 const char *security_descriptor;
1061 /** Length of the above security descriptor. */
1062 size_t security_descriptor_size;
1064 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
1065 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
1066 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
1067 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
1068 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
1069 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
1070 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
1071 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
1072 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
1073 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
1074 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
1075 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
1076 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1077 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
1078 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
1079 /** File attributes, such as whether the file is a directory or not.
1080 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1081 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1082 * on other platforms. */
1083 uint32_t attributes;
1085 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
1086 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
1087 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
1088 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
1089 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
1090 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
1091 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
1092 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
1093 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
1094 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
1095 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
1096 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1097 * attributes), this will give the reparse tag. This tells you whether
1098 * the reparse point is a symbolic link, junction point, or some other,
1099 * more unusual kind of reparse point. */
1100 uint32_t reparse_tag;
1102 /* Number of (hard) links to this file. */
1105 /** Number of named data streams that this file has. Normally 0. */
1106 uint32_t num_named_streams;
1108 /** Roughly, the inode number of this file. However, it may be 0 if
1109 * @p num_links == 1. */
1110 uint64_t hard_link_group_id;
1112 /** Time this file was created. */
1113 struct timespec creation_time;
1115 /** Time this file was last written to. */
1116 struct timespec last_write_time;
1118 /** Time this file was last accessed. */
1119 struct timespec last_access_time;
1120 uint64_t reserved[16];
1122 /** Array of streams that make up this file. The first entry will
1123 * always exist and will correspond to the unnamed data stream (default
1124 * file contents), so it will have @p stream_name == @c NULL. There
1125 * will then be @p num_named_streams additional entries that specify the
1126 * named data streams, if any, each of which will have @p stream_name !=
1128 struct wimlib_stream_entry streams[];
1132 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
1135 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1139 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
1142 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1145 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1146 * just on the specified path. */
1147 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1149 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1150 * itself; only its children (in the case of a non-empty directory) */
1151 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1153 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1154 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1155 * table of the ::WIMStruct. The default behavior without this flag is to fill
1156 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1157 * wimlib_resource_entry::is_missing "is_missing" flag. */
1158 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1162 /** @ingroup G_modifying_wims
1165 /** Directly capture a NTFS volume rather than a generic directory. This flag
1166 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1167 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1168 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1170 /** Follow symlinks; archive and dump the files they point to. Cannot be used
1171 * with ::WIMLIB_ADD_FLAG_NTFS. */
1172 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1174 /** Call the progress function with the message
1175 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
1176 * be scanned, or when a directory or file is being excluded from capture. */
1177 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1179 /** Mark the image being added as the bootable image of the WIM. */
1180 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1182 /** Store the UNIX owner, group, and mode. This is done by adding a special
1183 * alternate data stream to each regular file, symbolic link, and directory to
1184 * contain this information. Please note that this flag is for convenience
1185 * only; Microsoft's @a imagex.exe will not understand this special information.
1186 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
1187 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1189 /** Do not capture security descriptors. Only has an effect in NTFS capture
1190 * mode, or in Win32 native builds. */
1191 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1193 /** Fail immediately if the full security descriptor of any file or directory
1194 * cannot be accessed. Only has an effect in Win32 native builds. The default
1195 * behavior without this flag is to first try omitting the SACL from the
1196 * security descriptor, then to try omitting the security descriptor entirely.
1198 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1200 /** Call the progress function with the message
1201 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1202 * capture. This is a subset of the messages provided by
1203 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1204 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1206 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1207 * in the case of Windows) that point inside the directory being captured to
1208 * instead be absolute relative to the directory being captured, rather than the
1209 * current root; also exclude absolute symbolic links that point outside the
1210 * directory tree being captured.
1212 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1213 * the WIM header or if this is the first image being added.
1214 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1215 * reparse point fixups enabled and currently cannot be unset. */
1216 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1218 /** Don't do reparse point fixups. The default behavior is described in the
1219 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1220 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1222 /** Do not automatically exclude unsupported files or directories from capture;
1223 * e.g. encrypted directories in NTFS-3g capture mode, or device files and FIFOs
1224 * on UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1225 * such a file is encountered. */
1226 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1228 /** Automatically select a capture configuration appropriate for capturing
1229 * filesystems containing Windows operating systems. When this flag is
1230 * specified, the corresponding @p config parameter or member must be @c NULL.
1232 * Currently, selecting this capture configuration will cause the following
1233 * files and directories to be excluded from capture:
1238 * - "\System Volume Information"
1242 * Note that the default behavior--- that is, when this flag is not specified
1243 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1244 * no files are excluded from capture.
1246 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1248 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1249 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1250 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1251 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1252 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1253 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1254 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1255 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1256 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1257 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1258 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1259 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1260 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1263 /** @ingroup G_modifying_wims
1266 /** Do not issue an error if the path to delete does not exist. */
1267 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1269 /** Delete the file or directory tree recursively; if not specified, an error is
1270 * issued if the path to delete is a directory. */
1271 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1274 /** @ingroup G_modifying_wims
1278 * If a single image is being exported, mark it bootable in the destination WIM.
1279 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1280 * the image in the source WIM (if any) that is marked as bootable is also
1281 * marked as bootable in the destination WIM.
1283 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1285 /** Give the exported image(s) no names. Avoids problems with image name
1288 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1290 /** Give the exported image(s) no descriptions. */
1291 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1294 /** @ingroup G_extracting_wims
1297 /** Extract the image directly to a NTFS volume rather than a generic directory.
1298 * This mode is only available if wimlib was compiled with libntfs-3g support;
1299 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1300 * extraction target will be interpreted as the path to a NTFS volume image (as
1301 * a regular file or block device) rather than a directory. It will be opened
1302 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1303 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1304 * is called with ::WIMLIB_ALL_IMAGES as the @p image. */
1305 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1307 /** When identical files are extracted from the WIM, always hard link them
1309 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
1311 /** When identical files are extracted from the WIM, always symlink them
1313 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
1315 /** This flag no longer does anything but is reserved for future use. */
1316 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
1318 /** Read the WIM file sequentially while extracting the image. As of wimlib
1319 * v1.6.0 this is the default behavior, and this flag no longer does anything.
1321 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
1323 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA. Only
1324 * valid on UNIX-like platforms, and when ::WIMLIB_EXTRACT_FLAG_NTFS was not
1326 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1328 /** Do not extract security descriptors. */
1329 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1331 /** Fail immediately if the full security descriptor of any file or directory
1332 * cannot be set exactly as specified in the WIM file. On Windows, the default
1333 * behavior without this flag is to fall back to setting the security descriptor
1334 * with the SACL omitted, then only the default inherited security descriptor,
1335 * if we do not have permission to set the desired one. */
1336 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1338 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1339 * reparse-point fixups on, so absolute symbolic links or junction points will
1340 * be fixed to be absolute relative to the actual extraction root. Reparse
1341 * point fixups are done by default if WIM_HDR_FLAG_RP_FIX is set in the WIM
1342 * header. This flag may only be specified when extracting a full image (not a
1343 * file or directory tree within one). */
1344 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1346 /** Force reparse-point fixups on extraction off, regardless of the state of the
1347 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. */
1348 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1350 /** Extract the specified file to standard output. This is only valid in an
1351 * extraction command that specifies the extraction of a regular file in the WIM
1353 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1355 /** Instead of ignoring files and directories with names that cannot be
1356 * represented on the current platform (note: Windows has more restrictions on
1357 * filenames than POSIX-compliant systems), try to replace characters or append
1358 * junk to the names so that they can be extracted in some form. */
1359 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1361 /** On Windows, when there exist two or more files with the same case
1362 * insensitive name but different case sensitive names, try to extract them all
1363 * by appending junk to the end of them, rather than arbitrarily extracting only
1365 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1367 /** Do not ignore failure to set timestamps on extracted files. */
1368 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1370 /** Do not ignore failure to set short names on extracted files. */
1371 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1373 /** Do not ignore failure to extract symbolic links (and junction points, on
1374 * Windows) due to permissions problems. By default, such failures are ignored
1375 * since the default configuration of Windows only allows the Administrator to
1376 * create symbolic links. */
1377 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1379 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1380 * behavior is currently less than satisfactory. Do not use (yet). */
1381 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1383 /** Perform the extraction ordered by the tree of files to extract rather than
1384 * how the underlying streams are arranged in the WIM file. For regular WIM
1385 * files this may decrease or increase performance, depending on various
1386 * factors. For WIM files containing packed streams this will decrease
1388 #define WIMLIB_EXTRACT_FLAG_FILE_ORDER 0x00020000
1390 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only: Treat the
1391 * paths in the WIM as "glob" patterns which may contain the wildcard characters
1392 * '?' and '*'. The '?' character matches any character except a path
1393 * separator, whereas the '*' character matches zero or more non-path-separator
1394 * characters. Each glob pattern may match zero or more paths in the WIM file.
1395 * If a glob pattern ends in a path separator, it will only match directories
1396 * (including reparse points with FILE_ATTRIBUTE_DIRECTORY set). By default, if
1397 * a glob pattern does not match any files, a warning but not an error will be
1398 * issued, even if the glob pattern did not actually contain wildcard
1399 * characters. Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB to get an error instead.
1401 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS 0x00040000
1403 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1404 * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1405 * one of the provided globs did not match a file. */
1406 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000
1409 /** @ingroup G_mounting_wim_images
1412 /** Mount the WIM image read-write rather than the default of read-only. */
1413 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1415 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1416 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1418 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1419 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1421 /** Access alternate data streams in the mounted WIM image through extended file
1422 * attributes. This is the default mode. */
1423 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1425 /** Access alternate data streams in the mounted WIM image by specifying the
1426 * file name, a colon, then the alternate file stream name. */
1427 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1429 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1430 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1431 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1433 /** Allow other users to see the mounted filesystem. (this passes the @c
1434 * allow_other option to FUSE mount) */
1435 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1438 /** @ingroup G_creating_and_opening_wims
1441 /** Verify the WIM contents against the WIM's integrity table, if present. This
1442 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1443 * checksummed and checked against the SHA1 message digests specified in the
1444 * integrity table. ::WIMLIB_ERR_INTEGRITY is returned if there are any
1445 * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1446 * integrity table is invalid). */
1447 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1449 /** Issue an error if the WIM is part of a split WIM. Software can provide
1450 * this flag for convenience if it explicitly does not want to support split
1452 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1454 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1455 * is not. A WIM is considered writable only if it is writable at the
1456 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1457 * header, and is not part of a spanned set. It is not required to provide this
1458 * flag before attempting to make changes to the WIM, but with this flag you get
1459 * an error sooner rather than later. */
1460 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1463 /** @ingroup G_mounting_wim_images
1466 /** See ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
1467 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1469 /** Unless this flag is given, changes to a read-write mounted WIM are
1470 * discarded. Ignored for read-only mounts. */
1471 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1473 /** See ::WIMLIB_WRITE_FLAG_REBUILD. */
1474 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1476 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1477 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1479 /** Do a "lazy" unmount (detach filesystem immediately, even if busy). */
1480 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1483 /** @ingroup G_modifying_wims
1486 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1487 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1488 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1491 /** @ingroup G_writing_and_overwriting_wims
1494 /** Include an integrity table in the WIM.
1496 * For WIMs created with wimlib_open_wim(), the default behavior is to include
1497 * an integrity table if and only if one was present before. For WIMs created
1498 * with wimlib_create_new_wim(), the default behavior is to not include an
1499 * integrity table. */
1500 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1502 /** Do not include an integrity table in the new WIM file. This is the default
1503 * behavior, unless the WIM already included an integrity table. */
1504 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1506 /** Write the WIM as "pipable". After writing a WIM with this flag specified,
1507 * images from it can be applied directly from a pipe using
1508 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1509 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1510 * with this flag will not be compatible with Microsoft's software.
1512 * For WIMs created with wimlib_open_wim(), the default behavior is to write the
1513 * WIM as pipable if and only if it was pipable before. For WIMs created with
1514 * wimlib_create_new_wim(), the default behavior is to write the WIM as
1516 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1518 /** Do not write the WIM as "pipable". This is the default behavior, unless the
1519 * WIM was pipable already. */
1520 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1522 /** Recompress all resources, even if they could otherwise be copied from a
1523 * different WIM with the same compression type (in the case of
1524 * wimlib_export_image() being called previously). This flag is also valid in
1525 * the @p wim_write_flags of wimlib_join(), in which case all resources included
1526 * in the joined WIM file will be recompressed. */
1527 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1529 /** Call fsync() just before the WIM file is closed. */
1530 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1532 /** wimlib_overwrite() only: Re-build the entire WIM file rather than appending
1533 * data to it if possible. */
1534 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1536 /** wimlib_overwrite() only: Specifying this flag overrides the default
1537 * behavior of wimlib_overwrite() after one or more calls to
1538 * wimlib_delete_image(), which is to rebuild the entire WIM. With this flag,
1539 * only minimal changes to correctly remove the image from the WIM will be
1540 * taken. In particular, all streams will be left alone, even if they are no
1541 * longer referenced. This is probably not what you want, because almost no
1542 * space will be saved by deleting an image in this way. */
1543 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1545 /** wimlib_overwrite() only: Allow overwriting the WIM even if the readonly
1546 * flag is set in the WIM header. This can be used in combination with
1547 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1548 * set the readonly flag on the on-disk WIM file. */
1549 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1551 /** Do not include non-metadata resources already present in other WIMs. This
1552 * flag can be used to write a "delta" WIM after resources from the WIM on which
1553 * the delta is to be based were referenced with
1554 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1555 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1557 /** Asserts that for writes of all WIM images, all streams needed for the WIM
1558 * are already present (not in external resource WIMs) and their reference
1559 * counts are correct, so the code does not need to recalculate which streams
1560 * are referenced. This is for optimization purposes only, since with this flag
1561 * specified, the metadata resources may not need to be decompressed and parsed.
1563 * This flag can be passed to wimlib_write() and wimlib_write_to_fd(), but is
1564 * already implied for wimlib_overwrite(). */
1565 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1567 #define WIMLIB_WRITE_FLAG_RESERVED 0x00000800
1570 * When writing streams in the resulting WIM file, pack multiple streams into a
1571 * single WIM resource instead of compressing them independently. This tends to
1572 * produce a better compression ratio at the cost of less random access.
1573 * However, WIMs created with this flag are only compatible with wimlib v1.6.0
1574 * or later and WIMGAPI Windows 8 or later, seemingly for Windows Setup only and
1575 * <b>not including ImageX and Dism</b>. WIMs created with this flag must use
1576 * version number 3584 in their header instead of 68864.
1578 * If this flag is passed to wimlib_overwrite() and the WIM did not previously
1579 * contain packed streams, the WIM's version number will be changed to 3584 and
1580 * the new streams will be written packed. Use ::WIMLIB_WRITE_FLAG_REBUILD to
1581 * force the WIM to be fully rebuilt. */
1582 #define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
1585 /** @ingroup G_general
1588 /** Assume that strings are represented in UTF-8, even if this is not the
1589 * locale's character encoding. This flag is ignored on Windows, where wimlib
1590 * always uses UTF-16LE. */
1591 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1593 /** Windows-only: do not attempt to acquire additional privileges (currently
1594 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1595 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1596 * for the case where the calling program manages these privileges itself.
1597 * Note: no error is issued if privileges cannot be acquired, although related
1598 * errors may be reported later, depending on if the operations performed
1599 * actually require additional privileges or not. */
1600 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1602 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1603 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1604 * to read all possible data and metadata for a capture operation could not be
1605 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1607 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1609 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1610 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1611 * to restore all possible data and metadata for an apply operation could not be
1612 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1614 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1616 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1618 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE 0x00000010
1620 /** Default to interpreting WIM paths case insensitively (default on Windows).
1621 * This does not apply to mounted images. */
1622 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE 0x00000020
1625 /** @ingroup G_nonstandalone_wims
1628 /** wimlib_reference_resource_files() only: Enable shell-style filename
1630 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1632 /** wimlib_reference_resource_files() only: Issue an error
1633 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1634 * default behavior without this flag is to issue no error at that point, but
1635 * then attempt to open the glob as a literal path, which of course will fail
1636 * anyway if no file exists at that path. No effect if
1637 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. */
1638 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1641 /** @ingroup G_modifying_wims
1644 /** The specific type of update to perform. */
1645 enum wimlib_update_op {
1646 /** Add a new file or directory tree to the WIM image in a
1647 * certain location. */
1648 WIMLIB_UPDATE_OP_ADD = 0,
1650 /** Delete a file or directory tree from the WIM image. */
1651 WIMLIB_UPDATE_OP_DELETE,
1653 /** Rename a file or directory tree in the WIM image. */
1654 WIMLIB_UPDATE_OP_RENAME,
1657 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1658 struct wimlib_add_command {
1659 /** Filesystem path to the file or directory tree to
1661 wimlib_tchar *fs_source_path;
1662 /** Path, specified from the root of the WIM image, at
1663 * which to add the file or directory tree within the
1665 wimlib_tchar *wim_target_path;
1667 /** Configuration for excluded files. @c NULL means
1668 * exclude no files (use no configuration), unless
1669 * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
1671 struct wimlib_capture_config *config;
1673 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1677 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1678 struct wimlib_delete_command {
1679 /** Path, specified from the root of the WIM image, for
1680 * the file or directory tree within the WIM image to be
1682 wimlib_tchar *wim_path;
1683 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1687 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1688 struct wimlib_rename_command {
1689 /** Path, specified from the root of the WIM image, for
1690 * the source file or directory tree within the WIM
1692 wimlib_tchar *wim_source_path;
1693 /** Path, specified from the root of the WIM image, for
1694 * the destination file or directory tree within the WIM
1696 wimlib_tchar *wim_target_path;
1697 /** Reserved; set to 0. */
1701 /** Specification of an update to perform on a WIM image. */
1702 struct wimlib_update_command {
1704 enum wimlib_update_op op;
1707 struct wimlib_add_command add;
1708 struct wimlib_delete_command delete_; /* Underscore is for C++
1710 struct wimlib_rename_command rename;
1715 /** @ingroup G_extracting_wims
1718 /** Specification of a file or directory tree to extract from a WIM image. Used
1719 * in calls to wimlib_extract_files(). */
1720 struct wimlib_extract_command {
1721 /** Path to file or directory tree within the WIM image to extract. It
1722 * must be provided as an absolute path from the root of the WIM image.
1723 * The path separators may be either forward slashes or backslashes. */
1724 wimlib_tchar *wim_source_path;
1726 /** Filesystem path to extract the file or directory tree to. */
1727 wimlib_tchar *fs_dest_path;
1729 /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1735 /** @ingroup G_general
1739 * Possible values of the error code returned by many functions in wimlib.
1741 * See the documentation for each wimlib function to see specifically what error
1742 * codes can be returned by a given function, and what they mean.
1744 enum wimlib_error_code {
1745 WIMLIB_ERR_SUCCESS = 0,
1746 WIMLIB_ERR_ALREADY_LOCKED,
1747 WIMLIB_ERR_DECOMPRESSION,
1748 WIMLIB_ERR_DELETE_STAGING_DIR,
1749 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1752 WIMLIB_ERR_FUSERMOUNT,
1753 WIMLIB_ERR_GLOB_HAD_NO_MATCHES,
1754 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1755 WIMLIB_ERR_IMAGE_COUNT,
1756 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1757 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES,
1758 WIMLIB_ERR_INTEGRITY,
1759 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1760 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1761 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1762 WIMLIB_ERR_INVALID_HEADER,
1763 WIMLIB_ERR_INVALID_IMAGE,
1764 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1765 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1766 WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1767 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1768 WIMLIB_ERR_INVALID_OVERLAY,
1769 WIMLIB_ERR_INVALID_PARAM,
1770 WIMLIB_ERR_INVALID_PART_NUMBER,
1771 WIMLIB_ERR_INVALID_PIPABLE_WIM,
1772 WIMLIB_ERR_INVALID_REPARSE_DATA,
1773 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1774 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1775 WIMLIB_ERR_INVALID_UTF16_STRING,
1776 WIMLIB_ERR_INVALID_UTF8_STRING,
1777 WIMLIB_ERR_IS_DIRECTORY,
1778 WIMLIB_ERR_IS_SPLIT_WIM,
1779 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1781 WIMLIB_ERR_METADATA_NOT_FOUND,
1786 WIMLIB_ERR_NOTEMPTY,
1787 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1788 WIMLIB_ERR_NOT_A_WIM_FILE,
1789 WIMLIB_ERR_NOT_PIPABLE,
1790 WIMLIB_ERR_NO_FILENAME,
1794 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1796 WIMLIB_ERR_READLINK,
1799 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1800 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1801 WIMLIB_ERR_RESOURCE_ORDER,
1802 WIMLIB_ERR_SET_ATTRIBUTES,
1803 WIMLIB_ERR_SET_REPARSE_DATA,
1804 WIMLIB_ERR_SET_SECURITY,
1805 WIMLIB_ERR_SET_SHORT_NAME,
1806 WIMLIB_ERR_SET_TIMESTAMPS,
1807 WIMLIB_ERR_SPLIT_INVALID,
1810 WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
1811 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1812 WIMLIB_ERR_UNKNOWN_VERSION,
1813 WIMLIB_ERR_UNSUPPORTED,
1814 WIMLIB_ERR_UNSUPPORTED_FILE,
1815 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1816 WIMLIB_ERR_WIM_IS_READONLY,
1822 /** Used to indicate no WIM image or an invalid WIM image. */
1823 #define WIMLIB_NO_IMAGE 0
1825 /** Used to specify all images in the WIM. */
1826 #define WIMLIB_ALL_IMAGES (-1)
1829 * @ingroup G_modifying_wims
1831 * Appends an empty image to a WIM file. This empty image will initially
1832 * contain no files or directories, although if written without further
1833 * modifications, a root directory will be created automatically for it. After
1834 * calling this function, you can use wimlib_update_image() to add files to the
1835 * new WIM image. This gives you slightly more control over making the new
1836 * image compared to calling wimlib_add_image() or
1837 * wimlib_add_image_multisource() directly.
1840 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
1843 * Name to give the new image. If @c NULL or empty, the new image is given
1844 * no name. If nonempty, it must specify a name that does not already
1846 * @param new_idx_ret
1847 * If non-<code>NULL</code>, the index of the newly added image is returned
1850 * @return 0 on success; nonzero on failure. The possible error codes are:
1852 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1853 * There is already an image in @p wim named @p name.
1854 * @retval ::WIMLIB_ERR_NOMEM
1855 * Failed to allocate the memory needed to add the new image.
1856 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1857 * The WIM file is considered read-only because of any of the reasons
1858 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1862 wimlib_add_empty_image(WIMStruct *wim,
1863 const wimlib_tchar *name,
1867 * @ingroup G_modifying_wims
1869 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1871 * The directory tree or NTFS volume is scanned immediately to load the dentry
1872 * tree into memory, and file attributes and symbolic links are read. However,
1873 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1876 * See the manual page for the @b wimlib-imagex program for more information
1877 * about the "normal" capture mode versus the NTFS capture mode (entered by
1878 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1880 * Note that @b no changes are committed to the underlying WIM file (if
1881 * any) until wimlib_write() or wimlib_overwrite() is called.
1884 * Pointer to the ::WIMStruct for a WIM file to which the image will be
1887 * A path to a directory or unmounted NTFS volume that will be captured as
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
1894 * Capture configuration that specifies files, directories, or path globs
1895 * to exclude from being captured. If @c NULL, a dummy configuration where
1896 * no paths are treated specially is used.
1898 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1899 * @param progress_func
1900 * If non-NULL, a function that will be called periodically with the
1901 * progress of the current operation. The progress messages that will be
1902 * received are ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
1903 * ::WIMLIB_PROGRESS_MSG_SCAN_END, and, if ::WIMLIB_ADD_FLAG_VERBOSE was
1904 * included in @p add_flags, also ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
1906 * @return 0 on success; nonzero on error. On error, changes to @p wim are
1907 * discarded so that it appears to be in the same state as when this function
1910 * This function is implemented by calling wimlib_add_empty_image(), then
1911 * calling wimlib_update_image() with a single "add" command, so any error code
1912 * returned by wimlib_add_empty_image() may be returned, as well as any error
1913 * codes returned by wimlib_update_image() other than ones documented as only
1914 * being returned specifically by an update involving delete or rename commands.
1917 wimlib_add_image(WIMStruct *wim,
1918 const wimlib_tchar *source,
1919 const wimlib_tchar *name,
1920 const struct wimlib_capture_config *config,
1922 wimlib_progress_func_t progress_func);
1925 * @ingroup G_modifying_wims
1927 * This function is equivalent to wimlib_add_image() except it allows for
1928 * multiple sources to be combined into a single WIM image. This is done by
1929 * specifying the @p sources and @p num_sources parameters instead of the @p
1930 * source parameter of wimlib_add_image(). The rest of the parameters are the
1931 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
1932 * capture</b> for full details on how this mode works.
1934 * In addition to the error codes that wimlib_add_image() can return,
1935 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1936 * when trying to overlay a non-directory on a directory or when otherwise
1937 * trying to overlay multiple conflicting files to the same location in the WIM
1938 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
1939 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
1940 * was not exactly one capture source with the target being the root directory.
1941 * (In this respect, there is no advantage to using
1942 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1945 wimlib_add_image_multisource(WIMStruct *wim,
1946 const struct wimlib_capture_source *sources,
1948 const wimlib_tchar *name,
1949 const struct wimlib_capture_config *config,
1951 wimlib_progress_func_t progress_func);
1954 * @ingroup G_creating_and_opening_wims
1956 * Creates a ::WIMStruct for a new WIM file.
1958 * This only creates an in-memory structure for a WIM that initially contains no
1959 * images. No on-disk file is created until wimlib_write() is called.
1962 * The type of compression to be used in the new WIM file. Must be
1963 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
1964 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1966 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
1967 * written to the memory location pointed to by this paramater. The
1968 * ::WIMStruct must be freed using using wimlib_free() when finished with
1970 * @return 0 on success; nonzero on error.
1971 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1972 * @p ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
1973 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1974 * @retval ::WIMLIB_ERR_NOMEM
1975 * Failed to allocate needed memory.
1978 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
1981 * @ingroup G_modifying_wims
1983 * Deletes an image, or all images, from a WIM file.
1985 * All streams referenced by the image(s) being deleted are removed from the
1986 * lookup table of the WIM if they are not referenced by any other images in the
1989 * Please note that @b no changes are committed to the underlying WIM file (if
1990 * any) until wimlib_write() or wimlib_overwrite() is called.
1993 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
1996 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
1998 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
1999 * to be left unmodified only if @p image specified a single image. If instead
2000 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2001 * possible for some but not all of the images to have been deleted when a
2002 * failure status is returned.
2004 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2005 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2006 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2007 * The WIM file is considered read-only because of any of the reasons
2008 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2011 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2012 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2013 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2014 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2015 * different reasons) to read the metadata resource for an image that needed to
2019 wimlib_delete_image(WIMStruct *wim, int image);
2022 * @ingroup G_modifying_wims
2024 * Exports an image, or all the images, from a WIM file, into another WIM file.
2026 * The destination image is made to share the same dentry tree and security data
2027 * structure as the source image. This places some restrictions on additional
2028 * functions that may be called. wimlib_mount_image() may not be called on
2029 * either the source image or the destination image without an intervening call
2030 * to a function that un-shares the images, such as wimlib_free() on @p
2031 * dest_wim, or wimlib_delete_image() on either the source or destination image.
2032 * Furthermore, you may not call wimlib_free() on @p src_wim before calling
2033 * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
2034 * have references back to @p src_wim.
2036 * If this function fails, all changes to @p dest_wim are rolled back.
2038 * Please note that no changes are committed to the underlying WIM file of @p
2039 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2042 * The WIM from which to export the images, specified as a pointer to the
2043 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2044 * split WIM. In the case of a WIM file that is not standalone, this
2045 * ::WIMStruct must have had any needed external resources previously
2046 * referenced using wimlib_reference_resources() or
2047 * wimlib_reference_resource_files().
2049 * The image to export from @p src_wim, as either a 1-based image index to
2050 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2052 * Pointer to the ::WIMStruct for a WIM that will receive the images being
2055 * For single-image exports, the name to give the exported image in @p
2056 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
2057 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2058 * that case, the names are all taken from @p src_wim. This parameter is
2059 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2060 * @param dest_description
2061 * For single-image exports, the description to give the exported image in
2062 * the new WIM file. If left @c NULL, the description from @p src_wim is
2063 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2064 * NULL; in that case, the description are all taken from @p src_wim. This
2065 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2066 * @param export_flags
2067 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2068 * @param progress_func
2069 * Currently ignored, but reserved for a function that will be called with
2070 * information about the operation. Use NULL if no additional information
2073 * @return 0 on success; nonzero on error.
2074 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2075 * One or more of the names being given to an exported image was already in
2076 * use in the destination WIM.
2077 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2078 * @p src_image does not exist in @p src_wim and was not
2079 * ::WIMLIB_ALL_IMAGES.
2080 * @retval ::WIMLIB_ERR_INVALID_PARAM
2081 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2082 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2084 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2085 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
2086 * example, one of them was a non-first part of a split WIM.
2087 * @retval ::WIMLIB_ERR_NOMEM
2088 * Failed to allocate needed memory.
2089 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2090 * A resource that needed to be exported could not be found in either the
2091 * source or destination WIMs. This error can occur if, for example, @p
2092 * src_wim is part of a split WIM but needed resources from the other split
2093 * WIM parts were not referenced with wimlib_reference_resources() or
2094 * wimlib_reference_resource_files() before the call to
2095 * wimlib_export_image().
2096 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2097 * @p dest_wim is considered read-only because of any of the reasons
2098 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2101 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2102 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2103 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2104 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2105 * different reasons) to read the metadata resource for an image in @p src_wim
2106 * that needed to be exported.
2109 wimlib_export_image(WIMStruct *src_wim, int src_image,
2110 WIMStruct *dest_wim,
2111 const wimlib_tchar *dest_name,
2112 const wimlib_tchar *dest_description,
2114 wimlib_progress_func_t progress_func);
2117 * @ingroup G_extracting_wims
2119 * Extract zero or more files or directory trees from a WIM image.
2121 * This generalizes the single-image extraction functionality of
2122 * wimlib_extract_image() to allow extracting only the specified subsets of the
2126 * The WIM from which to extract the files, specified as a pointer to the
2127 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2128 * split WIM. In the case of a WIM file that is not standalone, this
2129 * ::WIMStruct must have had any needed external resources previously
2130 * referenced using wimlib_reference_resources() or
2131 * wimlib_reference_resource_files().
2134 * The 1-based number of the image in @p wim from which the files or
2135 * directory trees are to be extracted. It cannot be ::WIMLIB_ALL_IMAGES.
2138 * An array of ::wimlib_extract_command structures that specifies the
2139 * extractions to perform.
2142 * Number of commands in the @p cmds array.
2144 * @param default_extract_flags
2145 * Default extraction flags; the behavior shall be as if these flags had
2146 * been specified in the ::wimlib_extract_command.extract_flags member in
2147 * each extraction command, in combination with any flags already present.
2149 * @param progress_func
2150 * If non-NULL, a function that will be called periodically with the
2151 * progress of the current operation.
2153 * @return 0 on success; nonzero on error. The possible error codes include
2154 * most of those documented as returned by wimlib_extract_image() as well as the
2155 * following additional error codes:
2157 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2158 * @p image was ::WIMLIB_ALL_IMAGES (or was not otherwise a valid image in
2160 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2161 * The ::wimlib_extract_command.wim_source_path member in one of the
2162 * extract commands did not exist in the WIM.
2163 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2164 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
2165 * in which ::wimlib_extract_command.wim_source_path existed but was not a
2166 * regular file or directory.
2167 * @retval ::WIMLIB_ERR_INVALID_PARAM
2168 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
2169 * specified for some commands but not all; or
2170 * ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
2171 * for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
2172 * for a command in which ::wimlib_extract_command.wim_source_path did not
2173 * specify the root directory of the WIM image.
2176 wimlib_extract_files(WIMStruct *wim,
2178 const struct wimlib_extract_command *cmds,
2180 int default_extract_flags,
2181 wimlib_progress_func_t progress_func);
2184 * @ingroup G_extracting_wims
2186 * Extracts an image, or all images, from a WIM to a directory or directly to a
2187 * NTFS volume image.
2189 * The exact behavior of how wimlib extracts files from a WIM image is
2190 * controllable by the @p extract_flags parameter, but there also are
2191 * differences depending on the platform (UNIX-like vs Windows). See the manual
2192 * page for <b>wimlib-imagex apply</b> for more information, including about the
2193 * special "NTFS volume extraction mode" entered by providing
2194 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2196 * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
2197 * returned if any resulting SHA1 message digests do not match the values
2198 * provided in the WIM file. Therefore, if this function is successful, you can
2199 * be fairly sure that any compressed data in the WIM was uncompressed
2203 * The WIM from which to extract the image(s), specified as a pointer to
2204 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2205 * of a split WIM. In the case of a WIM file that is not standalone, this
2206 * ::WIMStruct must have had any needed external resources previously
2207 * referenced using wimlib_reference_resources() or
2208 * wimlib_reference_resource_files().
2210 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
2211 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
2212 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2214 * Directory to extract the WIM image(s) to (created if it does not already
2215 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @p extract_flags, the
2216 * path to the unmounted NTFS volume to extract the image to.
2217 * @param extract_flags
2218 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
2219 * @param progress_func
2220 * If non-NULL, a function that will be called periodically with the
2221 * progress of the current operation.
2223 * @return 0 on success; nonzero on error.
2224 * @retval ::WIMLIB_ERR_DECOMPRESSION
2225 * Failed to decompress a resource to be extracted.
2226 * @retval ::WIMLIB_ERR_INVALID_PARAM
2227 * Both ::WIMLIB_EXTRACT_FLAG_HARDLINK and ::WIMLIB_EXTRACT_FLAG_SYMLINK
2228 * were specified in @p extract_flags; or both
2229 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS and ::WIMLIB_EXTRACT_FLAG_NO_ACLS were
2230 * specified in @p extract_flags; or both ::WIMLIB_EXTRACT_FLAG_RPFIX and
2231 * ::WIMLIB_EXTRACT_FLAG_NORPFIX were specified in @p extract_flags; or
2232 * ::WIMLIB_EXTRACT_FLAG_RESUME was specified in @p extract_flags; or if
2233 * ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @p extract_flags and
2234 * @p image was ::WIMLIB_ALL_IMAGES.
2235 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2236 * The SHA1 message digest of an extracted stream did not match the SHA1
2237 * message digest given in the WIM file.
2238 * @retval ::WIMLIB_ERR_LINK
2239 * Failed to create a symbolic link or a hard link.
2240 * @retval ::WIMLIB_ERR_MKDIR
2241 * Failed create a directory.
2242 * @retval ::WIMLIB_ERR_NOMEM
2243 * Failed to allocate needed memory.
2244 * @retval ::WIMLIB_ERR_OPEN
2245 * Could not create a file, or failed to open an already-extracted file.
2246 * @retval ::WIMLIB_ERR_READ
2247 * Failed to read data from the WIM file associated with @p wim.
2248 * @retval ::WIMLIB_ERR_READLINK
2249 * Failed to determine the target of a symbolic link in the WIM.
2250 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2251 * Failed to fix the target of an absolute symbolic link (e.g. if the
2252 * target would have exceeded the maximum allowed length). (Only if
2253 * reparse data was supported by the extraction mode and
2254 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p extract_flags.)
2255 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2256 * One of the files or directories that needed to be extracted referenced a
2257 * stream not present in the WIM's lookup table (or in any of the lookup
2258 * tables of the split WIM parts).
2259 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2260 * Failed to set attributes on a file.
2261 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2262 * Failed to set reparse data on a file (only if reparse data was supported
2263 * by the extraction mode).
2264 * @retval ::WIMLIB_ERR_SET_SECURITY
2265 * Failed to set security descriptor on a file
2266 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2268 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2269 * Failed to set the short name of a file (only if
2270 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2271 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2272 * Failed to set timestamps on a file (only if
2273 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2274 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2275 * Unexpected end-of-file occurred when reading data from the WIM file
2276 * associated with @p wim.
2277 * @retval ::WIMLIB_ERR_UNSUPPORTED
2278 * A requested extraction flag, or the data or metadata that must be
2279 * extracted to support it, is unsupported in the build and configuration
2280 * of wimlib, or on the current platform or extraction mode or target
2281 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2282 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2283 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2284 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS,
2285 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS, ::WIMLIB_EXTRACT_FLAG_SYMLINK,
2286 * and ::WIMLIB_EXTRACT_FLAG_HARDLINK. For example, if
2287 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2289 * ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM image contains one
2290 * or more files with short names, but extracting short names is not
2291 * supported --- on Windows, this occurs if the target volume does not
2292 * support short names, while on non-Windows, this occurs if
2293 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2294 * @retval ::WIMLIB_ERR_WRITE
2295 * Failed to write data to a file being extracted.
2297 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2298 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2299 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2300 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2301 * different reasons) to read the metadata resource for an image that needed to
2305 wimlib_extract_image(WIMStruct *wim, int image,
2306 const wimlib_tchar *target,
2308 wimlib_progress_func_t progress_func);
2311 * @ingroup G_extracting_wims
2313 * Since wimlib v1.5.0: Extract one or more images from a pipe on which a
2314 * pipable WIM is being sent.
2316 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2317 * about pipable WIMs.
2319 * This function operates in a special way to read the WIM fully sequentially.
2320 * As a result, there is no ::WIMStruct is made visible to library users, and
2321 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2322 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2323 * seekable file, not a pipe.)
2326 * File descriptor, which may be a pipe, opened for reading and positioned
2327 * at the start of the pipable WIM.
2328 * @param image_num_or_name
2329 * String that specifies the 1-based index or name of the image to extract.
2330 * It is translated to an image index using the same rules that
2331 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2332 * only a single image (not all images) can be specified. Alternatively,
2333 * specify @p NULL here to use the first image in the WIM if it contains
2334 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2336 * Same as the corresponding parameter to wimlib_extract_image().
2337 * @param extract_flags
2338 * Same as the corresponding parameter to wimlib_extract_image(), except
2339 * for the following exceptions: ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is
2340 * always implied, since data is always read from @p pipe_fd sequentially
2341 * in this mode; also, ::WIMLIB_EXTRACT_FLAG_TO_STDOUT is invalid and will
2342 * result in ::WIMLIB_ERR_INVALID_PARAM being returned.
2343 * @param progress_func
2344 * Same as the corresponding parameter to wimlib_extract_image(), except
2345 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
2348 * @return 0 on success; nonzero on error. The possible error codes include
2349 * those returned by wimlib_extract_image() as well as the following:
2351 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2352 * Data read from the pipable WIM was invalid.
2353 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2354 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2357 wimlib_extract_image_from_pipe(int pipe_fd,
2358 const wimlib_tchar *image_num_or_name,
2359 const wimlib_tchar *target, int extract_flags,
2360 wimlib_progress_func_t progress_func);
2363 * Similar to wimlib_extract_paths(), but the paths to extract from the WIM
2364 * image specified in the UTF-8 text file named by @p path_list_file which
2365 * itself contains the list of paths to use, one per line. Leading and trailing
2366 * whitespace, and otherwise empty lines and lines beginning with the ';'
2367 * character are ignored. No quotes are needed as paths are otherwise delimited
2368 * by the newline character.
2371 wimlib_extract_pathlist(WIMStruct *wim, int image,
2372 const wimlib_tchar *target,
2373 const wimlib_tchar *path_list_file,
2375 wimlib_progress_func_t progress_func);
2378 * Similar to wimlib_extract_files(), but the files or directories to extract
2379 * from the WIM image are specified as an array of paths.
2381 * Each path will be extracted to a corresponding subdirectory of the @p target
2382 * based on its location in the WIM image. For example, if one of the paths to
2383 * extract is "/Windows/explorer.exe" and the target is "outdir", the file will
2384 * be extracted to "outdir/Windows/explorer.exe". Each path to extract must be
2385 * specified as the absolute path to a directory within the WIM image.
2386 * Separators in the paths to extract may be either forwards or backwards
2387 * slashes, and leading path separators are optional. Symbolic links are not
2388 * dereferenced when interpreting paths to extract. Paths to extract will be
2389 * interpreted either case-sensitively (UNIX default) or case-insensitively
2390 * (Windows default); this can be changed by wimlib_global_init().
2392 * The @p target path, on the other hand, is expected to be a native path. On
2393 * UNIX-like systems it may not contain backslashes, for example.
2395 * By default, if any paths to extract do not exist,
2396 * ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is issued. This behavior changes if
2397 * ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified.
2399 * With ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS specified in @p extract_flags, this
2400 * function additionally allows paths to be globs using the wildcard characters
2404 wimlib_extract_paths(WIMStruct *wim,
2406 const wimlib_tchar *target,
2407 const wimlib_tchar * const *paths,
2410 wimlib_progress_func_t progress_func);
2413 * @ingroup G_wim_information
2415 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2416 * includes a string of XML that describes the images contained in the WIM.
2418 * See wimlib_get_xml_data() to read the XML data into memory instead.
2421 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2422 * have to be standalone (e.g. it could be part of a split WIM).
2424 * @c stdout, or a FILE* opened for writing, to extract the data to.
2426 * @return 0 on success; nonzero on error.
2427 * @retval ::WIMLIB_ERR_INVALID_PARAM
2428 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2429 * @retval ::WIMLIB_ERR_NOMEM
2430 * @retval ::WIMLIB_ERR_READ
2431 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2432 * Failed to read the XML data from the WIM.
2433 * @retval ::WIMLIB_ERR_WRITE
2434 * Failed to completely write the XML data to @p fp.
2437 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2440 * @ingroup G_general
2442 * Frees all memory allocated for a WIMStruct and closes all files associated
2446 * Pointer to the ::WIMStruct for a WIM file.
2448 * @return This function has no return value.
2451 wimlib_free(WIMStruct *wim);
2454 * @ingroup G_general
2456 * Converts a ::wimlib_compression_type value into a string.
2459 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
2460 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
2463 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
2466 extern const wimlib_tchar *
2467 wimlib_get_compression_type_string(int ctype);
2470 * @ingroup G_general
2472 * Converts an error code into a string describing it.
2475 * The error code returned by one of wimlib's functions.
2478 * Pointer to a statically allocated string describing the error code,
2479 * or @c NULL if the error code is not valid.
2481 extern const wimlib_tchar *
2482 wimlib_get_error_string(enum wimlib_error_code code);
2485 * @ingroup G_wim_information
2487 * Returns the description of the specified image.
2490 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2491 * to be standalone (e.g. it could be part of a split WIM).
2493 * The number of the image, numbered starting at 1.
2496 * The description of the image, or @c NULL if there is no such image, or
2497 * @c NULL if the specified image has no description. The description
2498 * string is in library-internal memory and may not be modified or freed;
2499 * in addition, the string will become invalid if the description of the
2500 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2502 extern const wimlib_tchar *
2503 wimlib_get_image_description(const WIMStruct *wim, int image);
2506 * @ingroup G_wim_information
2508 * Returns the name of the specified image.
2511 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2512 * to be standalone (e.g. it could be part of a split WIM).
2514 * The number of the image, numbered starting at 1.
2517 * The name of the image, or @c NULL if there is no such image, or an empty
2518 * string if the image is unnamed. The name string is in
2519 * library-internal memory and may not be modified or freed; in addition,
2520 * the string will become invalid if the name of the image is changed, the
2521 * image is deleted, or the ::WIMStruct is destroyed.
2523 extern const wimlib_tchar *
2524 wimlib_get_image_name(const WIMStruct *wim, int image);
2528 * @ingroup G_wim_information
2530 * Get basic information about a WIM file.
2533 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2534 * to be standalone (e.g. it could be part of a split WIM).
2536 * A ::wimlib_wim_info structure that will be filled in with information
2537 * about the WIM file.
2542 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2545 * @ingroup G_wim_information
2547 * Read the XML data of a WIM file into an in-memory buffer. Every WIM file
2548 * includes a string of XML that describes the images contained in the WIM.
2550 * See wimlib_extract_xml_data() to extract the XML data to a file stream
2554 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2555 * have to be standalone (e.g. it could be part of a split WIM).
2557 * On success, a pointer to an allocated buffer containing the raw UTF16-LE
2558 * XML data is written to this location.
2559 * @param bufsize_ret
2560 * The size of the XML data in bytes is written to this location.
2562 * @return 0 on success; nonzero on error.
2563 * @retval ::WIMLIB_ERR_INVALID_PARAM
2564 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2565 * @p buf_ret or @p bufsize_ret was @c NULL.
2566 * @retval ::WIMLIB_ERR_NOMEM
2567 * @retval ::WIMLIB_ERR_READ
2568 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2569 * Failed to read the XML data from the WIM.
2572 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2575 * @ingroup G_general
2577 * Initialization function for wimlib. Call before using any other wimlib
2578 * function except wimlib_set_print_errors(). If not done manually, this
2579 * function will be called automatically with @p init_flags set to
2580 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8. This function does nothing if called again
2581 * after it has already successfully run.
2584 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2586 * @return 0 on success; nonzero on failure. Currently, only the following
2587 * error code is defined:
2589 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2590 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2591 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2592 * init_flags, but the corresponding privileges could not be acquired.
2595 wimlib_global_init(int init_flags);
2598 * @ingroup G_general
2600 * Cleanup function for wimlib. You are not required to call this function, but
2601 * it will release any global resources allocated by the library.
2604 wimlib_global_cleanup(void);
2607 * @ingroup G_wim_information
2609 * Determines if an image name is already used by some image in the WIM.
2612 * Pointer to the ::WIMStruct for a WIM file.
2614 * The name to check.
2617 * @c true if there is already an image in @p wim named @p name; @c false
2618 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2619 * the empty string, @c false is returned.
2622 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2625 * @ingroup G_wim_information
2627 * Iterate through a file or directory tree in the WIM image. By specifying
2628 * appropriate flags and a callback function, you can get the attributes of a
2629 * file in the WIM, get a directory listing, or even get a listing of the entire
2633 * The WIM containing the image(s) over which to iterate, specified as a
2634 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2635 * or part 1 of a split WIM. In the case of a WIM file that is not
2636 * standalone, this ::WIMStruct should have had any needed external
2637 * resources previously referenced using wimlib_reference_resources() or
2638 * wimlib_reference_resource_files(). If not, see
2639 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2640 * the behavior when resources are missing.
2643 * The 1-based number of the image in @p wim that contains the files or
2644 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2645 * iteration on all images in the WIM.
2648 * Path in the WIM image at which to do the iteration.
2651 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2654 * A callback function that will receive each directory entry.
2657 * An extra parameter that will always be passed to the callback function
2660 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2661 * first nonzero value that was returned from @p cb. However, additional error
2662 * codes may be returned, including the following:
2664 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2665 * @p path did not exist in the WIM image.
2666 * @retval ::WIMLIB_ERR_NOMEM
2667 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2669 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2670 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2671 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2672 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2673 * different reasons) to read the metadata resource for an image over which
2674 * iteration needed to be done.
2677 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2679 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2682 * @ingroup G_wim_information
2684 * Iterate through the lookup table of a WIM file. This can be used to directly
2685 * get a listing of the unique resources contained in a WIM file over all
2686 * images. Both file resources and metadata resources are included. However,
2687 * only resources actually included in the file represented by @a wim, plus
2688 * explicitly referenced external resources (via wimlib_reference_resources() or
2689 * wimlib_reference_resource_files()) are included in the iteration. For
2690 * example, if @p wim represents just one part of a split WIM, then only
2691 * resources in that part will be included, unless other resources were
2692 * explicitly referenced.
2695 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2696 * to be standalone (e.g. it could be part of a split WIM).
2699 * Reserved; set to 0.
2702 * A callback function that will receive each resource.
2705 * An extra parameter that will always be passed to the callback function
2708 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
2709 * that was returned from @p cb.
2712 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2713 wimlib_iterate_lookup_table_callback_t cb,
2717 * @ingroup G_nonstandalone_wims
2719 * Joins a split WIM into a stand-alone one-part WIM.
2722 * An array of strings that gives the filenames of all parts of the split
2723 * WIM. No specific order is required, but all parts must be included with
2726 * Number of filenames in @p swms.
2727 * @param swm_open_flags
2728 * Open flags for the split WIM parts (e.g.
2729 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
2730 * @param wim_write_flags
2731 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
2732 * be used to write the joined WIM.
2733 * @param output_path
2734 * The path to write the joined WIM file to.
2735 * @param progress_func
2736 * If non-NULL, a function that will be called periodically with the
2737 * progress of the current operation.
2739 * @return 0 on success; nonzero on error. This function may return most error
2740 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
2741 * as the following error code:
2743 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2744 * The split WIMs do not form a valid WIM because they do not include all
2745 * the parts of the original WIM, there are duplicate parts, or not all the
2746 * parts have the same GUID and compression type.
2748 * Note: wimlib is generalized enough that this function is not actually needed
2749 * to join a split WIM; instead, you could open the first part of the split WIM,
2750 * then reference the other parts with wimlib_reference_resource_files(), then
2751 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
2752 * an easy-to-use wrapper around this that has some advantages (e.g. extra
2756 wimlib_join(const wimlib_tchar * const *swms,
2758 const wimlib_tchar *output_path,
2760 int wim_write_flags,
2761 wimlib_progress_func_t progress_func);
2765 * @ingroup G_mounting_wim_images
2767 * Mounts an image in a WIM file on a directory read-only or read-write.
2769 * As this is implemented using FUSE (Filesystme in UserSpacE), this is not
2770 * supported if wimlib was configured with @c --without-fuse. This includes
2771 * Windows builds of wimlib; ::WIMLIB_ERR_UNSUPPORTED will be returned in such
2774 * Calling this function daemonizes the process, unless
2775 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early occur occurs. If the
2776 * mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified), modifications
2777 * to the WIM are staged in a temporary directory.
2779 * It is safe to mount multiple images from the same underlying WIM file
2780 * read-only at the same time, but only if different ::WIMStruct's are used. It
2781 * is @b not safe to mount multiple images from the same WIM file read-write at
2784 * wimlib_mount_image() cannot be used on an image that was exported with
2785 * wimlib_export_image() while the dentry trees for both images are still in
2786 * memory. In addition, wimlib_mount_image() may not be used to mount an image
2787 * that already has modifications pending (e.g. an image added with
2788 * wimlib_add_image()).
2791 * Pointer to the ::WIMStruct containing the image to be mounted.
2793 * The number of the image to mount, indexed starting from it. It must be
2794 * an existing, single image.
2796 * The path to an existing empty directory to mount the image on.
2797 * @param mount_flags
2798 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
2799 * @param staging_dir
2800 * If non-NULL, the name of a directory in which the staging directory will
2801 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2802 * in @p mount_flags. If left @c NULL, the staging directory is created in
2803 * the same directory as the WIM file that @p wim was originally read from.
2805 * @return 0 on success; nonzero on error.
2807 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2808 * A read-write mount was requested, but an an exclusive advisory lock on
2809 * the on-disk WIM file could not be acquired because another thread or
2810 * process has mounted an image from the WIM read-write or is currently
2811 * modifying the WIM in-place.
2812 * @retval ::WIMLIB_ERR_FUSE
2813 * A non-zero status was returned by @c fuse_main().
2814 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2815 * @p image does not specify an existing, single image in @p wim.
2816 * @retval ::WIMLIB_ERR_INVALID_PARAM
2817 * @p image is shared among multiple ::WIMStruct's as a result of a call to
2818 * wimlib_export_image(), or @p image has been added with
2819 * wimlib_add_image().
2820 * @retval ::WIMLIB_ERR_MKDIR
2821 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
2822 * staging directory could not be created.
2823 * @retval ::WIMLIB_ERR_NOTDIR
2824 * Could not determine the current working directory.
2825 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2826 * One of the dentries in the image referenced a stream not present in the
2827 * WIM's lookup table (or in any of the lookup tables of the split WIM
2829 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2830 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but @p
2831 * wim is considered read-only because of any of the reasons mentioned in
2832 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2833 * @retval ::WIMLIB_ERR_UNSUPPORTED
2834 * Mounting is not supported, either because the platform is Windows, or
2835 * because the platform is UNIX-like and wimlib was compiled with @c
2838 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2839 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2840 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2841 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2842 * different reasons) to read the metadata resource for the image to mount.
2845 wimlib_mount_image(WIMStruct *wim,
2847 const wimlib_tchar *dir,
2849 const wimlib_tchar *staging_dir);
2852 * @ingroup G_creating_and_opening_wims
2854 * Opens a WIM file and creates a ::WIMStruct for it.
2857 * The path to the WIM file to open.
2860 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
2862 * @param progress_func
2863 * If non-NULL, a function that will be called periodically with the
2864 * progress of the current operation. Currently, the only messages sent
2865 * will be ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY, and only if
2866 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags.
2869 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2870 * is written to the memory location pointed to by this parameter. The
2871 * ::WIMStruct can be freed using using wimlib_free() when finished with
2874 * @return 0 on success; nonzero on error.
2875 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2876 * The WIM is not the non-first part of a split WIM, and the number of
2877 * metadata resources found in the WIM did not match the image count given
2878 * in the WIM header, or the number of <IMAGE> elements in the XML
2879 * data for the WIM did not match the image count given in the WIM header.
2880 * @retval ::WIMLIB_ERR_INTEGRITY
2881 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2882 * wim_file contains an integrity table, but the SHA1 message digest for a
2883 * chunk of the WIM does not match the corresponding message digest given
2884 * in the integrity table.
2885 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2886 * Resources in @p wim_file are compressed, but the chunk size was invalid
2887 * for the WIM's compression format.
2888 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2889 * The header of @p wim_file says that resources in the WIM are compressed,
2890 * but the header flag indicating LZX or XPRESS compression is not set.
2891 * @retval ::WIMLIB_ERR_INVALID_HEADER
2892 * The header of @p wim_file was otherwise invalid.
2893 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2894 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2895 * wim_file contains an integrity table, but the integrity table is
2897 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2898 * The lookup table for the WIM contained duplicate entries that are not
2899 * for metadata resources, or it contained an entry with a SHA1 message
2900 * digest of all 0's.
2901 * @retval ::WIMLIB_ERR_INVALID_PARAM
2902 * @p wim_ret was @c NULL.
2903 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
2904 * @p wim_file is a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
2905 * specified in @p open_flags.
2906 * @retval ::WIMLIB_ERR_NOMEM
2907 * Failed to allocated needed memory.
2908 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2909 * @p wim_file does not begin with the expected magic characters.
2910 * @retval ::WIMLIB_ERR_OPEN
2911 * Failed to open the file @p wim_file for reading.
2912 * @retval ::WIMLIB_ERR_READ
2913 * Failed to read data from @p wim_file.
2914 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2915 * Unexpected end-of-file while reading data from @p wim_file.
2916 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2917 * A number other than 0x10d00 is written in the version field of the WIM
2918 * header of @p wim_file. (May be a pre-Vista WIM.)
2919 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2920 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2921 * considered read-only because of any of the reasons mentioned in the
2922 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2923 * @retval ::WIMLIB_ERR_XML
2924 * The XML data for @p wim_file is invalid.
2927 wimlib_open_wim(const wimlib_tchar *wim_file,
2929 WIMStruct **wim_ret,
2930 wimlib_progress_func_t progress_func);
2933 * @ingroup G_writing_and_overwriting_wims
2935 * Overwrites the file that the WIM was originally read from, with changes made.
2936 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2937 * rather than wimlib_create_new_wim().
2939 * There are two ways that a WIM may be overwritten. The first is to do a full
2940 * rebuild. In this mode, the new WIM is written to a temporary file and then
2941 * renamed to the original file after it is has been completely written. The
2942 * temporary file is made in the same directory as the original WIM file. A
2943 * full rebuild may take a while, but can be used even if images have been
2944 * modified or deleted, will produce a WIM with no holes, and has little chance
2945 * of unintentional data loss because the temporary WIM is fsync()ed before
2946 * being renamed to the original WIM.
2948 * The second way to overwrite a WIM is by appending to the end of it and
2949 * overwriting the header. This can be much faster than a full rebuild, but the
2950 * disadvantage is that some space will be wasted. Writing a WIM in this mode
2951 * begins with writing any new file resources *after* everything in the old WIM,
2952 * even though this will leave a hole where the old lookup table, XML data, and
2953 * integrity were. This is done so that the WIM remains valid even if the
2954 * operation is aborted mid-write. The WIM header is only overwritten at the
2955 * very last moment, and up until that point the WIM will be seen as the old
2958 * By default, wimlib_overwrite() does the append-style overwrite described
2959 * above, unless resources in the WIM are arranged in an unusual way or if
2960 * images have been deleted from the WIM. Use the flag
2961 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
2962 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
2963 * images have been deleted from the WIM.
2965 * In the temporary-file overwrite mode, no changes are made to the WIM on
2966 * failure, and the temporary file is deleted if possible. Abnormal termination
2967 * of the program will result in the temporary file being orphaned. In the
2968 * direct append mode, the WIM is truncated to the original length on failure;
2969 * and while abnormal termination of the program will result in extra data
2970 * appended to the original WIM, it should still be a valid WIM.
2972 * If this function completes successfully, no more functions should be called
2973 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
2974 * the WIM file anew.
2977 * Pointer to the ::WIMStruct for the WIM file to write. There may have
2978 * been in-memory changes made to it, which are then reflected in the
2980 * @param write_flags
2981 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
2982 * @param num_threads
2983 * Number of threads to use for compression (see wimlib_write()).
2984 * @param progress_func
2985 * If non-NULL, a function that will be called periodically with the
2986 * progress of the current operation.
2988 * @return 0 on success; nonzero on error. This function may return most error
2989 * codes returned by wimlib_write() as well as the following error codes:
2991 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2992 * The WIM was going to be modified in-place (with no temporary file), but
2993 * an exclusive advisory lock on the on-disk WIM file could not be acquired
2994 * because another thread or process has mounted an image from the WIM
2995 * read-write or is currently modifying the WIM in-place.
2996 * @retval ::WIMLIB_ERR_NO_FILENAME
2997 * @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
2998 * than a WIM read with wimlib_open_wim().
2999 * @retval ::WIMLIB_ERR_RENAME
3000 * The temporary file that the WIM was written to could not be renamed to
3001 * the original filename of @p wim.
3002 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3003 * The WIM file is considered read-only because of any of the reasons
3004 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3008 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
3009 wimlib_progress_func_t progress_func);
3012 * @ingroup G_wim_information
3014 * Prints information about one image, or all images, contained in a WIM.
3017 * Pointer to the ::WIMStruct for a WIM file.
3019 * The image about which to print information. Can be the number of an
3020 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3023 * @return This function has no return value. No error checking is done when
3024 * printing the information. If @p image is invalid, an error message is
3028 wimlib_print_available_images(const WIMStruct *wim, int image);
3031 * @ingroup G_wim_information
3033 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3034 * in a way that can be accessed programatically.
3037 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3040 * @ingroup G_wim_information
3042 * Deprecated in favor of wimlib_iterate_dir_tree(), which provides the
3043 * information in a way that can be accessed programatically.
3046 wimlib_print_metadata(WIMStruct *wim, int image) _wimlib_deprecated;
3049 * @ingroup G_nonstandalone_wims
3051 * Reference resources from other WIM files or split WIM parts. This function
3052 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3053 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3054 * from other files, before calling a function such as wimlib_extract_image()
3055 * that requires the resources to be present.
3058 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3059 * necessarily "standalone". In the case of split WIMs, this should be the
3060 * first part, since only the first part contains the metadata resources.
3061 * In the case of delta WIMs, this should be the delta WIM rather than the
3062 * WIM on which it is based.
3063 * @param resource_wimfiles_or_globs
3064 * Array of paths to WIM files and/or split WIM parts to reference.
3065 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3066 * ref_flags, these are treated as globs rather than literal paths. That
3067 * is, using this function you can specify zero or more globs, each of
3068 * which expands to one or more literal paths.
3070 * Number of entries in @p resource_wimfiles_or_globs.
3072 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3073 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3075 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3076 * pass to internal calls to wimlib_open_wim() on the reference files.
3077 * @param progress_func
3078 * Passed to internal calls to wimlib_open_wim() on the reference files.
3080 * @return 0 on success; nonzero on error.
3082 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3083 * One of the specified globs did not match any paths (only with both
3084 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3085 * specified in @p ref_flags).
3086 * @retval ::WIMLIB_ERR_NOMEM
3087 * Failed to allocate memory.
3088 * @retval ::WIMLIB_ERR_READ
3089 * I/O or permissions error while processing a file glob.
3091 * This function can additionally return most values that can be returned by
3092 * wimlib_open_wim().
3095 wimlib_reference_resource_files(WIMStruct *wim,
3096 const wimlib_tchar * const *resource_wimfiles_or_globs,
3100 wimlib_progress_func_t progress_func);
3103 * @ingroup G_nonstandalone_wims
3105 * Similar to wimlib_reference_resource_files(), but operates at a lower level
3106 * where the caller must open the ::WIMStruct for each referenced file itself.
3109 * The ::WIMStruct for a WIM that contains metadata resources, but is not
3110 * necessarily "standalone". In the case of split WIMs, this should be the
3111 * first part, since only the first part contains the metadata resources.
3112 * @param resource_wims
3113 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
3114 * split WIM parts to reference.
3115 * @param num_resource_wims
3116 * Number of entries in @p resource_wims.
3118 * Currently ignored (set to 0).
3120 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
3121 * @p resource_wims are referenced internally by @p wim and must not be freed
3122 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3123 * been freed with wimlib_free(), or immediately before freeing @p wim with
3126 * @retval ::WIMLIB_ERR_INVALID_PARAM
3127 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3128 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3129 * @retval ::WIMLIB_ERR_NOMEM
3130 * Failed to allocate memory.
3133 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3134 unsigned num_resource_wims, int ref_flags);
3137 * @ingroup G_modifying_wims
3139 * Declares that a newly added image is mostly the same as a prior image, but
3140 * captured at a later point in time, possibly with some modifications in the
3141 * intervening time. This is designed to be used in incremental backups of the
3142 * same filesystem or directory tree.
3144 * This function compares the metadata of the directory tree of the newly added
3145 * image against that of the old image. Any files that are present in both the
3146 * newly added image and the old image and have timestamps that indicate they
3147 * haven't been modified are deemed not to have been modified and have their
3148 * SHA1 message digest copied from the old image. Because of this and because
3149 * WIM uses single-instance streams, such files need not be read from the
3150 * filesystem when the WIM is being written or overwritten. Note that these
3151 * unchanged files will still be "archived" and will be logically present in the
3152 * new image; the optimization is that they don't need to actually be read from
3153 * the filesystem because the WIM already contains them.
3155 * This function is provided to optimize incremental backups. The resulting WIM
3156 * file will still be the same regardless of whether this function is called.
3157 * (This is, however, assuming that timestamps have not been manipulated or
3158 * unmaintained as to trick this function into thinking a file has not been
3159 * modified when really it has. To partly guard against such cases, other
3160 * metadata such as file sizes will be checked as well.)
3162 * This function must be called after adding the new image (e.g. with
3163 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3164 * wimlib_overwrite()).
3167 * Pointer to the ::WIMStruct for a WIM.
3169 * 1-based index in the WIM of the newly added image. This image can have
3170 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3171 * wimlib_add_empty_image() followed by wimlib_update_image().
3172 * @param template_wim
3173 * The ::WIMStruct for the WIM containing the template image. This can be
3174 * the same as @p wim, or it can be a different ::WIMStruct.
3175 * @param template_image
3176 * 1-based index in the WIM of a template image that reflects a prior state
3177 * of the directory tree being captured.
3179 * Reserved; must be 0.
3180 * @param progress_func
3181 * Currently ignored, but reserved for a function that will be called with
3182 * information about the operation. Use NULL if no additional information
3185 * @return 0 on success; nonzero on error.
3187 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3188 * @p new_image and/or @p template_image were not a valid image indices in
3190 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3191 * The specified ::WIMStruct did not actually contain the metadata resource
3192 * for the new or template image; for example, it was a non-first part of a
3194 * @retval ::WIMLIB_ERR_NOMEM
3195 * Failed to allocate needed memory.
3196 * @retval ::WIMLIB_ERR_INVALID_PARAM
3197 * @p new_image was equal to @p template_image, or @p new_image specified
3198 * an image that had not been modified since opening the WIM.
3200 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3201 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3202 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3203 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3204 * different reasons) to read the metadata resource for the template image.
3207 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3208 WIMStruct *template_wim, int template_image,
3209 int flags, wimlib_progress_func_t progress_func);
3212 * @ingroup G_wim_information
3214 * Translates a string specifying the name or number of an image in the WIM into
3215 * the number of the image. The images are numbered starting at 1.
3218 * Pointer to the ::WIMStruct for a WIM.
3219 * @param image_name_or_num
3220 * A string specifying the name or number of an image in the WIM. If it
3221 * parses to a positive integer, this integer is taken to specify the
3222 * number of the image, indexed starting at 1. Otherwise, it is taken to
3223 * be the name of an image, as given in the XML data for the WIM file. It
3224 * also may be the keyword "all" or the string "*", both of which will
3225 * resolve to ::WIMLIB_ALL_IMAGES.
3227 * There is no way to search for an image actually named "all", "*", or an
3228 * integer number, or an image that has no name. However, you can use
3229 * wimlib_get_image_name() to get the name of any image.
3232 * If the string resolved to a single existing image, the number of that
3233 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
3234 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
3235 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
3236 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3237 * images in @p wim has no name.
3240 wimlib_resolve_image(WIMStruct *wim,
3241 const wimlib_tchar *image_name_or_num);
3244 * @ingroup G_modifying_wims
3246 * Changes the description of an image in the WIM.
3249 * Pointer to the ::WIMStruct for a WIM.
3251 * The number of the image for which to change the description.
3252 * @param description
3253 * The new description to give the image. It may be @c NULL, which
3254 * indicates that the image is to be given no description.
3256 * @return 0 on success; nonzero on error.
3257 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3258 * @p image does not specify a single existing image in @p wim.
3259 * @retval ::WIMLIB_ERR_NOMEM
3260 * Failed to allocate the memory needed to duplicate the @p description
3262 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3263 * @p wim is considered read-only because of any of the reasons mentioned
3264 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3267 wimlib_set_image_descripton(WIMStruct *wim, int image,
3268 const wimlib_tchar *description);
3271 * @ingroup G_writing_and_overwriting_wims
3273 * Set the compression chunk size of a WIM to use in subsequent calls to
3274 * wimlib_write() or wimlib_overwrite().
3276 * A compression chunk size will result in a greater compression ratio, but the
3277 * speed of random access to the WIM will be reduced, and the effect of an
3278 * increased compression chunk size is limited by the size of each file being
3281 * <b>WARNING: Microsoft's software is seemingly incompatible with LZX chunk
3282 * sizes other than 32768. Chunk sizes other than 32768 (for any format) are
3283 * also incompatible with wimlib v1.5.3 and earlier.</b>
3286 * ::WIMStruct for a WIM.
3287 * @param out_chunk_size
3288 * The chunk size (in bytes) to set. The valid chunk sizes are dependent
3289 * on the compression format. The XPRESS compression format supports chunk
3290 * sizes that are powers of 2 with exponents between 15 and 26 inclusively,
3291 * whereas the LZX compression format supports chunk sizes that are powers
3292 * of 2 with exponents between 15 and 21 inclusively. As a special case,
3293 * if @p out_chunk_size is specified as 0, the chunk size is set to the
3294 * default for the currently selected output compression type.
3296 * @return 0 on success; nonzero on error.
3298 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3299 * @p ctype is not a supported chunk size.
3302 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3305 * @ingroup G_writing_and_overwriting_wims
3307 * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3311 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3314 * @ingroup G_writing_and_overwriting_wims
3316 * Set the compression type of a WIM to use in subsequent calls to
3317 * wimlib_write() or wimlib_overwrite().
3320 * ::WIMStruct for a WIM.
3322 * The compression type to set (one of ::wimlib_compression_type). If this
3323 * compression type is incompatible with the current output chunk size
3324 * (either the default or as set with wimlib_set_output_chunk_size()), the
3325 * output chunk size is reset to the default for that compression type.
3327 * @return 0 on success; nonzero on error.
3329 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3330 * @p ctype did not specify a valid compression type.
3333 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3336 * @ingroup G_writing_and_overwriting_wims
3338 * Similar to wimlib_set_output_compression_type(), but set the compression type
3339 * for writing packed streams.
3342 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3345 * @ingroup G_modifying_wims
3347 * Set basic information about a WIM.
3350 * Pointer to the ::WIMStruct for a WIM.
3352 * A struct ::wimlib_wim_info that contains the information to set. Only
3353 * the information explicitly specified in the @p which flags need be
3356 * Flags that specify which information to set. This is a bitwise OR of
3357 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3358 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3360 * @return 0 on success; nonzero on failure.
3361 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3362 * The WIM file is considered read-only because of any of the reasons
3363 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3364 * flag. However, as a special case, if you are using
3365 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3366 * function will not fail due to the readonly flag being previously set.
3367 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3368 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3369 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3373 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3377 * @ingroup G_modifying_wims
3379 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3380 * (something like "Core" or "Ultimate")
3383 * Pointer to the ::WIMStruct for a WIM.
3385 * The number of the image for which to change the description.
3387 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3388 * indicates that the image is to be given no \<FLAGS\> element.
3390 * @return 0 on success; nonzero on error.
3391 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3392 * @p image does not specify a single existing image in @p wim.
3393 * @retval ::WIMLIB_ERR_NOMEM
3394 * Failed to allocate the memory needed to duplicate the @p flags string.
3395 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3396 * @p wim is considered read-only because of any of the reasons mentioned
3397 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3400 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3403 * @ingroup G_modifying_wims
3405 * Changes the name of an image in the WIM.
3408 * Pointer to the ::WIMStruct for a WIM.
3410 * The number of the image for which to change the name.
3412 * New name to give the new image. If @c NULL or empty, the new image is
3413 * given no name. If nonempty, it must specify a name that does not
3414 * already exist in @p wim.
3416 * @return 0 on success; nonzero on error.
3417 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3418 * There is already an image named @p name in @p wim.
3419 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3420 * @p image does not specify a single existing image in @p wim.
3421 * @retval ::WIMLIB_ERR_NOMEM
3422 * Failed to allocate the memory needed to duplicate the @p name string.
3423 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3424 * @p wim is considered read-only because of any of the reasons mentioned
3425 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3428 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3431 * @ingroup G_general
3433 * Set the functions that wimlib uses to allocate and free memory.
3435 * These settings are global and not per-WIM.
3437 * The default is to use the default @c malloc() and @c free() from the C
3440 * Please note that some external functions, such as those in @c libntfs-3g, may
3441 * use the standard memory allocation functions.
3443 * @param malloc_func
3444 * A function equivalent to @c malloc() that wimlib will use to allocate
3445 * memory. If @c NULL, the allocator function is set back to the default
3446 * @c malloc() from the C library.
3448 * A function equivalent to @c free() that wimlib will use to free memory.
3449 * If @c NULL, the free function is set back to the default @c free() from
3451 * @param realloc_func
3452 * A function equivalent to @c realloc() that wimlib will use to reallocate
3453 * memory. If @c NULL, the free function is set back to the default @c
3454 * realloc() from the C library.
3458 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3459 void (*free_func)(void *),
3460 void *(*realloc_func)(void *, size_t));
3463 * @ingroup G_general
3465 * Sets whether wimlib is to print error messages to @c stderr when a function
3466 * fails. These error messages may provide information that cannot be
3467 * determined only from the error code that is returned. Not every error will
3468 * result in an error message being printed.
3470 * This setting is global and not per-WIM.
3472 * By default, error messages are not printed.
3474 * This can be called before wimlib_global_init().
3476 * @param show_messages
3477 * @c true if error messages are to be printed; @c false if error messages
3478 * are not to be printed.
3480 * @return 0 on success; nonzero on error.
3481 * @retval ::WIMLIB_ERR_UNSUPPORTED
3482 * @p show_messages was @c true, but wimlib was compiled with the @c
3483 * --without-error-messages option. Therefore, error messages cannot be
3487 wimlib_set_print_errors(bool show_messages);
3490 * @ingroup G_nonstandalone_wims
3492 * Splits a WIM into multiple parts.
3495 * The ::WIMStruct for the WIM to split.
3497 * Name of the SWM file to create. This will be the name of the first
3498 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3499 * appended before the suffix.
3501 * The maximum size per part, in bytes. Unfortunately, it is not
3502 * guaranteed that this will really be the maximum size per part, because
3503 * some file resources in the WIM may be larger than this size, and the WIM
3504 * file format provides no way to split up file resources among multiple
3506 * @param write_flags
3507 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3508 * flags will be used to write each split WIM part. Specify 0 here to get
3509 * the default behavior.
3510 * @param progress_func
3511 * If non-NULL, a function that will be called periodically with the
3512 * progress of the current operation
3513 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3514 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
3516 * @return 0 on success; nonzero on error. This function may return most error
3517 * codes that can be returned by wimlib_write() as well as the following error
3520 * @retval ::WIMLIB_ERR_INVALID_PARAM
3521 * @p swm_name was not a nonempty string, or @p part_size was 0.
3523 * Note: the WIM's uncompressed and compressed resources are not checksummed
3524 * when they are copied from the joined WIM to the split WIM parts, nor are
3525 * compressed resources re-compressed (unless explicitly requested with
3526 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
3529 wimlib_split(WIMStruct *wim,
3530 const wimlib_tchar *swm_name,
3533 wimlib_progress_func_t progress_func);
3536 * @ingroup G_mounting_wim_images
3538 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3540 * The image to unmount is specified by the path to the mountpoint, not the
3541 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
3542 * touched and also may have been allocated in a different process.
3544 * To unmount the image, the process calling this function communicates with the
3545 * process that is managing the mounted WIM image. This function blocks until it
3546 * is known whether the unmount succeeded or failed. In the case of a
3547 * read-write mounted WIM, the unmount is not considered to have succeeded until
3548 * all changes have been saved to the underlying WIM file.
3551 * The directory that the WIM image was mounted on.
3552 * @param unmount_flags
3553 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
3554 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
3555 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
3557 * @param progress_func
3558 * If non-NULL, a function that will be called periodically with the
3559 * progress of the current operation. Currently, only
3560 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS will be sent.
3562 * @return 0 on success; nonzero on error.
3564 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
3565 * The filesystem daemon was unable to remove the staging directory and the
3566 * temporary files that it contains.
3567 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
3568 * The filesystem daemon appears to have terminated before sending an exit
3570 * @retval ::WIMLIB_ERR_FORK
3571 * Could not @c fork() the process.
3572 * @retval ::WIMLIB_ERR_FUSERMOUNT
3573 * The @b fusermount program could not be executed or exited with a failure
3575 * @retval ::WIMLIB_ERR_MQUEUE
3576 * Could not open a POSIX message queue to communicate with the filesystem
3577 * daemon servicing the mounted filesystem, could not send a message
3578 * through the queue, or could not receive a message through the queue.
3579 * @retval ::WIMLIB_ERR_NOMEM
3580 * Failed to allocate needed memory.
3581 * @retval ::WIMLIB_ERR_OPEN
3582 * The filesystem daemon could not open a temporary file for writing the
3584 * @retval ::WIMLIB_ERR_READ
3585 * A read error occurred when the filesystem daemon tried to a file from
3586 * the staging directory
3587 * @retval ::WIMLIB_ERR_RENAME
3588 * The filesystem daemon failed to rename the newly written WIM file to the
3589 * original WIM file.
3590 * @retval ::WIMLIB_ERR_UNSUPPORTED
3591 * Mounting is not supported, either because the platform is Windows, or
3592 * because the platform is UNIX-like and wimlib was compiled with @c
3594 * @retval ::WIMLIB_ERR_WRITE
3595 * A write error occurred when the filesystem daemon was writing to the new
3596 * WIM file, or the filesystem daemon was unable to flush changes that had
3597 * been made to files in the staging directory.
3600 wimlib_unmount_image(const wimlib_tchar *dir,
3602 wimlib_progress_func_t progress_func);
3605 * @ingroup G_modifying_wims
3607 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3610 * Pointer to the ::WIMStruct for the WIM file to update.
3612 * The 1-based index of the image in the WIM to update. It cannot be
3613 * ::WIMLIB_ALL_IMAGES.
3615 * An array of ::wimlib_update_command's that specify the update operations
3618 * Number of commands in @p cmds.
3619 * @param update_flags
3620 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3621 * @param progress_func
3622 * If non-NULL, a function that will be called periodically with the
3623 * progress of the current operation.
3625 * @return 0 on success; nonzero on error. On failure, some but not all of the
3626 * update commands may have been executed. No individual update command will
3627 * have been partially executed. Possible error codes include:
3629 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3630 * The capture configuration structure specified for an add command was
3632 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3633 * @p image did not specify a single, existing image in @p wim.
3634 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3635 * Attempted to perform an add command that conflicted with previously
3636 * existing files in the WIM when an overlay was attempted.
3637 * @retval ::WIMLIB_ERR_INVALID_PARAM
3638 * An unknown operation type was specified in the update commands; or,
3639 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3640 * in the @p add_flags, but the same image had previously already been
3641 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3642 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3643 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3644 * specified in the @p add_flags for an add command in which @p
3645 * wim_target_path was not the root directory of the WIM image.
3646 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3647 * (Windows only): While executing an add command, tried to capture a
3648 * reparse point with invalid data.
3649 * @retval ::WIMLIB_ERR_IS_DIRECTORY
3650 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3651 * for a WIM path that corresponded to a directory; or, a rename command
3652 * attempted to rename a directory to a non-directory.
3653 * @retval ::WIMLIB_ERR_NOMEM
3654 * Failed to allocate needed memory.
3655 * @retval ::WIMLIB_ERR_NOTDIR
3656 * A rename command attempted to rename a directory to a non-directory; or,
3657 * an add command was executed that attempted to set the root of the WIM
3658 * image as a non-directory; or, a path component used as a directory in a
3659 * rename command was not, in fact, a directory.
3660 * @retval ::WIMLIB_ERR_NOTEMPTY
3661 * A rename command attempted to rename a directory to a non-empty
3663 * @retval ::WIMLIB_ERR_NTFS_3G
3664 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3665 * error occurred while reading data from the NTFS volume using libntfs-3g.
3666 * @retval ::WIMLIB_ERR_OPEN
3667 * Failed to open a file to be captured while executing an add command.
3668 * @retval ::WIMLIB_ERR_OPENDIR
3669 * Failed to open a directory to be captured while executing an add command.
3670 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3671 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3672 * WIM path that did not exist; or, a rename command attempted to rename a
3673 * file that does not exist.
3674 * @retval ::WIMLIB_ERR_READ
3675 * While executing an add command, failed to read data from a file or
3676 * directory to be captured.
3677 * @retval ::WIMLIB_ERR_READLINK
3678 * While executing an add command, failed to read the target of a symbolic
3679 * link or junction point.
3680 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3681 * (Windows only) Failed to perform a reparse point fixup because of
3682 * problems with the data of a reparse point.
3683 * @retval ::WIMLIB_ERR_STAT
3684 * While executing an add command, failed to get attributes for a file or
3686 * @retval ::WIMLIB_ERR_UNSUPPORTED
3687 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
3688 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
3689 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3690 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
3691 * add_flags for an update command.
3692 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
3693 * While executing an add command, attempted to capture a file that was not
3694 * a supported file type (e.g. a device file). Only if
3695 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
3696 * for an update command.
3697 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3698 * The WIM file is considered read-only because of any of the reasons
3699 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3702 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3703 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3704 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3705 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3706 * different reasons) to read the metadata resource for an image that needed to
3710 wimlib_update_image(WIMStruct *wim,
3712 const struct wimlib_update_command *cmds,
3715 wimlib_progress_func_t progress_func);
3718 * @ingroup G_writing_and_overwriting_wims
3720 * Writes a WIM to a file.
3722 * This brings in resources from any external locations, such as directory trees
3723 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3724 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3726 * By default, the new WIM file is written as stand-alone. Using the
3727 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
3728 * instead. However, this function cannot directly write a "split" WIM; use
3729 * wimlib_split() for that.
3732 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
3733 * changes made to it, which are then reflected in the output file.
3735 * The path to the file to write the WIM to.
3737 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
3738 * images are to be included in the new on-disk WIM file. If for some
3739 * reason you only want to include a single image, specify the index of
3740 * that image instead.
3741 * @param write_flags
3742 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3743 * @param num_threads
3744 * Number of threads to use for compressing data. If 0, the number of
3745 * threads is taken to be the number of online processors. Note: if no
3746 * data compression needs to be done, no additional threads will be created
3747 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
3748 * exporting an image from a compressed WIM to another WIM of the same
3749 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
3751 * @param progress_func
3752 * If non-NULL, a function that will be called periodically with the
3753 * progress of the current operation. The possible messages are
3754 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3755 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3756 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3758 * @return 0 on success; nonzero on error.
3760 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3761 * @p image does not specify a single existing image in @p wim, and is not
3762 * ::WIMLIB_ALL_IMAGES.
3763 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3764 * A file that had previously been scanned for inclusion in the WIM by
3765 * wimlib_add_image() was concurrently modified, so it failed the SHA1
3766 * message digest check.
3767 * @retval ::WIMLIB_ERR_INVALID_PARAM
3768 * @p path was @c NULL.
3769 * @retval ::WIMLIB_ERR_NOMEM
3770 * Failed to allocate needed memory.
3771 * @retval ::WIMLIB_ERR_OPEN
3772 * Failed to open @p path for writing, or some file resources in @p wim
3773 * refer to files in the outside filesystem, and one of these files could
3774 * not be opened for reading.
3775 * @retval ::WIMLIB_ERR_READ
3776 * An error occurred when trying to read data from the WIM file associated
3777 * with @p wim, or some file resources in @p wim refer to files in the
3778 * outside filesystem, and a read error occurred when reading one of these
3780 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3781 * A stream that needed to be written could not be found in the stream
3782 * lookup table of @p wim. This error can occur if, for example, @p wim is
3783 * part of a split WIM but needed resources from the other split WIM parts
3784 * were not referenced with wimlib_reference_resources() or
3785 * wimlib_reference_resource_files() before the call to wimlib_write().
3786 * @retval ::WIMLIB_ERR_WRITE
3787 * An error occurred when trying to write data to the new WIM file.
3789 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3790 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3791 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3792 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3793 * different reasons) to read the metadata resource for an image that needed to
3797 wimlib_write(WIMStruct *wim,
3798 const wimlib_tchar *path,
3801 unsigned num_threads,
3802 wimlib_progress_func_t progress_func);
3805 * @ingroup G_writing_and_overwriting_wims
3807 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
3808 * file descriptor, which need not be seekable if the write is done in a special
3809 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
3810 * write_flags. This can, for example, allow capturing a WIM image and
3811 * streaming it over the network. See the documentation for
3812 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
3814 * The file descriptor @p fd will @b not be closed when the write is complete;
3815 * the calling code is responsible for this.
3817 * Returns 0 on success; nonzero on failure. The possible error codes include
3818 * those that can be returned by wimlib_write() as well as the following:
3820 * @retval ::WIMLIB_ERR_INVALID_PARAM
3821 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
3822 * specified in @p write_flags.
3825 wimlib_write_to_fd(WIMStruct *wim,
3829 unsigned num_threads,
3830 wimlib_progress_func_t progress_func);
3833 * @defgroup G_compression Compression and decompression functions
3835 * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
3836 * exported for convenience only, as they are already used by wimlib internally
3839 * These functions can be used for general-purpose lossless data compression,
3840 * but some limitations apply; for example, none of the compressors or
3841 * decompressors currently support sliding windows, and there also exist
3842 * slightly different variants of these formats that are not supported
3847 * @ingroup G_compression
3851 /** Header for compression parameters to pass to wimlib_create_compressor() or
3852 * wimlib_set_default_compressor_params(). */
3853 struct wimlib_compressor_params_header {
3854 /** Size of the parameters, in bytes. */
3858 /** Header for decompression parameters to pass to wimlib_create_decompressor()
3859 * or wimlib_set_default_decompressor_params() */
3860 struct wimlib_decompressor_params_header {
3861 /** Size of the parameters, in bytes. */
3865 /** LZX compression parameters that can optionally be passed to
3866 * wimlib_create_compressor() with the compression type
3867 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
3868 struct wimlib_lzx_compressor_params {
3869 /** hdr.size Must be set to the size of this structure, in bytes. */
3870 struct wimlib_compressor_params_header hdr;
3872 /** Relatively fast LZX compression algorithm with a decent compression
3873 * ratio; the suggested default. */
3874 #define WIMLIB_LZX_ALGORITHM_FAST 0
3876 /** Slower LZX compression algorithm that provides a better compression
3878 #define WIMLIB_LZX_ALGORITHM_SLOW 1
3880 /** Algorithm to use to perform the compression: either
3881 * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW. The
3882 * format is still LZX; this refers to the method the code will use to
3883 * perform LZX-compatible compression. */
3884 uint32_t algorithm : 3;
3886 /** If set to 1, the default parameters for the specified algorithm are
3887 * used rather than the ones specified in the following union. */
3888 uint32_t use_defaults : 1;
3891 /** Parameters for the fast algorithm. */
3892 struct wimlib_lzx_fast_params {
3893 uint32_t fast_reserved1[10];
3896 /** Parameters for the slow algorithm. */
3897 struct wimlib_lzx_slow_params {
3898 /** If set to 1, the compressor can output length 2
3899 * matches. If set 0, the compressor only outputs
3900 * matches of length 3 or greater. Suggested value: 1
3902 uint32_t use_len2_matches : 1;
3904 uint32_t slow_reserved1 : 31;
3906 /** Matches with length (in bytes) longer than this
3907 * value are immediately taken without spending time on
3908 * minimum-cost measurements. Suggested value: 32. */
3909 uint32_t num_fast_bytes;
3911 /** Number of passes to compute a match/literal sequence
3912 * for each LZX block. This is for an iterative
3913 * algorithm that attempts to minimize the cost of the
3914 * match/literal sequence by using a cost model provided
3915 * by the previous iteration. Must be at least 1.
3916 * Suggested value: 2. */
3917 uint32_t num_optim_passes;
3919 /** Reserved; set to 0. */
3920 uint32_t slow_reserved_blocksplit;
3922 /** Maximum depth to search for matches at each
3923 * position. Suggested value: 50. */
3924 uint32_t max_search_depth;
3926 /** Maximum number of potentially good matches to
3927 * consider for each position. Suggested value: 3. */
3928 uint32_t max_matches_per_pos;
3930 uint32_t slow_reserved2[2];
3932 /** Assumed cost of a main symbol with zero frequency.
3933 * Must be at least 1 and no more than 16. Suggested
3935 uint8_t main_nostat_cost;
3937 /** Assumed cost of a length symbol with zero frequency.
3938 * Must be at least 1 and no more than 16. Suggested
3940 uint8_t len_nostat_cost;
3942 /** Assumed cost of an aligned symbol with zero
3943 * frequency. Must be at least 1 and no more than 8.
3944 * Suggested value: 7. */
3945 uint8_t aligned_nostat_cost;
3947 uint8_t slow_reserved3[5];
3952 /** Opaque compressor handle. */
3953 struct wimlib_compressor;
3955 /** Opaque decompressor handle. */
3956 struct wimlib_decompressor;
3959 * Set the default compression parameters for the specified compression type.
3960 * This will affect both explicit and wimlib-internal calls to
3961 * wimlib_create_compressor().
3964 * Compression type for which to set the default compression parameters.
3966 * Compression-type specific parameters. This may be @c NULL, in which
3967 * case the "default default" parameters are restored.
3969 * @return 0 on success; nonzero on error.
3971 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3972 * @p ctype was not a supported compression type.
3973 * @retval ::WIMLIB_ERR_NOMEM
3974 * Not enough memory to duplicate the parameters (perhaps @c params->size
3978 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
3979 const struct wimlib_compressor_params_header *params);
3982 * Allocate a compressor for the specified compression type using the specified
3986 * Compression type for which to create the compressor.
3987 * @param max_block_size
3988 * Maximum block size to support. The exact meaning and allowed values for
3989 * this parameter depend on the compression type, but it at least specifies
3990 * the maximum allowed value for @p uncompressed_size to wimlib_compress().
3991 * @param extra_params
3992 * An optional pointer to extra compressor parameters for the specified
3993 * compression type. For LZX, a pointer to ::wimlib_lzx_compressor_params
3994 * may be specified here. If left @c NULL, the default parameters are
3996 * @param compressor_ret
3997 * A location into which to return the pointer to the allocated compressor,
3998 * which can be used for any number of calls to wimlib_compress() before
3999 * being freed with wimlib_free_compressor().
4001 * @return 0 on success; nonzero on error.
4003 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4004 * @p ctype was not a supported compression type.
4005 * @retval ::WIMLIB_ERR_INVALID_PARAM
4006 * The compression parameters were invalid.
4007 * @retval ::WIMLIB_ERR_NOMEM
4008 * Insufficient memory to allocate the compressor.
4011 wimlib_create_compressor(enum wimlib_compression_type ctype,
4012 size_t max_block_size,
4013 const struct wimlib_compressor_params_header *extra_params,
4014 struct wimlib_compressor **compressor_ret);
4017 * Losslessly compress a block of data using a compressor previously created
4018 * with wimlib_create_compressor().
4020 * @param uncompressed_data
4021 * Buffer containing the data to compress.
4022 * @param uncompressed_size
4023 * Size, in bytes, of the data to compress.
4024 * @param compressed_data
4025 * Buffer into which to write the compressed data.
4026 * @param compressed_size_avail
4027 * Number of bytes available in @p compressed_data.
4029 * A compressor previously allocated with wimlib_create_compressor().
4032 * The size of the compressed data, in bytes, or 0 if the input data could
4033 * not be compressed to @p compressed_size_avail or fewer bytes.
4036 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4037 void *compressed_data, size_t compressed_size_avail,
4038 struct wimlib_compressor *compressor);
4041 * Free a compressor previously allocated with wimlib_create_compressor().
4044 * The compressor to free.
4047 wimlib_free_compressor(struct wimlib_compressor *compressor);
4050 * Set the default decompression parameters for the specified compression type.
4051 * This will affect both explicit and wimlib-internal calls to
4052 * wimlib_create_decompressor().
4055 * Compression type for which to set the default decompression parameters.
4057 * Compression-type specific parameters. This may be @c NULL, in which
4058 * case the "default default" parameters are restored.
4060 * @return 0 on success; nonzero on error.
4062 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4063 * @p ctype was not a supported compression type.
4064 * @retval ::WIMLIB_ERR_NOMEM
4065 * Not enough memory to duplicate the parameters (perhaps @c params->size
4069 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4070 const struct wimlib_decompressor_params_header *params);
4073 * Allocate a decompressor for the specified compression type using the
4074 * specified parameters.
4077 * Compression type for which to create the decompressor.
4078 * @param max_block_size
4079 * Maximum block size to support. The exact meaning and allowed values for
4080 * this parameter depend on the compression type, but it at least specifies
4081 * the maximum allowed value for @p uncompressed_size to
4082 * wimlib_decompress().
4083 * @param extra_params
4084 * An optional pointer to extra decompressor parameters for the specified
4085 * compression type. If @c NULL, the default parameters are used.
4086 * @param decompressor_ret
4087 * A location into which to return the pointer to the allocated
4088 * decompressor, which can be used for any number of calls to
4089 * wimlib_decompress() before being freed with wimlib_free_decompressor().
4091 * @return 0 on success; nonzero on error.
4093 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4094 * @p ctype was not a supported compression type.
4095 * @retval ::WIMLIB_ERR_INVALID_PARAM
4096 * The decompression parameters were invalid.
4097 * @retval ::WIMLIB_ERR_NOMEM
4098 * Insufficient memory to allocate the decompressor.
4101 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4102 size_t max_block_size,
4103 const struct wimlib_decompressor_params_header *extra_params,
4104 struct wimlib_decompressor **decompressor_ret);
4107 * Decompress a block of data using a decompressor previously created with
4108 * wimlib_create_decompressor().
4110 * @param compressed_data
4111 * Buffer containing the data to decompress.
4112 * @param compressed_size
4113 * Size, in bytes, of the data to decompress.
4114 * @param uncompressed_data
4115 * Buffer into which to write the uncompressed data.
4116 * @param uncompressed_size
4117 * Size, in bytes, of the data when uncompressed.
4118 * @param decompressor
4119 * A decompressor previously allocated with wimlib_create_decompressor().
4121 * @return 0 on success; nonzero on error.
4124 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4125 void *uncompressed_data, size_t uncompressed_size,
4126 struct wimlib_decompressor *decompressor);
4129 * Free a decompressor previously allocated with wimlib_create_decompressor().
4131 * @param decompressor
4132 * The decompressor to free.
4135 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4138 struct wimlib_lzx_params_old;
4139 struct wimlib_lzx_context_old;
4141 /** Deprecated; do not use. */
4143 wimlib_lzx_set_default_params(const struct wimlib_lzx_params_old *params)
4146 /** Deprecated; do not use. */
4148 wimlib_lzx_alloc_context(const struct wimlib_lzx_params_old *params,
4149 struct wimlib_lzx_context_old **ctx_pp)
4152 /** Deprecated; do not use. */
4154 wimlib_lzx_free_context(struct wimlib_lzx_context_old *ctx)
4157 /** Deprecated; do not use. */
4159 wimlib_lzx_compress2(const void *udata, unsigned ulen, void *cdata,
4160 struct wimlib_lzx_context_old *ctx)
4163 /** Deprecated; do not use. */
4165 wimlib_lzx_compress(const void *udata, unsigned ulen, void *cdata)
4168 /** Deprecated; do not use. */
4170 wimlib_xpress_compress(const void *udata, unsigned ulen, void *cdata)
4173 /** Deprecated; do not use. */
4175 wimlib_lzx_decompress(const void *cdata, unsigned clen,
4176 void *udata, unsigned ulen)
4179 /** Deprecated; do not use. */
4181 wimlib_xpress_decompress(const void *cdata, unsigned clen,
4182 void *udata, unsigned ulen)
4193 #endif /* _WIMLIB_H */