]> wimlib.net Git - wimlib/blob - include/wimlib.h
wimlib.h: Update docs
[wimlib] / include / wimlib.h
1 /**
2  * @file wimlib.h
3  * @brief External header for wimlib.
4  *
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
9  * in this header.
10  */
11
12 /*
13  * Copyright (C) 2012, 2013, 2014 Eric Biggers
14  *
15  * This file is part of wimlib, a library for working with WIM files.
16  *
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)
20  * any later version.
21  *
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
25  * details.
26  *
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/.
29  */
30
31 /**
32  * @mainpage
33  *
34  * @section sec_intro Introduction
35  *
36  * This is the documentation for the library interface of wimlib 1.7.0, a C
37  * library for creating, modifying, extracting, and mounting files in the
38  * Windows Imaging Format.  This documentation is intended for developers only.
39  * If you have installed wimlib and want to know how to use the @b wimlib-imagex
40  * program, please see the README file or manual pages.
41  *
42  * @section sec_installing_and_compiling Installing and Compiling
43  *
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.
47  *
48  * To use wimlib in your program after installing it, include wimlib.h and link
49  * your program with @c -lwim.
50  *
51  * As of wimlib 1.5.0, wimlib.h is also compatible with C++.
52  *
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.
56  *
57  * @section sec_basic_wim_handling_concepts Basic WIM handling concepts
58  *
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
64  * for more details.
65  *
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.
76  *
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:
81  *
82  * 1. wimlib_open_wim()
83  * 2. wimlib_add_image()
84  * 3. wimlib_overwrite()
85  *
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.
90  *
91  * @section sec_cleaning_up Cleaning up
92  *
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.
97  *
98  * @section sec_error_handling Error Handling
99  *
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.
108  *
109  * @section sec_encodings Locales and character encodings
110  *
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
113  * encoding.
114  *
115  * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
116  * and the encoding is UTF-16LE.
117  *
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.
123  *
124  * @section sec_advanced Additional information and features
125  *
126  *
127  * @subsection subsec_mounting_wim_images Mounting WIM images
128  *
129  * See @ref G_mounting_wim_images.
130  *
131  * @subsection subsec_progress_functions Progress Messages
132  *
133  * See @ref G_progress.
134  *
135  * @subsection subsec_non_standalone_wims Non-standalone WIMs
136  *
137  * See @ref G_nonstandalone_wims.
138  *
139  * @subsection subsec_pipable_wims Pipable WIMs
140  *
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()).
150  *
151  * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
152  * capture</b> for more information about pipable WIMs.
153  *
154  * @subsection subsec_thread_safety Thread Safety
155  *
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
160  *   functions.
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.
166  *
167  * @subsection subsec_limitations Limitations
168  *
169  * This section documents some technical limitations of wimlib not already
170  * documented in the man page for @b wimlib-imagex.
171  *
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
177  *   on top of wimlib.
178  *
179  * @subsection more_info More information
180  *
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.
184  */
185
186 /** @defgroup G_general General
187  *
188  * @brief Declarations and structures shared across the library.
189  */
190
191 /** @defgroup G_creating_and_opening_wims Creating and Opening WIMs
192  *
193  * @brief Create new WIMs and open existing WIMs.
194  */
195
196 /** @defgroup G_wim_information Retrieving WIM information and directory listings
197  *
198  * @brief Retrieve information about a WIM or WIM image.
199  */
200
201 /** @defgroup G_modifying_wims Modifying WIMs
202  *
203  * @brief Make changes to a WIM.
204  *
205  * @section sec_adding_images Capturing and adding WIM images
206  *
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.
215  *
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.
219  *
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.)
224  *
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>.
227  *
228  * @section sec_deleting_images Deleting WIM images
229  *
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.
233  *
234  * @section sec_exporting_images Exporting WIM images
235  *
236  * wimlib_export_image() can copy, or "export", an image from one WIM to
237  * another.
238  *
239  * @section sec_other_modifications Other modifications
240  *
241  * wimlib_update_image() can add, delete, and rename files in a WIM image.
242  *
243  * wimlib_set_image_name(), wimlib_set_image_descripton(), and
244  * wimlib_set_image_flags() can change other image metadata.
245  *
246  * wimlib_set_wim_info() can change information about the WIM file itself, such
247  * as the boot index.
248  */
249
250 /** @defgroup G_extracting_wims Extracting WIMs
251  *
252  * @brief Extract files, directories, and images from a WIM.
253  *
254  * wimlib_extract_image() extracts, or "applies", an image from a WIM,
255  * represented by a ::WIMStruct.  This normally extracts the image to a
256  * directory, but when supported by the build of the library there is also a
257  * special NTFS volume extraction mode (entered when ::WIMLIB_EXTRACT_FLAG_NTFS
258  * is specified) that allows extracting a WIM image directly to an unmounted
259  * NTFS volume.  Various other flags allow further customization of image
260  * extraction.
261  *
262  * wimlib_extract_paths() and wimlib_extract_pathlist() allow extracting a list
263  * of (possibly wildcard) paths from a WIM image.
264  *
265  * wimlib_extract_image_from_pipe() extracts an image from a pipable WIM sent
266  * over a pipe; see @ref subsec_pipable_wims.
267  *
268  * Some details of how WIM extraction works are documented more fully in the
269  * manual pages for <b>wimlib-imagex apply</b> and <b>wimlib-imagex extract</b>.
270  */
271
272 /** @defgroup G_mounting_wim_images Mounting WIM images
273  *
274  * @brief Mount and unmount WIM images.
275  *
276  * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
277  * mounting images from WIM files either read-only or read-write.  To mount an
278  * image, call wimlib_mount_image().  To unmount an image, call
279  * wimlib_unmount_image().  Mounting can be done without root privileges because
280  * it is implemented using FUSE (Filesystem in Userspace).  If wimlib is
281  * compiled with the <code>--without-fuse</code> flag, these functions will be
282  * available but will fail with ::WIMLIB_ERR_UNSUPPORTED.  Note that mounting an
283  * image read-write is an alternative to calling wimlib_update_image().
284  */
285
286 /**
287  * @defgroup G_progress Progress Messages
288  *
289  * @brief Track the progress of long WIM operations.
290  *
291  * Library users can provide a progress function which will be called
292  * periodically during operations such as extracting a WIM image or writing a
293  * WIM image.  A ::WIMStruct can have a progress function of type
294  * ::wimlib_progress_func_t associated with it by calling
295  * wimlib_register_progress_function() or by opening the ::WIMStruct using
296  * wimlib_open_wim_with_progress().  Once this is done, the progress function
297  * will be called automatically during many operations, such as
298  * wimlib_extract_image() and wimlib_write().
299  *
300  * Some functions that do not operate directly on a user-provided ::WIMStruct,
301  * such as wimlib_join(), also take the progress function directly using an
302  * extended version of the function, such as wimlib_join_with_progress().
303  *
304  * In wimlib v1.7.0 and later, progress functions are no longer just
305  * unidirectional.  You can now return ::WIMLIB_PROGRESS_STATUS_ABORT to cause
306  * the current operation to be aborted.  wimlib v1.7.0 also added the third
307  * argument to ::wimlib_progress_func_t, which is a user-supplied context.
308  */
309
310 /** @defgroup G_writing_and_overwriting_wims Writing and Overwriting WIMs
311  *
312  * @brief Write and overwrite on-disk WIM files.
313  *
314  * As described in @ref sec_basic_wim_handling_concepts, these functions are
315  * fundamental to the design of the library as they allow new or modified
316  * ::WIMStruct's to actually be written to on-disk files.  Call wimlib_write()
317  * to write a new WIM file, or wimlib_overwrite() to persistently update an
318  * existing WIM file.
319  */
320
321 /** @defgroup G_nonstandalone_wims Creating and handling non-standalone WIMs
322  *
323  * @brief Create and handle non-standalone WIMs, such as split and delta WIMs.
324  *
325  * Normally, a ::WIMStruct represents a WIM file, but there's a bit more to it
326  * than that.  Normally, WIM files are "standalone".  However, WIM files can
327  * also be arranged in non-standalone ways, such as a set of on-disk files that
328  * together form a single "split WIM" or "delta WIM".  Such arrangements are
329  * fully supported by wimlib.  However, as a result, in such cases a ::WIMStruct
330  * created from one of these on-disk files initially only partially represents
331  * the full WIM and needs to, in effect, be logically combined with other
332  * ::WIMStruct's before performing certain operations, such as extracting files
333  * with wimlib_extract_image() or wimlib_extract_paths().  This is done by
334  * calling wimlib_reference_resource_files() or wimlib_reference_resources().
335  *
336  * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
337  * specialized function (wimlib_split()) is needed to create a split WIM.
338  */
339
340 #ifndef _WIMLIB_H
341 #define _WIMLIB_H
342
343 #include <stdio.h>
344 #include <stddef.h>
345 #include <stdbool.h>
346 #include <inttypes.h>
347 #include <time.h>
348
349 #ifdef __GNUC__
350 #  define _wimlib_deprecated __attribute__((deprecated))
351 #else
352 #  define _wimlib_deprecated
353 #endif
354
355 /** @addtogroup G_general
356  * @{ */
357
358 /** Major version of the library (for example, the 1 in 1.2.5).  */
359 #define WIMLIB_MAJOR_VERSION 1
360
361 /** Minor version of the library (for example, the 2 in 1.2.5). */
362 #define WIMLIB_MINOR_VERSION 7
363
364 /** Patch version of the library (for example, the 5 in 1.2.5). */
365 #define WIMLIB_PATCH_VERSION 0
366
367 #ifdef __cplusplus
368 extern "C" {
369 #endif
370
371 /**
372  * Opaque structure that represents a WIM file.  This is an in-memory structure
373  * and need not correspond to a specific on-disk file.  However, a ::WIMStruct
374  * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
375  * continuing to exist so that data can be read from it as needed.
376  *
377  * Most functions in this library will work the same way regardless of whether a
378  * given ::WIMStruct was obtained through wimlib_open_wim() or
379  * wimlib_create_new_wim().  Exceptions are documented.
380  *
381  * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
382  * file from a ::WIMStruct.
383  *
384  * See @ref sec_basic_wim_handling_concepts for more information.
385  */
386 #ifndef WIMLIB_WIMSTRUCT_DECLARED
387 typedef struct WIMStruct WIMStruct;
388 #define WIMLIB_WIMSTRUCT_DECLARED
389 #endif
390
391 #ifdef __WIN32__
392 typedef wchar_t wimlib_tchar;
393 #else
394 /** See @ref sec_encodings */
395 typedef char wimlib_tchar;
396 #endif
397
398 #ifdef __WIN32__
399 /** Path separator for WIM paths passed back to progress callbacks.
400  * This is forward slash on UNIX and backslash on Windows.  */
401 #  define WIMLIB_WIM_PATH_SEPARATOR '\\'
402 #  define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
403 #else
404 /** Path separator for WIM paths passed back to progress callbacks.
405  * This is forward slash on UNIX and backslash on Windows.  */
406 #  define WIMLIB_WIM_PATH_SEPARATOR '/'
407 #  define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
408 #endif
409
410 /** Use this to specify the root directory of the WIM image.  */
411 #define WIMLIB_WIM_ROOT_PATH WIMLIB_WIM_PATH_SEPARATOR_STRING
412
413 /** Use this to test if the specified path refers to the root directory of the
414  * WIM image.  */
415 #define WIMLIB_IS_WIM_ROOT_PATH(path) \
416                 ((path)[0] == WIMLIB_WIM_PATH_SEPARATOR &&      \
417                  (path)[1] == 0)
418
419 /** Length of a Globally Unique Identifier (GUID)  */
420 #define WIMLIB_GUID_LEN 16
421
422 /**
423  * Specifies a compression format.  Pass one of these values to
424  * wimlib_create_new_wim(), wimlib_create_compressor(), or
425  * wimlib_create_decompressor().
426  *
427  * A WIM file has one default compression type and chunk size.  Normally, each
428  * resource is compressed with this compression type.  However, resources may be
429  * stored as uncompressed.  In addition, a WIM with the new version number of
430  * 3584, or "ESD file", might contain solid blocks with different compression
431  * types.
432  */
433 enum wimlib_compression_type {
434         /** No compression.  */
435         WIMLIB_COMPRESSION_TYPE_NONE = 0,
436
437         /** The XPRESS compression format.  This format combines Lempel-Ziv
438          * factorization with Huffman encoding.  Compression and decompression
439          * are both fast.  This format supports chunk sizes that are powers of 2
440          * between <c>2^12</c> and <c>2^26</c>, inclusively.  */
441         WIMLIB_COMPRESSION_TYPE_XPRESS = 1,
442
443         /** The LZX compression format.  This format combines Lempel-Ziv
444          * factorization with Huffman encoding, but with more features and
445          * complexity than XPRESS.  Compression is slow to somewhat fast,
446          * depending on the settings.  Decompression is fast but slower than
447          * XPRESS.  This format supports chunk sizes that are powers of 2
448          * between <c>2^15</c> and <c>2^21</c>, inclusively.  Note: chunk sizes
449          * other than <c>2^15</c> are not compatible with the Microsoft
450          * implementation.  */
451         WIMLIB_COMPRESSION_TYPE_LZX = 2,
452
453         /** The LZMS compression format.  This format combines Lempel-Ziv
454          * factorization with adaptive Huffman encoding and range coding.
455          * Compression and decompression are both fairly slow.  This format
456          * supports chunk sizes that are powers of 2 between <c>2^15</c> and
457          * <c>2^30</c>, inclusively.  This format is best used for large chunk
458          * sizes.  Note: LZMS compression is only compatible with wimlib v1.6.0
459          * and later, WIMGAPI Windows 8 and later, and DISM Windows 8.1 and
460          * later.  Also, chunk sizes larger than <c>2^26</c> are not compatible
461          * with the Microsoft implementation.  */
462         WIMLIB_COMPRESSION_TYPE_LZMS = 3,
463 };
464
465 /** @} */
466 /** @addtogroup G_progress
467  * @{ */
468
469 /** Possible values of the first parameter to the user-supplied
470  * ::wimlib_progress_func_t progress function */
471 enum wimlib_progress_msg {
472
473         /** A WIM image is about to be extracted.  @p info will point to
474          * ::wimlib_progress_info.extract.  This message is received once per
475          * image for calls to wimlib_extract_image() and
476          * wimlib_extract_image_from_pipe().  */
477         WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
478
479         /** One or more file or directory trees within a WIM image is about to
480          * be extracted.  @p info will point to ::wimlib_progress_info.extract.
481          * This message is received only once per wimlib_extract_paths() and
482          * wimlib_extract_pathlist(), since wimlib combines all paths into a
483          * single extraction operation for optimization purposes.  */
484         WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN = 1,
485
486         /** File data is currently being extracted.  @p info will point to
487          * ::wimlib_progress_info.extract.  This is the main message to track
488          * the progress of an extraction operation.  */
489         WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS = 4,
490
491         /** Starting to read a new part of a split pipable WIM over the pipe.
492          * @p info will point to ::wimlib_progress_info.extract.  */
493         WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN = 5,
494
495         /** Confirms that the image has been successfully extracted.  @p info
496          * will point to ::wimlib_progress_info.extract.  This is paired with
497          * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN.  */
498         WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END = 7,
499
500         /** Confirms that the files or directory trees have been successfully
501          * extracted.  @p info will point to ::wimlib_progress_info.extract.
502          * This is paired with ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN.  */
503         WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END = 8,
504
505         /** The directory or NTFS volume is about to be scanned for metadata.
506          * @p info will point to ::wimlib_progress_info.scan.  This message is
507          * received once per call to wimlib_add_image(), or once per capture
508          * source passed to wimlib_add_image_multisource(), or once per add
509          * command passed to wimlib_update_image().  */
510         WIMLIB_PROGRESS_MSG_SCAN_BEGIN = 9,
511
512         /** A directory or file has been scanned.  @p info will point to
513          * ::wimlib_progress_info.scan, and its @p cur_path member will be
514          * valid.  This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE has
515          * been specified.  */
516         WIMLIB_PROGRESS_MSG_SCAN_DENTRY = 10,
517
518         /** Confirms that the directory or NTFS volume has been successfully
519          * scanned.  @p info will point to ::wimlib_progress_info.scan.  This is
520          * paired with a previous ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN message,
521          * possibly with many intervening ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY
522          * messages.  */
523         WIMLIB_PROGRESS_MSG_SCAN_END = 11,
524
525         /** File resources ("streams") are currently being written to the WIM.
526          * @p info will point to ::wimlib_progress_info.write_streams.  This
527          * message may be received many times while the WIM file is being
528          * written or appended to with wimlib_write(), wimlib_overwrite(), or
529          * wimlib_write_to_fd().  */
530         WIMLIB_PROGRESS_MSG_WRITE_STREAMS = 12,
531
532         /** Per-image metadata is about to be written to the WIM file.  @p info
533          * will not be valid. */
534         WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN = 13,
535
536         /** Confirms that per-image metadata has been successfully been written
537          * to the WIM file.  @p info will not be valid.  This message is paired
538          * with a preceding ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN message.
539          */
540         WIMLIB_PROGRESS_MSG_WRITE_METADATA_END = 14,
541
542         /** wimlib_overwrite() has successfully renamed the temporary file to
543          * the original WIM file, thereby committing the update.  @p info will
544          * point to ::wimlib_progress_info.rename.  Note: this message is not
545          * received if wimlib_overwrite() chose to append to the WIM file
546          * in-place.  */
547         WIMLIB_PROGRESS_MSG_RENAME = 15,
548
549         /** The contents of the WIM file are being checked against the integrity
550          * table.  @p info will point to ::wimlib_progress_info.integrity.  This
551          * message is only received (and may be received many times) when
552          * wimlib_open_wim_with_progress() is called with the
553          * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag.  */
554         WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY = 16,
555
556         /** An integrity table is being calculated for the WIM being written.
557          * @p info will point to ::wimlib_progress_info.integrity.  This message
558          * is only received (and may be received many times) when a WIM file is
559          * being written with the flag ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY.  */
560         WIMLIB_PROGRESS_MSG_CALC_INTEGRITY = 17,
561
562         /** A wimlib_split() operation is in progress, and a new split part is
563          * about to be started.  @p info will point to
564          * ::wimlib_progress_info.split.  */
565         WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART = 19,
566
567         /** A wimlib_split() operation is in progress, and a split part has been
568          * finished. @p info will point to ::wimlib_progress_info.split.  */
569         WIMLIB_PROGRESS_MSG_SPLIT_END_PART = 20,
570
571         /** A WIM update command is just about to be executed. @p info will
572          * point to ::wimlib_progress_info.update.  This message is received
573          * once per update command when wimlib_update_image() is called with the
574          * flag ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS.  */
575         WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND = 21,
576
577         /** A WIM update command has just been executed. @p info will point to
578          * ::wimlib_progress_info.update.  This message is received once per
579          * update command when wimlib_update_image() is called with the flag
580          * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS.  */
581         WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND = 22,
582
583         /** A file in the WIM image is being replaced as a result of a
584          * ::wimlib_add_command without ::WIMLIB_ADD_FLAG_NO_REPLACE specified.
585          * @p info will point to ::wimlib_progress_info.replace.  This is only
586          * received when ::WIMLIB_ADD_FLAG_VERBOSE is also specified in the add
587          * command.  */
588         WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM = 23,
589
590         /** A WIM image is being applied with ::WIMLIB_EXTRACT_FLAG_WIMBOOT, and
591          * a file is being extracted normally (not as a WIMBoot "pointer file")
592          * due to it matching a pattern in the [PrepopulateList] section of the
593          * configuration file @c \\Windows\\System32\\WimBootCompress.ini in the
594          * WIM image.  @p info will point to
595          * ::wimlib_progress_info.wimboot_exclude.
596          */
597         WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE = 24,
598
599         /** Starting to unmount a WIM image.  @p info will point to
600          * ::wimlib_progress_info.unmount.  */
601         WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN = 25,
602 };
603
604 /** Valid return values from user-provided progress functions
605  * (::wimlib_progress_func_t).
606  *
607  * (Note: if an invalid value is returned, ::WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS
608  * will be issued.)
609  */
610 enum wimlib_progress_status {
611
612         /** The operation should be continued.  This is the normal return value.
613          */
614         WIMLIB_PROGRESS_STATUS_CONTINUE = 0,
615
616         /** The operation should be aborted.  This will cause the current
617          * operation to fail with ::WIMLIB_ERR_ABORTED_BY_PROGRESS.  */
618         WIMLIB_PROGRESS_STATUS_ABORT    = 1,
619 };
620
621 /**
622  * A pointer to this union is passed to the user-supplied
623  * ::wimlib_progress_func_t progress function.  One (or none) of the structures
624  * contained in this union will be applicable for the operation
625  * (::wimlib_progress_msg) indicated in the first argument to the progress
626  * function. */
627 union wimlib_progress_info {
628
629         /* N.B. I wanted these to be anonymous structs, but Doxygen won't
630          * document them if they aren't given a name... */
631
632         /** Valid on the message ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.  This is
633          * the primary message for tracking the progress of writing a WIM file.
634          */
635         struct wimlib_progress_info_write_streams {
636                 /** Total number of uncompressed bytes of stream data being
637                  * written.  This can be thought of as the total uncompressed
638                  * size of the files being archived, with some caveats.  WIM
639                  * files use single-instance streams, so the size provided here
640                  * only counts distinct streams, except for the following
641                  * exception: the size provided here may include the sizes of
642                  * all newly added (e.g. with wimlib_add_image() streams,
643                  * pending automatic de-duplication during the write operation
644                  * itself.  When each such stream de-duplication occurs, this
645                  * number will be decreased by the size of the duplicate stream
646                  * that need not be written.
647                  *
648                  * In the case of a wimlib_overwrite() that the library opted to
649                  * perform in-place, both @p total_streams and @p total_bytes
650                  * will only count the streams actually being written and not
651                  * pre-existing streams in the WIM file.  */
652                 uint64_t total_bytes;
653
654                 /** Total number of streams being written.  This can be thought
655                  * of as the total number of files being archived, with some
656                  * caveats.  In general, a single file or directory may contain
657                  * multiple data streams, each of which will be represented
658                  * separately in this number.  Furthermore, WIM files use
659                  * single-instance streams, so the stream count provided here
660                  * only counts distinct streams, except for the following
661                  * exception: the stream count provided here may include newly
662                  * added (e.g. with wimlib_add_image() streams, pending
663                  * automatic de-duplication during the write operation itself.
664                  * When each such stream de-duplication occurs, this number will
665                  * be decreased by 1 to account for the duplicate stream that
666                  * need not be written.  */
667                 uint64_t total_streams;
668
669                 /** Number of uncompressed bytes of stream data that have been
670                  * written so far.  This number be 0 initially, and will be
671                  * equal to @p total_bytes at the end of the write operation.
672                  * Note that @p total_bytes (but not @p completed_bytes) may
673                  * decrease throughout the write operation due to the discovery
674                  * of stream duplications.  */
675                 uint64_t completed_bytes;
676
677                 /** Number of streams that have been written so far.  This
678                  * number will be 0 initially, and will be equal to @p
679                  * total_streams at the end of the write operation.  Note that
680                  * @p total_streams (but not @p completed_streams) may decrease
681                  * throughout the write operation due to the discovery of stream
682                  * duplications.
683                  *
684                  * For applications that wish to calculate a simple "percent
685                  * complete" for the write operation, it will likely be more
686                  * accurate to calculate the percentage from @p completed_bytes
687                  * and @p total_bytes rather than @p completed_streams and
688                  * @p total_streams because the time for the operation to
689                  * complete is mainly determined by the number of bytes that
690                  * need to be read, compressed, and written, not just the number
691                  * of files being archived.  */
692                 uint64_t completed_streams;
693
694                 /** Number of threads that are being used to compress streams,
695                  * or 1 if streams are being written uncompressed.  */
696                 uint32_t num_threads;
697
698                 /** The compression type being used to write the streams, as one
699                  * of the ::wimlib_compression_type constants.  */
700                 int32_t  compression_type;
701
702                 /** Number of split WIM parts from which streams are being
703                  * written (may be 0 if irrelevant).   */
704                 uint32_t total_parts;
705
706                 /** This is currently broken and will always be 0.  */
707                 uint32_t completed_parts;
708         } write_streams;
709
710         /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
711          * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY, and
712          * ::WIMLIB_PROGRESS_MSG_SCAN_END.  */
713         struct wimlib_progress_info_scan {
714                 /** Top-level directory being scanned; or, when capturing an NTFS
715                  * volume with ::WIMLIB_ADD_FLAG_NTFS, this is instead the path
716                  * to the file or block device that contains the NTFS volume
717                  * being scanned.  */
718                 const wimlib_tchar *source;
719
720                 /** Path to the file (or directory) that has been scanned, valid
721                  * on ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.  When capturing an NTFS
722                  * volume with ::WIMLIB_ADD_FLAG_NTFS, this path will be
723                  * relative to the root of the NTFS volume.  */
724                 const wimlib_tchar *cur_path;
725
726                 /** Dentry scan status, valid on
727                  * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.  */
728                 enum {
729                         /** The file looks okay and will be captured.  */
730                         WIMLIB_SCAN_DENTRY_OK = 0,
731
732                         /** File is being excluded from capture due to the
733                          * capture configuration.  */
734                         WIMLIB_SCAN_DENTRY_EXCLUDED,
735
736                         /** File is being excluded from capture due to being
737                          * unsupported (e.g. an encrypted or device file).  */
738                         WIMLIB_SCAN_DENTRY_UNSUPPORTED,
739
740                         /** The file is an absolute symbolic link or junction
741                          * that points into the capture directory, and
742                          * reparse-point fixups are enabled, so its target is
743                          * being adjusted.  (Reparse point fixups can be
744                          * disabled with the flag ::WIMLIB_ADD_FLAG_NORPFIX.)
745                          */
746                         WIMLIB_SCAN_DENTRY_FIXED_SYMLINK,
747
748                         /** Reparse-point fixups are enabled, but the file is an
749                          * absolute symbolic link or junction that does
750                          * <b>not</b> point into the capture directory, so its
751                          * target is <b>not</b> being adjusted.  */
752                         WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK,
753                 } status;
754
755                 union {
756                         /** Target path in the WIM image.  Only valid on
757                          * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
758                          * ::WIMLIB_PROGRESS_MSG_SCAN_END.  */
759                         const wimlib_tchar *wim_target_path;
760
761                         /** For ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY and a status
762                          * of @p WIMLIB_SCAN_DENTRY_FIXED_SYMLINK or @p
763                          * WIMLIB_SCAN_DENTRY_NOT_FIXED_SYMLINK, this is the
764                          * target of the absolute symbolic link or junction.  */
765                         const wimlib_tchar *symlink_target;
766                 };
767
768                 /** Number of directories scanned so far, including the root
769                  * directory but excluding any unsupported/excluded directories.
770                  *
771                  * Details: On Windows and in NTFS capture mode, a reparse point
772                  * counts as a directory if and only if it has
773                  * FILE_ATTRIBUTE_DIRECTORY set.  Otherwise, a symbolic link
774                  * counts as a directory if and only if when fully dereferenced
775                  * it points to an accessible directory.  If a file has multiple
776                  * names (hard links), it is only counted one time.  */
777                 uint64_t num_dirs_scanned;
778
779                 /** Number of non-directories scanned so far, excluding any
780                  * unsupported/excluded files.
781                  *
782                  * Details: On Windows and in NTFS capture mode, a reparse point
783                  * counts as a non-directory if and only if it does not have
784                  * FILE_ATTRIBUTE_DIRECTORY set.  Otherwise, a symbolic link
785                  * counts as a non-directory if and only if when fully
786                  * dereferenced it points to a non-directory or its target is
787                  * inaccessible.  If a file has multiple names (hard links), it
788                  * is only counted one time.  */
789                 uint64_t num_nondirs_scanned;
790
791                 /** Number of bytes of file data that have been detected so far.
792                  *
793                  * Details: This data may not actually have been read yet, and
794                  * it will not actually be written to the WIM file until
795                  * wimlib_write() or wimlib_overwrite() has been called.  Data
796                  * from excluded files is not counted.  This number includes
797                  * default file contents as well as named data streams and
798                  * reparse point data.  The size of reparse point data is
799                  * tallied after any reparse-point fixups, and in the case of
800                  * capturing a symbolic link on a UNIX-like system, the creation
801                  * of the reparse point data itself.  If a file has multiple
802                  * names (hard links), its size(s) are only counted one time.
803                  * On Windows, encrypted files have their encrypted size
804                  * counted, not their unencrypted size; however, compressed
805                  * files have their uncompressed size counted.  */
806                 uint64_t num_bytes_scanned;
807         } scan;
808
809         /** Valid on messages
810          * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
811          * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
812          * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
813          * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
814          * ::WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END, and
815          * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
816          *
817          * Note: most of the time of an extraction operation will be spent
818          * extracting streams, and the application will receive
819          * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS during this time.  Using @p
820          * completed_bytes and @p total_bytes, the application can calculate a
821          * percentage complete.  However, note that this message does not, in
822          * general, actually provide information about which "file" is currently
823          * being extracted.  This is because wimlib, by default, extracts the
824          * individual data streams in whichever order it determines to be the
825          * most efficient.
826          */
827         struct wimlib_progress_info_extract {
828                 /** Number of the image from which files are being extracted
829                  * (1-based).  */
830                 uint32_t image;
831
832                 /** Extraction flags being used.  */
833                 uint32_t extract_flags;
834
835                 /** Full path to the WIM file from which files are being
836                  * extracted, or @c NULL if the WIMStruct has no associated
837                  * on-disk file.  */
838                 const wimlib_tchar *wimfile_name;
839
840                 /** Name of the image from which files are being extracted, or
841                  * the empty string if the image is unnamed.  */
842                 const wimlib_tchar *image_name;
843
844                 /** Path to the directory or NTFS volume to which the files are
845                  * being extracted.  */
846                 const wimlib_tchar *target;
847
848                 /** Reserved.  */
849                 const wimlib_tchar *reserved;
850
851                 /** Number of bytes of uncompressed data that will be extracted.
852                  * If a file has multiple names (hard links), its size (or
853                  * sizes, in the case of named data streams) is only counted one
854                  * time.  For "reparse points" and symbolic links, the size to
855                  * be extracted is the size of the reparse data buffer.
856                  *
857                  * This number will stay constant throughout the extraction.  */
858                 uint64_t total_bytes;
859
860                 /** Number of bytes of uncompressed data that have been
861                  * extracted so far.  This initially be 0 and will equal to @p
862                  * total_bytes at the end of the extraction.  */
863                 uint64_t completed_bytes;
864
865                 /** Number of (not necessarily unique) streams that will be
866                  * extracted.  This may be more or less than the number of
867                  * "files" to be extracted due to hard links as well as
868                  * potentially multiple streams per file (named data streams).
869                  * A "stream" may be the default contents of a file, a named
870                  * data stream, or a reparse data buffer.  */
871                 uint64_t num_streams;
872
873                 /** Reserved.  */
874                 const wimlib_tchar *reserved_2;
875
876                 /** Currently only used for
877                  * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.  */
878                 uint32_t part_number;
879
880                 /** Currently only used for
881                  * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.  */
882                 uint32_t total_parts;
883
884                 /** Currently only used for
885                  * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.  */
886                 uint8_t guid[WIMLIB_GUID_LEN];
887         } extract;
888
889         /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
890         struct wimlib_progress_info_rename {
891                 /** Name of the temporary file that the WIM was written to. */
892                 const wimlib_tchar *from;
893
894                 /** Name of the original WIM file to which the temporary file is
895                  * being renamed. */
896                 const wimlib_tchar *to;
897         } rename;
898
899         /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
900          * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
901         struct wimlib_progress_info_update {
902                 /** Pointer to the update command that will be executed or has
903                  * just been executed. */
904                 const struct wimlib_update_command *command;
905
906                 /** Number of update commands that have been completed so far.
907                  */
908                 size_t completed_commands;
909
910                 /** Number of update commands that are being executed as part of
911                  * this call to wimlib_update_image(). */
912                 size_t total_commands;
913         } update;
914
915         /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
916          * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
917         struct wimlib_progress_info_integrity {
918                 /** Number of bytes from the end of the WIM header to the end of
919                  * the lookup table (the area that is covered by the SHA1
920                  * integrity checks.) */
921                 uint64_t total_bytes;
922
923                 /** Number of bytes that have been SHA1-summed so far.  Will be
924                  * 0 initially, and equal @p total_bytes at the end. */
925                 uint64_t completed_bytes;
926
927                 /** Number of chunks that the checksummed region is divided
928                  * into. */
929                 uint32_t total_chunks;
930
931                 /** Number of chunks that have been SHA1-summed so far.   Will
932                  * be 0 initially, and equal to @p total_chunks at the end. */
933                 uint32_t completed_chunks;
934
935                 /** Size of the chunks used for the integrity calculation. */
936                 uint32_t chunk_size;
937
938                 /** Filename of the WIM (only valid if the message is
939                  * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
940                 const wimlib_tchar *filename;
941         } integrity;
942
943         /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
944          * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
945         struct wimlib_progress_info_split {
946                 /** Total size of the original WIM's file and metadata resources
947                  * (compressed). */
948                 uint64_t total_bytes;
949
950                 /** Number of bytes of file and metadata resources that have
951                  * been copied out of the original WIM so far.  Will be 0
952                  * initially, and equal to @p total_bytes at the end. */
953                 uint64_t completed_bytes;
954
955                 /** Number of the split WIM part that is about to be started
956                  * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
957                  * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
958                 unsigned cur_part_number;
959
960                 /** Total number of split WIM parts that are being written.  */
961                 unsigned total_parts;
962
963                 /** Name of the split WIM part that is about to be started
964                  * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
965                  * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
966                  * As of wimlib v1.7.0, the library user may change this when
967                  * receiving ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART in order to
968                  * cause the next split WIM part to be written to a different
969                  * location.  */
970                 wimlib_tchar *part_name;
971         } split;
972
973         /** Valid on messages ::WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM  */
974         struct wimlib_progress_info_replace {
975                 /** Path to the file in the WIM image that is being replaced  */
976                 const wimlib_tchar *path_in_wim;
977         } replace;
978
979         /** Valid on messages ::WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE  */
980         struct wimlib_progress_info_wimboot_exclude {
981                 /** Path to the file in the WIM image  */
982                 const wimlib_tchar *path_in_wim;
983
984                 /** Path to which the file is being extracted  */
985                 const wimlib_tchar *extraction_path;
986         } wimboot_exclude;
987
988         /** Valid on messages ::WIMLIB_PROGRESS_MSG_UNMOUNT_BEGIN.  */
989         struct wimlib_progress_info_unmount {
990                 /** Path to directory being unmounted  */
991                 const wimlib_tchar *mountpoint;
992
993                 /** Path to WIM file being unmounted  */
994                 const wimlib_tchar *mounted_wim;
995
996                 /** 1-based index of image being unmounted.  */
997                 uint32_t mounted_image;
998
999                 /** Flags that were passed to wimlib_mount_image() when the
1000                  * mountpoint was set up.  */
1001                 uint32_t mount_flags;
1002
1003                 /** Flags passed to wimlib_unmount_image().  */
1004                 uint32_t unmount_flags;
1005         } unmount;
1006 };
1007
1008 /**
1009  * A user-supplied function that will be called periodically during certain WIM
1010  * operations.
1011  *
1012  * The first argument will be the type of operation that is being performed or
1013  * is about to be started or has been completed.
1014  *
1015  * The second argument will be a pointer to one of a number of structures
1016  * depending on the first argument.  It may be @c NULL for some message types.
1017  * Note that although this argument is not @c const, users should not modify it
1018  * except in explicitly documented cases.
1019  *
1020  * The third argument will be a user-supplied value that was provided when
1021  * registering or specifying the progress function.
1022  *
1023  * This function must return one of the ::wimlib_progress_status values.  By
1024  * default, you should return ::WIMLIB_PROGRESS_STATUS_CONTINUE (0).
1025  */
1026 typedef enum wimlib_progress_status
1027         (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
1028                                   union wimlib_progress_info *info,
1029                                   void *progctx);
1030
1031 /** @} */
1032 /** @addtogroup G_modifying_wims
1033  * @{ */
1034
1035 /** An array of these structures is passed to wimlib_add_image_multisource() to
1036  * specify the sources from which to create a WIM image. */
1037 struct wimlib_capture_source {
1038         /** Absolute or relative path to a file or directory on the external
1039          * filesystem to be included in the WIM image. */
1040         wimlib_tchar *fs_source_path;
1041
1042         /** Destination path in the WIM image.  Use ::WIMLIB_WIM_ROOT_PATH to
1043          * specify the root directory of the WIM image.  */
1044         wimlib_tchar *wim_target_path;
1045
1046         /** Reserved; set to 0. */
1047         long reserved;
1048 };
1049
1050 /** Set or unset the WIM header flag that marks it read-only
1051  * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
1052  * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter.  This
1053  * is distinct from basic file permissions; this flag can be set on a WIM file
1054  * that is physically writable.  If this flag is set, all further operations to
1055  * modify the WIM will fail, except calling wimlib_overwrite() with
1056  * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
1057  * allows you to set this flag persistently on the underlying WIM file.
1058  */
1059 #define WIMLIB_CHANGE_READONLY_FLAG             0x00000001
1060
1061 /** Set the GUID (globally unique identifier) of the WIM file to the value
1062  * specified in ::wimlib_wim_info.guid of the @p info parameter. */
1063 #define WIMLIB_CHANGE_GUID                      0x00000002
1064
1065 /** Change the bootable image of the WIM to the value specified in
1066  * ::wimlib_wim_info.boot_index of the @p info parameter.  */
1067 #define WIMLIB_CHANGE_BOOT_INDEX                0x00000004
1068
1069 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
1070  * in ::wimlib_wim_info.has_rpfix of the @p info parameter.  This flag generally
1071  * indicates whether an image in the WIM has been captured with reparse-point
1072  * fixups enabled.  wimlib also treats this flag as specifying whether to do
1073  * reparse-point fixups by default when capturing or applying WIM images.  */
1074 #define WIMLIB_CHANGE_RPFIX_FLAG                0x00000008
1075
1076 /** @} */
1077
1078 /** @addtogroup G_wim_information
1079  * { */
1080
1081 /** @{ */
1082
1083 /** General information about a WIM file. */
1084 struct wimlib_wim_info {
1085
1086         /** Globally unique identifier for the WIM file.  Note: all parts of a
1087          * split WIM should have an identical value in this field.  */
1088         uint8_t  guid[WIMLIB_GUID_LEN];
1089
1090         /** Number of images in the WIM.  */
1091         uint32_t image_count;
1092
1093         /** 1-based index of the bootable image in the WIM, or 0 if no image is
1094          * bootable.  */
1095         uint32_t boot_index;
1096
1097         /** Version of the WIM file.  */
1098         uint32_t wim_version;
1099
1100         /** Chunk size used for compression.  */
1101         uint32_t chunk_size;
1102
1103         /** For split WIMs, the 1-based index of this part within the split WIM;
1104          * otherwise 1.  */
1105         uint16_t part_number;
1106
1107         /** For split WIMs, the total number of parts in the split WIM;
1108          * otherwise 1.  */
1109         uint16_t total_parts;
1110
1111         /** One of the ::wimlib_compression_type values that specifies the
1112          * method used to compress resources in the WIM.  */
1113         int32_t  compression_type;
1114
1115         /** Size of the WIM file in bytes, excluding the XML data and integrity
1116          * table.  */
1117         uint64_t total_bytes;
1118
1119         /** 1 if the WIM has an integrity table.  Note: if the ::WIMStruct was
1120          * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
1121          * this will always be 0, even if the ::WIMStruct was written to
1122          * somewhere by calling wimlib_write() with the
1123          * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
1124         uint32_t has_integrity_table : 1;
1125
1126         /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
1127          * wimlib_create_new_wim(). */
1128         uint32_t opened_from_file : 1;
1129
1130         /** 1 if the WIM is considered readonly for any reason. */
1131         uint32_t is_readonly : 1;
1132
1133         /** 1 if reparse-point fixups are supposedly enabled for one or more
1134          * images in the WIM.  */
1135         uint32_t has_rpfix : 1;
1136
1137         /** 1 if the WIM is marked as read-only.  */
1138         uint32_t is_marked_readonly : 1;
1139
1140         /** 1 if the WIM is part of a spanned set.  */
1141         uint32_t spanned : 1;
1142
1143         uint32_t write_in_progress : 1;
1144         uint32_t metadata_only : 1;
1145         uint32_t resource_only : 1;
1146
1147         /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE).  */
1148         uint32_t pipable : 1;
1149         uint32_t reserved_flags : 22;
1150         uint32_t reserved[9];
1151 };
1152
1153 /** Information about a unique stream in the WIM file.  (A stream is the same
1154  * thing as a "resource", except in the case of packed resources.)  */
1155 struct wimlib_resource_entry {
1156         /** Uncompressed size of the stream in bytes. */
1157         uint64_t uncompressed_size;
1158
1159         /** Compressed size of the stream in bytes.  This will be the same as @p
1160          * uncompressed_size if the stream is uncompressed.  Or, if @p
1161          * is_packed_streams is 1, this will be 0.  */
1162         uint64_t compressed_size;
1163
1164         /** Offset, in bytes, of this stream from the start of the WIM file.  Or
1165          * if @p packed is 1, then this is actually the offset at which this
1166          * stream begins in the uncompressed contents of the packed resource.
1167          */
1168         uint64_t offset;
1169
1170         /** SHA1 message digest of the stream's uncompressed contents.  */
1171         uint8_t sha1_hash[20];
1172
1173         /** Which part number of the split WIM this stream is in.  This should
1174          * be the same as the part number provided by wimlib_get_wim_info().  */
1175         uint32_t part_number;
1176
1177         /** Number of times this stream is referenced over all WIM images.  */
1178         uint32_t reference_count;
1179
1180         /** 1 if this stream is compressed.  */
1181         uint32_t is_compressed : 1;
1182
1183         /** 1 if this stream is a metadata resource rather than a file resource.
1184          * */
1185         uint32_t is_metadata : 1;
1186
1187         uint32_t is_free : 1;
1188         uint32_t is_spanned : 1;
1189
1190         /** 1 if this stream was not found in the lookup table of the
1191          * ::WIMStruct.  This normally implies a missing call to
1192          * wimlib_reference_resource_files() or wimlib_reference_resources().
1193          * */
1194         uint32_t is_missing : 1;
1195
1196         /** 1 if this stream is located in a packed resource which may contain
1197          * other streams (all compressed together) as well.  */
1198         uint32_t packed : 1;
1199
1200         uint32_t reserved_flags : 26;
1201
1202         /** If @p packed is 1, then this will specify the offset of the packed
1203          * resource in the WIM.  */
1204         uint64_t raw_resource_offset_in_wim;
1205
1206         /** If @p is_packed_streams is 1, then this will specify the compressed
1207          * size of the packed resource in the WIM.  */
1208         uint64_t raw_resource_compressed_size;
1209
1210         uint64_t reserved[2];
1211 };
1212
1213 /** Information about a stream of a particular file in the WIM.  */
1214 struct wimlib_stream_entry {
1215         /** Name of the stream, or NULL if the stream is unnamed. */
1216         const wimlib_tchar *stream_name;
1217         /** Location, size, etc. of the stream within the WIM file.  */
1218         struct wimlib_resource_entry resource;
1219         uint64_t reserved[4];
1220 };
1221
1222 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
1223  * Roughly, the information about a "file" in the WIM--- but really a directory
1224  * entry ("dentry") because hard links are allowed.  The hard_link_group_id
1225  * field can be used to distinguish actual file inodes.  */
1226 struct wimlib_dir_entry {
1227         /** Name of the file, or NULL if this file is unnamed (only possible for
1228          * the root directory) */
1229         const wimlib_tchar *filename;
1230
1231         /** 8.3 DOS name of this file, or NULL if this file has no such name.
1232          * */
1233         const wimlib_tchar *dos_name;
1234
1235         /** Full path to this file within the WIM image.  */
1236         const wimlib_tchar *full_path;
1237
1238         /** Depth of this directory entry, where 0 is the root, 1 is the root's
1239          * children, ..., etc. */
1240         size_t depth;
1241
1242         /** Pointer to the security descriptor for this file, in Windows
1243          * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
1244          * security descriptor.  */
1245         const char *security_descriptor;
1246
1247         /** Length of the above security descriptor.  */
1248         size_t security_descriptor_size;
1249
1250 #define WIMLIB_FILE_ATTRIBUTE_READONLY            0x00000001
1251 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN              0x00000002
1252 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM              0x00000004
1253 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY           0x00000010
1254 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE             0x00000020
1255 #define WIMLIB_FILE_ATTRIBUTE_DEVICE              0x00000040
1256 #define WIMLIB_FILE_ATTRIBUTE_NORMAL              0x00000080
1257 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY           0x00000100
1258 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE         0x00000200
1259 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT       0x00000400
1260 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED          0x00000800
1261 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE             0x00001000
1262 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
1263 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED           0x00004000
1264 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL             0x00010000
1265         /** File attributes, such as whether the file is a directory or not.
1266          * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
1267          * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
1268          * on other platforms.  */
1269         uint32_t attributes;
1270
1271 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO        0x00000000
1272 #define WIMLIB_REPARSE_TAG_RESERVED_ONE         0x00000001
1273 #define WIMLIB_REPARSE_TAG_MOUNT_POINT          0xA0000003
1274 #define WIMLIB_REPARSE_TAG_HSM                  0xC0000004
1275 #define WIMLIB_REPARSE_TAG_HSM2                 0x80000006
1276 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER      0x80000005
1277 #define WIMLIB_REPARSE_TAG_SIS                  0x80000007
1278 #define WIMLIB_REPARSE_TAG_DFS                  0x8000000A
1279 #define WIMLIB_REPARSE_TAG_DFSR                 0x80000012
1280 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER       0x8000000B
1281 #define WIMLIB_REPARSE_TAG_WOF                  0x80000017
1282 #define WIMLIB_REPARSE_TAG_SYMLINK              0xA000000C
1283         /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
1284          * attributes), this will give the reparse tag.  This tells you whether
1285          * the reparse point is a symbolic link, junction point, or some other,
1286          * more unusual kind of reparse point.  */
1287         uint32_t reparse_tag;
1288
1289         /*  Number of (hard) links to this file.  */
1290         uint32_t num_links;
1291
1292         /** Number of named data streams that this file has.  Normally 0.  */
1293         uint32_t num_named_streams;
1294
1295         /** Roughly, the inode number of this file.  However, it may be 0 if
1296          * @p num_links == 1.  */
1297         uint64_t hard_link_group_id;
1298
1299         /** Time this file was created.  */
1300         struct timespec creation_time;
1301
1302         /** Time this file was last written to.  */
1303         struct timespec last_write_time;
1304
1305         /** Time this file was last accessed.  */
1306         struct timespec last_access_time;
1307
1308         /* UNIX data (wimlib extension), only valid if unix_mode != 0  */
1309         uint32_t unix_uid;
1310         uint32_t unix_gid;
1311         uint32_t unix_mode;
1312         uint32_t unix_rdev;
1313
1314         uint64_t reserved[14];
1315
1316         /** Array of streams that make up this file.  The first entry will
1317          * always exist and will correspond to the unnamed data stream (default
1318          * file contents), so it will have @p stream_name == @c NULL.  There
1319          * will then be @p num_named_streams additional entries that specify the
1320          * named data streams, if any, each of which will have @p stream_name !=
1321          * @c NULL.  */
1322         struct wimlib_stream_entry streams[];
1323 };
1324
1325 /**
1326  * Type of a callback function to wimlib_iterate_dir_tree().  Must return 0 on
1327  * success.
1328  */
1329 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
1330                                                   void *user_ctx);
1331
1332 /**
1333  * Type of a callback function to wimlib_iterate_lookup_table().  Must return 0
1334  * on success.
1335  */
1336 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1337                                                       void *user_ctx);
1338
1339 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1340  * just on the specified path. */
1341 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1342
1343 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1344  * itself; only its children (in the case of a non-empty directory) */
1345 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN  0x00000002
1346
1347 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1348  * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1349  * table of the ::WIMStruct.  The default behavior without this flag is to fill
1350  * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1351  * wimlib_resource_entry::is_missing "is_missing" flag.  */
1352 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED  0x00000004
1353
1354
1355 /** @} */
1356 /** @addtogroup G_modifying_wims
1357  * @{ */
1358
1359 /** Directly capture an NTFS volume rather than a generic directory.  This flag
1360  * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1361  * ::WIMLIB_ADD_FLAG_UNIX_DATA.   */
1362 #define WIMLIB_ADD_FLAG_NTFS                    0x00000001
1363
1364 /** Follow symlinks; archive and dump the files they point to.  Currently only
1365  * supported on UNIX-like systems.  */
1366 #define WIMLIB_ADD_FLAG_DEREFERENCE             0x00000002
1367
1368 /** Call the progress function with the message
1369  * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file has been
1370  * scanned.  */
1371 #define WIMLIB_ADD_FLAG_VERBOSE                 0x00000004
1372
1373 /** Mark the image being added as the bootable image of the WIM.  Not valid for
1374  * wimlib_update_image().  */
1375 #define WIMLIB_ADD_FLAG_BOOT                    0x00000008
1376
1377 /** UNIX-like systems only: Store the UNIX owner, group, mode, and device ID
1378  * (major and minor number) of each file.  See the documentation for the
1379  * <b>--unix-data</b> option to <b>wimlib-imagex capture</b> for more
1380  * information.  */
1381 #define WIMLIB_ADD_FLAG_UNIX_DATA               0x00000010
1382
1383 /** Do not capture security descriptors.  Only has an effect in NTFS capture
1384  * mode, or in Windows native builds. */
1385 #define WIMLIB_ADD_FLAG_NO_ACLS                 0x00000020
1386
1387 /** Fail immediately if the full security descriptor of any file or directory
1388  * cannot be accessed.  Only has an effect in Windows native builds.  The
1389  * default behavior without this flag is to first try omitting the SACL from the
1390  * security descriptor, then to try omitting the security descriptor entirely.
1391  * */
1392 #define WIMLIB_ADD_FLAG_STRICT_ACLS             0x00000040
1393
1394 /** Call the progress function with the message
1395  * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1396  * capture.  This is a subset of the messages provided by
1397  * ::WIMLIB_ADD_FLAG_VERBOSE. */
1398 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE         0x00000080
1399
1400 /** Reparse-point fixups:  Modify absolute symbolic links (or junction points,
1401  * in the case of Windows) that point inside the directory being captured to
1402  * instead be absolute relative to the directory being captured, rather than the
1403  * current root.
1404  *
1405  * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1406  * the WIM header or if this is the first image being added.
1407  * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1408  * reparse point fixups enabled and currently cannot be unset. */
1409 #define WIMLIB_ADD_FLAG_RPFIX                   0x00000100
1410
1411 /** Don't do reparse point fixups.  The default behavior is described in the
1412  * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1413 #define WIMLIB_ADD_FLAG_NORPFIX                 0x00000200
1414
1415 /** Do not automatically exclude unsupported files or directories from capture;
1416  * e.g. encrypted files in NTFS-3g capture mode, or device files and FIFOs on
1417  * UNIX-like systems.  Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1418  * such a file is encountered.  */
1419 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE  0x00000400
1420
1421 /**
1422  * Automatically select a capture configuration appropriate for capturing
1423  * filesystems containing Windows operating systems.  For example,
1424  * "pagefile.sys" and "System Volume Information" will be excluded.
1425  *
1426  * When this flag is specified, the corresponding @p config parameter or member
1427  * must be @c NULL.
1428  *
1429  * Note that the default behavior--- that is, when this flag is not specified
1430  * and @p config is @c NULL--- is to use no capture configuration, meaning that
1431  * no files are excluded from capture.
1432  */
1433 #define WIMLIB_ADD_FLAG_WINCONFIG               0x00000800
1434
1435 /**
1436  * Capture image as WIMBoot compatible.  In addition, if no capture
1437  * configuration file is explicitly specified use the capture configuration file
1438  * <c>$SOURCE/Windows/System32/WimBootCompress.ini</c> if it exists, where
1439  * <c>$SOURCE</c> is the directory being captured; or, if a capture
1440  * configuration file is explicitly specified, use it and also place it at
1441  * /Windows/System32/WimBootCompress.ini in the WIM image.
1442  *
1443  * Note: this will not by itself change the compression type.  Before writing
1444  * the WIM file, it's recommended to also do:
1445  *
1446  * \code
1447  *      wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1448  *      wimlib_set_output_chunk_size(wim, 4096);
1449  * \endcode
1450  *
1451  * since that makes access to the data faster (at the cost of a worse
1452  * compression ratio compared to the 32768-byte LZX chunks usually used).
1453  */
1454 #define WIMLIB_ADD_FLAG_WIMBOOT                 0x00001000
1455
1456 /**
1457  * If the add command involves adding a non-directory file to a location at
1458  * which there already exists a nondirectory file in the WIM image, issue
1459  * ::WIMLIB_ERR_INVALID_OVERLAY instead of replacing the file.  This only has an
1460  * effect when updating an existing image with wimlib_update_image().
1461  * This was the default behavior in wimlib v1.6.2 and earlier.
1462  */
1463 #define WIMLIB_ADD_FLAG_NO_REPLACE              0x00002000
1464
1465 #define WIMLIB_ADD_IMAGE_FLAG_NTFS              WIMLIB_ADD_FLAG_NTFS
1466 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE       WIMLIB_ADD_FLAG_DEREFERENCE
1467 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE           WIMLIB_ADD_FLAG_VERBOSE
1468 #define WIMLIB_ADD_IMAGE_FLAG_BOOT              WIMLIB_ADD_FLAG_BOOT
1469 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA         WIMLIB_ADD_FLAG_UNIX_DATA
1470 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS           WIMLIB_ADD_FLAG_NO_ACLS
1471 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS       WIMLIB_ADD_FLAG_STRICT_ACLS
1472 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE   WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1473 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX             WIMLIB_ADD_FLAG_RPFIX
1474 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX           WIMLIB_ADD_FLAG_NORPFIX
1475 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1476                                                 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1477 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG         WIMLIB_ADD_FLAG_WINCONFIG
1478 #define WIMLIB_ADD_IMAGE_FLAG_WIMBOOT           WIMLIB_ADD_FLAG_WIMBOOT
1479
1480
1481 /** @} */
1482 /** @addtogroup G_modifying_wims
1483  * @{ */
1484
1485 /** Do not issue an error if the path to delete does not exist. */
1486 #define WIMLIB_DELETE_FLAG_FORCE                        0x00000001
1487
1488 /** Delete the file or directory tree recursively; if not specified, an error is
1489  * issued if the path to delete is a directory. */
1490 #define WIMLIB_DELETE_FLAG_RECURSIVE                    0x00000002
1491
1492 /** @} */
1493 /** @addtogroup G_modifying_wims
1494  * @{ */
1495
1496 /**
1497  * If a single image is being exported, mark it bootable in the destination WIM.
1498  * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1499  * the image in the source WIM (if any) that is marked as bootable is also
1500  * marked as bootable in the destination WIM.
1501  */
1502 #define WIMLIB_EXPORT_FLAG_BOOT                         0x00000001
1503
1504 /** Give the exported image(s) no names.  Avoids problems with image name
1505  * collisions.
1506  */
1507 #define WIMLIB_EXPORT_FLAG_NO_NAMES                     0x00000002
1508
1509 /** Give the exported image(s) no descriptions.  */
1510 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS              0x00000004
1511
1512 /** This advises the library that the program is finished with the source
1513  * WIMStruct and will not attempt to access it after the call to
1514  * wimlib_export_image(), with the exception of the call to wimlib_free().  */
1515 #define WIMLIB_EXPORT_FLAG_GIFT                         0x00000008
1516
1517 /**
1518  * Mark each exported image as WIMBoot-compatible.
1519  *
1520  * Note: by itself, this does change the destination WIM's compression type, nor
1521  * does it add the file @c \\Windows\\System32\\WimBootCompress.ini in the WIM
1522  * image.  Before writing the destination WIM, it's recommended to do something
1523  * like:
1524  *
1525  * \code
1526  *      wimlib_set_output_compression_type(wim, WIMLIB_COMPRESSION_TYPE_XPRESS);
1527  *      wimlib_set_output_chunk_size(wim, 4096);
1528  *      wimlib_add_tree(wim, image, L"myconfig.ini",
1529  *                      L"\\Windows\\System32\\WimBootCompress.ini", 0);
1530  * \endcode
1531  */
1532 #define WIMLIB_EXPORT_FLAG_WIMBOOT                      0x00000010
1533
1534 /** @} */
1535 /** @addtogroup G_extracting_wims
1536  * @{ */
1537
1538 /** Extract the image directly to an NTFS volume rather than a generic directory.
1539  * This mode is only available if wimlib was compiled with libntfs-3g support;
1540  * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned.  In this mode, the
1541  * extraction target will be interpreted as the path to an NTFS volume image (as
1542  * a regular file or block device) rather than a directory.  It will be opened
1543  * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1544  * root directory.  Note: this flag cannot be used when wimlib_extract_image()
1545  * is called with ::WIMLIB_ALL_IMAGES as the @p image, nor can it be used with
1546  * wimlib_extract_paths() when passed multiple paths.  */
1547 #define WIMLIB_EXTRACT_FLAG_NTFS                        0x00000001
1548
1549 /** UNIX-like systems only:  Extract special UNIX data captured with
1550  * ::WIMLIB_ADD_FLAG_UNIX_DATA.  This flag cannot be combined with
1551  * ::WIMLIB_EXTRACT_FLAG_NTFS.  */
1552 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA                   0x00000020
1553
1554 /** Do not extract security descriptors.  This flag cannot be combined with
1555  * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS.  */
1556 #define WIMLIB_EXTRACT_FLAG_NO_ACLS                     0x00000040
1557
1558 /** Fail immediately if the full security descriptor of any file or directory
1559  * cannot be set exactly as specified in the WIM file.  On Windows, the default
1560  * behavior without this flag when wimlib does not have permission to set the
1561  * correct security descriptor is to fall back to setting the security
1562  * descriptor with the SACL omitted, then with the DACL omitted, then with the
1563  * owner omitted, then not at all.  This flag cannot be combined with
1564  * ::WIMLIB_EXTRACT_FLAG_NO_ACLS.  */
1565 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS                 0x00000080
1566
1567 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX.  This forces
1568  * reparse-point fixups on, so absolute symbolic links or junction points will
1569  * be fixed to be absolute relative to the actual extraction root.  Reparse-
1570  * point fixups are done by default for wimlib_extract_image() and
1571  * wimlib_extract_image_from_pipe() if WIM_HDR_FLAG_RP_FIX is set in the WIM
1572  * header.  This flag cannot be combined with ::WIMLIB_EXTRACT_FLAG_NORPFIX.  */
1573 #define WIMLIB_EXTRACT_FLAG_RPFIX                       0x00000100
1574
1575 /** Force reparse-point fixups on extraction off, regardless of the state of the
1576  * WIM_HDR_FLAG_RP_FIX flag in the WIM header.  This flag cannot be combined
1577  * with ::WIMLIB_EXTRACT_FLAG_RPFIX.  */
1578 #define WIMLIB_EXTRACT_FLAG_NORPFIX                     0x00000200
1579
1580 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only:  Extract the
1581  * paths, each of which must name a regular file, to standard output.  */
1582 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT                   0x00000400
1583
1584 /** Instead of ignoring files and directories with names that cannot be
1585  * represented on the current platform (note: Windows has more restrictions on
1586  * filenames than POSIX-compliant systems), try to replace characters or append
1587  * junk to the names so that they can be extracted in some form.  */
1588 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES   0x00000800
1589
1590 /** On Windows, when there exist two or more files with the same case
1591  * insensitive name but different case sensitive names, try to extract them all
1592  * by appending junk to the end of them, rather than arbitrarily extracting only
1593  * one.  */
1594 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS          0x00001000
1595
1596 /** Do not ignore failure to set timestamps on extracted files.  */
1597 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS           0x00002000
1598
1599 /** Do not ignore failure to set short names on extracted files.  */
1600 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES          0x00004000
1601
1602 /** On Windows, do not ignore failure to extract symbolic links and junctions
1603  * due to permissions problems.  By default, such failures are ignored since the
1604  * default configuration of Windows only allows the Administrator to create
1605  * symbolic links.  */
1606 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS             0x00008000
1607
1608 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1609  * behavior is currently less than satisfactory.  Do not use (yet).  */
1610 #define WIMLIB_EXTRACT_FLAG_RESUME                      0x00010000
1611
1612 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only:  Treat the
1613  * paths to extract as wildcard patterns ("globs") which may contain the
1614  * wildcard characters @c ? and @c *.  The @c ? character matches any
1615  * non-path-separator character, whereas the @c * character matches zero or more
1616  * non-path-separator characters.  Consequently, each glob may match zero or
1617  * more actual paths in the WIM image.  By default, if a glob does not match any
1618  * files, a warning but not an error will be issued, even if the glob did not
1619  * actually contain wildcard characters.  Use ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
1620  * to get an error instead.  */
1621 #define WIMLIB_EXTRACT_FLAG_GLOB_PATHS                  0x00040000
1622
1623 /** In combination with ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS, causes an error
1624  * (::WIMLIB_ERR_PATH_DOES_NOT_EXIST) rather than a warning to be issued when
1625  * one of the provided globs did not match a file.  */
1626 #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB                 0x00080000
1627
1628 /** Do not extract Windows file attributes such as readonly, hidden, etc.  */
1629 #define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES               0x00100000
1630
1631 /** For wimlib_extract_paths() and wimlib_extract_pathlist() only:  Do not
1632  * preserve the directory structure of the archive when extracting --- that is,
1633  * place each extracted file or directory tree directly in the target directory.
1634  */
1635 #define WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE   0x00200000
1636
1637 /** Windows only: Extract files as "pointers" back to the WIM archive.  See the
1638  * documentation for the <b>--wimboot</b> option of <b>wimlib-imagex apply</b>
1639  * for more information.  */
1640 #define WIMLIB_EXTRACT_FLAG_WIMBOOT                     0x00400000
1641
1642 /** @} */
1643 /** @addtogroup G_mounting_wim_images
1644  * @{ */
1645
1646 /** Mount the WIM image read-write rather than the default of read-only. */
1647 #define WIMLIB_MOUNT_FLAG_READWRITE                     0x00000001
1648
1649 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1650 #define WIMLIB_MOUNT_FLAG_DEBUG                         0x00000002
1651
1652 /** Do not allow accessing named data streams in the mounted WIM image.  */
1653 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE         0x00000004
1654
1655 /** Access named data streams in the mounted WIM image through extended file
1656  * attributes named "user.X", where X is the name of a data stream.  This is the
1657  * default mode.  */
1658 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR        0x00000008
1659
1660 /** Access named data streams in the mounted WIM image by specifying the file
1661  * name, a colon, then the name of the data stream.  */
1662 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS      0x00000010
1663
1664 /** Use UNIX metadata if available in the WIM image.  See
1665  * ::WIMLIB_ADD_FLAG_UNIX_DATA.  */
1666 #define WIMLIB_MOUNT_FLAG_UNIX_DATA                     0x00000020
1667
1668 /** Allow other users to see the mounted filesystem.  This passes the @c
1669  * allow_other option to the FUSE mount.  */
1670 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER                   0x00000040
1671
1672 /** @} */
1673 /** @addtogroup G_creating_and_opening_wims
1674  * @{ */
1675
1676 /** Verify the WIM contents against the WIM's integrity table, if present.  This
1677  * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1678  * checksummed and checked against the SHA1 message digests specified in the
1679  * integrity table.  If there are any mismatches, ::WIMLIB_ERR_INTEGRITY is
1680  * issued.  If the WIM file does not contain an integrity table, this flag has
1681  * no effect.  */
1682 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY                0x00000001
1683
1684 /** Issue an error (::WIMLIB_ERR_IS_SPLIT_WIM) if the WIM is part of a split
1685  * WIM.  Software can provide this flag for convenience if it explicitly does
1686  * not want to support split WIMs.  */
1687 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT                 0x00000002
1688
1689 /** Check if the WIM is writable and issue an error
1690  * (::WIMLIB_ERR_WIM_IS_READONLY) if it is not.  A WIM is considered writable
1691  * only if it is writable at the filesystem level, does not have the
1692  * WIM_HDR_FLAG_READONLY flag set in its header, and is not part of a spanned
1693  * set.  It is not required to provide this flag before attempting to make
1694  * changes to the WIM, but with this flag you get an error sooner rather than
1695  * later.  */
1696 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS                   0x00000004
1697
1698 /** @} */
1699 /** @addtogroup G_mounting_wim_images
1700  * @{ */
1701
1702 /** Provide ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY when committing the WIM image.
1703  * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified.  */
1704 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY             0x00000001
1705
1706 /** Commit changes to the read-write mounted WIM image.
1707  * If this flag is not specified, changes will be discarded.  */
1708 #define WIMLIB_UNMOUNT_FLAG_COMMIT                      0x00000002
1709
1710 /** Provide ::WIMLIB_WRITE_FLAG_REBUILD when committing the WIM image.
1711  * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified.  */
1712 #define WIMLIB_UNMOUNT_FLAG_REBUILD                     0x00000004
1713
1714 /** Provide ::WIMLIB_WRITE_FLAG_RECOMPRESS when committing the WIM image.
1715  * Ignored if ::WIMLIB_UNMOUNT_FLAG_COMMIT not also specified.  */
1716 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS                  0x00000008
1717
1718 /**
1719  * In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted WIM
1720  * image, forces all file descriptors to the open WIM image to be closed before
1721  * committing it.
1722  *
1723  * Without ::WIMLIB_UNMOUNT_FLAG_COMMIT or with a read-only mounted WIM image,
1724  * this flag has no effect.
1725  */
1726 #define WIMLIB_UNMOUNT_FLAG_FORCE                       0x00000010
1727
1728 /** In combination with ::WIMLIB_UNMOUNT_FLAG_COMMIT for a read-write mounted
1729  * WIM image, causes the modified image to be committed to the WIM file as a
1730  * new, unnamed image appended to the archive.  The original image in the WIM
1731  * file will be unmodified.  */
1732 #define WIMLIB_UNMOUNT_FLAG_NEW_IMAGE                   0x00000020
1733
1734 /** @} */
1735 /** @addtogroup G_modifying_wims
1736  * @{ */
1737
1738 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1739  * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages.  */
1740 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS                0x00000001
1741
1742 /** @} */
1743 /** @addtogroup G_writing_and_overwriting_wims
1744  * @{ */
1745
1746 /**
1747  * Include an integrity table in the resulting WIM file.
1748  *
1749  * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1750  * include an integrity table if and only if one was present before.  For
1751  * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1752  * to not include an integrity table.
1753  */
1754 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY               0x00000001
1755
1756 /**
1757  * Do not include an integrity table in the resulting WIM file.  This is the
1758  * default behavior, unless the ::WIMStruct was created by opening a WIM with an
1759  * integrity table.
1760  */
1761 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY            0x00000002
1762
1763 /**
1764  * Write the WIM as "pipable".  After writing a WIM with this flag specified,
1765  * images from it can be applied directly from a pipe using
1766  * wimlib_extract_image_from_pipe().  See the documentation for the
1767  * <b>--pipable</b> option of <b>wimlib-imagex capture</b> for more information.
1768  * Beware: WIMs written with this flag will not be compatible with Microsoft's
1769  * software.
1770  *
1771  * For ::WIMStruct's created with wimlib_open_wim(), the default behavior is to
1772  * write the WIM as pipable if and only if it was pipable before.  For
1773  * ::WIMStruct's created with wimlib_create_new_wim(), the default behavior is
1774  * to write the WIM as non-pipable.
1775  */
1776 #define WIMLIB_WRITE_FLAG_PIPABLE                       0x00000004
1777
1778 /**
1779  * Do not write the WIM as "pipable".  This is the default behavior, unless the
1780  * ::WIMStruct was created by opening a pipable WIM.
1781  */
1782 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE                   0x00000008
1783
1784 /**
1785  * When writing streams to the WIM file, recompress them, even if their data is
1786  * already available in the desired compressed form (for example, in a WIM file
1787  * from which an image has been exported using wimlib_export_image()).
1788  *
1789  * ::WIMLIB_WRITE_FLAG_RECOMPRESS can be used to recompress with a higher
1790  * compression ratio for the same compression type and chunk size.  wimlib's LZX
1791  * compressor currently can be given different parameters in order to achieve
1792  * different balances between compression ratio and time.  In its default mode
1793  * as of v1.7.0, it usually compresses slightly better than the competing
1794  * Microsoft implementation and is almost as fast.
1795  *
1796  * ::WIMLIB_WRITE_FLAG_RECOMPRESS can also be used in combination with
1797  * ::WIMLIB_WRITE_FLAG_PACK_STREAMS to prevent any solid blocks from being
1798  * re-used.  (Otherwise, solid blocks are re-used somewhat more liberally than
1799  * normal compressed blocks.)
1800  *
1801  * ::WIMLIB_WRITE_FLAG_RECOMPRESS does <b>not</b> cause recompression of streams
1802  * that would not otherwise be written.  For example, a call to
1803  * wimlib_overwrite() with ::WIMLIB_WRITE_FLAG_RECOMPRESS will not, by itself,
1804  * cause already-existing streams in the WIM file to be recompressed.  To force
1805  * the WIM file to be fully rebuilt and recompressed, combine
1806  * ::WIMLIB_WRITE_FLAG_RECOMPRESS with ::WIMLIB_WRITE_FLAG_REBUILD.
1807  */
1808 #define WIMLIB_WRITE_FLAG_RECOMPRESS                    0x00000010
1809
1810 /**
1811  * Immediately before closing the WIM file, sync its data to disk.
1812  *
1813  * wimlib_overwrite() will set this flag automatically if it decides to
1814  * overwrite the WIM file via a temporary file instead of in-place.
1815  */
1816 #define WIMLIB_WRITE_FLAG_FSYNC                         0x00000020
1817
1818 /**
1819  * For wimlib_overwrite(), rebuild the entire WIM file, even if it otherwise
1820  * could be updated merely by appending to it.
1821  *
1822  * When rebuilding the WIM file, stream reference counts will be recomputed, and
1823  * any streams with 0 reference count (e.g. from deleted files or images) will
1824  * not be included in the resulting WIM file.
1825  *
1826  * This flag can be combined with ::WIMLIB_WRITE_FLAG_RECOMPRESS to force all
1827  * data to be recompressed.  Otherwise, compressed data is re-used if possible.
1828  *
1829  * wimlib_write() ignores this flag.
1830  */
1831 #define WIMLIB_WRITE_FLAG_REBUILD                       0x00000040
1832
1833 /**
1834  * For wimlib_overwrite(), override the default behavior after one or more calls
1835  * to wimlib_delete_image(), which is to rebuild the entire WIM file.  With this
1836  * flag, only minimal changes to correctly remove the image from the WIM file
1837  * will be taken.  In particular, all streams will be retained, even if they are
1838  * no longer referenced.  This may not be what you want, because no space will
1839  * be saved by deleting an image in this way.
1840  *
1841  * wimlib_write() ignores this flag.
1842  */
1843 #define WIMLIB_WRITE_FLAG_SOFT_DELETE                   0x00000080
1844
1845 /**
1846  * For wimlib_overwrite(), allow overwriting the WIM file even if the readonly
1847  * flag (WIM_HDR_FLAG_READONLY) is set in the WIM header.  This can be used
1848  * following a call to wimlib_set_wim_info() with the
1849  * ::WIMLIB_CHANGE_READONLY_FLAG flag to actually set the readonly flag on the
1850  * on-disk WIM file.
1851  *
1852  * wimlib_write() ignores this flag.
1853  */
1854 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG          0x00000100
1855
1856 /**
1857  * Do not include streams already present in other WIMs.  This flag can be used
1858  * to write a "delta" WIM after resources from the WIM on which the delta is to
1859  * be based were referenced with wimlib_reference_resource_files() or
1860  * wimlib_reference_resources().
1861  */
1862 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS            0x00000200
1863
1864 /**
1865  * Advises the library that for writes of all WIM images, all streams needed for
1866  * the WIM are already present (not in external resource WIMs) and their
1867  * reference counts are correct, so the code does not need to recalculate which
1868  * streams are referenced.  This is for optimization purposes only, since with
1869  * this flag specified, the metadata resources may not need to be decompressed
1870  * and parsed.
1871  *
1872  * wimlib_overwrite() will set this flag automatically.
1873  */
1874 #define WIMLIB_WRITE_FLAG_STREAMS_OK                    0x00000400
1875
1876 /**
1877  * For wimlib_write(), retain the WIM's GUID instead of generating a new one.
1878  *
1879  * wimlib_overwrite() sets this by default, since the WIM remains, logically,
1880  * the same file.
1881  */
1882 #define WIMLIB_WRITE_FLAG_RETAIN_GUID                   0x00000800
1883
1884 /**
1885  * When writing streams in the resulting WIM file, pack multiple streams into a
1886  * single compressed resource instead of compressing them independently.  This
1887  * is also known as creating a "solid archive".  This tends to produce a better
1888  * compression ratio at the cost of much slower random access.
1889  *
1890  * WIM files created with this flag are only compatible with wimlib v1.6.0 or
1891  * later, WIMGAPI Windows 8 or later, and DISM Windows 8.1 or later.  WIM files
1892  * created with this flag use a different version number in their header (3584
1893  * instead of 68864) and are also called "ESD files".
1894  *
1895  * If this flag is passed to wimlib_overwrite(), any new data streams will be
1896  * written in solid mode.  Use both ::WIMLIB_WRITE_FLAG_REBUILD and
1897  * ::WIMLIB_WRITE_FLAG_RECOMPRESS to force the entire WIM file be rebuilt with
1898  * all streams recompressed in solid mode.
1899  *
1900  * Currently, new solid blocks will, by default, be written using LZMS
1901  * compression with 64 MiB (67108864 byte) chunks.  Use
1902  * wimlib_set_output_pack_compression_type() and/or
1903  * wimlib_set_output_pack_chunk_size() to change this.  This is independent of
1904  * the WIM's main compression type and chunk size; you can have a WIM that
1905  * nominally uses LZX compression and 32768 byte chunks but actually contains
1906  * LZMS-compressed solid blocks, for example.  However, if including solid
1907  * blocks, I suggest that you set the WIM's main compression type to LZMS as
1908  * well, either by creating the WIM with
1909  * ::wimlib_create_new_wim(::WIMLIB_COMPRESSION_TYPE_LZMS, ...) or by calling
1910  * ::wimlib_set_output_compression_type(..., ::WIMLIB_COMPRESSION_TYPE_LZMS).
1911  *
1912  * This flag will be set by default when writing or overwriting a WIM file that
1913  * either already contains packed streams, or has had packed streams exported
1914  * into it and the WIM's main compression type is LZMS.
1915  */
1916 #define WIMLIB_WRITE_FLAG_PACK_STREAMS                  0x00001000
1917
1918 /** @} */
1919 /** @addtogroup G_general
1920  * @{ */
1921
1922 /** Assume that strings are represented in UTF-8, even if this is not the
1923  * locale's character encoding.  This flag is ignored on Windows, where wimlib
1924  * always uses UTF-16LE.  */
1925 #define WIMLIB_INIT_FLAG_ASSUME_UTF8                    0x00000001
1926
1927 /** Windows-only: do not attempt to acquire additional privileges (currently
1928  * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1929  * SeTakeOwnershipPrivilege) when initializing the library.  This is intended
1930  * for the case where the calling program manages these privileges itself.
1931  * Note: no error is issued if privileges cannot be acquired, although related
1932  * errors may be reported later, depending on if the operations performed
1933  * actually require additional privileges or not.  */
1934 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES        0x00000002
1935
1936 /** Windows only:  If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1937  * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1938  * to read all possible data and metadata for a capture operation could not be
1939  * acquired.  Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1940  */
1941 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES      0x00000004
1942
1943 /** Windows only:  If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1944  * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1945  * to restore all possible data and metadata for an apply operation could not be
1946  * acquired.  Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1947  */
1948 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES        0x00000008
1949
1950 /** Default to interpreting WIM paths case sensitively (default on UNIX-like
1951  * systems).  */
1952 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_SENSITIVE         0x00000010
1953
1954 /** Default to interpreting WIM paths case insensitively (default on Windows).
1955  * This does not apply to mounted images.  */
1956 #define WIMLIB_INIT_FLAG_DEFAULT_CASE_INSENSITIVE       0x00000020
1957
1958 /** @} */
1959 /** @addtogroup G_nonstandalone_wims
1960  * @{ */
1961
1962 /** For wimlib_reference_resource_files(), enable shell-style filename globbing.
1963  * Ignored by wimlib_reference_resources().  */
1964 #define WIMLIB_REF_FLAG_GLOB_ENABLE             0x00000001
1965
1966 /** For wimlib_reference_resource_files(), issue an error
1967  * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files.  The
1968  * default behavior without this flag is to issue no error at that point, but
1969  * then attempt to open the glob as a literal path, which of course will fail
1970  * anyway if no file exists at that path.  No effect if
1971  * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified.  Ignored by
1972  * wimlib_reference_resources().  */
1973 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH     0x00000002
1974
1975 /** @} */
1976 /** @addtogroup G_modifying_wims
1977  * @{ */
1978
1979 /** The specific type of update to perform. */
1980 enum wimlib_update_op {
1981         /** Add a new file or directory tree to the WIM image in a
1982          * certain location. */
1983         WIMLIB_UPDATE_OP_ADD = 0,
1984
1985         /** Delete a file or directory tree from the WIM image. */
1986         WIMLIB_UPDATE_OP_DELETE,
1987
1988         /** Rename a file or directory tree in the WIM image. */
1989         WIMLIB_UPDATE_OP_RENAME,
1990 };
1991
1992 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1993 struct wimlib_add_command {
1994         /** Filesystem path to the file or directory tree to add.  */
1995         wimlib_tchar *fs_source_path;
1996
1997         /** Destination path in the WIM image.  Use ::WIMLIB_WIM_ROOT_PATH to
1998          * specify the root directory of the WIM image.  */
1999         wimlib_tchar *wim_target_path;
2000
2001         /** Path to capture configuration file to use, or @c NULL for default.
2002          */
2003         wimlib_tchar *config_file;
2004
2005         /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
2006         int add_flags;
2007 };
2008
2009 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
2010 struct wimlib_delete_command {
2011
2012         /** Path, specified from the root of the WIM image, for the file or
2013          * directory tree within the WIM image to be deleted.  */
2014         wimlib_tchar *wim_path;
2015
2016         /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags.  */
2017         int delete_flags;
2018 };
2019
2020 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
2021 struct wimlib_rename_command {
2022
2023         /** Path, specified from the root of the WIM image, for the source file
2024          * or directory tree within the WIM image.  */
2025         wimlib_tchar *wim_source_path;
2026
2027         /** Path, specified from the root of the WIM image, for the destination
2028          * file or directory tree within the WIM image.  */
2029         wimlib_tchar *wim_target_path;
2030
2031         /** Reserved; set to 0.  */
2032         int rename_flags;
2033 };
2034
2035 /** Specification of an update to perform on a WIM image. */
2036 struct wimlib_update_command {
2037
2038         enum wimlib_update_op op;
2039
2040         union {
2041                 struct wimlib_add_command add;
2042                 struct wimlib_delete_command delete_; /* Underscore is for C++
2043                                                          compatibility.  */
2044                 struct wimlib_rename_command rename;
2045         };
2046 };
2047
2048 /** @} */
2049 /** @addtogroup G_general
2050  * @{ */
2051
2052 /**
2053  * Possible values of the error code returned by many functions in wimlib.
2054  *
2055  * See the documentation for each wimlib function to see specifically what error
2056  * codes can be returned by a given function, and what they mean.
2057  */
2058 enum wimlib_error_code {
2059         WIMLIB_ERR_SUCCESS                            = 0,
2060         WIMLIB_ERR_ALREADY_LOCKED                     = 1,
2061         WIMLIB_ERR_DECOMPRESSION                      = 2,
2062         WIMLIB_ERR_FUSE                               = 6,
2063         WIMLIB_ERR_GLOB_HAD_NO_MATCHES                = 8,
2064         WIMLIB_ERR_ICONV_NOT_AVAILABLE                = 9,
2065         WIMLIB_ERR_IMAGE_COUNT                        = 10,
2066         WIMLIB_ERR_IMAGE_NAME_COLLISION               = 11,
2067         WIMLIB_ERR_INSUFFICIENT_PRIVILEGES            = 12,
2068         WIMLIB_ERR_INTEGRITY                          = 13,
2069         WIMLIB_ERR_INVALID_CAPTURE_CONFIG             = 14,
2070         WIMLIB_ERR_INVALID_CHUNK_SIZE                 = 15,
2071         WIMLIB_ERR_INVALID_COMPRESSION_TYPE           = 16,
2072         WIMLIB_ERR_INVALID_HEADER                     = 17,
2073         WIMLIB_ERR_INVALID_IMAGE                      = 18,
2074         WIMLIB_ERR_INVALID_INTEGRITY_TABLE            = 19,
2075         WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY         = 20,
2076         WIMLIB_ERR_INVALID_METADATA_RESOURCE          = 21,
2077         WIMLIB_ERR_INVALID_MULTIBYTE_STRING           = 22,
2078         WIMLIB_ERR_INVALID_OVERLAY                    = 23,
2079         WIMLIB_ERR_INVALID_PARAM                      = 24,
2080         WIMLIB_ERR_INVALID_PART_NUMBER                = 25,
2081         WIMLIB_ERR_INVALID_PIPABLE_WIM                = 26,
2082         WIMLIB_ERR_INVALID_REPARSE_DATA               = 27,
2083         WIMLIB_ERR_INVALID_RESOURCE_HASH              = 28,
2084         WIMLIB_ERR_INVALID_UTF16_STRING               = 30,
2085         WIMLIB_ERR_INVALID_UTF8_STRING                = 31,
2086         WIMLIB_ERR_IS_DIRECTORY                       = 32,
2087         WIMLIB_ERR_IS_SPLIT_WIM                       = 33,
2088         WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE = 34,
2089         WIMLIB_ERR_LINK                               = 35,
2090         WIMLIB_ERR_METADATA_NOT_FOUND                 = 36,
2091         WIMLIB_ERR_MKDIR                              = 37,
2092         WIMLIB_ERR_MQUEUE                             = 38,
2093         WIMLIB_ERR_NOMEM                              = 39,
2094         WIMLIB_ERR_NOTDIR                             = 40,
2095         WIMLIB_ERR_NOTEMPTY                           = 41,
2096         WIMLIB_ERR_NOT_A_REGULAR_FILE                 = 42,
2097         WIMLIB_ERR_NOT_A_WIM_FILE                     = 43,
2098         WIMLIB_ERR_NOT_PIPABLE                        = 44,
2099         WIMLIB_ERR_NO_FILENAME                        = 45,
2100         WIMLIB_ERR_NTFS_3G                            = 46,
2101         WIMLIB_ERR_OPEN                               = 47,
2102         WIMLIB_ERR_OPENDIR                            = 48,
2103         WIMLIB_ERR_PATH_DOES_NOT_EXIST                = 49,
2104         WIMLIB_ERR_READ                               = 50,
2105         WIMLIB_ERR_READLINK                           = 51,
2106         WIMLIB_ERR_RENAME                             = 52,
2107         WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED         = 54,
2108         WIMLIB_ERR_RESOURCE_NOT_FOUND                 = 55,
2109         WIMLIB_ERR_RESOURCE_ORDER                     = 56,
2110         WIMLIB_ERR_SET_ATTRIBUTES                     = 57,
2111         WIMLIB_ERR_SET_REPARSE_DATA                   = 58,
2112         WIMLIB_ERR_SET_SECURITY                       = 59,
2113         WIMLIB_ERR_SET_SHORT_NAME                     = 60,
2114         WIMLIB_ERR_SET_TIMESTAMPS                     = 61,
2115         WIMLIB_ERR_SPLIT_INVALID                      = 62,
2116         WIMLIB_ERR_STAT                               = 63,
2117         WIMLIB_ERR_UNEXPECTED_END_OF_FILE             = 65,
2118         WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE   = 66,
2119         WIMLIB_ERR_UNKNOWN_VERSION                    = 67,
2120         WIMLIB_ERR_UNSUPPORTED                        = 68,
2121         WIMLIB_ERR_UNSUPPORTED_FILE                   = 69,
2122         WIMLIB_ERR_WIM_IS_READONLY                    = 71,
2123         WIMLIB_ERR_WRITE                              = 72,
2124         WIMLIB_ERR_XML                                = 73,
2125         WIMLIB_ERR_WIM_IS_ENCRYPTED                   = 74,
2126         WIMLIB_ERR_WIMBOOT                            = 75,
2127         WIMLIB_ERR_ABORTED_BY_PROGRESS                = 76,
2128         WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS            = 77,
2129         WIMLIB_ERR_MKNOD                              = 78,
2130         WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY              = 79,
2131         WIMLIB_ERR_NOT_A_MOUNTPOINT                   = 80,
2132         WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT           = 81,
2133 };
2134
2135
2136 /** Used to indicate no WIM image or an invalid WIM image. */
2137 #define WIMLIB_NO_IMAGE         0
2138
2139 /** Used to specify all images in the WIM. */
2140 #define WIMLIB_ALL_IMAGES       (-1)
2141
2142 /** @}  */
2143
2144 /**
2145  * @ingroup G_modifying_wims
2146  *
2147  * Appends an empty image to a WIM file.  This empty image will initially
2148  * contain no files or directories, although if written without further
2149  * modifications, a root directory will be created automatically for it.  After
2150  * calling this function, you can use wimlib_update_image() to add files to the
2151  * new WIM image.  This gives you slightly more control over making the new
2152  * image compared to calling wimlib_add_image() or
2153  * wimlib_add_image_multisource() directly.
2154  *
2155  * @param wim
2156  *      Pointer to the ::WIMStruct for the WIM file to which the image is to be
2157  *      added.
2158  * @param name
2159  *      Name to give the new image.  If @c NULL or empty, the new image is given
2160  *      no name.  If nonempty, it must specify a name that does not already
2161  *      exist in @p wim.
2162  * @param new_idx_ret
2163  *      If non-<code>NULL</code>, the index of the newly added image is returned
2164  *      in this location.
2165  *
2166  * @return 0 on success; nonzero on failure.  The possible error codes are:
2167  *
2168  * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2169  *      There is already an image in @p wim named @p name.
2170  * @retval ::WIMLIB_ERR_NOMEM
2171  *      Failed to allocate the memory needed to add the new image.
2172  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2173  *      The WIM file is considered read-only because of any of the reasons
2174  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2175  *      flag.
2176  */
2177 extern int
2178 wimlib_add_empty_image(WIMStruct *wim,
2179                        const wimlib_tchar *name,
2180                        int *new_idx_ret);
2181
2182 /**
2183  * @ingroup G_modifying_wims
2184  *
2185  * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
2186  *
2187  * The directory tree or NTFS volume is scanned immediately to load the dentry
2188  * tree into memory, and file attributes and symbolic links are read.  However,
2189  * actual file data is not read until wimlib_write() or wimlib_overwrite() is
2190  * called.
2191  *
2192  * See the manual page for the @b wimlib-imagex program for more information
2193  * about the "normal" capture mode versus the NTFS capture mode (entered by
2194  * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
2195  *
2196  * Note that @b no changes are committed to the underlying WIM file (if
2197  * any) until wimlib_write() or wimlib_overwrite() is called.
2198  *
2199  * @param wim
2200  *      Pointer to the ::WIMStruct to which to add the image.
2201  * @param source
2202  *      A path to a directory or unmounted NTFS volume that will be captured as
2203  *      a WIM image.
2204  * @param name
2205  *      Name to give the new image.  If @c NULL or empty, the new image is given
2206  *      no name.  If nonempty, it must specify a name that does not already
2207  *      exist in @p wim.
2208  * @param config_file
2209  *      Path to capture configuration file, or @c NULL.  This file may specify,
2210  *      among other things, which files to exclude from capture.  See the man
2211  *      page for <b>wimlib-imagex capture</b> (<b>--config</b> option) for
2212  *      details of the file format.  If @c NULL, the default capture
2213  *      configuration shall be used.  Ordinarily, the default capture
2214  *      configuration will result in no files being excluded from capture purely
2215  *      based on name; however, the ::WIMLIB_ADD_FLAG_WINCONFIG and
2216  *      ::WIMLIB_ADD_FLAG_WIMBOOT flags modify the default.
2217  * @param add_flags
2218  *      Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
2219  *
2220  * @return 0 on success; nonzero on error.  On error, changes to @p wim are
2221  * discarded so that it appears to be in the same state as when this function
2222  * was called.
2223  *
2224  * This function is implemented by calling wimlib_add_empty_image(), then
2225  * calling wimlib_update_image() with a single "add" command, so any error code
2226  * returned by wimlib_add_empty_image() may be returned, as well as any error
2227  * codes returned by wimlib_update_image() other than ones documented as only
2228  * being returned specifically by an update involving delete or rename commands.
2229  *
2230  * If a progress function is registered with @p wim, it will receive the
2231  * messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and ::WIMLIB_PROGRESS_MSG_SCAN_END.
2232  * In addition, if ::WIMLIB_ADD_FLAG_VERBOSE is specified in @p add_flags, it
2233  * will receive ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
2234  */
2235 extern int
2236 wimlib_add_image(WIMStruct *wim,
2237                  const wimlib_tchar *source,
2238                  const wimlib_tchar *name,
2239                  const wimlib_tchar *config_file,
2240                  int add_flags);
2241
2242 /**
2243  * @ingroup G_modifying_wims
2244  *
2245  * This function is equivalent to wimlib_add_image() except it allows for
2246  * multiple sources to be combined into a single WIM image.  This is done by
2247  * specifying the @p sources and @p num_sources parameters instead of the @p
2248  * source parameter of wimlib_add_image().  The rest of the parameters are the
2249  * same as wimlib_add_image().  See the documentation for <b>wimlib-imagex
2250  * capture</b> for full details on how this mode works.
2251  *
2252  * In addition to the error codes that wimlib_add_image() can return,
2253  * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
2254  * when trying to overlay a non-directory on a directory or when otherwise
2255  * trying to overlay multiple conflicting files to the same location in the WIM
2256  * image.  It will also return ::WIMLIB_ERR_INVALID_PARAM if
2257  * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
2258  * was not exactly one capture source with the target being the root directory.
2259  * (In this respect, there is no advantage to using
2260  * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
2261  * NTFS mode.) */
2262 extern int
2263 wimlib_add_image_multisource(WIMStruct *wim,
2264                              const struct wimlib_capture_source *sources,
2265                              size_t num_sources,
2266                              const wimlib_tchar *name,
2267                              const wimlib_tchar *config_file,
2268                              int add_flags);
2269
2270 /**
2271  * @ingroup G_modifying_wims
2272  *
2273  * Add the file or directory tree at @p fs_source_path on the filesystem to the
2274  * location @p wim_target_path within the specified @p image of the @p wim.
2275  *
2276  * This just builds an appropriate ::wimlib_add_command and passes it to
2277  * wimlib_update_image().
2278  */
2279 extern int
2280 wimlib_add_tree(WIMStruct *wim, int image,
2281                 const wimlib_tchar *fs_source_path,
2282                 const wimlib_tchar *wim_target_path, int add_flags);
2283
2284 /**
2285  * @ingroup G_creating_and_opening_wims
2286  *
2287  * Creates a ::WIMStruct for a new WIM file.
2288  *
2289  * This only creates an in-memory structure for a WIM that initially contains no
2290  * images.  No on-disk file is created until wimlib_write() is called.
2291  *
2292  * @param ctype
2293  *      The type of compression to be used in the new WIM file, as one of the
2294  *      ::wimlib_compression_type constants.
2295  * @param wim_ret
2296  *      On success, a pointer to an opaque ::WIMStruct for the new WIM file is
2297  *      written to the memory location pointed to by this parameter.  The
2298  *      ::WIMStruct must be freed using using wimlib_free() when finished with
2299  *      it.
2300  * @return 0 on success; nonzero on error.
2301  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2302  *      @p ctype was not a supported compression type.
2303  * @retval ::WIMLIB_ERR_NOMEM
2304  *      Failed to allocate needed memory.
2305  */
2306 extern int
2307 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
2308
2309 /**
2310  * @ingroup G_modifying_wims
2311  *
2312  * Deletes an image, or all images, from a WIM file.
2313  *
2314  * All streams referenced by the image(s) being deleted are removed from the
2315  * lookup table of the WIM if they are not referenced by any other images in the
2316  * WIM.
2317  *
2318  * Please note that @b no changes are committed to the underlying WIM file (if
2319  * any) until wimlib_write() or wimlib_overwrite() is called.
2320  *
2321  * @param wim
2322  *      Pointer to the ::WIMStruct for the WIM file that contains the image(s)
2323  *      being deleted.
2324  * @param image
2325  *      The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
2326  *      images.
2327  * @return 0 on success; nonzero on failure.  On failure, @p wim is guaranteed
2328  * to be left unmodified only if @p image specified a single image.  If instead
2329  * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
2330  * possible for some but not all of the images to have been deleted when a
2331  * failure status is returned.
2332  *
2333  * @retval ::WIMLIB_ERR_INVALID_IMAGE
2334  *      @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
2335  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2336  *      The WIM file is considered read-only because of any of the reasons
2337  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2338  *      flag.
2339  *
2340  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2341  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2342  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2343  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2344  * different reasons) to read the metadata resource for an image that needed to
2345  * be deleted.
2346  */
2347 extern int
2348 wimlib_delete_image(WIMStruct *wim, int image);
2349
2350 /**
2351  * @ingroup G_modifying_wims
2352  *
2353  * Delete the @p path from the specified @p image of the @p wim.
2354  *
2355  * This just builds an appropriate ::wimlib_delete_command and passes it to
2356  * wimlib_update_image().
2357  */
2358 extern int
2359 wimlib_delete_path(WIMStruct *wim, int image,
2360                    const wimlib_tchar *path, int delete_flags);
2361
2362 /**
2363  * @ingroup G_modifying_wims
2364  *
2365  * Exports an image, or all the images, from a WIM file, into another WIM file.
2366  *
2367  * The destination image is made to share the same dentry tree and security data
2368  * structure as the source image.  This places some restrictions on additional
2369  * functions that may be called.  For example, you may not call wimlib_free() on
2370  * @p src_wim before calling wimlib_write() or wimlib_overwrite() on @p dest_wim
2371  * because @p dest_wim will have references back to @p src_wim.
2372  *
2373  * If this function fails, all changes to @p dest_wim are rolled back.
2374  *
2375  * Please note that no changes are committed to the underlying WIM file of @p
2376  * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
2377  *
2378  * @param src_wim
2379  *      The WIM from which to export the images, specified as a pointer to the
2380  *      ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2381  *      split WIM.  In the case of a WIM file that is not standalone, this
2382  *      ::WIMStruct must have had any needed external resources previously
2383  *      referenced using wimlib_reference_resources() or
2384  *      wimlib_reference_resource_files().
2385  * @param src_image
2386  *      The image to export from @p src_wim, as either a 1-based image index to
2387  *      export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
2388  * @param dest_wim
2389  *      Pointer to the ::WIMStruct for a WIM that will receive the images being
2390  *      exported.
2391  * @param dest_name
2392  *      For single-image exports, the name to give the exported image in @p
2393  *      dest_wim.  If left @c NULL, the name from @p src_wim is used.  For
2394  *      ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
2395  *      that case, the names are all taken from @p src_wim.  This parameter is
2396  *      overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
2397  * @param dest_description
2398  *      For single-image exports, the description to give the exported image in
2399  *      the new WIM file.  If left @c NULL, the description from @p src_wim is
2400  *      used.  For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
2401  *      NULL; in that case, the description are all taken from @p src_wim.  This
2402  *      parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
2403  * @param export_flags
2404  *      Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
2405  *
2406  * @return 0 on success; nonzero on error.
2407  * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2408  *      One or more of the names being given to an exported image was already in
2409  *      use in the destination WIM.
2410  * @retval ::WIMLIB_ERR_INVALID_IMAGE
2411  *      @p src_image does not exist in @p src_wim and was not
2412  *      ::WIMLIB_ALL_IMAGES.
2413  * @retval ::WIMLIB_ERR_INVALID_PARAM
2414  *      @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
2415  *      ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
2416  *      @c NULL.
2417  * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2418  *      Either @p src_wim or @p dest_wim did not contain metadata resources; for
2419  *      example, one of them was a non-first part of a split WIM.
2420  * @retval ::WIMLIB_ERR_NOMEM
2421  *      Failed to allocate needed memory.
2422  * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2423  *      A resource that needed to be exported could not be found in either the
2424  *      source or destination WIMs.  This error can occur if, for example, @p
2425  *      src_wim is part of a split WIM but needed resources from the other split
2426  *      WIM parts were not referenced with wimlib_reference_resources() or
2427  *      wimlib_reference_resource_files() before the call to
2428  *      wimlib_export_image().
2429  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2430  *      @p dest_wim is considered read-only because of any of the reasons
2431  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2432  *      flag.
2433  *
2434  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2435  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2436  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2437  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2438  * different reasons) to read the metadata resource for an image in @p src_wim
2439  * that needed to be exported.
2440  */
2441 extern int
2442 wimlib_export_image(WIMStruct *src_wim, int src_image,
2443                     WIMStruct *dest_wim,
2444                     const wimlib_tchar *dest_name,
2445                     const wimlib_tchar *dest_description,
2446                     int export_flags);
2447
2448 /**
2449  * @ingroup G_extracting_wims
2450  *
2451  * Extracts an image, or all images, from a WIM to a directory or NTFS volume
2452  * image.
2453  *
2454  * The exact behavior of how wimlib extracts files from a WIM image is
2455  * controllable by the @p extract_flags parameter, but there also are
2456  * differences depending on the platform (UNIX-like vs Windows).  See the manual
2457  * page for <b>wimlib-imagex apply</b> for more information, including about the
2458  * special "NTFS volume extraction mode" entered by providing
2459  * ::WIMLIB_EXTRACT_FLAG_NTFS.
2460  *
2461  * @param wim
2462  *      The WIM from which to extract the image(s), specified as a pointer to
2463  *      the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2464  *      of a split WIM.  In the case of a WIM file that is not standalone, this
2465  *      ::WIMStruct must have had any needed external resources previously
2466  *      referenced using wimlib_reference_resources() or
2467  *      wimlib_reference_resource_files().
2468  * @param image
2469  *      The image to extract, specified as either the 1-based index of a single
2470  *      image to extract, or ::WIMLIB_ALL_IMAGES to specify that all images are
2471  *      to be extracted.  ::WIMLIB_ALL_IMAGES cannot be used if
2472  *      ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2473  * @param target
2474  *      Directory to extract the WIM image(s) to; or, with
2475  *      ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to
2476  *      the unmounted NTFS volume to which to extract the image.
2477  * @param extract_flags
2478  *      Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2479  *
2480  * @return 0 on success; nonzero on error.
2481  * @retval ::WIMLIB_ERR_DECOMPRESSION
2482  *      Failed to decompress data contained in the WIM.
2483  * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2484  *      The metadata for one of the images to extract was invalid.
2485  * @retval ::WIMLIB_ERR_INVALID_PARAM
2486  *      The extraction flags were invalid; more details may be found in the
2487  *      documentation for the specific extraction flags that were specified.  Or
2488  *      @p target was @c NULL or the empty string, or @p wim was @c NULL.
2489  * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2490  *      The SHA1 message digest of an extracted stream did not match the SHA1
2491  *      message digest given in the WIM.
2492  * @retval ::WIMLIB_ERR_LINK
2493  *      Failed to create a symbolic link or a hard link.
2494  * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2495  *      The metadata resource for one of the images to extract was not found.
2496  *      This can happen if @p wim represents a non-first part of a split WIM.
2497  * @retval ::WIMLIB_ERR_MKDIR
2498  *      Failed create a directory.
2499  * @retval ::WIMLIB_ERR_NOMEM
2500  *      Failed to allocate needed memory.
2501  * @retval ::WIMLIB_ERR_OPEN
2502  *      Could not create a file, or failed to open an already-extracted file.
2503  * @retval ::WIMLIB_ERR_READ
2504  *      Failed to read data from the WIM.
2505  * @retval ::WIMLIB_ERR_READLINK
2506  *      Failed to determine the target of a symbolic link in the WIM.
2507  * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2508  *      Failed to fix the target of an absolute symbolic link (e.g. if the
2509  *      target would have exceeded the maximum allowed length).  (Only if
2510  *      reparse data was supported by the extraction mode and
2511  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p
2512  *      extract_flags.)
2513  * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2514  *      One of the files or directories that needed to be extracted referenced a
2515  *      stream not present in the WIM's lookup table (or in any of the lookup
2516  *      tables of the split WIM parts).
2517  * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2518  *      Failed to set attributes on a file.
2519  * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2520  *      Failed to set reparse data on a file (only if reparse data was supported
2521  *      by the extraction mode).
2522  * @retval ::WIMLIB_ERR_SET_SECURITY
2523  *      Failed to set security descriptor on a file
2524  *      (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2525  *      extract_flags).
2526  * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2527  *      Failed to set the short name of a file (only if
2528  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2529  * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2530  *      Failed to set timestamps on a file (only if
2531  *      ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2532  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2533  *      Unexpected end-of-file occurred when reading data from the WIM.
2534  * @retval ::WIMLIB_ERR_UNSUPPORTED
2535  *      A requested extraction flag, or the data or metadata that must be
2536  *      extracted to support it, is unsupported in the build and configuration
2537  *      of wimlib, or on the current platform or extraction mode or target
2538  *      volume.  Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2539  *      ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2540  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2541  *      ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS, and
2542  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS.  For example, if
2543  *      ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2544  *      extract_flags, ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM
2545  *      image contains one or more files with short names, but extracting short
2546  *      names is not supported --- on Windows, this occurs if the target volume
2547  *      does not support short names, while on non-Windows, this occurs if
2548  *      ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2549  * @retval ::WIMLIB_ERR_WIMBOOT
2550  *      ::WIMLIB_EXTRACT_FLAG_WIMBOOT was specified in @p extract_flags, but
2551  *      there was a problem creating WIMBoot pointer files.
2552  * @retval ::WIMLIB_ERR_WRITE
2553  *      Failed to write data to a file being extracted.
2554  *
2555  * If a progress function is registered with @p wim, then as each image is
2556  * extracted it will receive ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN, then
2557  * zero or more ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS messages, then
2558  * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END.
2559  */
2560 extern int
2561 wimlib_extract_image(WIMStruct *wim, int image,
2562                      const wimlib_tchar *target, int extract_flags);
2563
2564 /**
2565  * @ingroup G_extracting_wims
2566  *
2567  * Since wimlib v1.5.0:  Extract one image from a pipe on which a pipable WIM is
2568  * being sent.
2569  *
2570  * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2571  * about pipable WIMs.
2572  *
2573  * This function operates in a special way to read the WIM fully sequentially.
2574  * As a result, there is no ::WIMStruct is made visible to library users, and
2575  * you cannot call wimlib_open_wim() on the pipe.  (You can, however, use
2576  * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2577  * seekable file, not a pipe.)
2578  *
2579  * @param pipe_fd
2580  *      File descriptor, which may be a pipe, opened for reading and positioned
2581  *      at the start of the pipable WIM.
2582  * @param image_num_or_name
2583  *      String that specifies the 1-based index or name of the image to extract.
2584  *      It is translated to an image index using the same rules that
2585  *      wimlib_resolve_image() uses.  However, unlike wimlib_extract_image(),
2586  *      only a single image (not all images) can be specified.  Alternatively,
2587  *      specify @p NULL here to use the first image in the WIM if it contains
2588  *      exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2589  * @param target
2590  *      Same as the corresponding parameter to wimlib_extract_image().
2591  * @param extract_flags
2592  *      Same as the corresponding parameter to wimlib_extract_image().
2593  *
2594  * @return 0 on success; nonzero on error.  The possible error codes include
2595  * those returned by wimlib_extract_image() and wimlib_open_wim() as well as the
2596  * following:
2597  *
2598  * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2599  *      Data read from the pipable WIM was invalid.
2600  * @retval ::WIMLIB_ERR_NOT_PIPABLE
2601  *      The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2602  */
2603 extern int
2604 wimlib_extract_image_from_pipe(int pipe_fd,
2605                                const wimlib_tchar *image_num_or_name,
2606                                const wimlib_tchar *target, int extract_flags);
2607
2608 /*
2609  * @ingroup G_extracting_wims
2610  *
2611  * Same as wimlib_extract_image_from_pipe(), but allows specifying a progress
2612  * function.  The progress function will be used while extracting the WIM image
2613  * and will receive the normal extraction progress messages, such as
2614  * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, in addition to
2615  * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.
2616  */
2617 extern int
2618 wimlib_extract_image_from_pipe_with_progress(int pipe_fd,
2619                                              const wimlib_tchar *image_num_or_name,
2620                                              const wimlib_tchar *target,
2621                                              int extract_flags,
2622                                              wimlib_progress_func_t progfunc,
2623                                              void *progctx);
2624
2625 /**
2626  * @ingroup G_extracting_wims
2627  *
2628  * Since wimlib v1.6.0:  Similar to wimlib_extract_paths(), but the paths to
2629  * extract from the WIM image are specified in the ASCII, UTF-8, or UTF-16LE
2630  * text file named by @p path_list_file which itself contains the list of paths
2631  * to use, one per line.  Leading and trailing whitespace, and otherwise empty
2632  * lines and lines beginning with the ';' character are ignored.  No quotes are
2633  * needed as paths are otherwise delimited by the newline character.
2634  *
2635  * The error codes are the same as those returned by wimlib_extract_paths(),
2636  * except that wimlib_extract_pathlist() returns an appropriate error code if it
2637  * cannot read the path list file (e.g. ::WIMLIB_ERR_OPEN, ::WIMLIB_ERR_STAT,
2638  * ::WIMLIB_ERR_READ).
2639  */
2640 extern int
2641 wimlib_extract_pathlist(WIMStruct *wim, int image,
2642                         const wimlib_tchar *target,
2643                         const wimlib_tchar *path_list_file,
2644                         int extract_flags);
2645
2646 /**
2647  * @ingroup G_extracting_wims
2648  *
2649  * Since wimlib v1.6.0:  Extract zero or more paths (files or directory trees)
2650  * from the specified WIM image.
2651  *
2652  * By default, each path will be extracted to a corresponding subdirectory of
2653  * the target based on its location in the WIM image.  For example, if one of
2654  * the paths to extract is "/Windows/explorer.exe" and the target is "outdir",
2655  * the file will be extracted to "outdir/Windows/explorer.exe".  This behavior
2656  * can be changed by providing the flag
2657  * ::WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE, which will cause each file
2658  * or directory tree to be placed directly in the target directory --- so the
2659  * same example would extract "/Windows/explorer.exe" to "outdir/explorer.exe".
2660  *
2661  * Symbolic links will not be dereferenced when paths in the WIM image are
2662  * interpreted.
2663  *
2664  * @param wim
2665  *      WIM from which to extract the paths, specified as a pointer to the
2666  *      ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
2667  *      split WIM.  In the case of a WIM file that is not standalone, this
2668  *      ::WIMStruct must have had any needed external resources previously
2669  *      referenced using wimlib_reference_resources() or
2670  *      wimlib_reference_resource_files().
2671  * @param image
2672  *      1-based index of the WIM image from which to extract the paths.
2673  * @param paths
2674  *      Array of paths to extract.  Each element must be the absolute path to a
2675  *      file or directory within the WIM image.  Separators may be either
2676  *      forwards or backwards slashes, and leading path separators are optional.
2677  *      The paths will be interpreted either case-sensitively (UNIX default) or
2678  *      case-insensitively (Windows default); this can be changed by
2679  *      wimlib_global_init().
2680  *      <br/>
2681  *      By default, the characters @c * and @c ? are interpreted literally.
2682  *      This can be changed by specifying ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS in @p
2683  *      extract_flags.
2684  *      <br/>
2685  *      By default, if any paths to extract do not exist, the error code
2686  *      ::WIMLIB_ERR_PATH_DOES_NOT_EXIST is returned.  This behavior changes if
2687  *      ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS is specified in @p extract_flags.
2688  * @param num_paths
2689  *      Number of paths specified in @p paths.
2690  * @param target
2691  *      Directory to which to extract the paths; or with
2692  *      ::WIMLIB_EXTRACT_FLAG_NTFS specified in @p extract_flags, the path to an
2693  *      unmounted NTFS volume to which to extract the paths.  Unlike the @p
2694  *      paths being extracted, the @p target must be native path.  On UNIX-like
2695  *      systems it may not contain backslashes, for example.
2696  * @param extract_flags
2697  *      Bitwise OR of flags prefixed with WIMLIB_EXTRACT_FLAG.
2698  *
2699  * @return 0 on success; nonzero on error.  Most of the error codes are the same
2700  * as those returned by wimlib_extract_image().  Below, some of the error codes
2701  * returned in situations specific to path-mode extraction are documented:
2702  *
2703  * @retval ::WIMLIB_ERR_INVALID_IMAGE
2704  *      @p image was ::WIMLIB_ALL_IMAGES or was otherwise not a valid single
2705  *      image in the WIM.
2706  * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2707  *      One of the paths to extract did not exist in the WIM image.  This error
2708  *      code can only be returned if ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS was not
2709  *      specified in @p extract_flags, or if both
2710  *      ::WIMLIB_EXTRACT_FLAG_GLOB_PATHS and ::WIMLIB_EXTRACT_FLAG_STRICT_GLOB
2711  *      were specified in @p extract_flags.
2712  * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
2713  *      ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified in @p extract_flags, but
2714  *      one of the paths to extract did not name a regular file.
2715  *
2716  * If a progress function is registered with @p wim, it will receive
2717  * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS.  Note that because the extraction code
2718  * is stream-based and not file-based, there is no way to get information about
2719  * which path is currently being extracted, but based on byte count you can
2720  * still calculate an approximate percentage complete for the extraction overall
2721  * which may be all you really need anyway.
2722  */
2723 extern int
2724 wimlib_extract_paths(WIMStruct *wim,
2725                      int image,
2726                      const wimlib_tchar *target,
2727                      const wimlib_tchar * const *paths,
2728                      size_t num_paths,
2729                      int extract_flags);
2730
2731 /**
2732  * @ingroup G_wim_information
2733  *
2734  * Extracts the XML data of a WIM file to a file stream.  Every WIM file
2735  * includes a string of XML that describes the images contained in the WIM.
2736  *
2737  * See wimlib_get_xml_data() to read the XML data into memory instead.
2738  *
2739  * @param wim
2740  *      Pointer to the ::WIMStruct to query.  This need not represent a
2741  *      standalone WIM (e.g. it could represent part of a split WIM).
2742  * @param fp
2743  *      @c stdout, or a FILE* opened for writing, to extract the data to.
2744  *
2745  * @return 0 on success; nonzero on error.
2746  * @retval ::WIMLIB_ERR_INVALID_PARAM
2747  *      @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2748  * @retval ::WIMLIB_ERR_NOMEM
2749  *      Failed to allocate needed memory.
2750  * @retval ::WIMLIB_ERR_READ
2751  *      Error reading the XML data from the WIM file.
2752  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2753  *      Error reading the XML data from the WIM file.
2754  * @retval ::WIMLIB_ERR_WRITE
2755  *      Failed to completely write the XML data to @p fp.
2756  */
2757 extern int
2758 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2759
2760 /**
2761  * @ingroup G_general
2762  *
2763  * Frees all memory allocated for a WIMStruct and closes all files associated
2764  * with it.
2765  *
2766  * @param wim
2767  *      Pointer to the ::WIMStruct to free.
2768  *
2769  * @return This function has no return value.
2770  */
2771 extern void
2772 wimlib_free(WIMStruct *wim);
2773
2774 /**
2775  * @ingroup G_general
2776  *
2777  * Converts a ::wimlib_compression_type value into a string.
2778  *
2779  * @param ctype
2780  *      The ::wimlib_compression_type value to convert.
2781  *
2782  * @return
2783  *      A statically allocated string naming the compression algorithm,
2784  *      such as "None", "LZX", "XPRESS", or "Invalid".
2785  */
2786 extern const wimlib_tchar *
2787 wimlib_get_compression_type_string(int ctype);
2788
2789 /**
2790  * @ingroup G_general
2791  *
2792  * Converts an error code into a string describing it.
2793  *
2794  * @param code
2795  *      The error code returned by one of wimlib's functions.
2796  *
2797  * @return
2798  *      Pointer to a statically allocated string describing the error code,
2799  *      or @c NULL if the error code is not valid.
2800  */
2801 extern const wimlib_tchar *
2802 wimlib_get_error_string(enum wimlib_error_code code);
2803
2804 /**
2805  * @ingroup G_wim_information
2806  *
2807  * Returns the description of the specified image.
2808  *
2809  * @param wim
2810  *      Pointer to the ::WIMStruct to query.  This need not represent a
2811  *      standalone WIM (e.g. it could represent part of a split WIM).
2812  * @param image
2813  *      The number of the image, numbered starting at 1.
2814  *
2815  * @return
2816  *      The description of the image, or @c NULL if there is no such image, or
2817  *      @c NULL if the specified image has no description.  The description
2818  *      string is in library-internal memory and may not be modified or freed;
2819  *      in addition, the string will become invalid if the description of the
2820  *      image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2821  */
2822 extern const wimlib_tchar *
2823 wimlib_get_image_description(const WIMStruct *wim, int image);
2824
2825 /**
2826  * @ingroup G_wim_information
2827  *
2828  * Returns the name of the specified image.
2829  *
2830  * @param wim
2831  *      Pointer to the ::WIMStruct to query.  This need not represent a
2832  *      standalone WIM (e.g. it could represent part of a split WIM).
2833  * @param image
2834  *      The number of the image, numbered starting at 1.
2835  *
2836  * @return
2837  *      The name of the image, or @c NULL if there is no such image, or an empty
2838  *      string if the image is unnamed.  The name string is in
2839  *      library-internal memory and may not be modified or freed; in addition,
2840  *      the string will become invalid if the name of the image is changed, the
2841  *      image is deleted, or the ::WIMStruct is destroyed.
2842  */
2843 extern const wimlib_tchar *
2844 wimlib_get_image_name(const WIMStruct *wim, int image);
2845
2846 /**
2847  * @ingroup G_general
2848  *
2849  * Returns the version of wimlib as a 32-bit number whose top 12 bits contain
2850  * the major version, the next 10 bits contain the minor version, and the low 10
2851  * bits contain the patch version.
2852  *
2853  * In other words, the returned value is equal to <code>((WIMLIB_MAJOR_VERSION
2854  * << 22) | (WIMLIB_MINOR_VERSION << 10) | WIMLIB_PATCH_VERSION)</code> for the
2855  * corresponding header file.
2856  */
2857 extern uint32_t
2858 wimlib_get_version(void);
2859
2860 /**
2861  * @ingroup G_wim_information
2862  *
2863  * Get basic information about a WIM file.
2864  *
2865  * @param wim
2866  *      Pointer to the ::WIMStruct to query.  This need not represent a
2867  *      standalone WIM (e.g. it could represent part of a split WIM).
2868  * @param info
2869  *      A ::wimlib_wim_info structure that will be filled in with information
2870  *      about the WIM file.
2871  * @return
2872  *      0
2873  */
2874 extern int
2875 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2876
2877 /**
2878  * @ingroup G_wim_information
2879  *
2880  * Read the XML data of a WIM file into an in-memory buffer.  Every WIM file
2881  * includes a string of XML that describes the images contained in the WIM.
2882  *
2883  * See wimlib_extract_xml_data() to extract the XML data to a file stream
2884  * instead.
2885  *
2886  * @param wim
2887  *      Pointer to the ::WIMStruct to query.  This need not represent a
2888  *      standalone WIM (e.g. it could represent part of a split WIM).
2889  * @param buf_ret
2890  *      On success, a pointer to an allocated buffer containing the raw UTF16-LE
2891  *      XML data is written to this location.
2892  * @param bufsize_ret
2893  *      The size of the XML data in bytes is written to this location.
2894  *
2895  * @return 0 on success; nonzero on error.
2896  * @retval ::WIMLIB_ERR_INVALID_PARAM
2897  *      @p wim is not a ::WIMStruct that was created by wimlib_open_wim(), or
2898  *      @p buf_ret or @p bufsize_ret was @c NULL.
2899  * @retval ::WIMLIB_ERR_NOMEM
2900  * @retval ::WIMLIB_ERR_READ
2901  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2902  *      Failed to read the XML data from the WIM.
2903  */
2904 extern int
2905 wimlib_get_xml_data(WIMStruct *wim, void **buf_ret, size_t *bufsize_ret);
2906
2907 /**
2908  * @ingroup G_general
2909  *
2910  * Initialization function for wimlib.  Call before using any other wimlib
2911  * function except wimlib_set_print_errors().  If not done manually, this
2912  * function will be called automatically with @p init_flags set to
2913  * ::WIMLIB_INIT_FLAG_ASSUME_UTF8.  This function does nothing if called again
2914  * after it has already successfully run.
2915  *
2916  * @param init_flags
2917  *      Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2918  *
2919  * @return 0 on success; nonzero on failure.  Currently, only the following
2920  * error code is defined:
2921  *
2922  * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2923  *      ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2924  *      ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2925  *      init_flags, but the corresponding privileges could not be acquired.
2926  */
2927 extern int
2928 wimlib_global_init(int init_flags);
2929
2930 /**
2931  * @ingroup G_general
2932  *
2933  * Cleanup function for wimlib.  You are not required to call this function, but
2934  * it will release any global resources allocated by the library.
2935  */
2936 extern void
2937 wimlib_global_cleanup(void);
2938
2939 /**
2940  * @ingroup G_wim_information
2941  *
2942  * Determines if an image name is already used by some image in the WIM.
2943  *
2944  * @param wim
2945  *      Pointer to the ::WIMStruct to query.  This need not represent a
2946  *      standalone WIM (e.g. it could represent part of a split WIM).
2947  * @param name
2948  *      The name to check.
2949  *
2950  * @return
2951  *      @c true if there is already an image in @p wim named @p name; @c false
2952  *      if there is no image named @p name in @p wim.  If @p name is @c NULL or
2953  *      the empty string, @c false is returned.
2954  */
2955 extern bool
2956 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2957
2958 /**
2959  * @ingroup G_wim_information
2960  *
2961  * Iterate through a file or directory tree in the WIM image.  By specifying
2962  * appropriate flags and a callback function, you can get the attributes of a
2963  * file in the WIM, get a directory listing, or even get a listing of the entire
2964  * WIM image.
2965  *
2966  * @param wim
2967  *      The WIM containing the image(s) over which to iterate, specified as a
2968  *      pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2969  *      or part 1 of a split WIM.  In the case of a WIM file that is not
2970  *      standalone, this ::WIMStruct should have had any needed external
2971  *      resources previously referenced using wimlib_reference_resources() or
2972  *      wimlib_reference_resource_files().  If not, see
2973  *      ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2974  *      the behavior when resources are missing.
2975  *
2976  * @param image
2977  *      The 1-based number of the image in @p wim that contains the files or
2978  *      directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2979  *      iteration on all images in the WIM.
2980  *
2981  * @param path
2982  *      Path in the WIM image at which to do the iteration.
2983  *
2984  * @param flags
2985  *      Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2986  *
2987  * @param cb
2988  *      A callback function that will receive each directory entry.
2989  *
2990  * @param user_ctx
2991  *      An extra parameter that will always be passed to the callback function
2992  *      @p cb.
2993  *
2994  * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2995  * first nonzero value that was returned from @p cb.  However, additional error
2996  * codes may be returned, including the following:
2997  *
2998  * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2999  *      @p path did not exist in the WIM image.
3000  * @retval ::WIMLIB_ERR_NOMEM
3001  *      Failed to allocate memory needed to create a ::wimlib_dir_entry.
3002  *
3003  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3004  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3005  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3006  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3007  * different reasons) to read the metadata resource for an image over which
3008  * iteration needed to be done.
3009  */
3010 extern int
3011 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
3012                         int flags,
3013                         wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
3014
3015 /**
3016  * @ingroup G_wim_information
3017  *
3018  * Iterate through the lookup table of a WIM file.  This can be used to directly
3019  * get a listing of the unique resources contained in a WIM file over all
3020  * images.  Both file resources and metadata resources are included.  However,
3021  * only resources actually included in the file represented by @a wim, plus
3022  * explicitly referenced external resources (via wimlib_reference_resources() or
3023  * wimlib_reference_resource_files()) are included in the iteration.  For
3024  * example, if @p wim represents just one part of a split WIM, then only
3025  * resources in that part will be included, unless other resources were
3026  * explicitly referenced.
3027  *
3028  * @param wim
3029  *      Pointer to the ::WIMStruct to query.  This need not represent a
3030  *      standalone WIM (e.g. it could represent part of a split WIM).
3031  *
3032  * @param flags
3033  *      Reserved; set to 0.
3034  *
3035  * @param cb
3036  *      A callback function that will receive each resource.
3037  *
3038  * @param user_ctx
3039  *      An extra parameter that will always be passed to the callback function
3040  *      @p cb.
3041  *
3042  * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
3043  * that was returned from @p cb.
3044  */
3045 extern int
3046 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
3047                             wimlib_iterate_lookup_table_callback_t cb,
3048                             void *user_ctx);
3049
3050 /**
3051  * @ingroup G_nonstandalone_wims
3052  *
3053  * Joins a split WIM into a stand-alone one-part WIM.
3054  *
3055  * @param swms
3056  *      An array of strings that gives the filenames of all parts of the split
3057  *      WIM.  No specific order is required, but all parts must be included with
3058  *      no duplicates.
3059  * @param num_swms
3060  *      Number of filenames in @p swms.
3061  * @param swm_open_flags
3062  *      Open flags for the split WIM parts (e.g.
3063  *      ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
3064  * @param wim_write_flags
3065  *      Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
3066  *      be used to write the joined WIM.
3067  * @param output_path
3068  *      The path to write the joined WIM file to.
3069  *
3070  * @return 0 on success; nonzero on error.  This function may return most error
3071  * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
3072  * as the following error code:
3073  *
3074  * @retval ::WIMLIB_ERR_SPLIT_INVALID
3075  *      The split WIMs do not form a valid WIM because they do not include all
3076  *      the parts of the original WIM, there are duplicate parts, or not all the
3077  *      parts have the same GUID and compression type.
3078  *
3079  * Note: wimlib is generalized enough that this function is not actually needed
3080  * to join a split WIM; instead, you could open the first part of the split WIM,
3081  * then reference the other parts with wimlib_reference_resource_files(), then
3082  * write the joined WIM using wimlib_write().  However, wimlib_join() provides
3083  * an easy-to-use wrapper around this that has some advantages (e.g.  extra
3084  * sanity checks).
3085  */
3086 extern int
3087 wimlib_join(const wimlib_tchar * const *swms,
3088             unsigned num_swms,
3089             const wimlib_tchar *output_path,
3090             int swm_open_flags,
3091             int wim_write_flags);
3092
3093 /**
3094  * @ingroup G_nonstandalone_wims
3095  *
3096  * Same as wimlib_join(), but allows specifying a progress function.  The
3097  * progress function will receive the write progress messages, such as
3098  * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS, while writing the joined WIM.  In
3099  * addition, if ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p
3100  * swm_open_flags, the progress function will receive a series of
3101  * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY messages when each of the split WIM
3102  * parts is opened.
3103  */
3104 extern int
3105 wimlib_join_with_progress(const wimlib_tchar * const *swms,
3106                           unsigned num_swms,
3107                           const wimlib_tchar *output_path,
3108                           int swm_open_flags,
3109                           int wim_write_flags,
3110                           wimlib_progress_func_t progfunc,
3111                           void *progctx);
3112
3113
3114 /**
3115  * @ingroup G_mounting_wim_images
3116  *
3117  * Mounts an image from a WIM file on a directory read-only or read-write.
3118  *
3119  * @param wim
3120  *      Pointer to the ::WIMStruct containing the image to be mounted.
3121  * @param image
3122  *      The 1-based index of the image to mount.
3123  * @param dir
3124  *      The path to an existing empty directory on which to mount the WIM image.
3125  * @param mount_flags
3126  *      Bitwise OR of flags prefixed with WIMLIB_MOUNT_FLAG.  Use
3127  *      ::WIMLIB_MOUNT_FLAG_READWRITE to request a read-write mount instead of a
3128  *      read-only mount.
3129  * @param staging_dir
3130  *      If non-NULL, the name of a directory in which a temporary directory for
3131  *      storing modified or added files will be created.  Ignored if
3132  *      ::WIMLIB_MOUNT_FLAG_READWRITE is not specified in @p mount_flags.  If
3133  *      left @c NULL, the staging directory is created in the same directory as
3134  *      the WIM file that @p wim was originally read from.  The staging
3135  *      directory is deleted when the image is unmounted.
3136  *
3137  * @return 0 on success; nonzero on error.  The possible error codes include:
3138  *
3139  * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3140  *      An image from the WIM file is already mounted read-write, or another
3141  *      process is currently appending data to the WIM file.
3142  * @retval ::WIMLIB_ERR_FUSE
3143  *      A non-zero status code was returned by @c fuse_main().
3144  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3145  *      @p image does not specify an existing, single image in @p wim.
3146  * @retval ::WIMLIB_ERR_INVALID_PARAM
3147  *      @p wim was @c NULL; or @p dir was NULL or the empty string; or an
3148  *      unrecognized flag was specified in @p mount_flags; or the WIM image has
3149  *      already been modified in memory (e.g. by wimlib_update_image()).
3150  * @retval ::WIMLIB_ERR_MKDIR
3151  *      ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3152  *      staging directory could not be created.
3153  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3154  *      ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
3155  *      WIM file is considered read-only because of any of the reasons mentioned
3156  *      in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3157  * @retval ::WIMLIB_ERR_UNSUPPORTED
3158  *      Mounting is not supported, either because the platform is Windows, or
3159  *      because the platform is UNIX-like and wimlib was compiled using
3160  *      <code>--without-fuse</code>.
3161  *
3162  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3163  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3164  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3165  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3166  * different reasons) to read the metadata resource for the image to mount.
3167  *
3168  * The ability to mount WIM image is implemented using FUSE (Filesystem in
3169  * UserSpacE).  Depending on how FUSE is set up on your system, this function
3170  * may work as normal users in addition to the root user.
3171  *
3172  * Mounting WIM images is not supported if wimlib was configured
3173  * <code>--without-fuse</code>.  This includes Windows builds of wimlib;
3174  * ::WIMLIB_ERR_UNSUPPORTED will be returned in such cases.
3175  *
3176  * Calling this function daemonizes the process, unless
3177  * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early error occurs.
3178  *
3179  * It is safe to mount multiple images from the same underlying WIM file
3180  * read-only at the same time, but only if different ::WIMStruct's are used.  It
3181  * is @b not safe to mount multiple images from the same WIM file read-write at
3182  * the same time.
3183  *
3184  * To unmount the image, call wimlib_unmount_image().  This may be done in a
3185  * different process.
3186  */
3187 extern int
3188 wimlib_mount_image(WIMStruct *wim,
3189                    int image,
3190                    const wimlib_tchar *dir,
3191                    int mount_flags,
3192                    const wimlib_tchar *staging_dir);
3193
3194 /**
3195  * @ingroup G_creating_and_opening_wims
3196  *
3197  * Opens a WIM file and creates a ::WIMStruct for it.
3198  *
3199  * @param wim_file
3200  *      The path to the WIM file to open.
3201  *
3202  * @param open_flags
3203  *      Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
3204  *
3205  * @param wim_ret
3206  *      On success, a pointer to an opaque ::WIMStruct for the opened WIM file
3207  *      is written to the memory location pointed to by this parameter.  The
3208  *      ::WIMStruct must be freed using using wimlib_free() when finished with
3209  *      it.
3210  *
3211  * @return 0 on success; nonzero on error.
3212  * @retval ::WIMLIB_ERR_IMAGE_COUNT
3213  *      The number of metadata resources found in the WIM did not match the
3214  *      image count specified in the WIM header, or the number of &lt;IMAGE&gt;
3215  *      elements in the XML data of the WIM did not match the image count
3216  *      specified in the WIM header.
3217  * @retval ::WIMLIB_ERR_INTEGRITY
3218  *      ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3219  *      the WIM contained an integrity table, but the SHA1 message digest for a
3220  *      chunk of the WIM did not match the corresponding value in the integrity
3221  *      table.
3222  * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3223  *      The library did not recognize the compression chunk size of the WIM as
3224  *      valid for its compression type.
3225  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3226  *      The library did not recognize the compression type of the WIM.
3227  * @retval ::WIMLIB_ERR_INVALID_HEADER
3228  *      The header of the WIM was otherwise invalid.
3229  * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
3230  *      ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and
3231  *      the WIM contained an integrity table, but the integrity table was
3232  *      invalid.
3233  * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
3234  *      The lookup table of the WIM was invalid.
3235  * @retval ::WIMLIB_ERR_INVALID_PARAM
3236  *      @p wim_ret was @c NULL.
3237  * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
3238  *      The WIM was a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
3239  *      specified in @p open_flags.
3240  * @retval ::WIMLIB_ERR_NOMEM
3241  *      Failed to allocated needed memory.
3242  * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
3243  *      The file did not begin with the magic characters that identify a WIM
3244  *      file.
3245  * @retval ::WIMLIB_ERR_OPEN
3246  *      Failed to open the file for reading.
3247  * @retval ::WIMLIB_ERR_READ
3248  *      Failed to read data from the file.
3249  * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
3250  *      Unexpected end-of-file while reading data from the file.
3251  * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
3252  *      The WIM version number was not recognized. (May be a pre-Vista WIM.)
3253  * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
3254  *      The WIM cannot be opened because it contains encrypted segments.  (It
3255  *      may be a Windows 8 "ESD" file.)
3256  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3257  *      ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
3258  *      considered read-only because of any of the reasons mentioned in the
3259  *      documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3260  * @retval ::WIMLIB_ERR_XML
3261  *      The XML data of the WIM was invalid.
3262  */
3263 extern int
3264 wimlib_open_wim(const wimlib_tchar *wim_file,
3265                 int open_flags,
3266                 WIMStruct **wim_ret);
3267
3268 /**
3269  * @ingroup G_creating_and_opening_wims
3270  *
3271  * Same as wimlib_open_wim(), but allows specifying a progress function and
3272  * progress context.  If successful, the progress function will be registered in
3273  * the newly open ::WIMStruct, as if by an automatic call to
3274  * wimlib_register_progress_function().  In addition, if
3275  * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, the
3276  * progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
3277  * messages while checking the WIM's integrity.
3278  */
3279 extern int
3280 wimlib_open_wim_with_progress(const wimlib_tchar *wim_file,
3281                               int open_flags,
3282                               WIMStruct **wim_ret,
3283                               wimlib_progress_func_t progfunc,
3284                               void *progctx);
3285
3286 /**
3287  * @ingroup G_writing_and_overwriting_wims
3288  *
3289  * Overwrites the file that the WIM was originally read from, with changes made.
3290  * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
3291  * rather than wimlib_create_new_wim().
3292  *
3293  * There are two ways that a WIM may be overwritten.  The first is to do a full
3294  * rebuild.  In this mode, the new WIM is written to a temporary file and then
3295  * renamed to the original file after it is has been completely written.  The
3296  * temporary file is made in the same directory as the original WIM file.  A
3297  * full rebuild may take a while, but it will save space by producing a WIM with
3298  * no "holes".
3299  *
3300  * The second way to overwrite a WIM is by appending to the end of it and
3301  * overwriting the header.  This can be much faster than a full rebuild, but the
3302  * disadvantage is that some space will be wasted.  Writing a WIM in this mode
3303  * begins with writing any new file resources *after* everything in the old WIM,
3304  * even though this will leave a hole where the old lookup table, XML data, and
3305  * integrity were.  This is done so that the WIM remains valid even if the
3306  * operation is aborted mid-write.  The WIM header is only overwritten at the
3307  * very last moment, and up until that point the WIM will be seen as the old
3308  * version.
3309  *
3310  * By default, wimlib_overwrite() does the append-style overwrite described
3311  * above, unless resources in the WIM are arranged in an unusual way or if
3312  * images have been deleted from the WIM.  Use the flag
3313  * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
3314  * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
3315  * images have been deleted from the WIM.
3316  *
3317  * If this function completes successfully, no more functions should be called
3318  * on @p wim other than wimlib_free().  You must use wimlib_open_wim() to read
3319  * the WIM file anew.
3320  *
3321  * @param wim
3322  *      Pointer to the ::WIMStruct for the WIM file to write.  There may have
3323  *      been in-memory changes made to it, which are then reflected in the
3324  *      output file.
3325  * @param write_flags
3326  *      Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
3327  * @param num_threads
3328  *      Number of threads to use for compression (see wimlib_write()).
3329  *
3330  * @return 0 on success; nonzero on error.  This function may return most error
3331  * codes returned by wimlib_write() as well as the following error codes:
3332  *
3333  * @retval ::WIMLIB_ERR_ALREADY_LOCKED
3334  *      The WIM was going to be modified in-place (with no temporary file), but
3335  *      an exclusive advisory lock on the on-disk WIM file could not be acquired
3336  *      because another thread or process has mounted an image from the WIM
3337  *      read-write or is currently modifying the WIM in-place.
3338  * @retval ::WIMLIB_ERR_NO_FILENAME
3339  *      @p wim corresponds to a ::WIMStruct created with wimlib_create_new_wim()
3340  *      rather than a WIM read with wimlib_open_wim().
3341  * @retval ::WIMLIB_ERR_RENAME
3342  *      The temporary file that the WIM was written to could not be renamed to
3343  *      the original filename of @p wim.
3344  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3345  *      The WIM file is considered read-only because of any of the reasons
3346  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3347  *      flag.
3348  *
3349  * If a progress function is registered with @p wim, it will receive the
3350  * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
3351  * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
3352  * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
3353  */
3354 extern int
3355 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads);
3356
3357 /**
3358  * @ingroup G_wim_information
3359  *
3360  * Prints information about one image, or all images, contained in a WIM.
3361  *
3362  * @param wim
3363  *      Pointer to the ::WIMStruct to query.  This need not represent a
3364  *      standalone WIM (e.g. it could represent part of a split WIM).
3365  * @param image
3366  *      The image about which to print information.  Can be the number of an
3367  *      image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
3368  *      WIM.
3369  *
3370  * @return This function has no return value.  No error checking is done when
3371  * printing the information.  If @p image is invalid, an error message is
3372  * printed.
3373  */
3374 extern void
3375 wimlib_print_available_images(const WIMStruct *wim, int image);
3376
3377 /**
3378  * @ingroup G_wim_information
3379  *
3380  * Deprecated in favor of wimlib_get_wim_info(), which provides the information
3381  * in a way that can be accessed programatically.
3382  */
3383 extern void
3384 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
3385
3386 /**
3387  * @ingroup G_nonstandalone_wims
3388  *
3389  * Reference resources from other WIM files or split WIM parts.  This function
3390  * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
3391  * to load needed resources (that is, "streams" keyed by SHA1 message digest)
3392  * from other files, before calling a function such as wimlib_extract_image()
3393  * that requires the resources to be present.
3394  *
3395  * @param wim
3396  *      The ::WIMStruct for a WIM that contains metadata resources, but is not
3397  *      necessarily "standalone".  In the case of split WIMs, this should be the
3398  *      first part, since only the first part contains the metadata resources.
3399  *      In the case of delta WIMs, this should be the delta WIM rather than the
3400  *      WIM on which it is based.
3401  * @param resource_wimfiles_or_globs
3402  *      Array of paths to WIM files and/or split WIM parts to reference.
3403  *      Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
3404  *      ref_flags, these are treated as globs rather than literal paths.  That
3405  *      is, using this function you can specify zero or more globs, each of
3406  *      which expands to one or more literal paths.
3407  * @param count
3408  *      Number of entries in @p resource_wimfiles_or_globs.
3409  * @param ref_flags
3410  *      Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
3411  *      ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
3412  * @param open_flags
3413  *      Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
3414  *      pass to internal calls to wimlib_open_wim() on the reference files.
3415  *
3416  * @return 0 on success; nonzero on error.
3417  *
3418  * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
3419  *      One of the specified globs did not match any paths (only with both
3420  *      ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
3421  *      specified in @p ref_flags).
3422  * @retval ::WIMLIB_ERR_NOMEM
3423  *      Failed to allocate memory.
3424  * @retval ::WIMLIB_ERR_READ
3425  *      I/O or permissions error while processing a file glob.
3426  *
3427  * This function can additionally return most values that can be returned by
3428  * wimlib_open_wim().
3429  */
3430 extern int
3431 wimlib_reference_resource_files(WIMStruct *wim,
3432                                 const wimlib_tchar * const *resource_wimfiles_or_globs,
3433                                 unsigned count,
3434                                 int ref_flags,
3435                                 int open_flags);
3436
3437 /**
3438  * @ingroup G_nonstandalone_wims
3439  *
3440  * Similar to wimlib_reference_resource_files(), but operates at a lower level
3441  * where the caller must open the ::WIMStruct for each referenced file itself.
3442  *
3443  * @param wim
3444  *      The ::WIMStruct for a WIM that contains metadata resources, but is not
3445  *      necessarily "standalone".  In the case of split WIMs, this should be the
3446  *      first part, since only the first part contains the metadata resources.
3447  * @param resource_wims
3448  *      Array of pointers to the ::WIMStruct's for additional resource WIMs or
3449  *      split WIM parts to reference.
3450  * @param num_resource_wims
3451  *      Number of entries in @p resource_wims.
3452  * @param ref_flags
3453  *      Currently ignored (set to 0).
3454  *
3455  * @return 0 on success; nonzero on error.  On success, the ::WIMStruct's of the
3456  * @p resource_wims are referenced internally by @p wim and must not be freed
3457  * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
3458  * been freed with wimlib_free(), or immediately before freeing @p wim with
3459  * wimlib_free().
3460  *
3461  * @retval ::WIMLIB_ERR_INVALID_PARAM
3462  *      @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
3463  *      resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
3464  * @retval ::WIMLIB_ERR_NOMEM
3465  *      Failed to allocate memory.
3466  */
3467 extern int
3468 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
3469                            unsigned num_resource_wims, int ref_flags);
3470
3471 /**
3472  * @ingroup G_modifying_wims
3473  *
3474  * Declares that a newly added image is mostly the same as a prior image, but
3475  * captured at a later point in time, possibly with some modifications in the
3476  * intervening time.  This is designed to be used in incremental backups of the
3477  * same filesystem or directory tree.
3478  *
3479  * This function compares the metadata of the directory tree of the newly added
3480  * image against that of the old image.  Any files that are present in both the
3481  * newly added image and the old image and have timestamps that indicate they
3482  * haven't been modified are deemed not to have been modified and have their
3483  * SHA1 message digest copied from the old image.  Because of this and because
3484  * WIM uses single-instance streams, such files need not be read from the
3485  * filesystem when the WIM is being written or overwritten.  Note that these
3486  * unchanged files will still be "archived" and will be logically present in the
3487  * new image; the optimization is that they don't need to actually be read from
3488  * the filesystem because the WIM already contains them.
3489  *
3490  * This function is provided to optimize incremental backups.  The resulting WIM
3491  * file will still be the same regardless of whether this function is called.
3492  * (This is, however, assuming that timestamps have not been manipulated or
3493  * unmaintained as to trick this function into thinking a file has not been
3494  * modified when really it has.  To partly guard against such cases, other
3495  * metadata such as file sizes will be checked as well.)
3496  *
3497  * This function must be called after adding the new image (e.g. with
3498  * wimlib_add_image()), but before writing the updated WIM file (e.g. with
3499  * wimlib_overwrite()).
3500  *
3501  * @param wim
3502  *      Pointer to the ::WIMStruct for a WIM.
3503  * @param new_image
3504  *      1-based index in the WIM of the newly added image.  This image can have
3505  *      been added with wimlib_add_image() or wimlib_add_image_multisource(), or
3506  *      wimlib_add_empty_image() followed by wimlib_update_image().
3507  * @param template_wim
3508  *      The ::WIMStruct for the WIM containing the template image.  This can be
3509  *      the same as @p wim, or it can be a different ::WIMStruct.
3510  * @param template_image
3511  *      1-based index in the WIM of a template image that reflects a prior state
3512  *      of the directory tree being captured.
3513  * @param flags
3514  *      Reserved; must be 0.
3515  *
3516  * @return 0 on success; nonzero on error.
3517  *
3518  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3519  *      @p new_image and/or @p template_image were not a valid image indices in
3520  *      the WIM.
3521  * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
3522  *      The specified ::WIMStruct did not actually contain the metadata resource
3523  *      for the new or template image; for example, it was a non-first part of a
3524  *      split WIM.
3525  * @retval ::WIMLIB_ERR_NOMEM
3526  *      Failed to allocate needed memory.
3527  * @retval ::WIMLIB_ERR_INVALID_PARAM
3528  *      @p new_image was equal to @p template_image, or @p new_image specified
3529  *      an image that had not been modified since opening the WIM.
3530  *
3531  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3532  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3533  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3534  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3535  * different reasons) to read the metadata resource for the template image.
3536  */
3537 extern int
3538 wimlib_reference_template_image(WIMStruct *wim, int new_image,
3539                                 WIMStruct *template_wim, int template_image,
3540                                 int flags);
3541
3542 /**
3543  * @ingroup G_general
3544  *
3545  * Registers a progress function with a ::WIMStruct.
3546  *
3547  * @param wim
3548  *      The ::WIMStruct for which to register the progress function.
3549  * @param progfunc
3550  *      Pointer to the progress function to register.  If the WIM already has a
3551  *      progress function registered, it will be replaced with this one.  If @p
3552  *      NULL, the current progress function (if any) will be unregistered.
3553  * @param progctx
3554  *      The value which will be passed as the third argument to calls to @p
3555  *      progfunc.
3556  */
3557 extern void
3558 wimlib_register_progress_function(WIMStruct *wim,
3559                                   wimlib_progress_func_t progfunc,
3560                                   void *progctx);
3561
3562 /**
3563  * @ingroup G_modifying_wims
3564  *
3565  * Rename the @p source_path to the @p dest_path in the specified @p image of
3566  * the @p wim.
3567  *
3568  * This just builds an appropriate ::wimlib_rename_command and passes it to
3569  * wimlib_update_image().
3570  */
3571 extern int
3572 wimlib_rename_path(WIMStruct *wim, int image,
3573                    const wimlib_tchar *source_path, const wimlib_tchar *dest_path);
3574
3575 /**
3576  * @ingroup G_wim_information
3577  *
3578  * Translates a string specifying the name or number of an image in the WIM into
3579  * the number of the image.  The images are numbered starting at 1.
3580  *
3581  * @param wim
3582  *      Pointer to the ::WIMStruct for a WIM.
3583  * @param image_name_or_num
3584  *      A string specifying the name or number of an image in the WIM.  If it
3585  *      parses to a positive integer, this integer is taken to specify the
3586  *      number of the image, indexed starting at 1.  Otherwise, it is taken to
3587  *      be the name of an image, as given in the XML data for the WIM file.  It
3588  *      also may be the keyword "all" or the string "*", both of which will
3589  *      resolve to ::WIMLIB_ALL_IMAGES.
3590  *      <br/> <br/>
3591  *      There is no way to search for an image actually named "all", "*", or an
3592  *      integer number, or an image that has no name.  However, you can use
3593  *      wimlib_get_image_name() to get the name of any image.
3594  *
3595  * @return
3596  *      If the string resolved to a single existing image, the number of that
3597  *      image, indexed starting at 1, is returned.  If the keyword "all" or "*"
3598  *      was specified, ::WIMLIB_ALL_IMAGES is returned.  Otherwise,
3599  *      ::WIMLIB_NO_IMAGE is returned.  If @p image_name_or_num was @c NULL or
3600  *      the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
3601  *      images in @p wim has no name.
3602  */
3603 extern int
3604 wimlib_resolve_image(WIMStruct *wim,
3605                      const wimlib_tchar *image_name_or_num);
3606
3607 /**
3608  * @ingroup G_modifying_wims
3609  *
3610  * Changes the description of an image in the WIM.
3611  *
3612  * @param wim
3613  *      Pointer to the ::WIMStruct for a WIM.
3614  * @param image
3615  *      The number of the image for which to change the description.
3616  * @param description
3617  *      The new description to give the image.  It may be @c NULL, which
3618  *      indicates that the image is to be given no description.
3619  *
3620  * @return 0 on success; nonzero on error.
3621  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3622  *      @p image does not specify a single existing image in @p wim.
3623  * @retval ::WIMLIB_ERR_NOMEM
3624  *      Failed to allocate the memory needed to duplicate the @p description
3625  *      string.
3626  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3627  *      @p wim is considered read-only because of any of the reasons mentioned
3628  *      in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3629  */
3630 extern int
3631 wimlib_set_image_descripton(WIMStruct *wim, int image,
3632                             const wimlib_tchar *description);
3633
3634 /**
3635  * @ingroup G_writing_and_overwriting_wims
3636  *
3637  * Set the compression chunk size of a WIM to use in subsequent calls to
3638  * wimlib_write() or wimlib_overwrite().
3639  *
3640  * A larger compression chunk size will likely result in a better compression
3641  * ratio, but the speed of random access to the WIM will be reduced.
3642  * Furthermore, the effect of a larger compression chunk size is limited by the
3643  * size of each stream ("file") being compressed.
3644  *
3645  * @param wim
3646  *      ::WIMStruct for a WIM.
3647  * @param chunk_size
3648  *      The chunk size (in bytes) to set.  The valid chunk sizes are dependent
3649  *      on the compression format.  See the documentation for each
3650  *      ::wimlib_compression_type constant for more information.  As a special
3651  *      case, if @p chunk_size is specified as 0, the chunk size is set to the
3652  *      default for the currently selected output compression type.
3653  *
3654  * @return 0 on success; nonzero on error.
3655  *
3656  * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
3657  *      @p chunk_size is not a supported chunk size for the currently selected
3658  *      output compression type.
3659  */
3660 extern int
3661 wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3662
3663 /**
3664  * @ingroup G_writing_and_overwriting_wims
3665  *
3666  * Similar to wimlib_set_output_chunk_size(), but set the chunk size for writing
3667  * packed streams (solid blocks).
3668  */
3669 extern int
3670 wimlib_set_output_pack_chunk_size(WIMStruct *wim, uint32_t chunk_size);
3671
3672 /**
3673  * @ingroup G_writing_and_overwriting_wims
3674  *
3675  * Set the compression type of a WIM to use in subsequent calls to
3676  * wimlib_write() or wimlib_overwrite().
3677  *
3678  * @param wim
3679  *      ::WIMStruct for a WIM.
3680  * @param ctype
3681  *      The compression type to set (one of ::wimlib_compression_type).  If this
3682  *      compression type is incompatible with the current output chunk size
3683  *      (either the default or as set with wimlib_set_output_chunk_size()), the
3684  *      output chunk size is reset to the default for that compression type.
3685  *
3686  * @return 0 on success; nonzero on error.
3687  *
3688  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
3689  *      @p ctype did not specify a valid compression type.
3690  */
3691 extern int
3692 wimlib_set_output_compression_type(WIMStruct *wim, int ctype);
3693
3694 /**
3695  * @ingroup G_writing_and_overwriting_wims
3696  *
3697  * Similar to wimlib_set_output_compression_type(), but set the compression type
3698  * for writing packed streams (solid blocks).
3699  */
3700 extern int
3701 wimlib_set_output_pack_compression_type(WIMStruct *wim, int ctype);
3702
3703 /**
3704  * @ingroup G_modifying_wims
3705  *
3706  * Set basic information about a WIM.
3707  *
3708  * @param wim
3709  *      Pointer to the ::WIMStruct for a WIM.
3710  * @param info
3711  *      A struct ::wimlib_wim_info that contains the information to set.  Only
3712  *      the information explicitly specified in the @p which flags need be
3713  *      valid.
3714  * @param which
3715  *      Flags that specify which information to set.  This is a bitwise OR of
3716  *      ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3717  *      ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3718  *
3719  * @return 0 on success; nonzero on failure.
3720  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3721  *      The WIM file is considered read-only because of any of the reasons
3722  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3723  *      flag.  However, as a special case, if you are using
3724  *      ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3725  *      function will not fail due to the readonly flag being previously set.
3726  * @retval ::WIMLIB_ERR_IMAGE_COUNT
3727  *      ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3728  *      ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3729  *      index in the WIM.
3730  */
3731 extern int
3732 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3733                     int which);
3734
3735 /**
3736  * @ingroup G_modifying_wims
3737  *
3738  * Changes what is written in the \<FLAGS\> element in the WIM XML data
3739  * (something like "Core" or "Ultimate")
3740  *
3741  * @param wim
3742  *      Pointer to the ::WIMStruct for a WIM.
3743  * @param image
3744  *      The number of the image for which to change the description.
3745  * @param flags
3746  *      The new \<FLAGS\> element to give the image.  It may be @c NULL, which
3747  *      indicates that the image is to be given no \<FLAGS\> element.
3748  *
3749  * @return 0 on success; nonzero on error.
3750  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3751  *      @p image does not specify a single existing image in @p wim.
3752  * @retval ::WIMLIB_ERR_NOMEM
3753  *      Failed to allocate the memory needed to duplicate the @p flags string.
3754  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3755  *      @p wim is considered read-only because of any of the reasons mentioned
3756  *      in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3757  */
3758 extern int
3759 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3760
3761 /**
3762  * @ingroup G_modifying_wims
3763  *
3764  * Changes the name of an image in the WIM.
3765  *
3766  * @param wim
3767  *      Pointer to the ::WIMStruct for a WIM.
3768  * @param image
3769  *      The number of the image for which to change the name.
3770  * @param name
3771  *      New name to give the new image.  If @c NULL or empty, the new image is
3772  *      given no name.  If nonempty, it must specify a name that does not
3773  *      already exist in @p wim.
3774  *
3775  * @return 0 on success; nonzero on error.
3776  * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3777  *      There is already an image named @p name in @p wim.
3778  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3779  *      @p image does not specify a single existing image in @p wim.
3780  * @retval ::WIMLIB_ERR_NOMEM
3781  *      Failed to allocate the memory needed to duplicate the @p name string.
3782  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3783  *      @p wim is considered read-only because of any of the reasons mentioned
3784  *      in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3785  */
3786 extern int
3787 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3788
3789 /**
3790  * @ingroup G_general
3791  *
3792  * Set the functions that wimlib uses to allocate and free memory.
3793  *
3794  * These settings are global and not per-WIM.
3795  *
3796  * The default is to use the default @c malloc() and @c free() from the C
3797  * library.
3798  *
3799  * Please note that some external functions, such as those in @c libntfs-3g, may
3800  * use the standard memory allocation functions regardless of this setting.
3801  *
3802  * @param malloc_func
3803  *      A function equivalent to @c malloc() that wimlib will use to allocate
3804  *      memory.  If @c NULL, the allocator function is set back to the default
3805  *      @c malloc() from the C library.
3806  * @param free_func
3807  *      A function equivalent to @c free() that wimlib will use to free memory.
3808  *      If @c NULL, the free function is set back to the default @c free() from
3809  *      the C library.
3810  * @param realloc_func
3811  *      A function equivalent to @c realloc() that wimlib will use to reallocate
3812  *      memory.  If @c NULL, the free function is set back to the default @c
3813  *      realloc() from the C library.
3814  * @return 0
3815  */
3816 extern int
3817 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3818                             void (*free_func)(void *),
3819                             void *(*realloc_func)(void *, size_t));
3820
3821 /**
3822  * @ingroup G_general
3823  *
3824  * Sets whether wimlib is to print error messages to @c stderr when a function
3825  * fails.  These error messages may provide information that cannot be
3826  * determined only from the error code that is returned.  Not every error will
3827  * result in an error message being printed.
3828  *
3829  * This setting is global and not per-WIM.
3830  *
3831  * By default, error messages are not printed.
3832  *
3833  * This can be called before wimlib_global_init().
3834  *
3835  * @param show_messages
3836  *      @c true if error messages are to be printed; @c false if error messages
3837  *      are not to be printed.
3838  *
3839  * @return 0 on success; nonzero on error.
3840  * @retval ::WIMLIB_ERR_UNSUPPORTED
3841  *      @p show_messages was @c true, but wimlib was compiled with the @c
3842  *      --without-error-messages option.   Therefore, error messages cannot be
3843  *      shown.
3844  */
3845 extern int
3846 wimlib_set_print_errors(bool show_messages);
3847
3848 /**
3849  * @ingroup G_nonstandalone_wims
3850  *
3851  * Splits a WIM into multiple parts.
3852  *
3853  * @param wim
3854  *      The ::WIMStruct for the WIM to split.
3855  * @param swm_name
3856  *      Name of the SWM file to create.  This will be the name of the first
3857  *      part.  The other parts will have the same name with 2, 3, 4, ..., etc.
3858  *      appended before the suffix.
3859  * @param part_size
3860  *      The maximum size per part, in bytes.  Unfortunately, it is not
3861  *      guaranteed that this will really be the maximum size per part, because
3862  *      some file resources in the WIM may be larger than this size, and the WIM
3863  *      file format provides no way to split up file resources among multiple
3864  *      WIMs.
3865  * @param write_flags
3866  *      Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG.  These
3867  *      flags will be used to write each split WIM part.  Specify 0 here to get
3868  *      the default behavior.
3869  *
3870  * @return 0 on success; nonzero on error.  This function may return most error
3871  * codes that can be returned by wimlib_write() as well as the following error
3872  * codes:
3873  *
3874  * @retval ::WIMLIB_ERR_INVALID_PARAM
3875  *      @p swm_name was not a nonempty string, or @p part_size was 0.
3876  *
3877  * If a progress function is registered with @p wim, for each split WIM part
3878  * that is written it will receive the messages
3879  * ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3880  * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART.
3881  */
3882 extern int
3883 wimlib_split(WIMStruct *wim,
3884              const wimlib_tchar *swm_name,
3885              uint64_t part_size,
3886              int write_flags);
3887
3888 /**
3889  * @ingroup G_mounting_wim_images
3890  *
3891  * Unmounts a WIM image that was mounted using wimlib_mount_image().
3892  *
3893  * When unmounting a read-write mounted image, the default behavior is to
3894  * discard changes to the image.  Use ::WIMLIB_UNMOUNT_FLAG_COMMIT to cause the
3895  * WIM image to be committed.
3896  *
3897  * @param dir
3898  *      The directory the WIM image was mounted on.
3899  * @param unmount_flags
3900  *      Bitwise OR of flags prefixed with @p WIMLIB_UNMOUNT_FLAG.
3901  *
3902  * @return 0 on success; nonzero on error.  The possible error codes include:
3903  *
3904  * @retval ::WIMLIB_ERR_NOT_A_MOUNTPOINT
3905  *      There is no WIM image mounted on the specified directory.
3906  * @retval ::WIMLIB_ERR_MOUNTED_IMAGE_IS_BUSY
3907  *      The read-write mounted WIM image cannot be committed because there are
3908  *      file descriptors open to it, and ::WIMLIB_UNMOUNT_FLAG_FORCE was not
3909  *      specified.
3910  * @retval ::WIMLIB_ERR_MQUEUE
3911  *      Could not create a POSIX message queue.
3912  * @retval ::WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT
3913  *      The WIM image was mounted by a different user.
3914  * @retval ::WIMLIB_ERR_UNSUPPORTED
3915  *      Mounting is not supported, either because the platform is Windows, or
3916  *      because the platform is UNIX-like and wimlib was compiled using @c
3917  *      --without-fuse.
3918  *
3919  * Note: you can also unmount the image by using the @c umount() system call, or
3920  * by using the @c umount or @c fusermount programs.  However, you need to call
3921  * this function if you want changes to be committed.
3922  */
3923 extern int
3924 wimlib_unmount_image(const wimlib_tchar *dir, int unmount_flags);
3925
3926 /**
3927  * @ingroup G_mounting_wim_images
3928  *
3929  * Same as wimlib_unmount_image(), but allows specifying a progress function.
3930  * If changes are committed from a read-write mount, the progress function will
3931  * receive ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages.
3932  */
3933 extern int
3934 wimlib_unmount_image_with_progress(const wimlib_tchar *dir,
3935                                    int unmount_flags,
3936                                    wimlib_progress_func_t progfunc,
3937                                    void *progctx);
3938
3939 /**
3940  * @ingroup G_modifying_wims
3941  *
3942  * Update a WIM image by adding, deleting, and/or renaming files or directories.
3943  *
3944  * @param wim
3945  *      Pointer to the ::WIMStruct for the WIM file to update.
3946  * @param image
3947  *      The 1-based index of the image in the WIM to update.  It cannot be
3948  *      ::WIMLIB_ALL_IMAGES.
3949  * @param cmds
3950  *      An array of ::wimlib_update_command's that specify the update operations
3951  *      to perform.
3952  * @param num_cmds
3953  *      Number of commands in @p cmds.
3954  * @param update_flags
3955  *      ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3956  *
3957  * @return 0 on success; nonzero on error.  On failure, all update commands will
3958  * be rolled back, and no visible changes shall have been made to @p wim.
3959  * Possible error codes include:
3960  *
3961  * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3962  *      The capture configuration structure specified for an add command was
3963  *      invalid.
3964  * @retval ::WIMLIB_ERR_INVALID_IMAGE
3965  *      @p image did not specify a single, existing image in @p wim.
3966  * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3967  *      Attempted to perform an add command that conflicted with previously
3968  *      existing files in the WIM when an overlay was attempted.
3969  * @retval ::WIMLIB_ERR_INVALID_PARAM
3970  *      An unknown operation type was specified in the update commands; or,
3971  *      attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3972  *      in the @p add_flags, but the same image had previously already been
3973  *      added from an NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3974  *      ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3975  *      command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3976  *      specified in the @p add_flags for an add command in which @p
3977  *      wim_target_path was not the root directory of the WIM image.
3978  * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3979  *      (Windows only):  While executing an add command, tried to capture a
3980  *      reparse point with invalid data.
3981  * @retval ::WIMLIB_ERR_IS_DIRECTORY
3982  *      A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3983  *      for a WIM path that corresponded to a directory; or, a rename command
3984  *      attempted to rename a directory to a non-directory.
3985  * @retval ::WIMLIB_ERR_NOMEM
3986  *      Failed to allocate needed memory.
3987  * @retval ::WIMLIB_ERR_NOTDIR
3988  *      A rename command attempted to rename a directory to a non-directory; or,
3989  *      an add command was executed that attempted to set the root of the WIM
3990  *      image as a non-directory; or, a path component used as a directory in a
3991  *      rename command was not, in fact, a directory.
3992  * @retval ::WIMLIB_ERR_NOTEMPTY
3993  *      A rename command attempted to rename a directory to a non-empty
3994  *      directory.
3995  * @retval ::WIMLIB_ERR_NTFS_3G
3996  *      While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3997  *      error occurred while reading data from the NTFS volume using libntfs-3g.
3998  * @retval ::WIMLIB_ERR_OPEN
3999  *      Failed to open a file to be captured while executing an add command.
4000  * @retval ::WIMLIB_ERR_OPENDIR
4001  *      Failed to open a directory to be captured while executing an add command.
4002  * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
4003  *      A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
4004  *      WIM path that did not exist; or, a rename command attempted to rename a
4005  *      file that does not exist.
4006  * @retval ::WIMLIB_ERR_READ
4007  *      While executing an add command, failed to read data from a file or
4008  *      directory to be captured.
4009  * @retval ::WIMLIB_ERR_READLINK
4010  *      While executing an add command, failed to read the target of a symbolic
4011  *      link or junction point.
4012  * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
4013  *      (Windows only) Failed to perform a reparse point fixup because of
4014  *      problems with the data of a reparse point.
4015  * @retval ::WIMLIB_ERR_STAT
4016  *      While executing an add command, failed to get attributes for a file or
4017  *      directory.
4018  * @retval ::WIMLIB_ERR_UNSUPPORTED
4019  *      ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
4020  *      command, but wimlib was configured with the @c --without-ntfs-3g flag;
4021  *      or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
4022  *      or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
4023  *      add_flags for an update command.
4024  * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
4025  *      While executing an add command, attempted to capture a file that was not
4026  *      a supported file type (e.g. a device file).  Only if
4027  *      ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
4028  *      for an update command.
4029  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
4030  *      The WIM file is considered read-only because of any of the reasons
4031  *      mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
4032  *      flag.
4033  *
4034  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4035  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4036  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4037  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4038  * different reasons) to read the metadata resource for an image that needed to
4039  * be updated.
4040  */
4041 extern int
4042 wimlib_update_image(WIMStruct *wim,
4043                     int image,
4044                     const struct wimlib_update_command *cmds,
4045                     size_t num_cmds,
4046                     int update_flags);
4047
4048 /**
4049  * @ingroup G_writing_and_overwriting_wims
4050  *
4051  * Writes a WIM to a file.
4052  *
4053  * This brings in resources from any external locations, such as directory trees
4054  * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
4055  * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
4056  *
4057  * By default, the new WIM file is written as stand-alone.  Using the
4058  * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
4059  * instead.  However, this function cannot directly write a "split" WIM; use
4060  * wimlib_split() for that.
4061  *
4062  * @param wim
4063  *      Pointer to the ::WIMStruct for a WIM.  There may have been in-memory
4064  *      changes made to it, which are then reflected in the output file.
4065  * @param path
4066  *      The path to the file to write the WIM to.
4067  * @param image
4068  *      Normally, specify ::WIMLIB_ALL_IMAGES here.  This indicates that all
4069  *      images are to be included in the new on-disk WIM file.  If for some
4070  *      reason you only want to include a single image, specify the index of
4071  *      that image instead.
4072  * @param write_flags
4073  *      Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
4074  * @param num_threads
4075  *      Number of threads to use for compressing data.  If 0, the number of
4076  *      threads is taken to be the number of online processors.  Note: if no
4077  *      data compression needs to be done, no additional threads will be created
4078  *      regardless of this parameter (e.g. if writing an uncompressed WIM, or
4079  *      exporting an image from a compressed WIM to another WIM of the same
4080  *      compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
4081  *      write_flags).
4082  *
4083  * @return 0 on success; nonzero on error.
4084  *
4085  * @retval ::WIMLIB_ERR_INVALID_IMAGE
4086  *      @p image does not specify a single existing image in @p wim, and is not
4087  *      ::WIMLIB_ALL_IMAGES.
4088  * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
4089  *      A file that had previously been scanned for inclusion in the WIM by
4090  *      wimlib_add_image() was concurrently modified, so it failed the SHA1
4091  *      message digest check.
4092  * @retval ::WIMLIB_ERR_INVALID_PARAM
4093  *      @p path was @c NULL.
4094  * @retval ::WIMLIB_ERR_NOMEM
4095  *      Failed to allocate needed memory.
4096  * @retval ::WIMLIB_ERR_OPEN
4097  *      Failed to open @p path for writing, or some file resources in @p wim
4098  *      refer to files in the outside filesystem, and one of these files could
4099  *      not be opened for reading.
4100  * @retval ::WIMLIB_ERR_READ
4101  *      An error occurred when trying to read data from the WIM file associated
4102  *      with @p wim, or some file resources in @p wim refer to files in the
4103  *      outside filesystem, and a read error occurred when reading one of these
4104  *      files.
4105  * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
4106  *      A stream that needed to be written could not be found in the stream
4107  *      lookup table of @p wim.  This error can occur if, for example, @p wim is
4108  *      part of a split WIM but needed resources from the other split WIM parts
4109  *      were not referenced with wimlib_reference_resources() or
4110  *      wimlib_reference_resource_files() before the call to wimlib_write().
4111  * @retval ::WIMLIB_ERR_WRITE
4112  *      An error occurred when trying to write data to the new WIM file.
4113  *
4114  * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
4115  * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
4116  * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
4117  * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
4118  * different reasons) to read the metadata resource for an image that needed to
4119  * be written.
4120  *
4121  * If a progress function is registered with @p wim, it will receive the
4122  * messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
4123  * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN, and
4124  * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END.
4125  */
4126 extern int
4127 wimlib_write(WIMStruct *wim,
4128              const wimlib_tchar *path,
4129              int image,
4130              int write_flags,
4131              unsigned num_threads);
4132
4133 /**
4134  * @ingroup G_writing_and_overwriting_wims
4135  *
4136  * Since wimlib v1.5.0:  Same as wimlib_write(), but write the WIM directly to a
4137  * file descriptor, which need not be seekable if the write is done in a special
4138  * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
4139  * write_flags.  This can, for example, allow capturing a WIM image and
4140  * streaming it over the network.  See the documentation for
4141  * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
4142  *
4143  * The file descriptor @p fd will @b not be closed when the write is complete;
4144  * the calling code is responsible for this.
4145  *
4146  * Returns 0 on success; nonzero on failure.  The possible error codes include
4147  * those that can be returned by wimlib_write() as well as the following:
4148  *
4149  * @retval ::WIMLIB_ERR_INVALID_PARAM
4150  *      @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
4151  *      specified in @p write_flags.
4152  */
4153 extern int
4154 wimlib_write_to_fd(WIMStruct *wim,
4155                    int fd,
4156                    int image,
4157                    int write_flags,
4158                    unsigned num_threads);
4159
4160 /**
4161  * @defgroup G_compression Compression and decompression functions
4162  *
4163  * @brief Functions for LZX, XPRESS, and LZMS compression and decompression,
4164  * exported for convenience only, as they are already used by wimlib internally
4165  * when appropriate.
4166  *
4167  * These functions can be used for general-purpose lossless data compression,
4168  * but some limitations apply; for example, none of the compressors or
4169  * decompressors currently support sliding windows, and there also exist
4170  * slightly different variants of these formats that are not supported
4171  * unmodified.
4172  *
4173  * @{
4174  */
4175
4176 /** Header for compression parameters to pass to wimlib_create_compressor() or
4177  * wimlib_set_default_compressor_params().  */
4178 struct wimlib_compressor_params_header {
4179         /** Size of the parameters, in bytes.  */
4180         uint32_t size;
4181 };
4182
4183 /** Header for decompression parameters to pass to wimlib_create_decompressor()
4184  * or wimlib_set_default_decompressor_params() */
4185 struct wimlib_decompressor_params_header {
4186         /** Size of the parameters, in bytes.  */
4187         uint32_t size;
4188 };
4189
4190 /** LZX compression parameters that can optionally be passed to
4191  * wimlib_create_compressor() with the compression type
4192  * ::WIMLIB_COMPRESSION_TYPE_LZX.  */
4193 struct wimlib_lzx_compressor_params {
4194         /** hdr.size Must be set to the size of this structure, in bytes.  */
4195         struct wimlib_compressor_params_header hdr;
4196
4197         /** Relatively fast LZX compression algorithm with a decent compression
4198          * ratio.  */
4199 #define WIMLIB_LZX_ALGORITHM_FAST 0
4200
4201         /** Slower LZX compression algorithm that provides a better compression
4202          * ratio.  This is the default.  */
4203 #define WIMLIB_LZX_ALGORITHM_SLOW 1
4204
4205         /** Algorithm to use to perform the compression: either
4206          * ::WIMLIB_LZX_ALGORITHM_FAST or ::WIMLIB_LZX_ALGORITHM_SLOW.  The
4207          * format is still LZX; this refers to the method the code will use to
4208          * perform LZX-compatible compression.  */
4209         uint32_t algorithm : 3;
4210
4211         /** If set to 1, the default parameters for the specified algorithm are
4212          * used rather than the ones specified in the following union.  */
4213         uint32_t use_defaults : 1;
4214
4215         union {
4216                 /** Parameters for the fast algorithm.  */
4217                 struct wimlib_lzx_fast_params {
4218                         uint32_t fast_reserved1[10];
4219                 } fast;
4220
4221                 /** Parameters for the "slow" algorithm.  */
4222                 struct wimlib_lzx_slow_params {
4223                         /** If set to 1, the compressor can output length 2
4224                          * matches.  If set 0, the compressor can only output
4225                          * matches of length 3 or greater.  Suggested value: 1
4226                          */
4227                         uint32_t use_len2_matches : 1;
4228
4229                         uint32_t slow_reserved1 : 31;
4230
4231                         /** Matches with length (in bytes) greater than or equal
4232                          * to this value are immediately taken without spending
4233                          * time on minimum-cost measurements.  Suggested value:
4234                          * 32.  */
4235                         uint32_t nice_match_length;
4236
4237                         /** Number of passes to compute a match/literal sequence
4238                          * for each LZX block.  This is for an iterative
4239                          * algorithm that attempts to minimize the cost of the
4240                          * match/literal sequence by using a cost model provided
4241                          * by the previous iteration.  Must be at least 1.
4242                          * Suggested value: 2.  */
4243                         uint32_t num_optim_passes;
4244
4245                         /** Reserved; set to 0.  */
4246                         uint32_t slow_reserved_blocksplit;
4247
4248                         /** Maximum depth to search for matches at each
4249                          * position.  Suggested value: 50.  */
4250                         uint32_t max_search_depth;
4251
4252                         /* Note: max_matches_per_pos has been removed and no
4253                          * longer has any effect.  */
4254
4255                         uint32_t slow_reserved2[3];
4256
4257                         /** Assumed cost of a main symbol with zero frequency.
4258                          * Must be at least 1 and no more than 16.  Suggested
4259                          * value: 15.  */
4260                         uint8_t main_nostat_cost;
4261
4262                         /** Assumed cost of a length symbol with zero frequency.
4263                          * Must be at least 1 and no more than 16.  Suggested
4264                          * value: 15.  */
4265                         uint8_t len_nostat_cost;
4266
4267                         /** Assumed cost of an aligned symbol with zero
4268                          * frequency.  Must be at least 1 and no more than 8.
4269                          * Suggested value: 7.  */
4270                         uint8_t aligned_nostat_cost;
4271
4272                         uint8_t slow_reserved3[5];
4273                 } slow;
4274         } alg_params;
4275 };
4276
4277 /** LZMS compression parameters that can optionally be passed to
4278  * wimlib_create_compressor() with the compression type
4279  * ::WIMLIB_COMPRESSION_TYPE_LZMS.  */
4280 struct wimlib_lzms_compressor_params {
4281         /** hdr.size Must be set to the size of this structure, in bytes.  */
4282         struct wimlib_compressor_params_header hdr;
4283
4284         /** Minimum match length to output.  This must be at least 2.  Suggested
4285          * value: 2  */
4286         uint32_t min_match_length;
4287
4288         /** Maximum match length to output.  This must be at least @p
4289          * min_match_length.  Suggested value: @p UINT32_MAX.  */
4290         uint32_t max_match_length;
4291
4292         /** Matches with length (in bytes) greater than or equal to this value
4293          * are immediately taken without spending time on minimum-cost
4294          * measurements.  The minimum of @p max_match_length and @p
4295          * nice_match_length may not exceed 65536.  Suggested value: 32.  */
4296         uint32_t nice_match_length;
4297
4298         /** Maximum depth to search for matches at each position.  Suggested
4299          * value: 50.  */
4300         uint32_t max_search_depth;
4301
4302         /* Note: max_matches_per_pos has been removed and no longer has any
4303          * effect.  */
4304
4305         uint32_t reserved1;
4306
4307         /** Length of the array for the near-optimal LZ parsing algorithm.  This
4308          * must be at least 1.  Suggested value: 1024.  */
4309         uint32_t optim_array_length;
4310
4311         uint64_t reserved2[4];
4312 };
4313
4314 /** Opaque compressor handle.  */
4315 struct wimlib_compressor;
4316
4317 /** Opaque decompressor handle.  */
4318 struct wimlib_decompressor;
4319
4320 /**
4321  * Set the default compression parameters for the specified compression type.
4322  * This will affect both explicit and library-internal calls to
4323  * wimlib_create_compressor().
4324  *
4325  * @param ctype
4326  *      Compression type for which to set the default compression parameters.
4327  * @param params
4328  *      Compression-type specific parameters.  This may be @c NULL, in which
4329  *      case the "default default" parameters are restored.
4330  *
4331  * @return 0 on success; nonzero on error.
4332  *
4333  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4334  *      @p ctype was not a supported compression type.
4335  * @retval ::WIMLIB_ERR_INVALID_PARAM
4336  *      @p params were invalid.
4337  * @retval ::WIMLIB_ERR_NOMEM
4338  *      Not enough memory to duplicate the parameters (perhaps @c params->size
4339  *      was invalid).
4340  */
4341 extern int
4342 wimlib_set_default_compressor_params(enum wimlib_compression_type ctype,
4343                                      const struct wimlib_compressor_params_header *params);
4344
4345 /**
4346  * Returns the approximate number of bytes needed to allocate a compressor with
4347  * wimlib_create_compressor() for the specified compression type, block size,
4348  * and parameters.  @p params may be @c NULL, in which case the current default
4349  * parameters for @p ctype are used.  Returns 0 if the compression type or
4350  * parameters are invalid.
4351  */
4352 extern uint64_t
4353 wimlib_get_compressor_needed_memory(enum wimlib_compression_type ctype,
4354                                     size_t max_block_size,
4355                                     const struct wimlib_compressor_params_header *params);
4356
4357 /**
4358  * Allocate a compressor for the specified compression type using the specified
4359  * parameters.  This function is part of wimlib's compression API; it is not
4360  * necessary to call this to process a WIM file.
4361  *
4362  * @param ctype
4363  *      Compression type for which to create the compressor.
4364  * @param max_block_size
4365  *      Maximum block size to support.  The exact meaning and allowed values for
4366  *      this parameter depend on the compression type, but it at least specifies
4367  *      the maximum allowed value for @p uncompressed_size to wimlib_compress().
4368  * @param extra_params
4369  *      An optional pointer to extra compressor parameters for the specified
4370  *      compression type.  For LZX, a pointer to ::wimlib_lzx_compressor_params
4371  *      may be specified here.  For LZMS, a pointer to
4372  *      ::wimlib_lzms_compressor_params may be specified here.  If left @c NULL,
4373  *      the default parameters are used.
4374  * @param compressor_ret
4375  *      A location into which to return the pointer to the allocated compressor,
4376  *      which can be used for any number of calls to wimlib_compress() before
4377  *      being freed with wimlib_free_compressor().
4378  *
4379  * @return 0 on success; nonzero on error.
4380  *
4381  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4382  *      @p ctype was not a supported compression type.
4383  * @retval ::WIMLIB_ERR_INVALID_PARAM
4384  *      The compression parameters were invalid.
4385  * @retval ::WIMLIB_ERR_NOMEM
4386  *      Insufficient memory to allocate the compressor.
4387  */
4388 extern int
4389 wimlib_create_compressor(enum wimlib_compression_type ctype,
4390                          size_t max_block_size,
4391                          const struct wimlib_compressor_params_header *extra_params,
4392                          struct wimlib_compressor **compressor_ret);
4393
4394 /**
4395  * Losslessly compress a block of data using a compressor previously created
4396  * with wimlib_create_compressor().
4397  *
4398  * @param uncompressed_data
4399  *      Buffer containing the data to compress.
4400  * @param uncompressed_size
4401  *      Size, in bytes, of the data to compress.
4402  * @param compressed_data
4403  *      Buffer into which to write the compressed data.
4404  * @param compressed_size_avail
4405  *      Number of bytes available in @p compressed_data.
4406  * @param compressor
4407  *      A compressor previously allocated with wimlib_create_compressor().
4408  *
4409  * @return
4410  *      The size of the compressed data, in bytes, or 0 if the input data could
4411  *      not be compressed to @p compressed_size_avail or fewer bytes.
4412  */
4413 extern size_t
4414 wimlib_compress(const void *uncompressed_data, size_t uncompressed_size,
4415                 void *compressed_data, size_t compressed_size_avail,
4416                 struct wimlib_compressor *compressor);
4417
4418 /**
4419  * Free a compressor previously allocated with wimlib_create_compressor().
4420  *
4421  * @param compressor
4422  *      The compressor to free.
4423  */
4424 extern void
4425 wimlib_free_compressor(struct wimlib_compressor *compressor);
4426
4427 /**
4428  * Set the default decompression parameters for the specified compression type.
4429  * This will affect both explicit and library-internal calls to
4430  * wimlib_create_decompressor().
4431  *
4432  * @param ctype
4433  *      Compression type for which to set the default decompression parameters.
4434  * @param params
4435  *      Compression-type specific parameters.  This may be @c NULL, in which
4436  *      case the "default default" parameters are restored.
4437  *
4438  * @return 0 on success; nonzero on error.
4439  *
4440  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4441  *      @p ctype was not a supported compression type.
4442  * @retval ::WIMLIB_ERR_NOMEM
4443  *      Not enough memory to duplicate the parameters (perhaps @c params->size
4444  *      was invalid).
4445  */
4446 extern int
4447 wimlib_set_default_decompressor_params(enum wimlib_compression_type ctype,
4448                                        const struct wimlib_decompressor_params_header *params);
4449
4450 /**
4451  * Allocate a decompressor for the specified compression type using the
4452  * specified parameters.  This function is part of wimlib's compression API; it
4453  * is not necessary to call this to process a WIM file.
4454  *
4455  * @param ctype
4456  *      Compression type for which to create the decompressor.
4457  * @param max_block_size
4458  *      Maximum block size to support.  The exact meaning and allowed values for
4459  *      this parameter depend on the compression type, but it at least specifies
4460  *      the maximum allowed value for @p uncompressed_size to
4461  *      wimlib_decompress().
4462  * @param extra_params
4463  *      An optional pointer to extra decompressor parameters for the specified
4464  *      compression type.  If @c NULL, the default parameters are used.
4465  * @param decompressor_ret
4466  *      A location into which to return the pointer to the allocated
4467  *      decompressor, which can be used for any number of calls to
4468  *      wimlib_decompress() before being freed with wimlib_free_decompressor().
4469  *
4470  * @return 0 on success; nonzero on error.
4471  *
4472  * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
4473  *      @p ctype was not a supported compression type.
4474  * @retval ::WIMLIB_ERR_INVALID_PARAM
4475  *      The decompression parameters were invalid.
4476  * @retval ::WIMLIB_ERR_NOMEM
4477  *      Insufficient memory to allocate the decompressor.
4478  */
4479 extern int
4480 wimlib_create_decompressor(enum wimlib_compression_type ctype,
4481                            size_t max_block_size,
4482                            const struct wimlib_decompressor_params_header *extra_params,
4483                            struct wimlib_decompressor **decompressor_ret);
4484
4485 /**
4486  * Decompress a block of data using a decompressor previously created with
4487  * wimlib_create_decompressor().
4488  *
4489  * @param compressed_data
4490  *      Buffer containing the data to decompress.
4491  * @param compressed_size
4492  *      Size, in bytes, of the data to decompress.
4493  * @param uncompressed_data
4494  *      Buffer into which to write the uncompressed data.
4495  * @param uncompressed_size
4496  *      Size, in bytes, of the data when uncompressed.
4497  * @param decompressor
4498  *      A decompressor previously allocated with wimlib_create_decompressor().
4499  *
4500  * @return 0 on success; nonzero on error.
4501  */
4502 extern int
4503 wimlib_decompress(const void *compressed_data, size_t compressed_size,
4504                   void *uncompressed_data, size_t uncompressed_size,
4505                   struct wimlib_decompressor *decompressor);
4506
4507 /**
4508  * Free a decompressor previously allocated with wimlib_create_decompressor().
4509  *
4510  * @param decompressor
4511  *      The decompressor to free.
4512  */
4513 extern void
4514 wimlib_free_decompressor(struct wimlib_decompressor *decompressor);
4515
4516
4517 /**
4518  * @}
4519  */
4520
4521
4522 #ifdef __cplusplus
4523 }
4524 #endif
4525
4526 #endif /* _WIMLIB_H */