3 * @brief External header for wimlib.
5 * This file contains extensive comments for generating documentation with
6 * Doxygen. The built HTML documentation can be viewed at
7 * http://wimlib.sourceforge.net.
11 * Copyright (C) 2012, 2013 Eric Biggers
13 * This file is part of wimlib, a library for working with WIM files.
15 * wimlib is free software; you can redistribute it and/or modify it under the
16 * terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 3 of the License, or (at your option)
20 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
22 * A PARTICULAR PURPOSE. See the GNU General Public License for more
25 * You should have received a copy of the GNU General Public License
26 * along with wimlib; if not, see http://www.gnu.org/licenses/.
31 * \section intro Introduction
33 * This is the documentation for the library interface of wimlib 1.5.0, a C
34 * library for creating, modifying, extracting, and mounting files in the
35 * Windows Imaging Format. This documentation is intended for developers only.
36 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
37 * program, please see the README file or manual pages.
39 * \section installing_and_compiling Installing and Compiling
41 * wimlib uses the GNU autotools, so, on UNIX-like systems, it should be easy to
42 * install with <code>configure && make && sudo make install</code>; however,
43 * please see the README for more information about installing it.
45 * To use wimlib in your program after installing it, include wimlib.h and link
46 * your program with @c -lwim.
48 * As of wimlib 1.5.0, wimlib.h is also compatible with C++.
50 * Note: before calling any other function declared in wimlib.h,
51 * wimlib_global_init() can (and in some cases, must) be called. See its
52 * documentation for more details.
54 * \section basic_wim_handling_concepts Basic WIM handling concepts
56 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. There are
57 * two ways to create such a structure: wimlib_open_wim(), which opens a WIM
58 * file and creates a ::WIMStruct representing it, and wimlib_create_new_wim(),
59 * which creates a new ::WIMStruct that initially contains no images and does
60 * not yet have a backing on-disk file.
62 * A WIM file, represented by a ::WIMStruct, contains zero or more images.
63 * Images can be extracted (or "applied") using wimlib_extract_image(), added
64 * (or "captured" or "appended") using wimlib_add_image(), deleted using
65 * wimlib_delete_image(), exported using wimlib_export_image(), and updated or
66 * modified using wimlib_update_image(). However, changes made to a WIM
67 * represented by a ::WIMStruct have no persistent effect until the WIM is
68 * actually written to an on-disk file. This can be done using wimlib_write(),
69 * but if the WIM was originally opened using wimlib_open_wim(), then
70 * wimlib_overwrite() can be used instead.
72 * Note that with this ::WIMStruct abstraction, performing many tasks on WIM
73 * files is a multi-step process. For example, to add, or "append" an image to
74 * an existing stand-alone WIM file in a way similar to <b>wimlib-imagex
75 * append</b>, you must call the following functions:
77 * 1. wimlib_open_wim()
78 * 2. wimlib_add_image()
79 * 3. wimlib_overwrite()
81 * This design is very much on purpose as it makes the library more useful in
82 * general by allowing functions to be composed in different ways. For example,
83 * you can make multiple changes to a WIM and commit them all to the underlying
84 * file in only one overwrite operation, which is more efficient.
86 * \section cleaning_up Cleaning up
88 * After you are done with any ::WIMStruct, you can call wimlib_free() to free
89 * all resources associated with it. Also, when you are completely done with
90 * using wimlib in your program, you can call wimlib_global_cleanup() to free
91 * any other resources allocated by the library.
93 * \section error_handling Error Handling
95 * Most functions in wimlib return 0 on success and a positive error code on
96 * failure. Use wimlib_get_error_string() to get a string that describes an
97 * error code. wimlib also can print error messages to standard error itself
98 * when an error happens, and these may be more informative than the error code;
99 * to enable this, call wimlib_set_print_errors(). Please note that this is for
100 * convenience only, and some errors can occur without a message being printed.
101 * Currently, error messages and strings (as well as all documentation, for that
102 * matter) are only available in English.
104 * \section encodings Locales and character encodings
106 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
107 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
110 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
111 * and the encoding is UTF-16LE.
113 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
114 * and the encoding is the locale-dependent multibyte encoding. I recommend you
115 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
116 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
117 * call wimlib_global_init() after having set your desired locale.
119 * \section advanced Additional information and features
121 * \subsection image_addition Image addition/capture
123 * As described in \ref basic_wim_handling_concepts, capturing a new WIM or
124 * appending an image to an existing WIM is a multi-step process, but at its
125 * core is wimlib_add_image() or an equivalent function. Normally,
126 * wimlib_add_image() takes an on-disk directory tree and logically adds it to a
127 * ::WIMStruct as a new image. However, when supported by the build of the
128 * library, there is also a special NTFS volume capture mode (entered when
129 * ::WIMLIB_ADD_FLAG_NTFS is specified) that allows adding the image directly
130 * from an unmounted NTFS volume.
132 * Another function, wimlib_add_image_multisource() is also provided. It
133 * generalizes wimlib_add_image() to allow combining multiple files or directory
134 * trees into a single WIM image in a configurable way.
136 * For maximum customization of WIM image creation, it is also possible to add a
137 * completely empty WIM image with wimlib_add_empty_image(), then update it with
138 * wimlib_update_image(). (This is in fact what wimlib_add_image() and
139 * wimlib_add_image_multisource() do internally.)
141 * Note that some details of how image addition/capture works are documented
142 * more fully in the manual page for <b>wimlib-imagex capture</b>.
144 * \subsection extraction Image extraction/application
146 * wimlib_extract_image() extracts, or "applies", an image from a WIM
147 * (represented, as usual, by a ::WIMStruct). This normally extracts the image
148 * to a directory, but when supported by the build of the library there is also
149 * a special NTFS volume extraction mode (entered when
150 * ::WIMLIB_EXTRACT_FLAG_NTFS is specified) that allows extracting a WIM image
151 * directly to an unmounted NTFS volume. Various other flags allow further
152 * customization of image extraction.
154 * Another function, wimlib_extract_files(), is also provided. It can extract
155 * certain files or directories from a WIM image, instead of a full image.
157 * A third function, wimlib_extract_image_from_pipe(), allows an image to be
158 * extracted from a pipable WIM sent over a pipe; see \ref pipable_wims.
160 * Note that some details of how image extraction/application works are
161 * documented more fully in the manual pages for <b>wimlib-imagex apply</b> and
162 * <b>wimlib-imagex extract</b>.
164 * \subsection non_standalone_wims Non-standalone WIMs
166 * Earlier it was stated that a ::WIMStruct represents a WIM file, but there's a
167 * bit more to it than that. Normally, WIM files are "standalone". However,
168 * WIM files can also be arranged in non-standalone ways, such as a set of
169 * on-disk files that together form a single "split WIM" or "delta WIM". Such
170 * arrangements are fully supported by wimlib. However, as a result, in such
171 * cases a ::WIMStruct created from one of these on-disk files initially only
172 * partially represents the full WIM and needs to, in effect, be logically
173 * combined with other ::WIMStruct's before performing certain operations, such
174 * as extracting files with wimlib_extract_image() or wimlib_extract_files().
175 * This is done by calling wimlib_reference_resource_files() or
176 * wimlib_reference_resources().
178 * wimlib_write() can create delta WIMs as well as standalone WIMs, but a
179 * specialized function (wimlib_split()) is needed to create a split WIM.
181 * \subsection mounting_wim_images Mounting WIM images
183 * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
184 * mounting images from WIM files either read-only or read-write. To mount an
185 * image, call wimlib_mount_image(). To unmount an image, call
186 * wimlib_unmount_image(). Mounting can be done without root privileges because
187 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
188 * compiled with the <code>--without-fuse</code> flag, these functions will be
189 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED. Note that mounting an
190 * image read-write is an alternative to calling wimlib_update_image().
192 * \subsection progress_functions Progress Functions
194 * When operating on large archives, operations such as extraction will
195 * naturally take a while to complete. Because of this and to improve the
196 * potential user-friendliness of library clients, a number of functions take a
197 * pointer to a progress function of type ::wimlib_progress_func_t. This
198 * function will be called periodically during the WIM operation(s) to report on
199 * the progress of the operation (for example, how many bytes have been written
202 * \subsection pipable_wims Pipable WIMs
204 * wimlib supports a special "pipable" WIM format which unfortunately is @b not
205 * compatible with Microsoft's software. To create a pipable WIM, call
206 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
207 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
208 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
209 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
210 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
211 * s using a seekable file descriptor using the regular function calls (e.g.
212 * wimlib_open_wim(), wimlib_extract_image()).
214 * See the documentation for the <b>--pipable</b> flag of <b>wimlib-imagex
215 * capture</b> for more information about pipable WIMs.
217 * \subsection thread_safety Thread Safety
219 * wimlib is thread-safe, with the following exceptions:
220 * - Different threads cannot operate on the same ::WIMStruct at the same time;
221 * they must use different ::WIMStruct's.
222 * - You must call wimlib_global_init() in one thread before calling any other
224 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
225 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
226 * concurrently in the same process, will daemonize the entire process when it
227 * does so for the first time. This includes changing the working directory
228 * to the root directory.
230 * \subsection limitations Limitations
232 * This section documents some technical limitations of wimlib not already
233 * documented in the man page for @b wimlib-imagex.
235 * - The old WIM format from Vista pre-releases is not supported.
236 * - Compressed resource chunk sizes other than 32768 are not supported. This
237 * doesn't seem to be a real problem because the chunk size always seems to be
239 * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
240 * functionality other than that already present in @b ImageX, that allows you
241 * to make certain Windows-specific modifications to a Windows PE image, such
242 * as adding a driver or Windows component. Such a tool could be implemented
245 * \subsection more_info More information
247 * You are advised to read the README as well as the manual pages for
248 * <b>wimlib-imagex</b>, since not all relevant information is repeated here in
249 * the API documentation.
258 #include <inttypes.h>
261 /** Major version of the library (for example, the 1 in 1.2.5). */
262 #define WIMLIB_MAJOR_VERSION 1
264 /** Minor version of the library (for example, the 2 in 1.2.5). */
265 #define WIMLIB_MINOR_VERSION 5
267 /** Patch version of the library (for example, the 5 in 1.2.5). */
268 #define WIMLIB_PATCH_VERSION 0
275 * Opaque structure that represents a WIM file. This is an in-memory structure
276 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
277 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
278 * continuing to exist so that data can be read from it as needed.
280 * Most functions in this library will work the same way regardless of whether a
281 * given ::WIMStruct was obtained through wimlib_open_wim() or
282 * wimlib_create_new_wim(). Exceptions are documented.
284 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
285 * file from a ::WIMStruct.
287 #ifndef WIMLIB_WIMSTRUCT_DECLARED
288 typedef struct WIMStruct WIMStruct;
289 #define WIMLIB_WIMSTRUCT_DECLARED
293 typedef wchar_t wimlib_tchar;
295 /** See \ref encodings */
296 typedef char wimlib_tchar;
300 /** Path separator for WIM paths passed back to progress callbacks. */
301 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
302 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
304 /** Path separator for WIM paths passed back to progress callbacks. */
305 # define WIMLIB_WIM_PATH_SEPARATOR '/'
306 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
310 # define _wimlib_deprecated __attribute__((deprecated))
312 # define _wimlib_deprecated
315 #define WIMLIB_GUID_LEN 16
318 * Specifies the compression type of a WIM file.
320 enum wimlib_compression_type {
321 /** An invalid compression type. */
322 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
324 /** The WIM does not include any compressed resources. */
325 WIMLIB_COMPRESSION_TYPE_NONE = 0,
327 /** Compressed resources in the WIM use LZX compression. */
328 WIMLIB_COMPRESSION_TYPE_LZX = 1,
330 /** Compressed resources in the WIM use XPRESS compression. */
331 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
334 /** Possible values of the first parameter to the user-supplied
335 * ::wimlib_progress_func_t progress function */
336 enum wimlib_progress_msg {
338 /** A WIM image is about to be extracted. @p info will point to
339 * ::wimlib_progress_info.extract. */
340 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
342 /** A file or directory tree within a WIM image (not the full image) is
343 * about to be extracted. @p info will point to
344 * ::wimlib_progress_info.extract. */
345 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
347 /** The directory structure of the WIM image is about to be extracted.
348 * @p info will point to ::wimlib_progress_info.extract. */
349 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
351 /** The directory structure of the WIM image has been successfully
352 * extracted. @p info will point to ::wimlib_progress_info.extract. */
353 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
355 /** The WIM image's files resources are currently being extracted. @p
356 * info will point to ::wimlib_progress_info.extract. */
357 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
359 /** Starting to read a new part of a split pipable WIM over the pipe.
360 * @p info will point to ::wimlib_progress_info.extract. */
361 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
363 /** All the WIM files and directories have been extracted, and
364 * timestamps are about to be applied. @p info will point to
365 * ::wimlib_progress_info.extract. */
366 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
368 /** A WIM image has been successfully extracted. @p info will point to
369 * ::wimlib_progress_info.extract. */
370 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
372 /** A file or directory tree within a WIM image (not the full image) has
373 * been successfully extracted. @p info will point to
374 * ::wimlib_progress_info.extract. */
375 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
377 /** The directory or NTFS volume is about to be scanned to build a tree
378 * of WIM dentries in-memory. @p info will point to
379 * ::wimlib_progress_info.scan. */
380 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
382 /** A directory or file is being scanned. @p info will point to
383 * ::wimlib_progress_info.scan, and its @p cur_path member will be
384 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE
385 * is passed to wimlib_add_image(). */
386 WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
388 /** The directory or NTFS volume has been successfully scanned, and a
389 * tree of WIM dentries has been built in-memory. @p info will point to
390 * ::wimlib_progress_info.scan. */
391 WIMLIB_PROGRESS_MSG_SCAN_END,
394 * File resources are currently being written to the WIM.
395 * @p info will point to ::wimlib_progress_info.write_streams. */
396 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
399 * The metadata resource for each image is about to be written to the
400 * WIM. @p info will not be valid. */
401 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
404 * The metadata resource for each image has successfully been writen to
405 * the WIM. @p info will not be valid. */
406 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
409 * The temporary file has successfully been renamed to the original WIM
410 * file. Only happens when wimlib_overwrite() is called and the
411 * overwrite is not done in-place.
412 * @p info will point to ::wimlib_progress_info.rename. */
413 WIMLIB_PROGRESS_MSG_RENAME,
415 /** The contents of the WIM are being checked against the integrity
416 * table. Only happens when wimlib_open_wim() is called with the
417 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. @p info will point to
418 * ::wimlib_progress_info.integrity. */
419 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
421 /** An integrity table is being calculated for the WIM being written.
422 * Only happens when wimlib_write() or wimlib_overwrite() is called with
423 * the ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag. @p info will point to
424 * ::wimlib_progress_info.integrity. */
425 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
427 /** Reserved. (Previously used for WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
428 * but in wimlib v1.5.0 this was removed to simplify the code and now
429 * you'll get ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages instead.) */
430 WIMLIB_PROGRESS_MSG_RESERVED,
432 /** A wimlib_split() operation is in progress, and a new split part is
433 * about to be started. @p info will point to
434 * ::wimlib_progress_info.split. */
435 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
437 /** A wimlib_split() operation is in progress, and a split part has been
438 * finished. @p info will point to ::wimlib_progress_info.split. */
439 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
442 * A WIM update command is just about to be executed; @p info will point
443 * to ::wimlib_progress_info.update.
445 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
448 * A WIM update command has just been executed; @p info will point to
449 * ::wimlib_progress_info.update.
451 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
455 /** A pointer to this union is passed to the user-supplied
456 * ::wimlib_progress_func_t progress function. One (or none) of the structures
457 * contained in this union will be applicable for the operation
458 * (::wimlib_progress_msg) indicated in the first argument to the progress
460 union wimlib_progress_info {
462 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
463 * document them if they aren't given a name... */
465 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. */
466 struct wimlib_progress_info_write_streams {
467 /** Number of bytes that are going to be written for all the
468 * streams combined. This is the amount in uncompressed data.
469 * (The actual number of bytes will be less if the data is being
470 * written compressed.) */
471 uint64_t total_bytes;
473 /** Number of streams that are going to be written. */
474 uint64_t total_streams;
476 /** Number of uncompressed bytes that have been written so far.
477 * Will be 0 initially, and equal to @p total_bytes at the end.
479 uint64_t completed_bytes;
481 /** Number of streams that have been written. Will be 0
482 * initially, and equal to @p total_streams at the end. */
483 uint64_t completed_streams;
485 /** Number of threads that are being used to compress resources
486 * (if applicable). */
487 unsigned num_threads;
489 /** The compression type being used to write the streams; either
490 * ::WIMLIB_COMPRESSION_TYPE_NONE,
491 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or
492 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
493 int compression_type;
495 /** Number of split WIM parts from which streams are being
496 * written (may be 0 if irrelevant). */
497 unsigned total_parts;
499 /** Number of split WIM parts from which streams have been
500 * written (may be 0 if irrelevant). */
501 unsigned completed_parts;
504 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
505 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
506 struct wimlib_progress_info_scan {
507 /** Directory or NTFS volume that is being scanned. */
508 const wimlib_tchar *source;
510 /** Path to the file or directory that is about to be scanned,
511 * relative to the root of the image capture or the NTFS volume.
513 const wimlib_tchar *cur_path;
516 /** File or directory looks okay and will be captured. */
517 WIMLIB_SCAN_DENTRY_OK = 0,
519 /** File or directory is being excluded from capture due
520 * to the capture configuration file. */
521 WIMLIB_SCAN_DENTRY_EXCLUDED,
523 /** File or directory is being excluded from capture due
524 * to being unsupported (e.g. an encrypted or device
526 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
529 /** Target path in the WIM. Only valid on messages
530 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
531 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
532 const wimlib_tchar *wim_target_path;
535 /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
536 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
537 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
538 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
539 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
540 struct wimlib_progress_info_extract {
541 /** Number of the image being extracted (1-based). */
544 /** Flags passed to to wimlib_extract_image() */
547 /** Full path to the WIM file being extracted. */
548 const wimlib_tchar *wimfile_name;
550 /** Name of the image being extracted. */
551 const wimlib_tchar *image_name;
553 /** Directory or NTFS volume to which the image is being
555 const wimlib_tchar *target;
558 const wimlib_tchar *cur_path;
560 /** Number of bytes of uncompressed data that will be extracted.
561 * Takes into account hard links (they are not counted for each
563 uint64_t total_bytes;
565 /** Number of bytes that have been written so far. Will be 0
566 * initially, and equal to @p total_bytes at the end. */
567 uint64_t completed_bytes;
569 /** Number of streams that will be extracted. This may more or
570 * less than the number of "files" to be extracted due to
571 * special cases (hard links, symbolic links, and alternate data
573 uint64_t num_streams;
575 /** Path to the root dentry within the WIM for the tree that is
576 * being extracted. Will be the empty string when extracting a
578 const wimlib_tchar *extract_root_wim_source_path;
580 /** Currently only used for
581 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
583 unsigned part_number;
585 /** Currently only used for
586 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
587 unsigned total_parts;
589 /** Currently only used for
590 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
591 uint8_t guid[WIMLIB_GUID_LEN];
594 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
595 struct wimlib_progress_info_rename {
596 /** Name of the temporary file that the WIM was written to. */
597 const wimlib_tchar *from;
599 /** Name of the original WIM file to which the temporary file is
601 const wimlib_tchar *to;
604 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
605 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
606 struct wimlib_progress_info_update {
607 /** Pointer to the update command that will be executed or has
608 * just been executed. */
609 const struct wimlib_update_command *command;
611 /** Number of update commands that have been completed so far.
613 size_t completed_commands;
615 /** Number of update commands that are being executed as part of
616 * this call to wimlib_update_image(). */
617 size_t total_commands;
620 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
621 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
622 struct wimlib_progress_info_integrity {
623 /** Number of bytes from the end of the WIM header to the end of
624 * the lookup table (the area that is covered by the SHA1
625 * integrity checks.) */
626 uint64_t total_bytes;
628 /** Number of bytes that have been SHA1-summed so far. Will be
629 * 0 initially, and equal @p total_bytes at the end. */
630 uint64_t completed_bytes;
632 /** Number of chunks that the checksummed region is divided
634 uint32_t total_chunks;
636 /** Number of chunks that have been SHA1-summed so far. Will
637 * be 0 initially, and equal to @p total_chunks at the end. */
638 uint32_t completed_chunks;
640 /** Size of the chunks used for the integrity calculation. */
643 /** Filename of the WIM (only valid if the message is
644 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
645 const wimlib_tchar *filename;
648 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
649 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
650 struct wimlib_progress_info_split {
651 /** Total size of the original WIM's file and metadata resources
653 uint64_t total_bytes;
655 /** Number of bytes of file and metadata resources that have
656 * been copied out of the original WIM so far. Will be 0
657 * initially, and equal to @p total_bytes at the end. */
658 uint64_t completed_bytes;
660 /** Number of the split WIM part that is about to be started
661 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
662 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
663 unsigned cur_part_number;
665 /** Total number of split WIM parts that are being written. */
666 unsigned total_parts;
668 /** Name of the split WIM part that is about to be started
669 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
670 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
671 const wimlib_tchar *part_name;
675 /** A user-supplied function that will be called periodically during certain WIM
676 * operations. The first argument will be the type of operation that is being
677 * performed or is about to be started or has been completed. The second
678 * argument will be a pointer to one of a number of structures depending on the
679 * first argument. It may be @c NULL for some message types.
681 * The return value of the progress function is currently ignored, but it may do
682 * something in the future. (Set it to 0 for now.)
684 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
685 const union wimlib_progress_info *info);
687 /** An array of these structures is passed to wimlib_add_image_multisource() to
688 * specify the sources from which to create a WIM image. */
689 struct wimlib_capture_source {
690 /** Absolute or relative path to a file or directory on the external
691 * filesystem to be included in the WIM image. */
692 wimlib_tchar *fs_source_path;
694 /** Destination path in the WIM image. Leading and trailing slashes are
695 * ignored. The empty string or @c NULL means the root directory of the
697 wimlib_tchar *wim_target_path;
699 /** Reserved; set to 0. */
703 /** Structure that specifies a list of path patterns. */
704 struct wimlib_pattern_list {
705 /** Array of patterns. The patterns may be modified by library code,
706 * but the @p pats pointer itself will not. See the man page for
707 * <b>wimlib-imagex capture</b> for more information about allowed
711 /** Number of patterns in the @p pats array. */
714 /** Ignored; may be used by the calling code. */
715 size_t num_allocated_pats;
718 /** A structure that contains lists of wildcards that match paths to treat
719 * specially when capturing a WIM image. */
720 struct wimlib_capture_config {
721 /** Paths matching any pattern this list are excluded from being
722 * captured, except if the same path appears in @p
723 * exclusion_exception_pats. */
724 struct wimlib_pattern_list exclusion_pats;
726 /** Paths matching any pattern in this list are never excluded from
728 struct wimlib_pattern_list exclusion_exception_pats;
730 /** Reserved for future capture configuration options. */
731 struct wimlib_pattern_list reserved1;
733 /** Reserved for future capture configuration options. */
734 struct wimlib_pattern_list reserved2;
736 /** Library internal use only. */
737 wimlib_tchar *_prefix;
739 /** Library internal use only. */
740 size_t _prefix_num_tchars;
743 /** Set or unset the WIM header flag that marks it read-only
744 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
745 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
746 * is distinct from basic file permissions; this flag can be set on a WIM file
747 * that is physically writable. If this flag is set, all further operations to
748 * modify the WIM will fail, except calling wimlib_overwrite() with
749 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
750 * allows you to set this flag persistently on the underlying WIM file.
752 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
754 /** Set the GUID (globally unique identifier) of the WIM file to the value
755 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
756 #define WIMLIB_CHANGE_GUID 0x00000002
758 /** Change the bootable image of the WIM to the value specified in
759 * ::wimlib_wim_info.boot_index of the @p info parameter. */
760 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
762 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
763 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
764 * indicates whether an image in the WIM has been captured with reparse-point
765 * fixups enabled. wimlib also treats this flag as specifying whether to do
766 * reparse-point fixups by default when capturing or applying WIM images. */
767 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
769 /** General information about a WIM file. */
770 struct wimlib_wim_info {
772 /** Globally unique identifier for the WIM file. Note: all parts of a
773 * split WIM should have an identical value in this field. */
774 uint8_t guid[WIMLIB_GUID_LEN];
776 /** Number of images in the WIM. */
777 uint32_t image_count;
779 /** 1-based index of the bootable image in the WIM, or 0 if no image is
783 /** Version of the WIM file. */
784 uint32_t wim_version;
786 /** Chunk size used for compression. */
789 /** For split WIMs, the 1-based index of this part within the split WIM;
791 uint16_t part_number;
793 /** For split WIMs, the total number of parts in the split WIM;
795 uint16_t total_parts;
797 /** One of the ::wimlib_compression_type values that specifies the
798 * method used to compress resources in the WIM. */
799 int32_t compression_type;
801 /** Size of the WIM file in bytes, excluding the XML data and integrity
803 uint64_t total_bytes;
805 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
806 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
807 * this will always be 0, even if the ::WIMStruct was written to
808 * somewhere by calling wimlib_write() with the
809 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
810 uint32_t has_integrity_table : 1;
812 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
813 * wimlib_create_new_wim(). */
814 uint32_t opened_from_file : 1;
816 /** 1 if the WIM is considered readonly for any reason. */
817 uint32_t is_readonly : 1;
819 /** 1 if reparse-point fixups are supposedly enabled for one or more
820 * images in the WIM. */
821 uint32_t has_rpfix : 1;
823 /** 1 if the WIM is marked as read-only. */
824 uint32_t is_marked_readonly : 1;
826 /** 1 if the WIM is part of a spanned set. */
827 uint32_t spanned : 1;
829 uint32_t write_in_progress : 1;
830 uint32_t metadata_only : 1;
831 uint32_t resource_only : 1;
833 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
834 uint32_t pipable : 1;
835 uint32_t reserved_flags : 22;
836 uint32_t reserved[9];
839 /** Information about a unique resource in the WIM file.
841 struct wimlib_resource_entry {
842 /** Uncompressed size of the resource in bytes. */
843 uint64_t uncompressed_size;
845 /** Compressed size of the resource in bytes. This will be the same as
846 * @p uncompressed_size if the resource is uncompressed. */
847 uint64_t compressed_size;
849 /** Offset, in bytes, of this resource from the start of the WIM file.
853 /** SHA1 message digest of the resource's uncompressed contents. */
854 uint8_t sha1_hash[20];
856 /** Which part number of the split WIM this resource is in. This should
857 * be the same as the part number provided by wimlib_get_wim_info(). */
858 uint32_t part_number;
860 /** Number of times this resource is referenced over all WIM images. */
861 uint32_t reference_count;
863 /** 1 if this resource is compressed. */
864 uint32_t is_compressed : 1;
866 /** 1 if this resource is a metadata resource rather than a file
868 uint32_t is_metadata : 1;
870 uint32_t is_free : 1;
871 uint32_t is_spanned : 1;
873 /** 1 if this resource was not found in the lookup table of the
874 * ::WIMStruct. This normally implies a missing call to
875 * wimlib_reference_resource_files() or wimlib_reference_resources().
877 uint32_t is_missing : 1;
879 uint32_t reserved_flags : 27;
880 uint64_t reserved[4];
883 /** A stream of a file in the WIM. */
884 struct wimlib_stream_entry {
885 /** Name of the stream, or NULL if the stream is unnamed. */
886 const wimlib_tchar *stream_name;
887 /** Location, size, etc. of the stream within the WIM file. */
888 struct wimlib_resource_entry resource;
889 uint64_t reserved[4];
892 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
893 * Roughly, the information about a "file" in the WIM--- but really a directory
894 * entry ("dentry") because hard links are allowed. The hard_link_group_id
895 * field can be used to distinguish actual file inodes. */
896 struct wimlib_dir_entry {
897 /** Name of the file, or NULL if this file is unnamed (only possible for
898 * the root directory) */
899 const wimlib_tchar *filename;
901 /** 8.3 DOS name of this file, or NULL if this file has no such name.
903 const wimlib_tchar *dos_name;
905 /** Full path to this file within the WIM image. */
906 const wimlib_tchar *full_path;
908 /** Depth of this directory entry, where 0 is the root, 1 is the root's
909 * children, ..., etc. */
912 /** Pointer to the security descriptor for this file, in Windows
913 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
914 * security descriptor. */
915 const char *security_descriptor;
917 /** Length of the above security descriptor. */
918 size_t security_descriptor_size;
920 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
921 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
922 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
923 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
924 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
925 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
926 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
927 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
928 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
929 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
930 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
931 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
932 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
933 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
934 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
935 /** File attributes, such as whether the file is a directory or not.
936 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
937 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
938 * on other platforms. */
941 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
942 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
943 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
944 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
945 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
946 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
947 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
948 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
949 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
950 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
951 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
952 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
953 * attributes), this will give the reparse tag. This tells you whether
954 * the reparse point is a symbolic link, junction point, or some other,
955 * more unusual kind of reparse point. */
956 uint32_t reparse_tag;
958 /* Number of (hard) links to this file. */
961 /** Number of named data streams that this file has. Normally 0. */
962 uint32_t num_named_streams;
964 /** Roughly, the inode number of this file. However, it may be 0 if
965 * @p num_links == 1. */
966 uint64_t hard_link_group_id;
968 /** Time this file was created. */
969 struct timespec creation_time;
971 /** Time this file was last written to. */
972 struct timespec last_write_time;
974 /** Time this file was last accessed. */
975 struct timespec last_access_time;
976 uint64_t reserved[16];
978 /** Array of streams that make up this file. The first entry will
979 * always exist and will correspond to the unnamed data stream (default
980 * file contents), so it will have @p stream_name == @c NULL. There
981 * will then be @p num_named_streams additional entries that specify the
982 * named data streams, if any, each of which will have @p stream_name !=
984 struct wimlib_stream_entry streams[];
988 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
991 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
995 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
998 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
1002 * @name Directory tree iteration flags
1004 * The following flags can be passed to wimlib_iterate_dir_tree().
1009 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
1010 * just on the specified path. */
1011 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
1013 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
1014 * itself; only its children (in the case of a non-empty directory) */
1015 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
1017 /** Return ::WIMLIB_ERR_RESOURCE_NOT_FOUND if any resources needed to fill in
1018 * the ::wimlib_resource_entry's for the iteration cannot be found in the lookup
1019 * table of the ::WIMStruct. The default behavior without this flag is to fill
1020 * in the SHA1 message digest of the ::wimlib_resource_entry and set the @ref
1021 * wimlib_resource_entry::is_missing "is_missing" flag. */
1022 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED 0x00000004
1028 * The following flags can be passed to wimlib_add_image(),
1029 * wimlib_add_image_multisource(), and add commands passed to
1030 * wimlib_update_image().
1035 /** Directly capture a NTFS volume rather than a generic directory. This flag
1036 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
1037 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
1038 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
1040 /** Follow symlinks; archive and dump the files they point to. Cannot be used
1041 * with ::WIMLIB_ADD_FLAG_NTFS. */
1042 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
1044 /** Call the progress function with the message
1045 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
1046 * be scanned, or when a directory or file is being excluded from capture. */
1047 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
1049 /** Mark the image being added as the bootable image of the WIM. */
1050 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
1052 /** Store the UNIX owner, group, and mode. This is done by adding a special
1053 * alternate data stream to each regular file, symbolic link, and directory to
1054 * contain this information. Please note that this flag is for convenience
1055 * only; Microsoft's @a imagex.exe will not understand this special information.
1056 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
1057 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
1059 /** Do not capture security descriptors. Only has an effect in NTFS capture
1060 * mode, or in Win32 native builds. */
1061 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
1063 /** Fail immediately if the full security descriptor of any file or directory
1064 * cannot be accessed. Only has an effect in Win32 native builds. The default
1065 * behavior without this flag is to first try omitting the SACL from the
1066 * security descriptor, then to try omitting the security descriptor entirely.
1068 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
1070 /** Call the progress function with the message
1071 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
1072 * capture. This is a subset of the messages provided by
1073 * ::WIMLIB_ADD_FLAG_VERBOSE. */
1074 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
1076 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
1077 * in the case of Windows) that point inside the directory being captured to
1078 * instead be absolute relative to the directory being captured, rather than the
1079 * current root; also exclude absolute symbolic links that point outside the
1080 * directory tree being captured.
1082 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
1083 * the WIM header or if this is the first image being added.
1084 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
1085 * reparse point fixups enabled and currently cannot be unset. */
1086 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
1088 /** Don't do reparse point fixups. The default behavior is described in the
1089 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
1090 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
1092 /** Do not automatically exclude unsupported files or directories from capture;
1093 * e.g. encrypted directories in NTFS-3g capture mode, or device files and FIFOs
1094 * on UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
1095 * such a file is encountered. */
1096 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
1098 /** Automatically select a capture configuration appropriate for capturing
1099 * filesystems containing Windows operating systems. When this flag is
1100 * specified, the corresponding @p config parameter or member must be @c NULL.
1102 * Currently, selecting this capture configuration will cause the following
1103 * files and directories to be excluded from capture:
1108 * - "\System Volume Information"
1112 * Note that the default behavior--- that is, when this flag is not specified
1113 * and @p config is @c NULL--- is to use no capture configuration, meaning that
1114 * no files are excluded from capture.
1116 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1118 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1119 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1120 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1121 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1122 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1123 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1124 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1125 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1126 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1127 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1128 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1129 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1130 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1133 * @name Delete flags
1135 * The following flags can be specified in delete commands passed to
1136 * wimlib_update_image().
1141 /** Do not issue an error if the path to delete does not exist. */
1142 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1144 /** Delete the file or directory tree recursively; if not specified, an error is
1145 * issued if the path to delete is a directory. */
1146 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1149 * @name Export flags
1151 * The following flags can be passed to wimlib_export_image().
1157 * If a single image is being exported, mark it bootable in the destination WIM.
1158 * Alternatively, if ::WIMLIB_ALL_IMAGES is specified as the image to export,
1159 * the image in the source WIM (if any) that is marked as bootable is also
1160 * marked as bootable in the destination WIM.
1162 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1164 /** Give the exported image(s) no names. Avoids problems with image name
1167 #define WIMLIB_EXPORT_FLAG_NO_NAMES 0x00000002
1169 /** Give the exported image(s) no descriptions. */
1170 #define WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS 0x00000004
1173 * @name Extract flags
1175 * The following flags can be passed to wimlib_extract_image(),
1176 * wimlib_extract_files(), and wimlib_extract_image_from_pipe().
1181 /** Extract the image directly to a NTFS volume rather than a generic directory.
1182 * This mode is only available if wimlib was compiled with libntfs-3g support;
1183 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1184 * extraction target will be interpreted as the path to a NTFS volume image (as
1185 * a regular file or block device) rather than a directory. It will be opened
1186 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1187 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1188 * is called with ::WIMLIB_ALL_IMAGES as the @p image. */
1189 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1191 /** When identical files are extracted from the WIM, always hard link them
1193 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
1195 /** When identical files are extracted from the WIM, always symlink them
1197 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
1199 /** This flag no longer does anything but is reserved for future use. */
1200 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
1202 /** Read the WIM file sequentially while extracting the image. */
1203 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
1205 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA. Only
1206 * valid on UNIX-like platforms, and when ::WIMLIB_EXTRACT_FLAG_NTFS was not
1208 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1210 /** Do not extract security descriptors. */
1211 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1213 /** Fail immediately if the full security descriptor of any file or directory
1214 * cannot be set exactly as specified in the WIM file. On Windows, the default
1215 * behavior without this flag is to fall back to setting the security descriptor
1216 * with the SACL omitted, then only the default inherited security descriptor,
1217 * if we do not have permission to set the desired one. */
1218 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1220 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1221 * reparse-point fixups on, so absolute symbolic links or junction points will
1222 * be fixed to be absolute relative to the actual extraction root. Reparse
1223 * point fixups are done by default if WIM_HDR_FLAG_RP_FIX is set in the WIM
1224 * header. This flag may only be specified when extracting a full image (not a
1225 * file or directory tree within one). */
1226 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1228 /** Force reparse-point fixups on extraction off, regardless of the state of the
1229 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. */
1230 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1232 /** Extract the specified file to standard output. This is only valid in an
1233 * extraction command that specifies the extraction of a regular file in the WIM
1235 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1237 /** Instead of ignoring files and directories with names that cannot be
1238 * represented on the current platform (note: Windows has more restrictions on
1239 * filenames than POSIX-compliant systems), try to replace characters or append
1240 * junk to the names so that they can be extracted in some form. */
1241 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1243 /** On Windows, when there exist two or more files with the same case
1244 * insensitive name but different case sensitive names, try to extract them all
1245 * by appending junk to the end of them, rather than arbitrarily extracting only
1247 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1249 /** Do not ignore failure to set timestamps on extracted files. */
1250 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1252 /** Do not ignore failure to set short names on extracted files. */
1253 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1255 /** Do not ignore failure to extract symbolic links (and junction points, on
1256 * Windows) due to permissions problems. By default, such failures are ignored
1257 * since the default configuration of Windows only allows the Administrator to
1258 * create symbolic links. */
1259 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1261 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1262 * behavior is currently less than satisfactory. Do not use (yet). */
1263 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1268 * The following flags can be passed to wimlib_mount_image().
1273 /** Mount the WIM image read-write rather than the default of read-only. */
1274 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1276 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1277 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1279 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1280 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1282 /** Access alternate data streams in the mounted WIM image through extended file
1283 * attributes. This is the default mode. */
1284 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1286 /** Access alternate data streams in the mounted WIM image by specifying the
1287 * file name, a colon, then the alternate file stream name. */
1288 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1290 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1291 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1292 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1294 /** Allow other users to see the mounted filesystem. (this passes the @c
1295 * allow_other option to FUSE mount) */
1296 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1301 * The following flags can be passed to wimlib_open_wim() and several other
1302 * functions such as wimlib_join().
1306 /** Verify the WIM contents against the WIM's integrity table, if present. This
1307 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1308 * checksummed and checked against the SHA1 message digests specified in the
1309 * integrity table. ::WIMLIB_ERR_INTEGRITY is returned if there are any
1310 * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1311 * integrity table is invalid). */
1312 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1314 /** Issue an error if the WIM is part of a split WIM. */
1315 #define WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT 0x00000002
1317 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1318 * is not. A WIM is considered writable only if it is writable at the
1319 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1320 * header, and is not part of a spanned set. It is not required to provide this
1321 * flag before attempting to make changes to the WIM, but with this flag you get
1322 * an error sooner rather than later. */
1323 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1326 * @name Unmount flags
1328 * The following flags can be passed to wimlib_unmount_image().
1332 /** See ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
1333 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1335 /** Unless this flag is given, changes to a read-write mounted WIM are
1336 * discarded. Ignored for read-only mounts. */
1337 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1339 /** See ::WIMLIB_WRITE_FLAG_REBUILD. */
1340 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1342 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1343 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1345 /** Do a "lazy" unmount (detach filesystem immediately, even if busy). */
1346 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1349 * @name Update flags
1351 * The following flags can be passed to wimlib_update_image().
1355 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1356 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1357 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1362 * The following flags can be passed to wimlib_write(), wimlib_overwrite(),
1363 * wimlib_write_to_fd(), and several other functions such as wimlib_join().
1367 /** Include an integrity table in the WIM.
1369 * For WIMs created with wimlib_open_wim(), the default behavior is to include
1370 * an integrity table if and only if one was present before. For WIMs created
1371 * with wimlib_create_new_wim(), the default behavior is to not include an
1372 * integrity table. */
1373 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1375 /** Do not include an integrity table in the new WIM file. This is the default
1376 * behavior, unless the WIM already included an integrity table. */
1377 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1379 /** Write the WIM as "pipable". After writing a WIM with this flag specified,
1380 * images from it can be applied directly from a pipe using
1381 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1382 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1383 * with this flag will not be compatible with Microsoft's software.
1385 * For WIMs created with wimlib_open_wim(), the default behavior is to write the
1386 * WIM as pipable if and only if it was pipable before. For WIMs created with
1387 * wimlib_create_new_wim(), the default behavior is to write the WIM as
1389 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1391 /** Do not write the WIM as "pipable". This is the default behavior, unless the
1392 * WIM was pipable already. */
1393 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1395 /** Recompress all resources, even if they could otherwise be copied from a
1396 * different WIM with the same compression type (in the case of
1397 * wimlib_export_image() being called previously). This flag is also valid in
1398 * the @p wim_write_flags of wimlib_join(), in which case all resources included
1399 * in the joined WIM file will be recompressed. */
1400 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1402 /** Call fsync() just before the WIM file is closed. */
1403 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1405 /** wimlib_overwrite() only: Re-build the entire WIM file rather than appending
1406 * data to it if possible. */
1407 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1409 /** wimlib_overwrite() only: Specifying this flag overrides the default
1410 * behavior of wimlib_overwrite() after one or more calls to
1411 * wimlib_delete_image(), which is to rebuild the entire WIM. With this flag,
1412 * only minimal changes to correctly remove the image from the WIM will be
1413 * taken. In particular, all streams will be left alone, even if they are no
1414 * longer referenced. This is probably not what you want, because almost no
1415 * space will be saved by deleting an image in this way. */
1416 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1418 /** wimlib_overwrite() only: Allow overwriting the WIM even if the readonly
1419 * flag is set in the WIM header. This can be used in combination with
1420 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1421 * set the readonly flag on the on-disk WIM file. */
1422 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1424 /** Do not include non-metadata resources already present in other WIMs. This
1425 * flag can be used to write a "delta" WIM after resources from the WIM on which
1426 * the delta is to be based were referenced with
1427 * wimlib_reference_resource_files() or wimlib_reference_resources(). */
1428 #define WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS 0x00000200
1430 /** Asserts that for writes of all WIM images, all streams needed for the WIM
1431 * are already present (not in external resource WIMs) and their reference
1432 * counts are correct, so the code does not need to recalculate which streams
1433 * are referenced. This is for optimization purposes only, since with this flag
1434 * specified, the metadata resources may not need to be decompressed and parsed.
1436 * This flag can be passed to wimlib_write() and wimlib_write_to_fd(), but is
1437 * already implied for wimlib_overwrite(). */
1438 #define WIMLIB_WRITE_FLAG_STREAMS_OK 0x00000400
1443 * The following flags can be passed to wimlib_global_init().
1447 /** Assume that strings are represented in UTF-8, even if this is not the
1448 * locale's character encoding. This flag is ignored on Windows, where wimlib
1449 * always uses UTF-16LE. */
1450 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1452 /** Windows-only: do not attempt to acquire additional privileges (currently
1453 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1454 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1455 * for the case where the calling program manages these privileges itself.
1456 * Note: no error is issued if privileges cannot be acquired, although related
1457 * errors may be reported later, depending on if the operations performed
1458 * actually require additional privileges or not. */
1459 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1461 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1462 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1463 * to read all possible data and metadata for a capture operation could not be
1464 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1466 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1468 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1469 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1470 * to restore all possible data and metadata for an apply operation could not be
1471 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1473 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1476 * @name Resource reference flags
1478 * The following flags can be passed to wimlib_reference_resource_files() and
1479 * wimlib_reference_resources().
1483 /** wimlib_reference_resource_files() only: Enable shell-style filename
1485 #define WIMLIB_REF_FLAG_GLOB_ENABLE 0x00000001
1487 /** wimlib_reference_resource_files() only: Issue an error
1488 * (::WIMLIB_ERR_GLOB_HAD_NO_MATCHES) if a glob did not match any files. The
1489 * default behavior without this flag is to issue no error at that point, but
1490 * then attempt to open the glob as a literal path, which of course will fail
1491 * anyway if no file exists at that path. No effect if
1492 * ::WIMLIB_REF_FLAG_GLOB_ENABLE is not also specified. */
1493 #define WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH 0x00000002
1499 /** The specific type of update to perform. */
1500 enum wimlib_update_op {
1501 /** Add a new file or directory tree to the WIM image in a
1502 * certain location. */
1503 WIMLIB_UPDATE_OP_ADD = 0,
1505 /** Delete a file or directory tree from the WIM image. */
1506 WIMLIB_UPDATE_OP_DELETE,
1508 /** Rename a file or directory tree in the WIM image. */
1509 WIMLIB_UPDATE_OP_RENAME,
1512 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1513 struct wimlib_add_command {
1514 /** Filesystem path to the file or directory tree to
1516 wimlib_tchar *fs_source_path;
1517 /** Path, specified from the root of the WIM image, at
1518 * which to add the file or directory tree within the
1520 wimlib_tchar *wim_target_path;
1522 /** Configuration for excluded files. @c NULL means
1523 * exclude no files (use no configuration), unless
1524 * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
1526 struct wimlib_capture_config *config;
1528 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1532 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1533 struct wimlib_delete_command {
1534 /** Path, specified from the root of the WIM image, for
1535 * the file or directory tree within the WIM image to be
1537 wimlib_tchar *wim_path;
1538 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1542 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1543 struct wimlib_rename_command {
1544 /** Path, specified from the root of the WIM image, for
1545 * the source file or directory tree within the WIM
1547 wimlib_tchar *wim_source_path;
1548 /** Path, specified from the root of the WIM image, for
1549 * the destination file or directory tree within the WIM
1551 wimlib_tchar *wim_target_path;
1552 /** Reserved; set to 0. */
1556 /** Specification of an update to perform on a WIM image. */
1557 struct wimlib_update_command {
1559 enum wimlib_update_op op;
1562 struct wimlib_add_command add;
1563 struct wimlib_delete_command delete_; /* Underscore is for C++
1565 struct wimlib_rename_command rename;
1569 /** Specification of a file or directory tree to extract from a WIM image. */
1570 struct wimlib_extract_command {
1571 /** Path to file or directory tree within the WIM image to extract. It
1572 * must be provided as an absolute path from the root of the WIM image.
1573 * The path separators may be either forward slashes or backslashes. */
1574 wimlib_tchar *wim_source_path;
1576 /** Filesystem path to extract the file or directory tree to. */
1577 wimlib_tchar *fs_dest_path;
1579 /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1584 * Possible values of the error code returned by many functions in wimlib.
1586 * See the documentation for each wimlib function to see specifically what error
1587 * codes can be returned by a given function, and what they mean.
1589 enum wimlib_error_code {
1590 WIMLIB_ERR_SUCCESS = 0,
1591 WIMLIB_ERR_ALREADY_LOCKED,
1592 WIMLIB_ERR_DECOMPRESSION,
1593 WIMLIB_ERR_DELETE_STAGING_DIR,
1594 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1597 WIMLIB_ERR_FUSERMOUNT,
1598 WIMLIB_ERR_GLOB_HAD_NO_MATCHES,
1599 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1600 WIMLIB_ERR_IMAGE_COUNT,
1601 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1602 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES,
1603 WIMLIB_ERR_INTEGRITY,
1604 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1605 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1606 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1607 WIMLIB_ERR_INVALID_HEADER,
1608 WIMLIB_ERR_INVALID_IMAGE,
1609 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1610 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1611 WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1612 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1613 WIMLIB_ERR_INVALID_OVERLAY,
1614 WIMLIB_ERR_INVALID_PARAM,
1615 WIMLIB_ERR_INVALID_PART_NUMBER,
1616 WIMLIB_ERR_INVALID_PIPABLE_WIM,
1617 WIMLIB_ERR_INVALID_REPARSE_DATA,
1618 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1619 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1620 WIMLIB_ERR_INVALID_UTF16_STRING,
1621 WIMLIB_ERR_INVALID_UTF8_STRING,
1622 WIMLIB_ERR_IS_DIRECTORY,
1623 WIMLIB_ERR_IS_SPLIT_WIM,
1624 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1626 WIMLIB_ERR_METADATA_NOT_FOUND,
1631 WIMLIB_ERR_NOTEMPTY,
1632 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1633 WIMLIB_ERR_NOT_A_WIM_FILE,
1634 WIMLIB_ERR_NOT_PIPABLE,
1635 WIMLIB_ERR_NO_FILENAME,
1639 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1641 WIMLIB_ERR_READLINK,
1644 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1645 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1646 WIMLIB_ERR_RESOURCE_ORDER,
1647 WIMLIB_ERR_SET_ATTRIBUTES,
1648 WIMLIB_ERR_SET_REPARSE_DATA,
1649 WIMLIB_ERR_SET_SECURITY,
1650 WIMLIB_ERR_SET_SHORT_NAME,
1651 WIMLIB_ERR_SET_TIMESTAMPS,
1652 WIMLIB_ERR_SPLIT_INVALID,
1655 WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
1656 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1657 WIMLIB_ERR_UNKNOWN_VERSION,
1658 WIMLIB_ERR_UNSUPPORTED,
1659 WIMLIB_ERR_UNSUPPORTED_FILE,
1660 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1661 WIMLIB_ERR_WIM_IS_READONLY,
1667 /** Used to indicate no WIM image or an invalid WIM image. */
1668 #define WIMLIB_NO_IMAGE 0
1670 /** Used to specify all images in the WIM. */
1671 #define WIMLIB_ALL_IMAGES (-1)
1674 * Appends an empty image to a WIM file. This empty image will initially
1675 * contain no files or directories, although if written without further
1676 * modifications, a root directory will be created automatically for it. After
1677 * calling this function, you can use wimlib_update_image() to add files to the
1678 * new WIM image. This gives you slightly more control over making the new
1679 * image compared to calling wimlib_add_image() or
1680 * wimlib_add_image_multisource() directly.
1683 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
1686 * Name to give the new image. If @c NULL or empty, the new image is given
1687 * no name. If nonempty, it must specify a name that does not already
1689 * @param new_idx_ret
1690 * If non-<code>NULL</code>, the index of the newly added image is returned
1693 * @return 0 on success; nonzero on failure. The possible error codes are:
1695 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1696 * There is already an image in @p wim named @p name.
1697 * @retval ::WIMLIB_ERR_NOMEM
1698 * Failed to allocate the memory needed to add the new image.
1699 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1700 * The WIM file is considered read-only because of any of the reasons
1701 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1705 wimlib_add_empty_image(WIMStruct *wim,
1706 const wimlib_tchar *name,
1710 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1712 * The directory tree or NTFS volume is scanned immediately to load the dentry
1713 * tree into memory, and file attributes and symbolic links are read. However,
1714 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1717 * See the manual page for the @b wimlib-imagex program for more information
1718 * about the "normal" capture mode versus the NTFS capture mode (entered by
1719 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1721 * Note that @b no changes are committed to the underlying WIM file (if
1722 * any) until wimlib_write() or wimlib_overwrite() is called.
1725 * Pointer to the ::WIMStruct for a WIM file to which the image will be
1728 * A path to a directory or unmounted NTFS volume that will be captured as
1731 * Name to give the new image. If @c NULL or empty, the new image is given
1732 * no name. If nonempty, it must specify a name that does not already
1735 * Capture configuration that specifies files, directories, or path globs
1736 * to exclude from being captured. If @c NULL, a dummy configuration where
1737 * no paths are treated specially is used.
1739 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1740 * @param progress_func
1741 * If non-NULL, a function that will be called periodically with the
1742 * progress of the current operation. The progress messages that will be
1743 * received are ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
1744 * ::WIMLIB_PROGRESS_MSG_SCAN_END, and, if ::WIMLIB_ADD_FLAG_VERBOSE was
1745 * included in @p add_flags, also ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
1747 * @return 0 on success; nonzero on error. On error, changes to @p wim are
1748 * discarded so that it appears to be in the same state as when this function
1751 * This function is implemented by calling wimlib_add_empty_image(), then
1752 * calling wimlib_update_image() with a single "add" command, so any error code
1753 * returned by wimlib_add_empty_image() may be returned, as well as any error
1754 * codes returned by wimlib_update_image() other than ones documented as only
1755 * being returned specifically by an update involving delete or rename commands.
1758 wimlib_add_image(WIMStruct *wim,
1759 const wimlib_tchar *source,
1760 const wimlib_tchar *name,
1761 const struct wimlib_capture_config *config,
1763 wimlib_progress_func_t progress_func);
1765 /** This function is equivalent to wimlib_add_image() except it allows for
1766 * multiple sources to be combined into a single WIM image. This is done by
1767 * specifying the @p sources and @p num_sources parameters instead of the @p
1768 * source parameter of wimlib_add_image(). The rest of the parameters are the
1769 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
1770 * capture</b> for full details on how this mode works.
1772 * In addition to the error codes that wimlib_add_image() can return,
1773 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1774 * when trying to overlay a non-directory on a directory or when otherwise
1775 * trying to overlay multiple conflicting files to the same location in the WIM
1776 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
1777 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
1778 * was not exactly one capture source with the target being the root directory.
1779 * (In this respect, there is no advantage to using
1780 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1783 wimlib_add_image_multisource(WIMStruct *wim,
1784 const struct wimlib_capture_source *sources,
1786 const wimlib_tchar *name,
1787 const struct wimlib_capture_config *config,
1789 wimlib_progress_func_t progress_func);
1792 * Creates a ::WIMStruct for a new WIM file.
1794 * This only creates an in-memory structure for a WIM that initially contains no
1795 * images. No on-disk file is created until wimlib_write() is called.
1798 * The type of compression to be used in the new WIM file. Must be
1799 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
1800 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1802 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
1803 * written to the memory location pointed to by this paramater. The
1804 * ::WIMStruct must be freed using using wimlib_free() when finished with
1806 * @return 0 on success; nonzero on error.
1807 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1808 * @p ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
1809 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1810 * @retval ::WIMLIB_ERR_NOMEM
1811 * Failed to allocate needed memory.
1814 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
1817 * Deletes an image, or all images, from a WIM file.
1819 * All streams referenced by the image(s) being deleted are removed from the
1820 * lookup table of the WIM if they are not referenced by any other images in the
1823 * Please note that @b no changes are committed to the underlying WIM file (if
1824 * any) until wimlib_write() or wimlib_overwrite() is called.
1827 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
1830 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
1832 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
1833 * to be left unmodified only if @p image specified a single image. If instead
1834 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
1835 * possible for some but not all of the images to have been deleted when a
1836 * failure status is returned.
1838 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1839 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
1840 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1841 * The WIM file is considered read-only because of any of the reasons
1842 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1845 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
1846 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
1847 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
1848 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
1849 * different reasons) to read the metadata resource for an image that needed to
1853 wimlib_delete_image(WIMStruct *wim, int image);
1856 * Exports an image, or all the images, from a WIM file, into another WIM file.
1858 * The destination image is made to share the same dentry tree and security data
1859 * structure as the source image. This places some restrictions on additional
1860 * functions that may be called. wimlib_mount_image() may not be called on
1861 * either the source image or the destination image without an intervening call
1862 * to a function that un-shares the images, such as wimlib_free() on @p
1863 * dest_wim, or wimlib_delete_image() on either the source or destination image.
1864 * Furthermore, you may not call wimlib_free() on @p src_wim before calling
1865 * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
1866 * have references back to @p src_wim.
1868 * If this function fails, all changes to @p dest_wim are rolled back.
1870 * Please note that no changes are committed to the underlying WIM file of @p
1871 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
1874 * The WIM from which to export the images, specified as a pointer to the
1875 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
1876 * split WIM. In the case of a WIM file that is not standalone, this
1877 * ::WIMStruct must have had any needed external resources previously
1878 * referenced using wimlib_reference_resources() or
1879 * wimlib_reference_resource_files().
1881 * The image to export from @p src_wim, as either a 1-based image index to
1882 * export a single image, or ::WIMLIB_ALL_IMAGES to export all images.
1884 * Pointer to the ::WIMStruct for a WIM that will receive the images being
1887 * For single-image exports, the name to give the exported image in @p
1888 * dest_wim. If left @c NULL, the name from @p src_wim is used. For
1889 * ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c NULL; in
1890 * that case, the names are all taken from @p src_wim. This parameter is
1891 * overridden by ::WIMLIB_EXPORT_FLAG_NO_NAMES.
1892 * @param dest_description
1893 * For single-image exports, the description to give the exported image in
1894 * the new WIM file. If left @c NULL, the description from @p src_wim is
1895 * used. For ::WIMLIB_ALL_IMAGES exports, this parameter must be left @c
1896 * NULL; in that case, the description are all taken from @p src_wim. This
1897 * parameter is overridden by ::WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS.
1898 * @param export_flags
1899 * Bitwise OR of flags prefixed with WIMLIB_EXPORT_FLAG.
1900 * @param progress_func
1901 * Currently ignored, but reserved for a function that will be called with
1902 * information about the operation. Use NULL if no additional information
1905 * @return 0 on success; nonzero on error.
1906 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1907 * One or more of the names being given to an exported image was already in
1908 * use in the destination WIM.
1909 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1910 * @p src_image does not exist in @p src_wim and was not
1911 * ::WIMLIB_ALL_IMAGES.
1912 * @retval ::WIMLIB_ERR_INVALID_PARAM
1913 * @p src_wim and/or @p dest_wim were @c NULL; or @p src_image was
1914 * ::WIMLIB_ALL_IMAGES but @p dest_name and/or @p dest_description were not
1916 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
1917 * Either @p src_wim or @p dest_wim did not contain metadata resources; for
1918 * example, one of them was a non-first part of a split WIM.
1919 * @retval ::WIMLIB_ERR_NOMEM
1920 * Failed to allocate needed memory.
1921 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
1922 * A resource that needed to be exported could not be found in either the
1923 * source or destination WIMs. This error can occur if, for example, @p
1924 * src_wim is part of a split WIM but needed resources from the other split
1925 * WIM parts were not referenced with wimlib_reference_resources() or
1926 * wimlib_reference_resource_files() before the call to
1927 * wimlib_export_image().
1928 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1929 * @p dest_wim is considered read-only because of any of the reasons
1930 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1933 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
1934 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
1935 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
1936 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
1937 * different reasons) to read the metadata resource for an image in @p src_wim
1938 * that needed to be exported.
1941 wimlib_export_image(WIMStruct *src_wim, int src_image,
1942 WIMStruct *dest_wim,
1943 const wimlib_tchar *dest_name,
1944 const wimlib_tchar *dest_description,
1946 wimlib_progress_func_t progress_func);
1949 * Extract zero or more files or directory trees from a WIM image.
1951 * This generalizes the single-image extraction functionality of
1952 * wimlib_extract_image() to allow extracting only the specified subsets of the
1956 * The WIM from which to extract the files, specified as a pointer to the
1957 * ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1 of a
1958 * split WIM. In the case of a WIM file that is not standalone, this
1959 * ::WIMStruct must have had any needed external resources previously
1960 * referenced using wimlib_reference_resources() or
1961 * wimlib_reference_resource_files().
1964 * The 1-based number of the image in @p wim from which the files or
1965 * directory trees are to be extracted. It cannot be ::WIMLIB_ALL_IMAGES.
1968 * An array of ::wimlib_extract_command structures that specifies the
1969 * extractions to perform.
1972 * Number of commands in the @p cmds array.
1974 * @param default_extract_flags
1975 * Default extraction flags; the behavior shall be as if these flags had
1976 * been specified in the ::wimlib_extract_command.extract_flags member in
1977 * each extraction command, in combination with any flags already present.
1979 * @param progress_func
1980 * If non-NULL, a function that will be called periodically with the
1981 * progress of the current operation.
1983 * @return 0 on success; nonzero on error. The possible error codes include
1984 * most of those documented as returned by wimlib_extract_image() as well as the
1985 * following additional error codes:
1987 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1988 * @p image was ::WIMLIB_ALL_IMAGES (or was not otherwise a valid image in
1990 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
1991 * The ::wimlib_extract_command.wim_source_path member in one of the
1992 * extract commands did not exist in the WIM.
1993 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
1994 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
1995 * in which ::wimlib_extract_command.wim_source_path existed but was not a
1996 * regular file or directory.
1997 * @retval ::WIMLIB_ERR_INVALID_PARAM
1998 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
1999 * specified for some commands but not all; or
2000 * ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
2001 * for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
2002 * for a command in which ::wimlib_extract_command.wim_source_path did not
2003 * specify the root directory of the WIM image.
2006 wimlib_extract_files(WIMStruct *wim,
2008 const struct wimlib_extract_command *cmds,
2010 int default_extract_flags,
2011 wimlib_progress_func_t progress_func);
2014 * Extracts an image, or all images, from a WIM to a directory or directly to a
2015 * NTFS volume image.
2017 * The exact behavior of how wimlib extracts files from a WIM image is
2018 * controllable by the @p extract_flags parameter, but there also are
2019 * differences depending on the platform (UNIX-like vs Windows). See the manual
2020 * page for <b>wimlib-imagex apply</b> for more information, including about the
2021 * special "NTFS volume extraction mode" entered by providing
2022 * ::WIMLIB_EXTRACT_FLAG_NTFS.
2024 * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
2025 * returned if any resulting SHA1 message digests do not match the values
2026 * provided in the WIM file. Therefore, if this function is successful, you can
2027 * be fairly sure that any compressed data in the WIM was uncompressed
2031 * The WIM from which to extract the image(s), specified as a pointer to
2032 * the ::WIMStruct for a standalone WIM file, a delta WIM file, or part 1
2033 * of a split WIM. In the case of a WIM file that is not standalone, this
2034 * ::WIMStruct must have had any needed external resources previously
2035 * referenced using wimlib_reference_resources() or
2036 * wimlib_reference_resource_files().
2038 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
2039 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
2040 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
2042 * Directory to extract the WIM image(s) to (created if it does not already
2043 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @p extract_flags, the
2044 * path to the unmounted NTFS volume to extract the image to.
2045 * @param extract_flags
2046 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
2047 * @param progress_func
2048 * If non-NULL, a function that will be called periodically with the
2049 * progress of the current operation.
2051 * @return 0 on success; nonzero on error.
2052 * @retval ::WIMLIB_ERR_DECOMPRESSION
2053 * Failed to decompress a resource to be extracted.
2054 * @retval ::WIMLIB_ERR_INVALID_PARAM
2055 * Both ::WIMLIB_EXTRACT_FLAG_HARDLINK and ::WIMLIB_EXTRACT_FLAG_SYMLINK
2056 * were specified in @p extract_flags; or both
2057 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS and ::WIMLIB_EXTRACT_FLAG_NO_ACLS were
2058 * specified in @p extract_flags; or both ::WIMLIB_EXTRACT_FLAG_RPFIX and
2059 * ::WIMLIB_EXTRACT_FLAG_NORPFIX were specified in @p extract_flags; or
2060 * ::WIMLIB_EXTRACT_FLAG_RESUME was specified in @p extract_flags; or if
2061 * ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @p extract_flags and
2062 * @p image was ::WIMLIB_ALL_IMAGES.
2063 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2064 * The SHA1 message digest of an extracted stream did not match the SHA1
2065 * message digest given in the WIM file.
2066 * @retval ::WIMLIB_ERR_LINK
2067 * Failed to create a symbolic link or a hard link.
2068 * @retval ::WIMLIB_ERR_MKDIR
2069 * Failed create a directory.
2070 * @retval ::WIMLIB_ERR_NOMEM
2071 * Failed to allocate needed memory.
2072 * @retval ::WIMLIB_ERR_OPEN
2073 * Could not create a file, or failed to open an already-extracted file.
2074 * @retval ::WIMLIB_ERR_READ
2075 * Failed to read data from the WIM file associated with @p wim.
2076 * @retval ::WIMLIB_ERR_READLINK
2077 * Failed to determine the target of a symbolic link in the WIM.
2078 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2079 * Failed to fix the target of an absolute symbolic link (e.g. if the
2080 * target would have exceeded the maximum allowed length). (Only if
2081 * reparse data was supported by the extraction mode and
2082 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p extract_flags.)
2083 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2084 * One of the files or directories that needed to be extracted referenced a
2085 * stream not present in the WIM's lookup table (or in any of the lookup
2086 * tables of the split WIM parts).
2087 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
2088 * Failed to set attributes on a file.
2089 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
2090 * Failed to set reparse data on a file (only if reparse data was supported
2091 * by the extraction mode).
2092 * @retval ::WIMLIB_ERR_SET_SECURITY
2093 * Failed to set security descriptor on a file
2094 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
2096 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
2097 * Failed to set the short name of a file (only if
2098 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
2099 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
2100 * Failed to set timestamps on a file (only if
2101 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
2102 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2103 * Unexpected end-of-file occurred when reading data from the WIM file
2104 * associated with @p wim.
2105 * @retval ::WIMLIB_ERR_UNSUPPORTED
2106 * A requested extraction flag, or the data or metadata that must be
2107 * extracted to support it, is unsupported in the build and configuration
2108 * of wimlib, or on the current platform or extraction mode or target
2109 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
2110 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
2111 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
2112 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS,
2113 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS, ::WIMLIB_EXTRACT_FLAG_SYMLINK,
2114 * and ::WIMLIB_EXTRACT_FLAG_HARDLINK. For example, if
2115 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
2117 * ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM image contains one
2118 * or more files with short names, but extracting short names is not
2119 * supported --- on Windows, this occurs if the target volume does not
2120 * support short names, while on non-Windows, this occurs if
2121 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
2122 * @retval ::WIMLIB_ERR_WRITE
2123 * Failed to write data to a file being extracted.
2125 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2126 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2127 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2128 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2129 * different reasons) to read the metadata resource for an image that needed to
2133 wimlib_extract_image(WIMStruct *wim, int image,
2134 const wimlib_tchar *target,
2136 wimlib_progress_func_t progress_func);
2139 * Since wimlib v1.5.0: Extract one or more images from a pipe on which a
2140 * pipable WIM is being sent.
2142 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
2143 * about pipable WIMs.
2145 * This function operates in a special way to read the WIM fully sequentially.
2146 * As a result, there is no ::WIMStruct is made visible to library users, and
2147 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
2148 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
2149 * seekable file, not a pipe.)
2152 * File descriptor, which may be a pipe, opened for reading and positioned
2153 * at the start of the pipable WIM.
2154 * @param image_num_or_name
2155 * String that specifies the 1-based index or name of the image to extract.
2156 * It is translated to an image index using the same rules that
2157 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
2158 * only a single image (not all images) can be specified. Alternatively,
2159 * specify @p NULL here to use the first image in the WIM if it contains
2160 * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE.
2162 * Same as the corresponding parameter to wimlib_extract_image().
2163 * @param extract_flags
2164 * Same as the corresponding parameter to wimlib_extract_image(), except
2165 * for the following exceptions: ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is
2166 * always implied, since data is always read from @p pipe_fd sequentially
2167 * in this mode; also, ::WIMLIB_EXTRACT_FLAG_TO_STDOUT is invalid and will
2168 * result in ::WIMLIB_ERR_INVALID_PARAM being returned.
2169 * @param progress_func
2170 * Same as the corresponding parameter to wimlib_extract_image(), except
2171 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
2174 * @return 0 on success; nonzero on error. The possible error codes include
2175 * those returned by wimlib_extract_image() as well as the following:
2177 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
2178 * Data read from the pipable WIM was invalid.
2179 * @retval ::WIMLIB_ERR_NOT_PIPABLE
2180 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
2183 wimlib_extract_image_from_pipe(int pipe_fd,
2184 const wimlib_tchar *image_num_or_name,
2185 const wimlib_tchar *target, int extract_flags,
2186 wimlib_progress_func_t progress_func);
2189 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2190 * includes a string of XML that describes the images contained in the WIM.
2193 * Pointer to the ::WIMStruct for a WIM file, which does not necessarily
2194 * have to be standalone (e.g. it could be part of a split WIM).
2196 * @c stdout, or a FILE* opened for writing, to extract the data to.
2198 * @return 0 on success; nonzero on error.
2199 * @retval ::WIMLIB_ERR_INVALID_PARAM
2200 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2201 * @retval ::WIMLIB_ERR_NOMEM
2202 * @retval ::WIMLIB_ERR_READ
2203 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2204 * Failed to read the XML data from the WIM.
2205 * @retval ::WIMLIB_ERR_WRITE
2206 * Failed to completely write the XML data to @p fp.
2209 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2212 * Frees all memory allocated for a WIMStruct and closes all files associated
2216 * Pointer to the ::WIMStruct for a WIM file.
2218 * @return This function has no return value.
2221 wimlib_free(WIMStruct *wim);
2224 * Converts a ::wimlib_compression_type value into a string.
2227 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
2228 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
2231 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
2234 extern const wimlib_tchar *
2235 wimlib_get_compression_type_string(int ctype);
2238 * Converts an error code into a string describing it.
2241 * The error code returned by one of wimlib's functions.
2244 * Pointer to a statically allocated string describing the error code,
2245 * or @c NULL if the error code is not valid.
2247 extern const wimlib_tchar *
2248 wimlib_get_error_string(enum wimlib_error_code code);
2251 * Returns the description of the specified image.
2254 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2255 * to be standalone (e.g. it could be part of a split WIM).
2257 * The number of the image, numbered starting at 1.
2260 * The description of the image, or @c NULL if there is no such image, or
2261 * @c NULL if the specified image has no description. The description
2262 * string is in library-internal memory and may not be modified or freed;
2263 * in addition, the string will become invalid if the description of the
2264 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2266 extern const wimlib_tchar *
2267 wimlib_get_image_description(const WIMStruct *wim, int image);
2270 * Returns the name of the specified image.
2273 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2274 * to be standalone (e.g. it could be part of a split WIM).
2276 * The number of the image, numbered starting at 1.
2279 * The name of the image, or @c NULL if there is no such image, or an empty
2280 * string if the image is unnamed. The name string is in
2281 * library-internal memory and may not be modified or freed; in addition,
2282 * the string will become invalid if the name of the image is changed, the
2283 * image is deleted, or the ::WIMStruct is destroyed.
2285 extern const wimlib_tchar *
2286 wimlib_get_image_name(const WIMStruct *wim, int image);
2290 * Get basic information about a WIM file.
2293 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2294 * to be standalone (e.g. it could be part of a split WIM).
2296 * A ::wimlib_wim_info structure that will be filled in with information
2297 * about the WIM file.
2302 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2305 * Initialization function for wimlib. Call before using any other wimlib
2306 * function except wimlib_set_print_errors(). If not done manually, this
2307 * function will be called automatically with @p init_flags set to
2308 * ::WIMLIB_INIT_FLAG_ASSUME_UTF8.
2311 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2313 * @return 0 on success; nonzero on failure. Currently, only the following
2314 * error code is defined:
2316 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2317 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2318 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2319 * init_flags, but the corresponding privileges could not be acquired.
2322 wimlib_global_init(int init_flags);
2325 * Cleanup function for wimlib. You are not required to call this function, but
2326 * it will release any global resources allocated by the library.
2329 wimlib_global_cleanup(void);
2332 * Determines if an image name is already used by some image in the WIM.
2335 * Pointer to the ::WIMStruct for a WIM file.
2337 * The name to check.
2340 * @c true if there is already an image in @p wim named @p name; @c false
2341 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2342 * the empty string, @c false is returned.
2345 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2348 * Iterate through a file or directory tree in the WIM image. By specifying
2349 * appropriate flags and a callback function, you can get the attributes of a
2350 * file in the WIM, get a directory listing, or even get a listing of the entire
2354 * The WIM containing the image(s) over which to iterate, specified as a
2355 * pointer to the ::WIMStruct for a standalone WIM file, a delta WIM file,
2356 * or part 1 of a split WIM. In the case of a WIM file that is not
2357 * standalone, this ::WIMStruct should have had any needed external
2358 * resources previously referenced using wimlib_reference_resources() or
2359 * wimlib_reference_resource_files(). If not, see
2360 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_RESOURCES_NEEDED for information about
2361 * the behavior when resources are missing.
2364 * The 1-based number of the image in @p wim that contains the files or
2365 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2366 * iteration on all images in the WIM.
2369 * Path in the WIM image at which to do the iteration.
2372 * Bitwise OR of flags prefixed with WIMLIB_ITERATE_DIR_TREE_FLAG.
2375 * A callback function that will receive each directory entry.
2378 * An extra parameter that will always be passed to the callback function
2381 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2382 * first nonzero value that was returned from @p cb. However, additional error
2383 * codes may be returned, including the following:
2385 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2386 * @p path did not exist in the WIM image.
2387 * @retval ::WIMLIB_ERR_NOMEM
2388 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2390 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2391 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2392 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2393 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2394 * different reasons) to read the metadata resource for an image over which
2395 * iteration needed to be done.
2398 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2400 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2403 * Iterate through the lookup table of a WIM file. This can be used to directly
2404 * get a listing of the unique resources contained in a WIM file over all
2405 * images. Both file resources and metadata resources are included. However,
2406 * only resources actually included in the file represented by @a wim, plus
2407 * explicitly referenced external resources (via wimlib_reference_resources() or
2408 * wimlib_reference_resource_files()) are included in the iteration. For
2409 * example, if @p wim represents just one part of a split WIM, then only
2410 * resources in that part will be included, unless other resources were
2411 * explicitly referenced.
2414 * Pointer to the ::WIMStruct for a WIM file that does not necessarily have
2415 * to be standalone (e.g. it could be part of a split WIM).
2418 * Reserved; set to 0.
2421 * A callback function that will receive each resource.
2424 * An extra parameter that will always be passed to the callback function
2427 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
2428 * that was returned from @p cb.
2431 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2432 wimlib_iterate_lookup_table_callback_t cb,
2436 * Joins a split WIM into a stand-alone one-part WIM.
2439 * An array of strings that gives the filenames of all parts of the split
2440 * WIM. No specific order is required, but all parts must be included with
2443 * Number of filenames in @p swms.
2444 * @param swm_open_flags
2445 * Open flags for the split WIM parts (e.g.
2446 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY).
2447 * @param wim_write_flags
2448 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
2449 * be used to write the joined WIM.
2450 * @param output_path
2451 * The path to write the joined WIM file to.
2452 * @param progress_func
2453 * If non-NULL, a function that will be called periodically with the
2454 * progress of the current operation.
2456 * @return 0 on success; nonzero on error. This function may return most error
2457 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
2458 * as the following error code:
2460 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2461 * The split WIMs do not form a valid WIM because they do not include all
2462 * the parts of the original WIM, there are duplicate parts, or not all the
2463 * parts have the same GUID and compression type.
2465 * Note: wimlib is generalized enough that this function is not actually needed
2466 * to join a split WIM; instead, you could open the first part of the split WIM,
2467 * then reference the other parts with wimlib_reference_resource_files(), then
2468 * write the joined WIM using wimlib_write(). However, wimlib_join() provides
2469 * an easy-to-use wrapper around this that has some advantages (e.g. extra
2473 wimlib_join(const wimlib_tchar * const *swms,
2475 const wimlib_tchar *output_path,
2477 int wim_write_flags,
2478 wimlib_progress_func_t progress_func);
2481 * Compress a chunk of a WIM resource using LZX compression.
2483 * This function is exported for convenience only and should only be used by
2484 * library clients looking to make use of wimlib's compression code for another
2488 * Uncompressed data of the chunk.
2490 * Size of the uncompressed chunk, in bytes.
2492 * Pointer to output buffer of size at least (@p chunk_size - 1) bytes.
2495 * The size of the compressed data written to @p out in bytes, or 0 if the
2496 * data could not be compressed to (@p chunk_size - 1) bytes or fewer.
2498 * As a special requirement, the compression code is optimized for the WIM
2499 * format and therefore requires (@p chunk_size <= 32768).
2502 wimlib_lzx_compress(const void *chunk, unsigned chunk_size, void *out);
2505 * Decompresses a block of LZX-compressed data as used in the WIM file format.
2507 * Note that this will NOT work unmodified for LZX as used in the cabinet
2508 * format, which is not the same as in the WIM format!
2510 * This function is exported for convenience only and should only be used by
2511 * library clients looking to make use of wimlib's compression code for another
2514 * @param compressed_data
2515 * Pointer to the compressed data.
2517 * @param compressed_len
2518 * Length of the compressed data, in bytes.
2520 * @param uncompressed_data
2521 * Pointer to the buffer into which to write the uncompressed data.
2523 * @param uncompressed_len
2524 * Length of the uncompressed data. It must be 32768 bytes or less.
2527 * 0 on success; non-zero on failure.
2530 wimlib_lzx_decompress(const void *compressed_data, unsigned compressed_len,
2531 void *uncompressed_data, unsigned uncompressed_len);
2535 * Mounts an image in a WIM file on a directory read-only or read-write.
2537 * As this is implemented using FUSE (Filesystme in UserSpacE), this is not
2538 * supported if wimlib was configured with @c --without-fuse. This includes
2539 * Windows builds of wimlib; ::WIMLIB_ERR_UNSUPPORTED will be returned in such
2542 * Calling this function daemonizes the process, unless
2543 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early occur occurs. If the
2544 * mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified), modifications
2545 * to the WIM are staged in a temporary directory.
2547 * It is safe to mount multiple images from the same underlying WIM file
2548 * read-only at the same time, but only if different ::WIMStruct's are used. It
2549 * is @b not safe to mount multiple images from the same WIM file read-write at
2552 * wimlib_mount_image() cannot be used on an image that was exported with
2553 * wimlib_export_image() while the dentry trees for both images are still in
2554 * memory. In addition, wimlib_mount_image() may not be used to mount an image
2555 * that already has modifications pending (e.g. an image added with
2556 * wimlib_add_image()).
2559 * Pointer to the ::WIMStruct containing the image to be mounted.
2561 * The number of the image to mount, indexed starting from it. It must be
2562 * an existing, single image.
2564 * The path to an existing empty directory to mount the image on.
2565 * @param mount_flags
2566 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
2567 * @param staging_dir
2568 * If non-NULL, the name of a directory in which the staging directory will
2569 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2570 * in @p mount_flags. If left @c NULL, the staging directory is created in
2571 * the same directory as the WIM file that @p wim was originally read from.
2573 * @return 0 on success; nonzero on error.
2575 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2576 * A read-write mount was requested, but an an exclusive advisory lock on
2577 * the on-disk WIM file could not be acquired because another thread or
2578 * process has mounted an image from the WIM read-write or is currently
2579 * modifying the WIM in-place.
2580 * @retval ::WIMLIB_ERR_FUSE
2581 * A non-zero status was returned by @c fuse_main().
2582 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2583 * @p image does not specify an existing, single image in @p wim.
2584 * @retval ::WIMLIB_ERR_INVALID_PARAM
2585 * @p image is shared among multiple ::WIMStruct's as a result of a call to
2586 * wimlib_export_image(), or @p image has been added with
2587 * wimlib_add_image().
2588 * @retval ::WIMLIB_ERR_MKDIR
2589 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
2590 * staging directory could not be created.
2591 * @retval ::WIMLIB_ERR_NOTDIR
2592 * Could not determine the current working directory.
2593 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2594 * One of the dentries in the image referenced a stream not present in the
2595 * WIM's lookup table (or in any of the lookup tables of the split WIM
2597 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2598 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but @p
2599 * wim is considered read-only because of any of the reasons mentioned in
2600 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2601 * @retval ::WIMLIB_ERR_UNSUPPORTED
2602 * Mounting is not supported, either because the platform is Windows, or
2603 * because the platform is UNIX-like and wimlib was compiled with @c
2606 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2607 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2608 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2609 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2610 * different reasons) to read the metadata resource for the image to mount.
2613 wimlib_mount_image(WIMStruct *wim,
2615 const wimlib_tchar *dir,
2617 const wimlib_tchar *staging_dir);
2620 * Opens a WIM file and creates a ::WIMStruct for it.
2623 * The path to the WIM file to open.
2626 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
2628 * @param progress_func
2629 * If non-NULL, a function that will be called periodically with the
2630 * progress of the current operation. Currently, the only messages sent
2631 * will be ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY, and only if
2632 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags.
2635 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2636 * is written to the memory location pointed to by this parameter. The
2637 * ::WIMStruct can be freed using using wimlib_free() when finished with
2640 * @return 0 on success; nonzero on error.
2641 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2642 * The WIM is not the non-first part of a split WIM, and the number of
2643 * metadata resources found in the WIM did not match the image count given
2644 * in the WIM header, or the number of <IMAGE> elements in the XML
2645 * data for the WIM did not match the image count given in the WIM header.
2646 * @retval ::WIMLIB_ERR_INTEGRITY
2647 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2648 * wim_file contains an integrity table, but the SHA1 message digest for a
2649 * chunk of the WIM does not match the corresponding message digest given
2650 * in the integrity table.
2651 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2652 * Resources in @p wim_file are compressed, but the chunk size is not 32768.
2653 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2654 * The header of @p wim_file says that resources in the WIM are compressed,
2655 * but the header flag indicating LZX or XPRESS compression is not set.
2656 * @retval ::WIMLIB_ERR_INVALID_HEADER
2657 * The header of @p wim_file was otherwise invalid.
2658 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2659 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2660 * wim_file contains an integrity table, but the integrity table is
2662 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2663 * The lookup table for the WIM contained duplicate entries that are not
2664 * for metadata resources, or it contained an entry with a SHA1 message
2665 * digest of all 0's.
2666 * @retval ::WIMLIB_ERR_INVALID_PARAM
2667 * @p wim_ret was @c NULL.
2668 * @retval ::WIMLIB_ERR_IS_SPLIT_WIM
2669 * @p wim_file is a split WIM and ::WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT was
2670 * specified in @p open_flags.
2671 * @retval ::WIMLIB_ERR_NOMEM
2672 * Failed to allocated needed memory.
2673 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2674 * @p wim_file does not begin with the expected magic characters.
2675 * @retval ::WIMLIB_ERR_OPEN
2676 * Failed to open the file @p wim_file for reading.
2677 * @retval ::WIMLIB_ERR_READ
2678 * Failed to read data from @p wim_file.
2679 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2680 * Unexpected end-of-file while reading data from @p wim_file.
2681 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2682 * A number other than 0x10d00 is written in the version field of the WIM
2683 * header of @p wim_file. (May be a pre-Vista WIM.)
2684 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2685 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2686 * considered read-only because of any of the reasons mentioned in the
2687 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2688 * @retval ::WIMLIB_ERR_XML
2689 * The XML data for @p wim_file is invalid.
2692 wimlib_open_wim(const wimlib_tchar *wim_file,
2694 WIMStruct **wim_ret,
2695 wimlib_progress_func_t progress_func);
2698 * Overwrites the file that the WIM was originally read from, with changes made.
2699 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2700 * rather than wimlib_create_new_wim().
2702 * There are two ways that a WIM may be overwritten. The first is to do a full
2703 * rebuild. In this mode, the new WIM is written to a temporary file and then
2704 * renamed to the original file after it is has been completely written. The
2705 * temporary file is made in the same directory as the original WIM file. A
2706 * full rebuild may take a while, but can be used even if images have been
2707 * modified or deleted, will produce a WIM with no holes, and has little chance
2708 * of unintentional data loss because the temporary WIM is fsync()ed before
2709 * being renamed to the original WIM.
2711 * The second way to overwrite a WIM is by appending to the end of it and
2712 * overwriting the header. This can be much faster than a full rebuild, but the
2713 * disadvantage is that some space will be wasted. Writing a WIM in this mode
2714 * begins with writing any new file resources *after* everything in the old WIM,
2715 * even though this will leave a hole where the old lookup table, XML data, and
2716 * integrity were. This is done so that the WIM remains valid even if the
2717 * operation is aborted mid-write. The WIM header is only overwritten at the
2718 * very last moment, and up until that point the WIM will be seen as the old
2721 * By default, wimlib_overwrite() does the append-style overwrite described
2722 * above, unless resources in the WIM are arranged in an unusual way or if
2723 * images have been deleted from the WIM. Use the flag
2724 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
2725 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
2726 * images have been deleted from the WIM.
2728 * In the temporary-file overwrite mode, no changes are made to the WIM on
2729 * failure, and the temporary file is deleted if possible. Abnormal termination
2730 * of the program will result in the temporary file being orphaned. In the
2731 * direct append mode, the WIM is truncated to the original length on failure;
2732 * and while abnormal termination of the program will result in extra data
2733 * appended to the original WIM, it should still be a valid WIM.
2735 * If this function completes successfully, no more functions should be called
2736 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
2737 * the WIM file anew.
2740 * Pointer to the ::WIMStruct for the WIM file to write. There may have
2741 * been in-memory changes made to it, which are then reflected in the
2743 * @param write_flags
2744 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
2745 * @param num_threads
2746 * Number of threads to use for compression (see wimlib_write()).
2747 * @param progress_func
2748 * If non-NULL, a function that will be called periodically with the
2749 * progress of the current operation.
2751 * @return 0 on success; nonzero on error. This function may return most error
2752 * codes returned by wimlib_write() as well as the following error codes:
2754 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2755 * The WIM was going to be modified in-place (with no temporary file), but
2756 * an exclusive advisory lock on the on-disk WIM file could not be acquired
2757 * because another thread or process has mounted an image from the WIM
2758 * read-write or is currently modifying the WIM in-place.
2759 * @retval ::WIMLIB_ERR_NO_FILENAME
2760 * @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
2761 * than a WIM read with wimlib_open_wim().
2762 * @retval ::WIMLIB_ERR_RENAME
2763 * The temporary file that the WIM was written to could not be renamed to
2764 * the original filename of @p wim.
2765 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2766 * The WIM file is considered read-only because of any of the reasons
2767 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2771 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
2772 wimlib_progress_func_t progress_func);
2775 * Prints information about one image, or all images, contained in a WIM.
2778 * Pointer to the ::WIMStruct for a WIM file.
2780 * The image about which to print information. Can be the number of an
2781 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
2784 * @return This function has no return value. No error checking is done when
2785 * printing the information. If @p image is invalid, an error message is
2789 wimlib_print_available_images(const WIMStruct *wim, int image);
2792 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
2793 * in a way that can be accessed programatically.
2796 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
2799 * Deprecated in favor of wimlib_iterate_dir_tree(), which provides the
2800 * information in a way that can be accessed programatically.
2803 wimlib_print_metadata(WIMStruct *wim, int image) _wimlib_deprecated;
2806 * Reference resources from other WIM files or split WIM parts. This function
2807 * can be used on WIMs that are not standalone, such as split or "delta" WIMs,
2808 * to load needed resources (that is, "streams" keyed by SHA1 message digest)
2809 * from other files, before calling a function such as wimlib_extract_image()
2810 * that requires the resources to be present.
2813 * The ::WIMStruct for a WIM that contains metadata resources, but is not
2814 * necessarily "standalone". In the case of split WIMs, this should be the
2815 * first part, since only the first part contains the metadata resources.
2816 * In the case of delta WIMs, this should be the delta WIM rather than the
2817 * WIM on which it is based.
2818 * @param resource_wimfiles_or_globs
2819 * Array of paths to WIM files and/or split WIM parts to reference.
2820 * Alternatively, when ::WIMLIB_REF_FLAG_GLOB_ENABLE is specified in @p
2821 * ref_flags, these are treated as globs rather than literal paths. That
2822 * is, using this function you can specify zero or more globs, each of
2823 * which expands to one or more literal paths.
2825 * Number of entries in @p resource_wimfiles_or_globs.
2827 * Bitwise OR of ::WIMLIB_REF_FLAG_GLOB_ENABLE and/or
2828 * ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH.
2830 * Additional open flags, such as ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY, to
2831 * pass to internal calls to wimlib_open_wim() on the reference files.
2832 * @param progress_func
2833 * Passed to internal calls to wimlib_open_wim() on the reference files.
2835 * @return 0 on success; nonzero on error.
2837 * @retval ::WIMLIB_ERR_GLOB_HAD_NO_MATCHES
2838 * One of the specified globs did not match any paths (only with both
2839 * ::WIMLIB_REF_FLAG_GLOB_ENABLE and ::WIMLIB_REF_FLAG_GLOB_ERR_ON_NOMATCH
2840 * specified in @p ref_flags).
2841 * @retval ::WIMLIB_ERR_NOMEM
2842 * Failed to allocate memory.
2843 * @retval ::WIMLIB_ERR_READ
2844 * I/O or permissions error while processing a file glob.
2846 * This function can additionally return most values that can be returned by
2847 * wimlib_open_wim().
2850 wimlib_reference_resource_files(WIMStruct *wim,
2851 const wimlib_tchar * const *resource_wimfiles_or_globs,
2855 wimlib_progress_func_t progress_func);
2858 * Similar to wimlib_reference_resource_files(), but operates at a lower level
2859 * where the caller must open the ::WIMStruct for each referenced file itself.
2862 * The ::WIMStruct for a WIM that contains metadata resources, but is not
2863 * necessarily "standalone". In the case of split WIMs, this should be the
2864 * first part, since only the first part contains the metadata resources.
2865 * @param resource_wims
2866 * Array of pointers to the ::WIMStruct's for additional resource WIMs or
2867 * split WIM parts to reference.
2868 * @param num_resource_wims
2869 * Number of entries in @p resource_wims.
2871 * Currently ignored (set to 0).
2873 * @return 0 on success; nonzero on error. On success, the ::WIMStruct's of the
2874 * @p resource_wims are referenced internally by @p wim and must not be freed
2875 * with wimlib_free() or overwritten with wimlib_overwrite() until @p wim has
2876 * been freed with wimlib_free(), or immediately before freeing @p wim with
2879 * @retval ::WIMLIB_ERR_INVALID_PARAM
2880 * @p wim was @c NULL, or @p num_resource_wims was nonzero but @p
2881 * resource_wims was @c NULL, or an entry in @p resource_wims was @p NULL.
2882 * @retval ::WIMLIB_ERR_NOMEM
2883 * Failed to allocate memory.
2886 wimlib_reference_resources(WIMStruct *wim, WIMStruct **resource_wims,
2887 unsigned num_resource_wims, int ref_flags);
2890 * Declares that a newly added image is mostly the same as a prior image, but
2891 * captured at a later point in time, possibly with some modifications in the
2892 * intervening time. This is designed to be used in incremental backups of the
2893 * same filesystem or directory tree.
2895 * This function compares the metadata of the directory tree of the newly added
2896 * image against that of the old image. Any files that are present in both the
2897 * newly added image and the old image and have timestamps that indicate they
2898 * haven't been modified are deemed not to have been modified and have their
2899 * SHA1 message digest copied from the old image. Because of this and because
2900 * WIM uses single-instance streams, such files need not be read from the
2901 * filesystem when the WIM is being written or overwritten. Note that these
2902 * unchanged files will still be "archived" and will be logically present in the
2903 * new image; the optimization is that they don't need to actually be read from
2904 * the filesystem because the WIM already contains them.
2906 * This function is provided to optimize incremental backups. The resulting WIM
2907 * file will still be the same regardless of whether this function is called.
2908 * (This is, however, assuming that timestamps have not been manipulated or
2909 * unmaintained as to trick this function into thinking a file has not been
2910 * modified when really it has. To partly guard against such cases, other
2911 * metadata such as file sizes will be checked as well.)
2913 * This function must be called after adding the new image (e.g. with
2914 * wimlib_add_image()), but before writing the updated WIM file (e.g. with
2915 * wimlib_overwrite()).
2918 * Pointer to the ::WIMStruct for a WIM.
2920 * 1-based index in the WIM of the newly added image. This image can have
2921 * been added with wimlib_add_image() or wimlib_add_image_multisource(), or
2922 * wimlib_add_empty_image() followed by wimlib_update_image().
2923 * @param template_wim
2924 * The ::WIMStruct for the WIM containing the template image. This can be
2925 * the same as @p wim, or it can be a different ::WIMStruct.
2926 * @param template_image
2927 * 1-based index in the WIM of a template image that reflects a prior state
2928 * of the directory tree being captured.
2930 * Reserved; must be 0.
2931 * @param progress_func
2932 * Currently ignored, but reserved for a function that will be called with
2933 * information about the operation. Use NULL if no additional information
2936 * @return 0 on success; nonzero on error.
2938 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2939 * @p new_image and/or @p template_image were not a valid image indices in
2941 * @retval ::WIMLIB_ERR_METADATA_NOT_FOUND
2942 * The specified ::WIMStruct did not actually contain the metadata resource
2943 * for the new or template image; for example, it was a non-first part of a
2945 * @retval ::WIMLIB_ERR_NOMEM
2946 * Failed to allocate needed memory.
2947 * @retval ::WIMLIB_ERR_INVALID_PARAM
2948 * @p new_image was equal to @p template_image, or @p new_image specified
2949 * an image that had not been modified since opening the WIM.
2951 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2952 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
2953 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
2954 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
2955 * different reasons) to read the metadata resource for the template image.
2958 wimlib_reference_template_image(WIMStruct *wim, int new_image,
2959 WIMStruct *template_wim, int template_image,
2960 int flags, wimlib_progress_func_t progress_func);
2963 * Translates a string specifying the name or number of an image in the WIM into
2964 * the number of the image. The images are numbered starting at 1.
2967 * Pointer to the ::WIMStruct for a WIM.
2968 * @param image_name_or_num
2969 * A string specifying the name or number of an image in the WIM. If it
2970 * parses to a positive integer, this integer is taken to specify the
2971 * number of the image, indexed starting at 1. Otherwise, it is taken to
2972 * be the name of an image, as given in the XML data for the WIM file. It
2973 * also may be the keyword "all" or the string "*", both of which will
2974 * resolve to ::WIMLIB_ALL_IMAGES.
2976 * There is no way to search for an image actually named "all", "*", or an
2977 * integer number, or an image that has no name. However, you can use
2978 * wimlib_get_image_name() to get the name of any image.
2981 * If the string resolved to a single existing image, the number of that
2982 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
2983 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
2984 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
2985 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
2986 * images in @p wim has no name.
2989 wimlib_resolve_image(WIMStruct *wim,
2990 const wimlib_tchar *image_name_or_num);
2993 * Changes the description of an image in the WIM.
2996 * Pointer to the ::WIMStruct for a WIM.
2998 * The number of the image for which to change the description.
2999 * @param description
3000 * The new description to give the image. It may be @c NULL, which
3001 * indicates that the image is to be given no description.
3003 * @return 0 on success; nonzero on error.
3004 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3005 * @p image does not specify a single existing image in @p wim.
3006 * @retval ::WIMLIB_ERR_NOMEM
3007 * Failed to allocate the memory needed to duplicate the @p description
3009 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3010 * @p wim is considered read-only because of any of the reasons mentioned
3011 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3014 wimlib_set_image_descripton(WIMStruct *wim, int image,
3015 const wimlib_tchar *description);
3018 * Set basic information about a WIM.
3021 * Pointer to the ::WIMStruct for a WIM.
3023 * A struct ::wimlib_wim_info that contains the information to set. Only
3024 * the information explicitly specified in the @p which flags need be
3027 * Flags that specify which information to set. This is a bitwise OR of
3028 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
3029 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
3031 * @return 0 on success; nonzero on failure.
3032 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3033 * The WIM file is considered read-only because of any of the reasons
3034 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3035 * flag. However, as a special case, if you are using
3036 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
3037 * function will not fail due to the readonly flag being previously set.
3038 * @retval ::WIMLIB_ERR_IMAGE_COUNT
3039 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
3040 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
3044 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
3048 * Changes what is written in the \<FLAGS\> element in the WIM XML data
3049 * (something like "Core" or "Ultimate")
3052 * Pointer to the ::WIMStruct for a WIM.
3054 * The number of the image for which to change the description.
3056 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
3057 * indicates that the image is to be given no \<FLAGS\> element.
3059 * @return 0 on success; nonzero on error.
3060 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3061 * @p image does not specify a single existing image in @p wim.
3062 * @retval ::WIMLIB_ERR_NOMEM
3063 * Failed to allocate the memory needed to duplicate the @p flags string.
3064 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3065 * @p wim is considered read-only because of any of the reasons mentioned
3066 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3069 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
3072 * Changes the name of an image in the WIM.
3075 * Pointer to the ::WIMStruct for a WIM.
3077 * The number of the image for which to change the name.
3079 * New name to give the new image. If @c NULL or empty, the new image is
3080 * given no name. If nonempty, it must specify a name that does not
3081 * already exist in @p wim.
3083 * @return 0 on success; nonzero on error.
3084 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
3085 * There is already an image named @p name in @p wim.
3086 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3087 * @p image does not specify a single existing image in @p wim.
3088 * @retval ::WIMLIB_ERR_NOMEM
3089 * Failed to allocate the memory needed to duplicate the @p name string.
3090 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3091 * @p wim is considered read-only because of any of the reasons mentioned
3092 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
3095 wimlib_set_image_name(WIMStruct *wim, int image, const wimlib_tchar *name);
3098 * Set the functions that wimlib uses to allocate and free memory.
3100 * These settings are global and not per-WIM.
3102 * The default is to use the default @c malloc() and @c free() from the C
3105 * Please note that some external functions, such as those in @c libntfs-3g, may
3106 * use the standard memory allocation functions.
3108 * @param malloc_func
3109 * A function equivalent to @c malloc() that wimlib will use to allocate
3110 * memory. If @c NULL, the allocator function is set back to the default
3111 * @c malloc() from the C library.
3113 * A function equivalent to @c free() that wimlib will use to free memory.
3114 * If @c NULL, the free function is set back to the default @c free() from
3116 * @param realloc_func
3117 * A function equivalent to @c realloc() that wimlib will use to reallocate
3118 * memory. If @c NULL, the free function is set back to the default @c
3119 * realloc() from the C library.
3120 * @return 0 on success; nonzero on error.
3121 * @retval ::WIMLIB_ERR_UNSUPPORTED
3122 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
3123 * so custom memory allocators are unsupported.
3126 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
3127 void (*free_func)(void *),
3128 void *(*realloc_func)(void *, size_t));
3131 * Sets whether wimlib is to print error messages to @c stderr when a function
3132 * fails. These error messages may provide information that cannot be
3133 * determined only from the error code that is returned. Not every error will
3134 * result in an error message being printed.
3136 * This setting is global and not per-WIM.
3138 * By default, error messages are not printed.
3140 * This can be called before wimlib_global_init().
3142 * @param show_messages
3143 * @c true if error messages are to be printed; @c false if error messages
3144 * are not to be printed.
3146 * @return 0 on success; nonzero on error.
3147 * @retval ::WIMLIB_ERR_UNSUPPORTED
3148 * @p show_messages was @c true, but wimlib was compiled with the @c
3149 * --without-error-messages option. Therefore, error messages cannot be
3153 wimlib_set_print_errors(bool show_messages);
3156 * Splits a WIM into multiple parts.
3159 * The ::WIMStruct for the WIM to split.
3161 * Name of the SWM file to create. This will be the name of the first
3162 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
3163 * appended before the suffix.
3165 * The maximum size per part, in bytes. Unfortunately, it is not
3166 * guaranteed that this will really be the maximum size per part, because
3167 * some file resources in the WIM may be larger than this size, and the WIM
3168 * file format provides no way to split up file resources among multiple
3170 * @param write_flags
3171 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
3172 * flags will be used to write each split WIM part. Specify 0 here to get
3173 * the default behavior.
3174 * @param progress_func
3175 * If non-NULL, a function that will be called periodically with the
3176 * progress of the current operation
3177 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
3178 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
3180 * @return 0 on success; nonzero on error. This function may return most error
3181 * codes that can be returned by wimlib_write() as well as the following error
3184 * @retval ::WIMLIB_ERR_INVALID_PARAM
3185 * @p swm_name was not a nonempty string, or @p part_size was 0.
3187 * Note: the WIM's uncompressed and compressed resources are not checksummed
3188 * when they are copied from the joined WIM to the split WIM parts, nor are
3189 * compressed resources re-compressed (unless explicitly requested with
3190 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
3193 wimlib_split(WIMStruct *wim,
3194 const wimlib_tchar *swm_name,
3197 wimlib_progress_func_t progress_func);
3200 * Unmounts a WIM image that was mounted using wimlib_mount_image().
3202 * The image to unmount is specified by the path to the mountpoint, not the
3203 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
3204 * touched and also may have been allocated in a different process.
3206 * To unmount the image, the process calling this function communicates with the
3207 * process that is managing the mounted WIM image. This function blocks until it
3208 * is known whether the unmount succeeded or failed. In the case of a
3209 * read-write mounted WIM, the unmount is not considered to have succeeded until
3210 * all changes have been saved to the underlying WIM file.
3213 * The directory that the WIM image was mounted on.
3214 * @param unmount_flags
3215 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
3216 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
3217 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
3219 * @param progress_func
3220 * If non-NULL, a function that will be called periodically with the
3221 * progress of the current operation. Currently, only
3222 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS will be sent.
3224 * @return 0 on success; nonzero on error.
3226 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
3227 * The filesystem daemon was unable to remove the staging directory and the
3228 * temporary files that it contains.
3229 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
3230 * The filesystem daemon appears to have terminated before sending an exit
3232 * @retval ::WIMLIB_ERR_FORK
3233 * Could not @c fork() the process.
3234 * @retval ::WIMLIB_ERR_FUSERMOUNT
3235 * The @b fusermount program could not be executed or exited with a failure
3237 * @retval ::WIMLIB_ERR_MQUEUE
3238 * Could not open a POSIX message queue to communicate with the filesystem
3239 * daemon servicing the mounted filesystem, could not send a message
3240 * through the queue, or could not receive a message through the queue.
3241 * @retval ::WIMLIB_ERR_NOMEM
3242 * Failed to allocate needed memory.
3243 * @retval ::WIMLIB_ERR_OPEN
3244 * The filesystem daemon could not open a temporary file for writing the
3246 * @retval ::WIMLIB_ERR_READ
3247 * A read error occurred when the filesystem daemon tried to a file from
3248 * the staging directory
3249 * @retval ::WIMLIB_ERR_RENAME
3250 * The filesystem daemon failed to rename the newly written WIM file to the
3251 * original WIM file.
3252 * @retval ::WIMLIB_ERR_UNSUPPORTED
3253 * Mounting is not supported, either because the platform is Windows, or
3254 * because the platform is UNIX-like and wimlib was compiled with @c
3256 * @retval ::WIMLIB_ERR_WRITE
3257 * A write error occurred when the filesystem daemon was writing to the new
3258 * WIM file, or the filesystem daemon was unable to flush changes that had
3259 * been made to files in the staging directory.
3262 wimlib_unmount_image(const wimlib_tchar *dir,
3264 wimlib_progress_func_t progress_func);
3267 * Update a WIM image by adding, deleting, and/or renaming files or directories.
3270 * Pointer to the ::WIMStruct for the WIM file to update.
3272 * The 1-based index of the image in the WIM to update. It cannot be
3273 * ::WIMLIB_ALL_IMAGES.
3275 * An array of ::wimlib_update_command's that specify the update operations
3278 * Number of commands in @p cmds.
3279 * @param update_flags
3280 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
3281 * @param progress_func
3282 * If non-NULL, a function that will be called periodically with the
3283 * progress of the current operation.
3285 * @return 0 on success; nonzero on error. On failure, some but not all of the
3286 * update commands may have been executed. No individual update command will
3287 * have been partially executed. Possible error codes include:
3289 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
3290 * The capture configuration structure specified for an add command was
3292 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3293 * @p image did not specify a single, existing image in @p wim.
3294 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
3295 * Attempted to perform an add command that conflicted with previously
3296 * existing files in the WIM when an overlay was attempted.
3297 * @retval ::WIMLIB_ERR_INVALID_PARAM
3298 * An unknown operation type was specified in the update commands; or,
3299 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
3300 * in the @p add_flags, but the same image had previously already been
3301 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
3302 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
3303 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
3304 * specified in the @p add_flags for an add command in which @p
3305 * wim_target_path was not the root directory of the WIM image.
3306 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
3307 * (Windows only): While executing an add command, tried to capture a
3308 * reparse point with invalid data.
3309 * @retval ::WIMLIB_ERR_IS_DIRECTORY
3310 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
3311 * for a WIM path that corresponded to a directory; or, a rename command
3312 * attempted to rename a directory to a non-directory.
3313 * @retval ::WIMLIB_ERR_NOMEM
3314 * Failed to allocate needed memory.
3315 * @retval ::WIMLIB_ERR_NOTDIR
3316 * A rename command attempted to rename a directory to a non-directory; or,
3317 * an add command was executed that attempted to set the root of the WIM
3318 * image as a non-directory; or, a path component used as a directory in a
3319 * rename command was not, in fact, a directory.
3320 * @retval ::WIMLIB_ERR_NOTEMPTY
3321 * A rename command attempted to rename a directory to a non-empty
3323 * @retval ::WIMLIB_ERR_NTFS_3G
3324 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3325 * error occurred while reading data from the NTFS volume using libntfs-3g.
3326 * @retval ::WIMLIB_ERR_OPEN
3327 * Failed to open a file to be captured while executing an add command.
3328 * @retval ::WIMLIB_ERR_OPENDIR
3329 * Failed to open a directory to be captured while executing an add command.
3330 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3331 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3332 * WIM path that did not exist; or, a rename command attempted to rename a
3333 * file that does not exist.
3334 * @retval ::WIMLIB_ERR_READ
3335 * While executing an add command, failed to read data from a file or
3336 * directory to be captured.
3337 * @retval ::WIMLIB_ERR_READLINK
3338 * While executing an add command, failed to read the target of a symbolic
3339 * link or junction point.
3340 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3341 * (Windows only) Failed to perform a reparse point fixup because of
3342 * problems with the data of a reparse point.
3343 * @retval ::WIMLIB_ERR_STAT
3344 * While executing an add command, failed to get attributes for a file or
3346 * @retval ::WIMLIB_ERR_UNSUPPORTED
3347 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
3348 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
3349 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3350 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
3351 * add_flags for an update command.
3352 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
3353 * While executing an add command, attempted to capture a file that was not
3354 * a supported file type (e.g. a device file). Only if
3355 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
3356 * for an update command.
3357 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3358 * The WIM file is considered read-only because of any of the reasons
3359 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3362 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3363 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3364 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3365 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3366 * different reasons) to read the metadata resource for an image that needed to
3370 wimlib_update_image(WIMStruct *wim,
3372 const struct wimlib_update_command *cmds,
3375 wimlib_progress_func_t progress_func);
3378 * Writes a WIM to a file.
3380 * This brings in resources from any external locations, such as directory trees
3381 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3382 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3384 * By default, the new WIM file is written as stand-alone. Using the
3385 * ::WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS flag, a "delta" WIM can be written
3386 * instead. However, this function cannot directly write a "split" WIM; use
3387 * wimlib_split() for that.
3390 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
3391 * changes made to it, which are then reflected in the output file.
3393 * The path to the file to write the WIM to.
3395 * Normally, specify ::WIMLIB_ALL_IMAGES here. This indicates that all
3396 * images are to be included in the new on-disk WIM file. If for some
3397 * reason you only want to include a single image, specify the index of
3398 * that image instead.
3399 * @param write_flags
3400 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3401 * @param num_threads
3402 * Number of threads to use for compressing data. If 0, the number of
3403 * threads is taken to be the number of online processors. Note: if no
3404 * data compression needs to be done, no additional threads will be created
3405 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
3406 * exporting an image from a compressed WIM to another WIM of the same
3407 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
3409 * @param progress_func
3410 * If non-NULL, a function that will be called periodically with the
3411 * progress of the current operation. The possible messages are
3412 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3413 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3414 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3416 * @return 0 on success; nonzero on error.
3418 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3419 * @p image does not specify a single existing image in @p wim, and is not
3420 * ::WIMLIB_ALL_IMAGES.
3421 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3422 * A file that had previously been scanned for inclusion in the WIM by
3423 * wimlib_add_image() was concurrently modified, so it failed the SHA1
3424 * message digest check.
3425 * @retval ::WIMLIB_ERR_INVALID_PARAM
3426 * @p path was @c NULL.
3427 * @retval ::WIMLIB_ERR_NOMEM
3428 * Failed to allocate needed memory.
3429 * @retval ::WIMLIB_ERR_OPEN
3430 * Failed to open @p path for writing, or some file resources in @p wim
3431 * refer to files in the outside filesystem, and one of these files could
3432 * not be opened for reading.
3433 * @retval ::WIMLIB_ERR_READ
3434 * An error occurred when trying to read data from the WIM file associated
3435 * with @p wim, or some file resources in @p wim refer to files in the
3436 * outside filesystem, and a read error occurred when reading one of these
3438 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
3439 * A stream that needed to be written could not be found in the stream
3440 * lookup table of @p wim. This error can occur if, for example, @p wim is
3441 * part of a split WIM but needed resources from the other split WIM parts
3442 * were not referenced with wimlib_reference_resources() or
3443 * wimlib_reference_resource_files() before the call to wimlib_write().
3444 * @retval ::WIMLIB_ERR_WRITE
3445 * An error occurred when trying to write data to the new WIM file.
3447 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
3448 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_METADATA_NOT_FOUND,
3449 * ::WIMLIB_ERR_NOMEM, ::WIMLIB_ERR_READ, or
3450 * ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which indicate failure (for
3451 * different reasons) to read the metadata resource for an image that needed to
3455 wimlib_write(WIMStruct *wim,
3456 const wimlib_tchar *path,
3459 unsigned num_threads,
3460 wimlib_progress_func_t progress_func);
3463 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
3464 * file descriptor, which need not be seekable if the write is done in a special
3465 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
3466 * write_flags. This can, for example, allow capturing a WIM image and
3467 * streaming it over the network. See the documentation for
3468 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
3470 * The file descriptor @p fd will @b not be closed when the write is complete;
3471 * the calling code is responsible for this.
3473 * Returns 0 on success; nonzero on failure. The possible error codes include
3474 * those that can be returned by wimlib_write() as well as the following:
3476 * @retval ::WIMLIB_ERR_INVALID_PARAM
3477 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
3478 * specified in @p write_flags.
3481 wimlib_write_to_fd(WIMStruct *wim,
3485 unsigned num_threads,
3486 wimlib_progress_func_t progress_func);
3489 * This function is equivalent to wimlib_lzx_compress(), but instead compresses
3490 * the data using "XPRESS" compression.
3493 wimlib_xpress_compress(const void *chunk, unsigned chunk_size, void *out);
3496 * This function is equivalent to wimlib_lzx_decompress(), but instead assumes
3497 * the data is compressed using "XPRESS" compression.
3500 wimlib_xpress_decompress(const void *compressed_data, unsigned compressed_len,
3501 void *uncompressed_data, unsigned uncompressed_len);
3507 #endif /* _WIMLIB_H */