4 * External header for wimlib.
6 * This file contains extensive comments for generating documentation with
7 * Doxygen. The built HTML documentation can be viewed at
8 * http://wimlib.sourceforge.net.
12 * Copyright (C) 2012, 2013 Eric Biggers
14 * This file is part of wimlib, a library for working with WIM files.
16 * wimlib is free software; you can redistribute it and/or modify it under the
17 * terms of the GNU General Public License as published by the Free
18 * Software Foundation; either version 3 of the License, or (at your option)
21 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
22 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
23 * A PARTICULAR PURPOSE. See the GNU General Public License for more
26 * You should have received a copy of the GNU General Public License
27 * along with wimlib; if not, see http://www.gnu.org/licenses/.
32 * \section intro Introduction
34 * This is the documentation for the library interface of wimlib 1.5.0, a C
35 * library for creating, modifying, extracting, and mounting files in the
36 * Windows Imaging Format. This documentation is intended for developers only.
37 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
38 * program, please see the README file or manual pages.
40 * \section starting Getting Started
42 * wimlib uses the GNU autotools, so, on UNIX-like systems, it should be easy to
43 * install with <code>configure && make && sudo make install</code>; however,
44 * please see the README for more information about installing it. To use
45 * wimlib in a program after installing it, include @c wimlib.h and link your
46 * program with @c -lwim.
48 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. A ::WIMStruct
49 * may represent either a stand-alone WIM or one part of a split WIM.
51 * All functions in wimlib's public API are prefixed with @c wimlib. Most
52 * return 0 on success and a positive error code on failure. Use
53 * wimlib_get_error_string() to get a string that describes an error code.
54 * wimlib also can print error messages itself when an error happens, and these
55 * may be more informative than the error code; to enable this, call
56 * wimlib_set_print_errors(). Please note that this is for convenience only,
57 * and some errors can occur without a message being printed.
59 * First before calling any other functions, you should call
60 * wimlib_global_init() to initialize the library.
62 * To open an existing WIM, use wimlib_open_wim().
64 * To create a new WIM that initially contains no images, use
65 * wimlib_create_new_wim().
67 * To add an image to a WIM file from a directory tree on your filesystem, call
68 * wimlib_add_image(). This can be done with a ::WIMStruct gotten from
69 * wimlib_open_wim() or from wimlib_create_new_wim(). On UNIX-like systems,
70 * wimlib_add_image() can also capture a WIM image directly from a block device
71 * containing a NTFS filesystem.
73 * To extract an image from a WIM file, call wimlib_extract_image(). This can
74 * be done either to a directory, or, on UNIX-like systems, directly to a block
75 * device containing a NTFS filesystem.
77 * To extract individual files or directories from a WIM image, rather than a
78 * full image, call wimlib_extract_files().
80 * To programatically make changes to a WIM image without mounting it, call
81 * wimlib_update_image().
83 * On UNIX-like systems supporting FUSE (such as Linux), wimlib supports
84 * mounting WIM files either read-only or read-write. Mounting is done using
85 * wimlib_mount_image() and unmounting is done using wimlib_unmount_image().
86 * Mounting can be done without root privileges because it is implemented using
87 * FUSE (Filesystem in Userspace). If wimlib is compiled with the
88 * <code>--without-fuse</code> flag, these functions will be available but will
89 * fail with ::WIMLIB_ERR_UNSUPPORTED.
91 * After creating or modifying a WIM file, you can write it to a file using
92 * wimlib_write(). Alternatively, if the WIM was originally read from a file
93 * (using wimlib_open_wim() rather than wimlib_create_new_wim()), you can use
94 * wimlib_overwrite() to overwrite the original file. Still alternatively, you
95 * can write a WIM directly to a file descriptor by calling wimlib_write_to_fd()
98 * wimlib supports a special "pipable" WIM format (which unfortunately is @b not
99 * compatible with Microsoft's software). To create a pipable WIM, call
100 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
101 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
102 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
103 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
104 * a pipable WIM. wimlib can also transparently open and operate on pipable WIM
105 * s using a seekable file descriptor using the regular function calls (e.g.
106 * wimlib_open_wim(), wimlib_extract_image()).
108 * Please note: merely by calling wimlib_add_image() or many of the other
109 * functions in this library that operate on ::WIMStruct's, you are @b not
110 * modifying the WIM file on disk. Changes are not saved until you explicitly
111 * call wimlib_write() or wimlib_overwrite().
113 * After you are done with the WIM file, use wimlib_free() to free all memory
114 * associated with a ::WIMStruct and close all files associated with it.
116 * When you are completely done with using wimlib in your program, you should
117 * call wimlib_global_cleanup().
119 * A number of functions take a pointer to a progress function of type
120 * ::wimlib_progress_func_t. This function will be called periodically during
121 * the WIM operation(s) to report on the progress of the operation (for example,
122 * how many bytes have been written so far).
124 * wimlib is thread-safe as long as different ::WIMStruct's are used, except for
125 * the following exceptions:
126 * - You must call wimlib_global_init() in one thread before calling any other
128 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
129 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
130 * concurrently in the same process, will daemonize the entire process when it
131 * does so for the first time. This includes changing the working directory
132 * to the root directory.
134 * \section encodings Locales and character encodings
136 * To support Windows as well as UNIX-like systems, wimlib's API typically takes
137 * and returns strings of ::wimlib_tchar, which are in a platform-dependent
140 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
141 * and the encoding is UTF-16LE.
143 * On UNIX-like systems, each ::wimlib_tchar is 1 byte and is simply a "char",
144 * and the encoding is the locale-dependent multibyte encoding. I recommend you
145 * set your locale to a UTF-8 capable locale to avoid any issues. Also, by
146 * default, wimlib on UNIX will assume the locale is UTF-8 capable unless you
147 * call wimlib_global_init() after having set your desired locale.
149 * \section Limitations
151 * This section documents some technical limitations of wimlib not already
152 * documented in the man page for @b wimlib-imagex.
154 * - The old WIM format from Vista pre-releases is not supported.
155 * - Compressed resource chunk sizes other than 32768 are not supported. This
156 * doesn't seem to be a real problem because the chunk size always seems to be
158 * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
159 * functionality other than that already present in @b ImageX, that allows you
160 * to make certain Windows-specific modifications to a Windows PE image, such
161 * as adding a driver or Windows component. Such a tool possibly could be
162 * implemented on top of wimlib.
171 #include <inttypes.h>
174 /** Major version of the library (for example, the 1 in 1.2.5). */
175 #define WIMLIB_MAJOR_VERSION 1
177 /** Minor version of the library (for example, the 2 in 1.2.5). */
178 #define WIMLIB_MINOR_VERSION 5
180 /** Patch version of the library (for example, the 5 in 1.2.5). */
181 #define WIMLIB_PATCH_VERSION 0
184 * Opaque structure that represents a WIM file. This is an in-memory structure
185 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
186 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
187 * continuing to exist so that data can be read from it as needed.
189 * Most functions in this library will work the same way regardless of whether a
190 * given ::WIMStruct was obtained through wimlib_open_wim() or
191 * wimlib_create_new_wim(). Exceptions are documented.
193 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
194 * file from a ::WIMStruct.
196 #ifndef WIMLIB_WIMSTRUCT_DECLARED
197 typedef struct WIMStruct WIMStruct;
198 #define WIMLIB_WIMSTRUCT_DECLARED
202 typedef wchar_t wimlib_tchar;
204 /** See \ref encodings */
205 typedef char wimlib_tchar;
209 /** Path separator for WIM paths passed back to progress callbacks. */
210 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
211 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
213 /** Path separator for WIM paths passed back to progress callbacks. */
214 # define WIMLIB_WIM_PATH_SEPARATOR '/'
215 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
219 # define _wimlib_deprecated __attribute__((deprecated))
221 # define _wimlib_deprecated
224 #define WIMLIB_GUID_LEN 16
227 * Specifies the compression type of a WIM file.
229 enum wimlib_compression_type {
230 /** An invalid compression type. */
231 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
233 /** The WIM does not include any compressed resources. */
234 WIMLIB_COMPRESSION_TYPE_NONE = 0,
236 /** Compressed resources in the WIM use LZX compression. */
237 WIMLIB_COMPRESSION_TYPE_LZX = 1,
239 /** Compressed resources in the WIM use XPRESS compression. */
240 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
243 /** Possible values of the first parameter to the user-supplied
244 * ::wimlib_progress_func_t progress function */
245 enum wimlib_progress_msg {
247 /** A WIM image is about to be extracted. @p info will point to
248 * ::wimlib_progress_info.extract. */
249 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
251 /** A file or directory tree within a WIM image (not the full image) is
252 * about to be extracted. @p info will point to
253 * ::wimlib_progress_info.extract. */
254 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
256 /** The directory structure of the WIM image is about to be extracted.
257 * @p info will point to ::wimlib_progress_info.extract. */
258 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
260 /** The directory structure of the WIM image has been successfully
261 * extracted. @p info will point to ::wimlib_progress_info.extract. */
262 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
264 /** The WIM image's files resources are currently being extracted. @p
265 * info will point to ::wimlib_progress_info.extract. */
266 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
268 /** Starting to read a new part of a split pipable WIM over the pipe.
269 * @p info will point to ::wimlib_progress_info.extract. */
270 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
272 /** All the WIM files and directories have been extracted, and
273 * timestamps are about to be applied. @p info will point to
274 * ::wimlib_progress_info.extract. */
275 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
277 /** A WIM image has been successfully extracted. @p info will point to
278 * ::wimlib_progress_info.extract. */
279 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
281 /** A file or directory tree within a WIM image (not the full image) has
282 * been successfully extracted. @p info will point to
283 * ::wimlib_progress_info.extract. */
284 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
286 /** The directory or NTFS volume is about to be scanned to build a tree
287 * of WIM dentries in-memory. @p info will point to
288 * ::wimlib_progress_info.scan. */
289 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
291 /** A directory or file is being scanned. @p info will point to
292 * ::wimlib_progress_info.scan, and its @p cur_path member will be
293 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE
294 * is passed to wimlib_add_image(). */
295 WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
297 /** The directory or NTFS volume has been successfully scanned, and a
298 * tree of WIM dentries has been built in-memory. @p info will point to
299 * ::wimlib_progress_info.scan. */
300 WIMLIB_PROGRESS_MSG_SCAN_END,
303 * File resources are currently being written to the WIM.
304 * @p info will point to ::wimlib_progress_info.write_streams. */
305 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
308 * The metadata resource for each image is about to be written to the
309 * WIM. @p info will not be valid. */
310 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
313 * The metadata resource for each image has successfully been writen to
314 * the WIM. @p info will not be valid. */
315 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
318 * The temporary file has successfully been renamed to the original WIM
319 * file. Only happens when wimlib_overwrite() is called and the
320 * overwrite is not done in-place.
321 * @p info will point to ::wimlib_progress_info.rename. */
322 WIMLIB_PROGRESS_MSG_RENAME,
324 /** The contents of the WIM are being checked against the integrity
325 * table. Only happens when wimlib_open_wim() is called with the
326 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. @p info will point to
327 * ::wimlib_progress_info.integrity. */
328 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
330 /** An integrity table is being calculated for the WIM being written.
331 * Only happens when wimlib_write() or wimlib_overwrite() is called with
332 * the ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag. @p info will point to
333 * ::wimlib_progress_info.integrity. */
334 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
336 /** Reserved. (Previously used for WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
337 * but in wimlib v1.5.0 this was removed to simplify the code and now
338 * you'll get ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages instead.) */
339 WIMLIB_PROGRESS_MSG_RESERVED,
341 /** A wimlib_split() operation is in progress, and a new split part is
342 * about to be started. @p info will point to
343 * ::wimlib_progress_info.split. */
344 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
346 /** A wimlib_split() operation is in progress, and a split part has been
347 * finished. @p info will point to ::wimlib_progress_info.split. */
348 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
351 * A WIM update command is just about to be executed; @p info will point
352 * to ::wimlib_progress_info.update.
354 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
357 * A WIM update command has just been executed; @p info will point to
358 * ::wimlib_progress_info.update.
360 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
364 /** A pointer to this union is passed to the user-supplied
365 * ::wimlib_progress_func_t progress function. One (or none) of the structures
366 * contained in this union will be applicable for the operation
367 * (::wimlib_progress_msg) indicated in the first argument to the progress
369 union wimlib_progress_info {
371 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
372 * document them if they aren't given a name... */
374 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. */
375 struct wimlib_progress_info_write_streams {
376 /** Number of bytes that are going to be written for all the
377 * streams combined. This is the amount in uncompressed data.
378 * (The actual number of bytes will be less if the data is being
379 * written compressed.) */
380 uint64_t total_bytes;
382 /** Number of streams that are going to be written. */
383 uint64_t total_streams;
385 /** Number of uncompressed bytes that have been written so far.
386 * Will be 0 initially, and equal to @p total_bytes at the end.
388 uint64_t completed_bytes;
390 /** Number of streams that have been written. Will be 0
391 * initially, and equal to @p total_streams at the end. */
392 uint64_t completed_streams;
394 /** Number of threads that are being used to compress resources
395 * (if applicable). */
396 unsigned num_threads;
398 /** The compression type being used to write the streams; either
399 * ::WIMLIB_COMPRESSION_TYPE_NONE,
400 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or
401 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
402 int compression_type;
404 /** Number of split WIM parts from which streams are being
405 * written (may be 0 if irrelevant). */
406 unsigned total_parts;
408 /** Number of split WIM parts from which streams have been
409 * written (may be 0 if irrelevant). */
410 unsigned completed_parts;
413 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
414 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
415 struct wimlib_progress_info_scan {
416 /** Directory or NTFS volume that is being scanned. */
417 const wimlib_tchar *source;
419 /** Path to the file or directory that is about to be scanned,
420 * relative to the root of the image capture or the NTFS volume.
422 const wimlib_tchar *cur_path;
425 /** File or directory looks okay and will be captured. */
426 WIMLIB_SCAN_DENTRY_OK = 0,
428 /** File or directory is being excluded from capture due
429 * to the capture configuration file. */
430 WIMLIB_SCAN_DENTRY_EXCLUDED,
432 /** File or directory is being excluded from capture due
433 * to being unsupported (e.g. an encrypted or device
435 WIMLIB_SCAN_DENTRY_UNSUPPORTED,
438 /** Target path in the WIM. Only valid on messages
439 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
440 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
441 const wimlib_tchar *wim_target_path;
444 /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
445 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
446 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
447 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
448 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
449 struct wimlib_progress_info_extract {
450 /** Number of the image being extracted (1-based). */
453 /** Flags passed to to wimlib_extract_image() */
456 /** Full path to the WIM file being extracted. */
457 const wimlib_tchar *wimfile_name;
459 /** Name of the image being extracted. */
460 const wimlib_tchar *image_name;
462 /** Directory or NTFS volume to which the image is being
464 const wimlib_tchar *target;
467 const wimlib_tchar *cur_path;
469 /** Number of bytes of uncompressed data that will be extracted.
470 * Takes into account hard links (they are not counted for each
472 uint64_t total_bytes;
474 /** Number of bytes that have been written so far. Will be 0
475 * initially, and equal to @p total_bytes at the end. */
476 uint64_t completed_bytes;
478 /** Number of streams that will be extracted. This may more or
479 * less than the number of "files" to be extracted due to
480 * special cases (hard links, symbolic links, and alternate data
482 uint64_t num_streams;
484 /** Path to the root dentry within the WIM for the tree that is
485 * being extracted. Will be the empty string when extracting a
487 const wimlib_tchar *extract_root_wim_source_path;
489 /** Currently only used for
490 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
492 unsigned part_number;
494 /** Currently only used for
495 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
496 unsigned total_parts;
498 /** Currently only used for
499 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
500 uint8_t guid[WIMLIB_GUID_LEN];
503 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
504 struct wimlib_progress_info_rename {
505 /** Name of the temporary file that the WIM was written to. */
506 const wimlib_tchar *from;
508 /** Name of the original WIM file to which the temporary file is
510 const wimlib_tchar *to;
513 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
514 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
515 struct wimlib_progress_info_update {
516 /** Pointer to the update command that will be executed or has
517 * just been executed. */
518 const struct wimlib_update_command *command;
520 /** Number of update commands that have been completed so far.
522 size_t completed_commands;
524 /** Number of update commands that are being executed as part of
525 * this call to wimlib_update_image(). */
526 size_t total_commands;
529 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
530 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
531 struct wimlib_progress_info_integrity {
532 /** Number of bytes from the end of the WIM header to the end of
533 * the lookup table (the area that is covered by the SHA1
534 * integrity checks.) */
535 uint64_t total_bytes;
537 /** Number of bytes that have been SHA1-summed so far. Will be
538 * 0 initially, and equal @p total_bytes at the end. */
539 uint64_t completed_bytes;
541 /** Number of chunks that the checksummed region is divided
543 uint32_t total_chunks;
545 /** Number of chunks that have been SHA1-summed so far. Will
546 * be 0 initially, and equal to @p total_chunks at the end. */
547 uint32_t completed_chunks;
549 /** Size of the chunks used for the integrity calculation. */
552 /** Filename of the WIM (only valid if the message is
553 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
554 const wimlib_tchar *filename;
557 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
558 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
559 struct wimlib_progress_info_split {
560 /** Total size of the original WIM's file and metadata resources
562 uint64_t total_bytes;
564 /** Number of bytes of file and metadata resources that have
565 * been copied out of the original WIM so far. Will be 0
566 * initially, and equal to @p total_bytes at the end. */
567 uint64_t completed_bytes;
569 /** Number of the split WIM part that is about to be started
570 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
571 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
572 unsigned cur_part_number;
574 /** Total number of split WIM parts that are being written. */
575 unsigned total_parts;
577 /** Name of the split WIM part that is about to be started
578 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
579 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
580 const wimlib_tchar *part_name;
584 /** A user-supplied function that will be called periodically during certain WIM
585 * operations. The first argument will be the type of operation that is being
586 * performed or is about to be started or has been completed. The second
587 * argument will be a pointer to one of a number of structures depending on the
588 * first argument. It may be @c NULL for some message types.
590 * The return value of the progress function is currently ignored, but it may do
591 * something in the future. (Set it to 0 for now.)
593 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
594 const union wimlib_progress_info *info);
596 /** An array of these structures is passed to wimlib_add_image_multisource() to
597 * specify the sources from which to create a WIM image. */
598 struct wimlib_capture_source {
599 /** Absolute or relative path to a file or directory on the external
600 * filesystem to be included in the WIM image. */
601 wimlib_tchar *fs_source_path;
603 /** Destination path in the WIM image. Leading and trailing slashes are
604 * ignored. The empty string or @c NULL means the root directory of the
606 wimlib_tchar *wim_target_path;
608 /** Reserved; set to 0. */
612 /** Structure that specifies a list of path patterns. */
613 struct wimlib_pattern_list {
614 /** Array of patterns. The patterns may be modified by library code,
615 * but the @p pats pointer itself will not. See the man page for
616 * <b>wimlib-imagex capture</b> for more information about allowed
620 /** Number of patterns in the @p pats array. */
623 /** Ignored; may be used by the calling code. */
624 size_t num_allocated_pats;
627 /** A structure that contains lists of wildcards that match paths to treat
628 * specially when capturing a WIM image. */
629 struct wimlib_capture_config {
630 /** Paths matching any pattern this list are excluded from being
631 * captured, except if the same path appears in @p
632 * exclusion_exception_pats. */
633 struct wimlib_pattern_list exclusion_pats;
635 /** Paths matching any pattern in this list are never excluded from
637 struct wimlib_pattern_list exclusion_exception_pats;
639 /** Reserved for future capture configuration options. */
640 struct wimlib_pattern_list reserved1;
642 /** Reserved for future capture configuration options. */
643 struct wimlib_pattern_list reserved2;
645 /** Library internal use only. */
646 wimlib_tchar *_prefix;
648 /** Library internal use only. */
649 size_t _prefix_num_tchars;
652 /** Set or unset the WIM header flag that marks it read-only
653 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
654 * ::wimlib_wim_info.is_marked_readonly member of the @p info parameter. This
655 * is distinct from basic file permissions; this flag can be set on a WIM file
656 * that is physically writable. If this flag is set, all further operations to
657 * modify the WIM will fail, except calling wimlib_overwrite() with
658 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
659 * allows you to set this flag persistently on the underlying WIM file.
661 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
663 /** Set the GUID (globally unique identifier) of the WIM file to the value
664 * specified in ::wimlib_wim_info.guid of the @p info parameter. */
665 #define WIMLIB_CHANGE_GUID 0x00000002
667 /** Change the bootable image of the WIM to the value specified in
668 * ::wimlib_wim_info.boot_index of the @p info parameter. */
669 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
671 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
672 * in ::wimlib_wim_info.has_rpfix of the @p info parameter. This flag generally
673 * indicates whether an image in the WIM has been captured with reparse-point
674 * fixups enabled. wimlib also treats this flag as specifying whether to do
675 * reparse-point fixups by default when capturing or applying WIM images. */
676 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
678 /** General information about a WIM file. */
679 struct wimlib_wim_info {
681 /** Globally unique identifier for the WIM file. Note: all parts of a
682 * split WIM should have an identical value in this field. */
683 uint8_t guid[WIMLIB_GUID_LEN];
685 /** Number of images in the WIM. */
686 uint32_t image_count;
688 /** 1-based index of the bootable image in the WIM, or 0 if no image is
692 /** Version of the WIM file. */
693 uint32_t wim_version;
695 /** Chunk size used for compression. */
698 /** 1-based index of this part within a split WIM, or 1 if the WIM is
700 uint16_t part_number;
702 /** Total number of parts in the split WIM, or 1 if the WIM is
704 uint16_t total_parts;
706 /** One of the ::wimlib_compression_type values that specifies the
707 * method used to compress resources in the WIM. */
708 int32_t compression_type;
710 /** Size of the WIM file in bytes, excluding the XML data and integrity
712 uint64_t total_bytes;
714 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
715 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
716 * this will always be 0, even if the ::WIMStruct was written to
717 * somewhere by calling wimlib_write() with the
718 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
719 uint32_t has_integrity_table : 1;
721 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
722 * wimlib_create_new_wim(). */
723 uint32_t opened_from_file : 1;
725 /** 1 if the WIM is considered readonly for any reason. */
726 uint32_t is_readonly : 1;
728 /** 1 if reparse-point fixups are supposedly enabled for one or more
729 * images in the WIM. */
730 uint32_t has_rpfix : 1;
732 /** 1 if the WIM is marked as read-only. */
733 uint32_t is_marked_readonly : 1;
735 /** 1 if the WIM is part of a spanned set. */
736 uint32_t spanned : 1;
738 uint32_t write_in_progress : 1;
739 uint32_t metadata_only : 1;
740 uint32_t resource_only : 1;
742 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
743 uint32_t pipable : 1;
744 uint32_t reserved_flags : 22;
745 uint32_t reserved[9];
748 /** Information about a unique resource in the WIM file.
750 struct wimlib_resource_entry {
751 /** Uncompressed size of the resource in bytes. */
752 uint64_t uncompressed_size;
754 /** Compressed size of the resource in bytes. This will be the same as
755 * @p uncompressed_size if the resource is uncompressed. */
756 uint64_t compressed_size;
758 /** Offset, in bytes, of this resource from the start of the WIM file.
762 /** SHA1 message digest of the resource's uncompressed contents. */
763 uint8_t sha1_hash[20];
765 /** Which part number of the split WIM this resource is in. This should
766 * be the same as the part number provided by wimlib_get_wim_info(). */
767 uint32_t part_number;
769 /** Number of times this resource is referenced over all WIM images. */
770 uint32_t reference_count;
772 /** 1 if this resource is compressed. */
773 uint32_t is_compressed : 1;
775 /** 1 if this resource is a metadata resource rather than a file
777 uint32_t is_metadata : 1;
779 uint32_t is_free : 1;
780 uint32_t is_spanned : 1;
781 uint32_t reserved_flags : 28;
782 uint64_t reserved[4];
785 /** A stream of a file in the WIM. */
786 struct wimlib_stream_entry {
787 /** Name of the stream, or NULL if the stream is unnamed. */
788 const wimlib_tchar *stream_name;
789 /** Location, size, etc. of the stream within the WIM file. */
790 struct wimlib_resource_entry resource;
791 uint64_t reserved[4];
794 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
795 * Roughly, the information about a "file" in the WIM--- but really a directory
796 * entry ("dentry") because hard links are allowed. The hard_link_group_id
797 * field can be used to distinguish actual file inodes. */
798 struct wimlib_dir_entry {
799 /** Name of the file, or NULL if this file is unnamed (only possible for
800 * the root directory) */
801 const wimlib_tchar *filename;
803 /** 8.3 DOS name of this file, or NULL if this file has no such name.
805 const wimlib_tchar *dos_name;
807 /** Full path to this file within the WIM image. */
808 const wimlib_tchar *full_path;
810 /** Depth of this directory entry, where 0 is the root, 1 is the root's
811 * children, ..., etc. */
814 /** Pointer to the security descriptor for this file, in Windows
815 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
816 * security descriptor. */
817 const char *security_descriptor;
819 /** Length of the above security descriptor. */
820 size_t security_descriptor_size;
822 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
823 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
824 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
825 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
826 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
827 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
828 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
829 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
830 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
831 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
832 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
833 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
834 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
835 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
836 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
837 /** File attributes, such as whether the file is a directory or not.
838 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
839 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
840 * on other platforms. */
843 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
844 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
845 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
846 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
847 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
848 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
849 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
850 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
851 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
852 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
853 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
854 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
855 * attributes), this will give the reparse tag. This tells you whether
856 * the reparse point is a symbolic link, junction point, or some other,
857 * more unusual kind of reparse point. */
858 uint32_t reparse_tag;
860 /* Number of (hard) links to this file. */
863 /** Number of named data streams that this file has. Normally 0. */
864 uint32_t num_named_streams;
866 /** Roughly, the inode number of this file. However, it may be 0 if
867 * @p num_links == 1. */
868 uint64_t hard_link_group_id;
870 /** Time this file was created. */
871 struct timespec creation_time;
873 /** Time this file was last written to. */
874 struct timespec last_write_time;
876 /** Time this file was last accessed. */
877 struct timespec last_access_time;
878 uint64_t reserved[16];
880 /** Array of streams that make up this file. The first entry will
881 * always exist and will correspond to the unnamed data stream (default
882 * file contents), so it will have @p stream_name == @c NULL. There
883 * will then be @p num_named_streams additional entries that specify the
884 * named data streams, if any, each of which will have @p stream_name !=
886 struct wimlib_stream_entry streams[];
890 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
893 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
897 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
900 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
903 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
904 * just on the specified path. */
905 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
907 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
908 * itself; only its children (in the case of a non-empty directory) */
909 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
913 /*****************************
915 *****************************/
917 /** Directly capture a NTFS volume rather than a generic directory. This flag
918 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
919 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
920 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
922 /** Follow symlinks; archive and dump the files they point to. Cannot be used
923 * with ::WIMLIB_ADD_FLAG_NTFS. */
924 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
926 /** Call the progress function with the message
927 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
928 * be scanned, or when a directory or file is being excluded from capture. */
929 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
931 /** Mark the image being added as the bootable image of the WIM. */
932 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
934 /** Store the UNIX owner, group, and mode. This is done by adding a special
935 * alternate data stream to each regular file, symbolic link, and directory to
936 * contain this information. Please note that this flag is for convenience
937 * only; Microsoft's @a imagex.exe will not understand this special information.
938 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
939 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
941 /** Do not capture security descriptors. Only has an effect in NTFS capture
942 * mode, or in Win32 native builds. */
943 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
945 /** Fail immediately if the full security descriptor of any file or directory
946 * cannot be accessed. Only has an effect in Win32 native builds. The default
947 * behavior without this flag is to first try omitting the SACL from the
948 * security descriptor, then to try omitting the security descriptor entirely.
950 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
952 /** Call the progress function with the message
953 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
954 * capture. This is a subset of the messages provided by
955 * ::WIMLIB_ADD_FLAG_VERBOSE. */
956 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
958 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
959 * in the case of Windows) that point inside the directory being captured to
960 * instead be absolute relative to the directory being captured, rather than the
961 * current root; also exclude absolute symbolic links that point outside the
962 * directory tree being captured.
964 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
965 * the WIM header or if this is the first image being added.
966 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
967 * reparse point fixups enabled and currently cannot be unset. */
968 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
970 /** Don't do reparse point fixups. The default behavior is described in the
971 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
972 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
974 /** Do not automatically exclude unsupported files or directories from capture;
975 * e.g. encrypted directories in NTFS-3g capture mode, or device files and FIFOs
976 * on UNIX-like systems. Instead, fail with ::WIMLIB_ERR_UNSUPPORTED_FILE when
977 * such a file is encountered. */
978 #define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
980 /** Automatically select a capture configuration appropriate for capturing
981 * filesystems containing Windows operating systems. When this flag is
982 * specified, the corresponding @p config parameter or member must be @c NULL.
984 * Currently, selecting this capture configuration will cause the following
985 * files and directories to be excluded from capture:
990 * - "\System Volume Information"
994 * Note that the default behavior--- that is, when this flag is not specified
995 * and @p config is @c NULL--- is to use no capture configuration, meaning that
996 * no files are excluded from capture.
998 #define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
1000 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
1001 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
1002 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
1003 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
1004 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
1005 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
1006 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
1007 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
1008 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
1009 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
1010 #define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
1011 WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
1012 #define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
1014 /******************************
1015 * WIMLIB_DELETE_FLAG_*
1016 ******************************/
1018 /** Do not issue an error if the path to delete does not exist. */
1019 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
1021 /** Delete the file or directory tree recursively; if not specified, an error is
1022 * issued if the path to delete is a directory. */
1023 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
1025 /******************************
1026 * WIMLIB_EXPORT_FLAG_*
1027 ******************************/
1029 /** See documentation for wimlib_export_image(). */
1030 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
1032 /******************************
1033 * WIMLIB_EXTRACT_FLAG_*
1034 ******************************/
1036 /** Extract the image directly to a NTFS volume rather than a generic directory.
1037 * This mode is only available if wimlib was compiled with libntfs-3g support;
1038 * if not, ::WIMLIB_ERR_UNSUPPORTED will be returned. In this mode, the
1039 * extraction target will be interpreted as the path to a NTFS volume image (as
1040 * a regular file or block device) rather than a directory. It will be opened
1041 * using libntfs-3g, and the image will be extracted to the NTFS filesystem's
1042 * root directory. Note: this flag cannot be used when wimlib_extract_image()
1043 * is called with ::WIMLIB_ALL_IMAGES as the @p image. */
1044 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
1046 /** When identical files are extracted from the WIM, always hard link them
1048 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
1050 /** When identical files are extracted from the WIM, always symlink them
1052 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
1054 /** This flag no longer does anything but is reserved for future use. */
1055 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
1057 /** Read the WIM file sequentially while extracting the image. */
1058 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
1060 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA. Only
1061 * valid on UNIX-like platforms, and when ::WIMLIB_EXTRACT_FLAG_NTFS was not
1063 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1065 /** Do not extract security descriptors. */
1066 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1068 /** Fail immediately if the full security descriptor of any file or directory
1069 * cannot be set exactly as specified in the WIM file. On Windows, the default
1070 * behavior without this flag is to fall back to setting the security descriptor
1071 * with the SACL omitted, then only the default inherited security descriptor,
1072 * if we do not have permission to set the desired one. */
1073 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1075 /** This is the extraction equivalent to ::WIMLIB_ADD_FLAG_RPFIX. This forces
1076 * reparse-point fixups on, so absolute symbolic links or junction points will
1077 * be fixed to be absolute relative to the actual extraction root. Reparse
1078 * point fixups are done by default if WIM_HDR_FLAG_RP_FIX is set in the WIM
1079 * header. This flag may only be specified when extracting a full image (not a
1080 * file or directory tree within one). */
1081 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1083 /** Force reparse-point fixups on extraction off, regardless of the state of the
1084 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. */
1085 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1087 /** Extract the specified file to standard output. This is only valid in an
1088 * extraction command that specifies the extraction of a regular file in the WIM
1090 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1092 /** Instead of ignoring files and directories with names that cannot be
1093 * represented on the current platform (note: Windows has more restrictions on
1094 * filenames than POSIX-compliant systems), try to replace characters or append
1095 * junk to the names so that they can be extracted in some form. */
1096 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1098 /** On Windows, when there exist two or more files with the same case
1099 * insensitive name but different case sensitive names, try to extract them all
1100 * by appending junk to the end of them, rather than arbitrarily extracting only
1102 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1104 /** Do not ignore failure to set timestamps on extracted files. */
1105 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1107 /** Do not ignore failure to set short names on extracted files. */
1108 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1110 /** Do not ignore failure to extract symbolic links (and junction points, on
1111 * Windows) due to permissions problems. By default, such failures are ignored
1112 * since the default configuration of Windows only allows the Administrator to
1113 * create symbolic links. */
1114 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1116 /** TODO: this flag is intended to allow resuming an aborted extraction, but the
1117 * behavior is currently less than satisfactory. Do not use (yet). */
1118 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1120 /******************************
1121 * WIMLIB_MOUNT_FLAG_*
1122 ******************************/
1124 /** Mount the WIM image read-write rather than the default of read-only. */
1125 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1127 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1128 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1130 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1131 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1133 /** Access alternate data streams in the mounted WIM image through extended file
1134 * attributes. This is the default mode. */
1135 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1137 /** Access alternate data streams in the mounted WIM image by specifying the
1138 * file name, a colon, then the alternate file stream name. */
1139 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1141 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1142 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1143 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1145 /** Allow other users to see the mounted filesystem. (this passes the @c
1146 * allow_other option to FUSE mount) */
1147 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1149 /******************************
1150 * WIMLIB_OPEN_FLAG_*
1151 ******************************/
1153 /** Verify the WIM contents against the WIM's integrity table, if present. This
1154 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1155 * checksummed and checked against the SHA1 message digests specified in the
1156 * integrity table. ::WIMLIB_ERR_INTEGRITY is returned if there are any
1157 * mismatches (or, ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE is returned if the
1158 * integrity table is invalid). */
1159 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1161 /** Do not issue an error if the WIM is part of a split WIM. Programs must
1162 * specify this flag if they intend to open part of a split WIM, rather than
1163 * only supporting standalone WIMs. */
1164 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x00000002
1166 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1167 * is not. A WIM is considered writable only if it is writable at the
1168 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1169 * header, and is not part of a spanned set. It is not required to provide this
1170 * flag before attempting to make changes to the WIM, but with this flag you get
1171 * an error sooner rather than later. */
1172 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1174 /******************************
1175 * WIMLIB_UNMOUNT_FLAG_*
1176 ******************************/
1178 /** See ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY. */
1179 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1181 /** Unless this flag is given, changes to a read-write mounted WIM are
1182 * discarded. Ignored for read-only mounts. */
1183 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1185 /** See ::WIMLIB_WRITE_FLAG_REBUILD. */
1186 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1188 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1189 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1191 /** Do a "lazy" unmount (detach filesystem immediately, even if busy). */
1192 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1194 /******************************
1195 * WIMLIB_UPDATE_FLAG_*
1196 ******************************/
1198 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1199 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1200 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1202 /******************************
1203 * WIMLIB_WRITE_FLAG_*
1204 ******************************/
1206 /** Include an integrity table in the WIM.
1208 * For WIMs created with wimlib_open_wim(), the default behavior is to include
1209 * an integrity table if and only if one was present before. For WIMs created
1210 * with wimlib_create_new_wim(), the default behavior is to not include an
1211 * integrity table. */
1212 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1214 /** Do not include an integrity table in the new WIM file. This is the default
1215 * behavior, unless the WIM already included an integrity table. */
1216 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1218 /** Write the WIM as "pipable". After writing a WIM with this flag specified,
1219 * images from it can be applied directly from a pipe using
1220 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1221 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1222 * with this flag will not be compatible with Microsoft's software.
1224 * For WIMs created with wimlib_open_wim(), the default behavior is to write the
1225 * WIM as pipable if and only if it was pipable before. For WIMs created with
1226 * wimlib_create_new_wim(), the default behavior is to write the WIM as
1228 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1230 /** Do not write the WIM as "pipable". This is the default behavior, unless the
1231 * WIM was pipable already. */
1232 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1234 /** Recompress all resources, even if they could otherwise be copied from a
1235 * different WIM with the same compression type (in the case of
1236 * wimlib_export_image() being called previously). This flag is also valid in
1237 * the @p wim_write_flags of wimlib_join(), in which case all resources included
1238 * in the joined WIM file will be recompressed. */
1239 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1241 /** Call fsync() just before the WIM file is closed. */
1242 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1244 /** wimlib_overwrite() only: Re-build the entire WIM file rather than appending
1245 * data to it if possible. */
1246 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1248 /** wimlib_overwrite() only: Specifying this flag overrides the default
1249 * behavior of wimlib_overwrite() after one or more calls to
1250 * wimlib_delete_image(), which is to rebuild the entire WIM. With this flag,
1251 * only minimal changes to correctly remove the image from the WIM will be
1252 * taken. In particular, all streams will be left alone, even if they are no
1253 * longer referenced. This is probably not what you want, because almost no
1254 * space will be saved by deleting an image in this way. */
1255 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1257 /** wimlib_overwrite() only: Allow overwriting the WIM even if the readonly
1258 * flag is set in the WIM header. This can be used in combination with
1259 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1260 * set the readonly flag on the on-disk WIM file. */
1261 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1263 /******************************
1264 * WIMLIB_INIT_FLAG_*
1265 ******************************/
1267 /** Assume that strings are represented in UTF-8, even if this is not the
1268 * locale's character encoding. This flag is ignored on Windows, where wimlib
1269 * always uses UTF-16LE. */
1270 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1272 /** Windows-only: do not attempt to acquire additional privileges (currently
1273 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1274 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1275 * for the case where the calling program manages these privileges itself.
1276 * Note: no error is issued if privileges cannot be acquired, although related
1277 * errors may be reported later, depending on if the operations performed
1278 * actually require additional privileges or not. */
1279 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1281 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1282 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1283 * to read all possible data and metadata for a capture operation could not be
1284 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES.
1286 #define WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES 0x00000004
1288 /** Windows only: If ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES not specified,
1289 * return ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES if privileges that may be needed
1290 * to restore all possible data and metadata for an apply operation could not be
1291 * acquired. Can be combined with ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES.
1293 #define WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES 0x00000008
1295 /** Specification of an update to perform on a WIM image. */
1296 struct wimlib_update_command {
1298 /** The specific type of update to perform. */
1299 enum wimlib_update_op {
1300 /** Add a new file or directory tree to the WIM image in a
1301 * certain location. */
1302 WIMLIB_UPDATE_OP_ADD = 0,
1304 /** Delete a file or directory tree from the WIM image. */
1305 WIMLIB_UPDATE_OP_DELETE,
1307 /** Rename a file or directory tree in the WIM image. */
1308 WIMLIB_UPDATE_OP_RENAME,
1311 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1312 struct wimlib_add_command {
1313 /** Filesystem path to the file or directory tree to
1315 wimlib_tchar *fs_source_path;
1316 /** Path, specified from the root of the WIM image, at
1317 * which to add the file or directory tree within the
1319 wimlib_tchar *wim_target_path;
1321 /** Configuration for excluded files. @c NULL means
1322 * exclude no files (use no configuration), unless
1323 * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
1325 struct wimlib_capture_config *config;
1327 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1330 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1331 struct wimlib_delete_command {
1332 /** Path, specified from the root of the WIM image, for
1333 * the file or directory tree within the WIM image to be
1335 wimlib_tchar *wim_path;
1336 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1339 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1340 struct wimlib_rename_command {
1341 /** Path, specified from the root of the WIM image, for
1342 * the source file or directory tree within the WIM
1344 wimlib_tchar *wim_source_path;
1345 /** Path, specified from the root of the WIM image, for
1346 * the destination file or directory tree within the WIM
1348 wimlib_tchar *wim_target_path;
1349 /** Reserved; set to 0. */
1355 /** Specification of a file or directory tree to extract from a WIM image. */
1356 struct wimlib_extract_command {
1357 /** Path to file or directory tree within the WIM image to extract. It
1358 * must be provided as an absolute path from the root of the WIM image.
1359 * The path separators may be either forward slashes or backslashes. */
1360 wimlib_tchar *wim_source_path;
1362 /** Filesystem path to extract the file or directory tree to. */
1363 wimlib_tchar *fs_dest_path;
1365 /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1370 * Possible values of the error code returned by many functions in wimlib.
1372 * See the documentation for each wimlib function to see specifically what error
1373 * codes can be returned by a given function, and what they mean.
1375 enum wimlib_error_code {
1376 WIMLIB_ERR_SUCCESS = 0,
1377 WIMLIB_ERR_ALREADY_LOCKED,
1378 WIMLIB_ERR_DECOMPRESSION,
1379 WIMLIB_ERR_DELETE_STAGING_DIR,
1380 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1383 WIMLIB_ERR_FUSERMOUNT,
1384 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1385 WIMLIB_ERR_IMAGE_COUNT,
1386 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1387 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES,
1388 WIMLIB_ERR_INTEGRITY,
1389 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1390 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1391 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1392 WIMLIB_ERR_INVALID_HEADER,
1393 WIMLIB_ERR_INVALID_IMAGE,
1394 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1395 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1396 WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1397 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1398 WIMLIB_ERR_INVALID_OVERLAY,
1399 WIMLIB_ERR_INVALID_PARAM,
1400 WIMLIB_ERR_INVALID_PART_NUMBER,
1401 WIMLIB_ERR_INVALID_PIPABLE_WIM,
1402 WIMLIB_ERR_INVALID_REPARSE_DATA,
1403 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1404 WIMLIB_ERR_INVALID_SECURITY_DATA,
1405 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1406 WIMLIB_ERR_INVALID_UTF16_STRING,
1407 WIMLIB_ERR_INVALID_UTF8_STRING,
1408 WIMLIB_ERR_IS_DIRECTORY,
1409 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1415 WIMLIB_ERR_NOTEMPTY,
1416 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1417 WIMLIB_ERR_NOT_A_WIM_FILE,
1418 WIMLIB_ERR_NOT_PIPABLE,
1419 WIMLIB_ERR_NO_FILENAME,
1423 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1425 WIMLIB_ERR_READLINK,
1428 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1429 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1430 WIMLIB_ERR_RESOURCE_ORDER,
1431 WIMLIB_ERR_SET_ATTRIBUTES,
1432 WIMLIB_ERR_SET_REPARSE_DATA,
1433 WIMLIB_ERR_SET_SECURITY,
1434 WIMLIB_ERR_SET_SHORT_NAME,
1435 WIMLIB_ERR_SET_TIMESTAMPS,
1436 WIMLIB_ERR_SPLIT_INVALID,
1437 WIMLIB_ERR_SPLIT_UNSUPPORTED,
1440 WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
1441 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1442 WIMLIB_ERR_UNKNOWN_VERSION,
1443 WIMLIB_ERR_UNSUPPORTED,
1444 WIMLIB_ERR_UNSUPPORTED_FILE,
1445 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1446 WIMLIB_ERR_WIM_IS_READONLY,
1452 /** Used to indicate no WIM image or an invalid WIM image. */
1453 #define WIMLIB_NO_IMAGE 0
1455 /** Used to specify all images in the WIM. */
1456 #define WIMLIB_ALL_IMAGES (-1)
1459 * Appends an empty image to a WIM file. This empty image will initially
1460 * contain no files or directories, although if written without further
1461 * modifications, a root directory will be created automatically for it. After
1462 * calling this function, you can use wimlib_update_image() to add files to the
1463 * new WIM image. This gives you slightly more control over making the new
1464 * image compared to calling wimlib_add_image() or
1465 * wimlib_add_image_multisource() directly.
1468 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
1471 * Name to give the new image. If @c NULL or empty, the new image is given
1472 * no name. If nonempty, it must specify a name that does not already
1474 * @param new_idx_ret
1475 * If non-<code>NULL</code>, the index of the newly added image is returned
1478 * @return 0 on success; nonzero on failure. The possible error codes are:
1480 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1481 * There is already an image in @p wim named @p name.
1482 * @retval ::WIMLIB_ERR_NOMEM
1483 * Failed to allocate the memory needed to add the new image.
1484 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1485 * The WIM file is considered read-only because of any of the reasons
1486 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1490 wimlib_add_empty_image(WIMStruct *wim,
1491 const wimlib_tchar *name,
1495 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1497 * The directory tree or NTFS volume is scanned immediately to load the dentry
1498 * tree into memory, and file attributes and symbolic links are read. However,
1499 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1502 * See the manual page for the @b wimlib-imagex program for more information
1503 * about the "normal" capture mode versus the NTFS capture mode (entered by
1504 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1506 * Note that @b no changes are committed to the underlying WIM file (if
1507 * any) until wimlib_write() or wimlib_overwrite() is called.
1510 * Pointer to the ::WIMStruct for a WIM file to which the image will be
1513 * A path to a directory or unmounted NTFS volume that will be captured as
1516 * Name to give the new image. If @c NULL or empty, the new image is given
1517 * no name. If nonempty, it must specify a name that does not already
1520 * Capture configuration that specifies files, directories, or path globs
1521 * to exclude from being captured. If @c NULL, a dummy configuration where
1522 * no paths are treated specially is used.
1524 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1525 * @param progress_func
1526 * If non-NULL, a function that will be called periodically with the
1527 * progress of the current operation. The progress messages that will be
1528 * received are ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
1529 * ::WIMLIB_PROGRESS_MSG_SCAN_END, and, if ::WIMLIB_ADD_FLAG_VERBOSE was
1530 * included in @p add_flags, also ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY.
1532 * @return 0 on success; nonzero on error. On error, changes to @p wim are
1533 * discarded so that it appears to be in the same state as when this function
1536 * This function is implemented by calling wimlib_add_empty_image(), then
1537 * calling wimlib_update_image() with a single "add" command, so any error code
1538 * returned by wimlib_add_empty_image() may be returned, as well as any error
1539 * codes returned by wimlib_update_image() other than ones documented as only
1540 * being returned specifically by an update involving delete or rename commands.
1543 wimlib_add_image(WIMStruct *wim,
1544 const wimlib_tchar *source,
1545 const wimlib_tchar *name,
1546 const struct wimlib_capture_config *config,
1548 wimlib_progress_func_t progress_func);
1550 /** This function is equivalent to wimlib_add_image() except it allows for
1551 * multiple sources to be combined into a single WIM image. This is done by
1552 * specifying the @p sources and @p num_sources parameters instead of the @p
1553 * source parameter of wimlib_add_image(). The rest of the parameters are the
1554 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
1555 * capture</b> for full details on how this mode works.
1557 * In addition to the error codes that wimlib_add_image() can return,
1558 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1559 * when trying to overlay a non-directory on a directory or when otherwise
1560 * trying to overlay multiple conflicting files to the same location in the WIM
1561 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
1562 * ::WIMLIB_ADD_FLAG_NTFS was specified in @p add_flags but there
1563 * was not exactly one capture source with the target being the root directory.
1564 * (In this respect, there is no advantage to using
1565 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1568 wimlib_add_image_multisource(WIMStruct *wim,
1569 const struct wimlib_capture_source *sources,
1571 const wimlib_tchar *name,
1572 const struct wimlib_capture_config *config,
1574 wimlib_progress_func_t progress_func);
1577 * Creates a ::WIMStruct for a new WIM file.
1579 * This only creates an in-memory structure for a WIM that initially contains no
1580 * images. No on-disk file is created until wimlib_write() is called.
1583 * The type of compression to be used in the new WIM file. Must be
1584 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
1585 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1587 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
1588 * written to the memory location pointed to by this paramater. The
1589 * ::WIMStruct must be freed using using wimlib_free() when finished with
1591 * @return 0 on success; nonzero on error.
1592 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1593 * @p ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
1594 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1595 * @retval ::WIMLIB_ERR_NOMEM
1596 * Failed to allocate needed memory.
1599 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
1602 * Deletes an image, or all images, from a WIM file.
1604 * All streams referenced by the image(s) being deleted are removed from the
1605 * lookup table of the WIM if they are not referenced by any other images in the
1608 * Please note that @b no changes are committed to the underlying WIM file (if
1609 * any) until wimlib_write() or wimlib_overwrite() is called.
1612 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
1615 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
1617 * @return 0 on success; nonzero on failure. On failure, @p wim is guaranteed
1618 * to be left unmodified only if @p image specified a single image. If instead
1619 * @p image was ::WIMLIB_ALL_IMAGES and @p wim contained more than one image, it's
1620 * possible for some but not all of the images to have been deleted when a
1621 * failure status is returned.
1623 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1624 * @p image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
1625 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1626 * The WIM file is considered read-only because of any of the reasons
1627 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1630 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
1631 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_NOMEM,
1632 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
1633 * indicate failure (for different reasons) to read the metadata resource for an
1634 * image that needed to be deleted.
1637 wimlib_delete_image(WIMStruct *wim, int image);
1640 * Exports an image, or all the images, from a WIM file, into another WIM file.
1642 * The destination image is made to share the same dentry tree and security data
1643 * structure as the source image. This places some restrictions on additional
1644 * functions that may be called. wimlib_mount_image() may not be called on
1645 * either the source image or the destination image without an intervening call
1646 * to a function that un-shares the images, such as wimlib_free() on @p
1647 * dest_wim, or wimlib_delete_image() on either the source or destination image.
1648 * Furthermore, you may not call wimlib_free() on @p src_wim before calling
1649 * wimlib_write() or wimlib_overwrite() on @p dest_wim because @p dest_wim will
1650 * have references back to @p src_wim.
1652 * If this function fails, all changes to @p dest_wim are rolled back.
1654 * Please note that no changes are committed to the underlying WIM file of @p
1655 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
1658 * Pointer to the ::WIMStruct for a stand-alone WIM or part 1 of a split
1659 * WIM that contains the image(s) being exported.
1661 * The image to export from @p src_wim. Can be the number of an image, or
1662 * ::WIMLIB_ALL_IMAGES to export all images.
1664 * Pointer to the ::WIMStruct for a WIM file that will receive the images
1667 * The name to give the exported image in the new WIM file. If left @c
1668 * NULL, the name from @p src_wim is used. This parameter must be left @c
1669 * NULL if @p src_image is ::WIMLIB_ALL_IMAGES and @p src_wim contains more
1670 * than one image; in that case, the names are all taken from the @p
1671 * src_wim. (This is allowed even if one or more images being exported has
1673 * @param dest_description
1674 * The description to give the exported image in the new WIM file. If left
1675 * @c NULL, the description from the @p src_wim is used. This parameter must
1676 * be left @c NULL if @p src_image is ::WIMLIB_ALL_IMAGES and @p src_wim contains
1677 * more than one image; in that case, the descriptions are all taken from
1678 * @p src_wim. (This is allowed even if one or more images being exported
1679 * has no description.)
1680 * @param export_flags
1681 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
1682 * bootable, or 0 if which image is marked as bootable in the destination
1683 * WIM is to be left unchanged. If @p src_image is ::WIMLIB_ALL_IMAGES and
1684 * there are multiple images in @p src_wim, specifying
1685 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
1686 * currently marked as bootable in @p src_wim; if that is the case, then
1687 * that image is marked as bootable in the destination WIM.
1688 * @param additional_swms
1689 * Array of pointers to the ::WIMStruct for each additional part in the
1690 * split WIM. Ignored if @p num_additional_swms is 0. The pointers do not
1691 * need to be in any particular order, but they must include all parts of
1692 * the split WIM other than the first part, which must be provided in the
1694 * @param num_additional_swms
1695 * Number of additional WIM parts provided in the @p additional_swms array.
1696 * This number should be one less than the total number of parts in the
1697 * split WIM. Set to 0 if the WIM is a standalone WIM.
1698 * @param progress_func
1699 * If non-NULL, a function that will be called periodically with the
1700 * progress of the current operation.
1702 * @return 0 on success; nonzero on error.
1703 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1704 * One or more of the names being given to an exported image was already in
1705 * use in the destination WIM.
1706 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1707 * @p src_image does not exist in @p src_wim.
1708 * @retval ::WIMLIB_ERR_INVALID_PARAM
1709 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @p flags, @p src_image was
1710 * ::WIMLIB_ALL_IMAGES, @p src_wim contains multiple images, and no images in
1711 * @p src_wim are marked as bootable; or @p dest_name and/or @p
1712 * dest_description were non-<code>NULL</code>, @p src_image was
1713 * ::WIMLIB_ALL_IMAGES, and @p src_wim contains multiple images.
1714 * @retval ::WIMLIB_ERR_NOMEM
1715 * Failed to allocate needed memory.
1716 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1717 * The source WIM is a split WIM, but the parts specified do not form a
1718 * complete split WIM because they do not include all the parts of the
1719 * split WIM, there are duplicate parts, or not all the parts are in fact
1720 * from the same split WIM.
1721 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1722 * @p dest_wim is considered read-only because of any of the reasons
1723 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1726 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
1727 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_NOMEM,
1728 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
1729 * indicate failure (for different reasons) to read the metadata resource for an
1730 * image in @p src_wim that needed to be exported.
1733 wimlib_export_image(WIMStruct *src_wim, int src_image,
1734 WIMStruct *dest_wim,
1735 const wimlib_tchar *dest_name,
1736 const wimlib_tchar *dest_description,
1738 WIMStruct **additional_swms,
1739 unsigned num_additional_swms,
1740 wimlib_progress_func_t progress_func);
1743 * Extract zero or more files or directory trees from a WIM image.
1745 * This generalizes the single-image extraction functionality of
1746 * wimlib_extract_image() to allow extracting only the specified subsets of the
1750 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1754 * The 1-based number of the image in @p wim from which the files or
1755 * directory trees are to be extracted. It cannot be ::WIMLIB_ALL_IMAGES.
1758 * An array of ::wimlib_extract_command structures that specifies the
1759 * extractions to perform.
1762 * Number of commands in the @p cmds array.
1764 * @param default_extract_flags
1765 * Default extraction flags; the behavior shall be as if these flags had
1766 * been specified in the ::wimlib_extract_command.extract_flags member in
1767 * each extraction command, in combination with any flags already present.
1769 * @param additional_swms
1770 * Array of pointers to the ::WIMStruct for each additional part in the
1771 * split WIM. Ignored if @p num_additional_swms is 0. The pointers do not
1772 * need to be in any particular order, but they must include all parts of
1773 * the split WIM other than the first part, which must be provided in the
1776 * @param num_additional_swms
1777 * Number of additional WIM parts provided in the @p additional_swms array.
1778 * This number should be one less than the total number of parts in the
1779 * split WIM. Set to 0 if the WIM is a standalone WIM.
1781 * @param progress_func
1782 * If non-NULL, a function that will be called periodically with the
1783 * progress of the current operation.
1785 * @return 0 on success; nonzero on error. The possible error codes include
1786 * most of those documented as returned by wimlib_extract_image() as well as the
1787 * following additional error codes:
1789 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1790 * @p image was ::WIMLIB_ALL_IMAGES (or was not otherwise a valid image in
1792 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
1793 * The ::wimlib_extract_command.wim_source_path member in one of the
1794 * extract commands did not exist in the WIM.
1795 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
1796 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
1797 * in which ::wimlib_extract_command.wim_source_path existed but was not a
1798 * regular file or directory.
1799 * @retval ::WIMLIB_ERR_INVALID_PARAM
1800 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
1801 * specified for some commands but not all; or
1802 * ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
1803 * for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
1804 * for a command in which ::wimlib_extract_command.wim_source_path did not
1805 * specify the root directory of the WIM image.
1808 wimlib_extract_files(WIMStruct *wim,
1810 const struct wimlib_extract_command *cmds,
1812 int default_extract_flags,
1813 WIMStruct **additional_swms,
1814 unsigned num_additional_swms,
1815 wimlib_progress_func_t progress_func);
1818 * Extracts an image, or all images, from a standalone or split WIM file to a
1819 * directory or directly to a NTFS volume image.
1821 * The exact behavior of how wimlib extracts files from a WIM image is
1822 * controllable by the @p extract_flags parameter, but there also are
1823 * differences depending on the platform (UNIX-like vs Windows). See the manual
1824 * page for <b>wimlib-imagex apply</b> for more information, including about the
1825 * special "NTFS volume extraction mode" entered by providing
1826 * ::WIMLIB_EXTRACT_FLAG_NTFS.
1828 * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
1829 * returned if any resulting SHA1 message digests do not match the values
1830 * provided in the WIM file. Therefore, if this function is successful, you can
1831 * be fairly sure that any compressed data in the WIM was uncompressed
1835 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1838 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
1839 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
1840 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @p extract_flags.
1842 * Directory to extract the WIM image(s) to (created if it does not already
1843 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @p extract_flags, the
1844 * path to the unmounted NTFS volume to extract the image to.
1845 * @param extract_flags
1846 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
1847 * @param additional_swms
1848 * Array of pointers to the ::WIMStruct for each additional part in the
1849 * split WIM. Ignored if @p num_additional_swms is 0. The pointers do not
1850 * need to be in any particular order, but they must include all parts of
1851 * the split WIM other than the first part, which must be provided in the
1853 * @param num_additional_swms
1854 * Number of additional WIM parts provided in the @p additional_swms array.
1855 * This number should be one less than the total number of parts in the
1856 * split WIM. Set to 0 if the WIM is a standalone WIM.
1858 * @param progress_func
1859 * If non-NULL, a function that will be called periodically with the
1860 * progress of the current operation.
1862 * @return 0 on success; nonzero on error.
1863 * @retval ::WIMLIB_ERR_DECOMPRESSION
1864 * Failed to decompress a resource to be extracted, or failed to decompress
1865 * a needed metadata resource.
1866 * @retval ::WIMLIB_ERR_INVALID_PARAM
1867 * Both ::WIMLIB_EXTRACT_FLAG_HARDLINK and ::WIMLIB_EXTRACT_FLAG_SYMLINK
1868 * were specified in @p extract_flags; or both
1869 * ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS and ::WIMLIB_EXTRACT_FLAG_NO_ACLS were
1870 * specified in @p extract_flags; or both ::WIMLIB_EXTRACT_FLAG_RPFIX and
1871 * ::WIMLIB_EXTRACT_FLAG_NORPFIX were specified in @p extract_flags; or
1872 * ::WIMLIB_EXTRACT_FLAG_RESUME was specified in @p extract_flags; or if
1873 * ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @p extract_flags and
1874 * @p image was ::WIMLIB_ALL_IMAGES.
1875 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
1876 * The metadata resource for an image being extracted was invalid.
1877 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
1878 * The SHA1 message digest of an extracted stream did not match the SHA1
1879 * message digest given in the WIM file.
1880 * @retval ::WIMLIB_ERR_LINK
1881 * Failed to create a symbolic link or a hard link.
1882 * @retval ::WIMLIB_ERR_MKDIR
1883 * Failed create a directory.
1884 * @retval ::WIMLIB_ERR_NOMEM
1885 * Failed to allocate needed memory.
1886 * @retval ::WIMLIB_ERR_OPEN
1887 * Could not create a file, or failed to open an already-extracted file.
1888 * @retval ::WIMLIB_ERR_READ
1889 * Failed to read data from the WIM file associated with @p wim.
1890 * @retval ::WIMLIB_ERR_READLINK
1891 * Failed to determine the target of a symbolic link in the WIM.
1892 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
1893 * Failed to fix the target of an absolute symbolic link (e.g. if the
1894 * target would have exceeded the maximum allowed length). (Only if
1895 * reparse data was supported by the extraction mode and
1896 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS was specified in @p extract_flags.)
1897 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
1898 * One of the files or directories that needed to be extracted referenced a
1899 * stream not present in the WIM's lookup table (or in any of the lookup
1900 * tables of the split WIM parts).
1901 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
1902 * Failed to set attributes on a file.
1903 * @retval ::WIMLIB_ERR_SET_REPARSE_DATA
1904 * Failed to set reparse data on a file (only if reparse data was supported
1905 * by the extraction mode).
1906 * @retval ::WIMLIB_ERR_SET_SECURITY
1907 * Failed to set security descriptor on a file
1908 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS was specified in @p
1910 * @retval ::WIMLIB_ERR_SET_SHORT_NAME
1911 * Failed to set the short name of a file (only if
1912 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES was specified in @p extract_flags).
1913 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
1914 * Failed to set timestamps on a file (only if
1915 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS was specified in @p extract_flags).
1916 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1917 * The WIM is a split WIM, but the parts specified do not form a complete
1918 * split WIM because they do not include all the parts of the original WIM,
1919 * there are duplicate parts, or not all the parts have the same GUID and
1921 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
1922 * Unexpected end-of-file occurred when reading data from the WIM file
1923 * associated with @p wim.
1924 * @retval ::WIMLIB_ERR_UNSUPPORTED
1925 * A requested extraction flag, or the data or metadata that must be
1926 * extracted to support it, is unsupported in the build and configuration
1927 * of wimlib, or on the current platform or extraction mode or target
1928 * volume. Flags affected by this include ::WIMLIB_EXTRACT_FLAG_NTFS,
1929 * ::WIMLIB_EXTRACT_FLAG_UNIX_DATA, ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS,
1930 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES,
1931 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS,
1932 * ::WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS, ::WIMLIB_EXTRACT_FLAG_SYMLINK,
1933 * and ::WIMLIB_EXTRACT_FLAG_HARDLINK. For example, if
1934 * ::WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES is specified in @p
1936 * ::WIMLIB_ERR_UNSUPPORTED will be returned if the WIM image contains one
1937 * or more files with short names, but extracting short names is not
1938 * supported --- on Windows, this occurs if the target volume does not
1939 * support short names, while on non-Windows, this occurs if
1940 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @p extract_flags.
1941 * @retval ::WIMLIB_ERR_WRITE
1942 * Failed to write data to a file being extracted.
1945 wimlib_extract_image(WIMStruct *wim, int image,
1946 const wimlib_tchar *target,
1948 WIMStruct **additional_swms,
1949 unsigned num_additional_swms,
1950 wimlib_progress_func_t progress_func);
1953 * Since wimlib v1.5.0: Extract one or more images from a pipe on which a
1954 * pipable WIM is being sent.
1956 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
1957 * about pipable WIMs.
1959 * This function operates in a special way to read the WIM fully sequentially.
1960 * As a result, there is no ::WIMStruct is made visible to library users, and
1961 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
1962 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
1963 * seekable file, not a pipe.)
1966 * File descriptor, which may be a pipe, opened for reading and positioned
1967 * at the start of the pipable WIM.
1968 * @param image_num_or_name
1969 * String that specifies the 1-based index or name of the image to extract.
1970 * It is translated to an image index using the same rules that
1971 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
1972 * only a single image (not all images) can be specified. Alternatively,
1973 * specify @p NULL here to use the first image in the WIM if it contains
1974 * exactly one image but otherwise return @p WIMLIB_ERR_INVALID_IMAGE.
1976 * Same as the corresponding parameter to wimlib_extract_image().
1977 * @param extract_flags
1978 * Same as the corresponding parameter to wimlib_extract_image(), except
1979 * for the following exceptions: ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is
1980 * always implied, since data is always read from @p pipe_fd sequentially
1981 * in this mode; also, ::WIMLIB_EXTRACT_FLAG_TO_STDOUT is invalid and will
1982 * result in ::WIMLIB_ERR_INVALID_PARAM being returned.
1983 * @param progress_func
1984 * Same as the corresponding parameter to wimlib_extract_image(), except
1985 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
1988 * @return 0 on success; nonzero on error. The possible error codes include
1989 * those returned by wimlib_extract_image() as well as the following:
1991 * @retval ::WIMLIB_ERR_INVALID_PIPABLE_WIM
1992 * Data read from the pipable WIM was invalid.
1993 * @retval ::WIMLIB_ERR_NOT_PIPABLE
1994 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
1997 wimlib_extract_image_from_pipe(int pipe_fd,
1998 const wimlib_tchar *image_num_or_name,
1999 const wimlib_tchar *target, int extract_flags,
2000 wimlib_progress_func_t progress_func);
2003 * Extracts the XML data of a WIM file to a file stream. Every WIM file
2004 * includes a string of XML that describes the images contained in the WIM.
2005 * This function works on standalone WIMs as well as split WIM parts.
2008 * Pointer to the ::WIMStruct for a WIM file.
2010 * @c stdout, or a FILE* opened for writing, to extract the data to.
2012 * @return 0 on success; nonzero on error.
2013 * @retval ::WIMLIB_ERR_INVALID_PARAM
2014 * @p wim is not a ::WIMStruct that was created by wimlib_open_wim().
2015 * @retval ::WIMLIB_ERR_NOMEM
2016 * @retval ::WIMLIB_ERR_READ
2017 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2018 * Failed to read the XML data from the WIM.
2019 * @retval ::WIMLIB_ERR_WRITE
2020 * Failed to completely write the XML data to @p fp.
2023 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
2026 * Frees all memory allocated for a WIMStruct and closes all files associated
2030 * Pointer to the ::WIMStruct for a WIM file.
2032 * @return This function has no return value.
2035 wimlib_free(WIMStruct *wim);
2038 * Converts a ::wimlib_compression_type value into a string.
2041 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
2042 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
2045 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
2048 extern const wimlib_tchar *
2049 wimlib_get_compression_type_string(int ctype);
2052 * Converts an error code into a string describing it.
2055 * The error code returned by one of wimlib's functions.
2058 * Pointer to a statically allocated string describing the error code,
2059 * or @c NULL if the error code is not valid.
2061 extern const wimlib_tchar *
2062 wimlib_get_error_string(enum wimlib_error_code code);
2065 * Returns the description of the specified image.
2068 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2069 * standalone WIM or a split WIM part.
2071 * The number of the image, numbered starting at 1.
2074 * The description of the image, or @c NULL if there is no such image, or
2075 * @c NULL if the specified image has no description. The description
2076 * string is in library-internal memory and may not be modified or freed;
2077 * in addition, the string will become invalid if the description of the
2078 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2080 extern const wimlib_tchar *
2081 wimlib_get_image_description(const WIMStruct *wim, int image);
2084 * Returns the name of the specified image.
2087 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2088 * standalone WIM or a split WIM part.
2090 * The number of the image, numbered starting at 1.
2093 * The name of the image, or @c NULL if there is no such image, or an empty
2094 * string if the image is unnamed. The name string is in
2095 * library-internal memory and may not be modified or freed; in addition,
2096 * the string will become invalid if the name of the image is changed, the
2097 * image is deleted, or the ::WIMStruct is destroyed.
2099 extern const wimlib_tchar *
2100 wimlib_get_image_name(const WIMStruct *wim, int image);
2104 * Get basic information about a WIM file.
2107 * Pointer to the ::WIMStruct for a WIM file. It may be for either a
2108 * standalone WIM or part of a split WIM.
2110 * A ::wimlib_wim_info structure that will be filled in with information
2111 * about the WIM file.
2116 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2119 * Initialization function for wimlib. Call before using any other wimlib
2120 * function except wimlib_set_print_errors(). (However, currently this is not
2121 * strictly necessary and it will be called automatically if not done manually,
2122 * but you should not rely on this behavior.)
2125 * Bitwise OR of flags prefixed with WIMLIB_INIT_FLAG.
2127 * @return 0 on success; nonzero on failure. Currently, only the following
2128 * error code is defined:
2130 * @retval ::WIMLIB_ERR_INSUFFICIENT_PRIVILEGES
2131 * ::WIMLIB_INIT_FLAG_STRICT_APPLY_PRIVILEGES and/or
2132 * ::WIMLIB_INIT_FLAG_STRICT_CAPTURE_PRIVILEGES were specified in @p
2133 * init_flags, but the corresponding privileges could not be acquired.
2136 wimlib_global_init(int init_flags);
2139 * Cleanup function for wimlib. You are not required to call this function, but
2140 * it will release any global resources allocated by the library.
2143 wimlib_global_cleanup(void);
2146 * Determines if an image name is already used by some image in the WIM.
2149 * Pointer to the ::WIMStruct for a WIM file.
2151 * The name to check.
2154 * @c true if there is already an image in @p wim named @p name; @c false
2155 * if there is no image named @p name in @p wim. If @p name is @c NULL or
2156 * the empty string, @c false is returned.
2159 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2162 * Iterate through a file or directory tree in the WIM image. By specifying
2163 * appropriate flags and a callback function, you can get the attributes of a
2164 * file in the WIM, get a directory listing, or even get a listing of the entire
2168 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
2172 * The 1-based number of the image in @p wim that contains the files or
2173 * directories to iterate over, or ::WIMLIB_ALL_IMAGES to repeat the same
2174 * iteration on all images in the WIM.
2177 * Path in the WIM image at which to do the iteration.
2180 * Bitwise OR of ::WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE and/or
2181 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN.
2184 * A callback function that will receive each directory entry.
2187 * An extra parameter that will always be passed to the callback function
2190 * @return Normally, returns 0 if all calls to @p cb returned 0; otherwise the
2191 * first nonzero value that was returned from @p cb. However, additional error
2192 * codes may be returned, including the following:
2194 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2195 * @p path did not exist in the WIM image.
2196 * @retval ::WIMLIB_ERR_NOMEM
2197 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2199 * This function can additionally return ::WIMLIB_ERR_DECOMPRESSION,
2200 * ::WIMLIB_ERR_INVALID_METADATA_RESOURCE, ::WIMLIB_ERR_NOMEM,
2201 * ::WIMLIB_ERR_READ, or ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE, all of which
2202 * indicate failure (for different reasons) to read the metadata resource for an
2203 * image over which iteration needed to be done.
2206 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2208 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2211 * Iterate through the lookup table of a WIM file. This can be used to directly
2212 * get a listing of the unique resources contained in a WIM file. Both file
2213 * resources and metadata resources are included.
2216 * Pointer to the ::WIMStruct of a standalone WIM file or a split WIM part.
2217 * Note: metadata resources will only be included if the WIM is standalone
2218 * or the first part of the split WIM.
2221 * Reserved; set to 0.
2224 * A callback function that will receive each resource.
2227 * An extra parameter that will always be passed to the callback function
2230 * @return 0 if all calls to @p cb returned 0; otherwise the first nonzero value
2231 * that was returned from @p cb.
2234 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2235 wimlib_iterate_lookup_table_callback_t cb,
2239 * Joins a split WIM into a stand-alone one-part WIM.
2242 * An array of strings that gives the filenames of all parts of the split
2243 * WIM. No specific order is required, but all parts must be included with
2246 * Number of filenames in @p swms.
2247 * @param swm_open_flags
2248 * Open flags for the split WIM parts (e.g.
2249 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY). Note: WIMLIB_OPEN_FLAG_SPLIT_OK is
2250 * automatically added to the value specified here.
2251 * @param wim_write_flags
2252 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will
2253 * be used to write the joined WIM.
2254 * @param output_path
2255 * The path to write the joined WIM file to.
2256 * @param progress_func
2257 * If non-NULL, a function that will be called periodically with the
2258 * progress of the current operation.
2260 * @return 0 on success; nonzero on error. This function may return most error
2261 * codes that can be returned by wimlib_open_wim() and wimlib_write(), as well
2262 * as the following error code:
2264 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2265 * The split WIMs do not form a valid WIM because they do not include all
2266 * the parts of the original WIM, there are duplicate parts, or not all the
2267 * parts have the same GUID and compression type.
2269 * Note: wimlib_export_image() can provide similar functionality to
2270 * wimlib_join(), since it is possible to export all images from a split WIM.
2271 * Actually, wimlib_join() currently calls wimlib_export_image internally.
2274 wimlib_join(const wimlib_tchar * const *swms,
2276 const wimlib_tchar *output_path,
2278 int wim_write_flags,
2279 wimlib_progress_func_t progress_func);
2282 * Compress a chunk of a WIM resource using LZX compression.
2284 * This function is exported for convenience only and should only be used by
2285 * library clients looking to make use of wimlib's compression code for another
2289 * Uncompressed data of the chunk.
2291 * Size of the uncompressed chunk, in bytes.
2293 * Pointer to output buffer of size at least (@p chunk_size - 1) bytes.
2296 * The size of the compressed data written to @p out in bytes, or 0 if the
2297 * data could not be compressed to (@p chunk_size - 1) bytes or fewer.
2299 * As a special requirement, the compression code is optimized for the WIM
2300 * format and therefore requires (@p chunk_size <= 32768).
2303 wimlib_lzx_compress(const void *chunk, unsigned chunk_size, void *out);
2306 * Decompresses a block of LZX-compressed data as used in the WIM file format.
2308 * Note that this will NOT work unmodified for LZX as used in the cabinet
2309 * format, which is not the same as in the WIM format!
2311 * This function is exported for convenience only and should only be used by
2312 * library clients looking to make use of wimlib's compression code for another
2315 * @param compressed_data
2316 * Pointer to the compressed data.
2318 * @param compressed_len
2319 * Length of the compressed data, in bytes.
2321 * @param uncompressed_data
2322 * Pointer to the buffer into which to write the uncompressed data.
2324 * @param uncompressed_len
2325 * Length of the uncompressed data. It must be 32768 bytes or less.
2328 * 0 on success; non-zero on failure.
2331 wimlib_lzx_decompress(const void *compressed_data, unsigned compressed_len,
2332 void *uncompressed_data, unsigned uncompressed_len);
2336 * Mounts an image in a WIM file on a directory read-only or read-write.
2338 * As this is implemented using FUSE (Filesystme in UserSpacE), this is not
2339 * supported if wimlib was configured with @c --without-fuse. This includes
2340 * Windows builds of wimlib; ::WIMLIB_ERR_UNSUPPORTED will be returned in such
2343 * Calling this function daemonizes the process, unless
2344 * ::WIMLIB_MOUNT_FLAG_DEBUG was specified or an early occur occurs. If the
2345 * mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified), modifications
2346 * to the WIM are staged in a temporary directory.
2348 * It is safe to mount multiple images from the same underlying WIM file
2349 * read-only at the same time, but only if different ::WIMStruct's are used. It
2350 * is @b not safe to mount multiple images from the same WIM file read-write at
2353 * wimlib_mount_image() cannot be used on an image that was exported with
2354 * wimlib_export_image() while the dentry trees for both images are still in
2355 * memory. In addition, wimlib_mount_image() may not be used to mount an image
2356 * that already has modifications pending (e.g. an image added with
2357 * wimlib_add_image()).
2360 * Pointer to the ::WIMStruct containing the image to be mounted.
2362 * The number of the image to mount, indexed starting from it. It must be
2363 * an existing, single image.
2365 * The path to an existing empty directory to mount the image on.
2366 * @param mount_flags
2367 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
2368 * @param additional_swms
2369 * Array of pointers to the ::WIMStruct for each additional part in the
2370 * split WIM. Ignored if @p num_additional_swms is 0. The pointers do not
2371 * need to be in any particular order, but they must include all parts of
2372 * the split WIM other than the first part, which must be provided in the
2374 * @param num_additional_swms
2375 * Number of additional WIM parts provided in the @p additional_swms array.
2376 * This number should be one less than the total number of parts in the
2377 * split WIM. Set to 0 if the WIM is a standalone WIM.
2378 * @param staging_dir
2379 * If non-NULL, the name of a directory in which the staging directory will
2380 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2381 * in @p mount_flags. If left @c NULL, the staging directory is created in
2382 * the same directory as the WIM file that @p wim was originally read from.
2384 * @return 0 on success; nonzero on error.
2386 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2387 * A read-write mount was requested, but an an exclusive advisory lock on
2388 * the on-disk WIM file could not be acquired because another thread or
2389 * process has mounted an image from the WIM read-write or is currently
2390 * modifying the WIM in-place.
2391 * @retval ::WIMLIB_ERR_DECOMPRESSION
2392 * Could not decompress the metadata resource for @p image in @p wim.
2393 * @retval ::WIMLIB_ERR_FUSE
2394 * A non-zero status was returned by @c fuse_main().
2395 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2396 * @p image does not specify an existing, single image in @p wim.
2397 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
2398 * The metadata resource for @p image is invalid.
2399 * @retval ::WIMLIB_ERR_INVALID_PARAM
2400 * @p image is shared among multiple ::WIMStruct's as a result of a call to
2401 * wimlib_export_image(), or @p image has been added with
2402 * wimlib_add_image().
2403 * @retval ::WIMLIB_ERR_MKDIR
2404 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but the
2405 * staging directory could not be created.
2406 * @retval ::WIMLIB_ERR_NOMEM
2407 * Failed to allocate needed memory.
2408 * @retval ::WIMLIB_ERR_NOTDIR
2409 * Could not determine the current working directory.
2410 * @retval ::WIMLIB_ERR_READ
2411 * Failed to read data from the WIM file associated with @p wim.
2412 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2413 * One of the dentries in the image referenced a stream not present in the
2414 * WIM's lookup table (or in any of the lookup tables of the split WIM
2416 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2417 * The WIM is a split WIM, but the parts specified do not form a complete
2418 * split WIM because they do not include all the parts of the original WIM,
2419 * there are duplicate parts, or not all the parts have the same GUID and
2421 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2422 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @p mount_flags, but @p
2423 * wim is considered read-only because of any of the reasons mentioned in
2424 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2425 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2426 * Unexpected end-of-file occurred while reading data from the WIM file
2427 * associated with @p wim.
2428 * @retval ::WIMLIB_ERR_UNSUPPORTED
2429 * Mounting is not supported, either because the platform is Windows, or
2430 * because the platform is UNIX-like and wimlib was compiled with @c
2434 wimlib_mount_image(WIMStruct *wim,
2436 const wimlib_tchar *dir,
2438 WIMStruct **additional_swms,
2439 unsigned num_additional_swms,
2440 const wimlib_tchar *staging_dir);
2443 * Opens a WIM file and creates a ::WIMStruct for it.
2446 * The path to the WIM file to open.
2449 * Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.
2451 * @param progress_func
2452 * If non-NULL, a function that will be called periodically with the
2453 * progress of the current operation. Currently, the only messages sent
2454 * will be ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY, and only if
2455 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags.
2458 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2459 * is written to the memory location pointed to by this parameter. The
2460 * ::WIMStruct can be freed using using wimlib_free() when finished with
2463 * @return 0 on success; nonzero on error.
2464 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2465 * The WIM is not the non-first part of a split WIM, and the number of
2466 * metadata resources found in the WIM did not match the image count given
2467 * in the WIM header, or the number of <IMAGE> elements in the XML
2468 * data for the WIM did not match the image count given in the WIM header.
2469 * @retval ::WIMLIB_ERR_INTEGRITY
2470 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2471 * wim_file contains an integrity table, but the SHA1 message digest for a
2472 * chunk of the WIM does not match the corresponding message digest given
2473 * in the integrity table.
2474 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2475 * Resources in @p wim_file are compressed, but the chunk size is not 32768.
2476 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2477 * The header of @p wim_file says that resources in the WIM are compressed,
2478 * but the header flag indicating LZX or XPRESS compression is not set.
2479 * @retval ::WIMLIB_ERR_INVALID_HEADER
2480 * The header of @p wim_file was otherwise invalid.
2481 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2482 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @p open_flags and @p
2483 * wim_file contains an integrity table, but the integrity table is
2485 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2486 * The lookup table for the WIM contained duplicate entries that are not
2487 * for metadata resources, or it contained an entry with a SHA1 message
2488 * digest of all 0's.
2489 * @retval ::WIMLIB_ERR_INVALID_PARAM
2490 * @p wim_ret was @c NULL.
2491 * @retval ::WIMLIB_ERR_NOMEM
2492 * Failed to allocated needed memory.
2493 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2494 * @p wim_file does not begin with the expected magic characters.
2495 * @retval ::WIMLIB_ERR_OPEN
2496 * Failed to open the file @p wim_file for reading.
2497 * @retval ::WIMLIB_ERR_READ
2498 * Failed to read data from @p wim_file.
2499 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2500 * @p wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
2501 * specified in @p open_flags.
2502 * @retval ::WIMLIB_ERR_UNEXPECTED_END_OF_FILE
2503 * Unexpected end-of-file while reading data from @p wim_file.
2504 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2505 * A number other than 0x10d00 is written in the version field of the WIM
2506 * header of @p wim_file. (May be a pre-Vista WIM.)
2507 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2508 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2509 * considered read-only because of any of the reasons mentioned in the
2510 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2511 * @retval ::WIMLIB_ERR_XML
2512 * The XML data for @p wim_file is invalid.
2515 wimlib_open_wim(const wimlib_tchar *wim_file,
2517 WIMStruct **wim_ret,
2518 wimlib_progress_func_t progress_func);
2521 * Overwrites the file that the WIM was originally read from, with changes made.
2522 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2523 * rather than wimlib_create_new_wim().
2525 * There are two ways that a WIM may be overwritten. The first is to do a full
2526 * rebuild. In this mode, the new WIM is written to a temporary file and then
2527 * renamed to the original file after it is has been completely written. The
2528 * temporary file is made in the same directory as the original WIM file. A
2529 * full rebuild may take a while, but can be used even if images have been
2530 * modified or deleted, will produce a WIM with no holes, and has little chance
2531 * of unintentional data loss because the temporary WIM is fsync()ed before
2532 * being renamed to the original WIM.
2534 * The second way to overwrite a WIM is by appending to the end of it and
2535 * overwriting the header. This can be much faster than a full rebuild, but the
2536 * disadvantage is that some space will be wasted. Writing a WIM in this mode
2537 * begins with writing any new file resources *after* everything in the old WIM,
2538 * even though this will leave a hole where the old lookup table, XML data, and
2539 * integrity were. This is done so that the WIM remains valid even if the
2540 * operation is aborted mid-write. The WIM header is only overwritten at the
2541 * very last moment, and up until that point the WIM will be seen as the old
2544 * By default, wimlib_overwrite() does the append-style overwrite described
2545 * above, unless resources in the WIM are arranged in an unusual way or if
2546 * images have been deleted from the WIM. Use the flag
2547 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
2548 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
2549 * images have been deleted from the WIM.
2551 * In the temporary-file overwrite mode, no changes are made to the WIM on
2552 * failure, and the temporary file is deleted if possible. Abnormal termination
2553 * of the program will result in the temporary file being orphaned. In the
2554 * direct append mode, the WIM is truncated to the original length on failure;
2555 * and while abnormal termination of the program will result in extra data
2556 * appended to the original WIM, it should still be a valid WIM.
2558 * If this function completes successfully, no more functions should be called
2559 * on @p wim other than wimlib_free(). You must use wimlib_open_wim() to read
2560 * the WIM file anew.
2563 * Pointer to the ::WIMStruct for the WIM file to write. There may have
2564 * been in-memory changes made to it, which are then reflected in the
2566 * @param write_flags
2567 * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG.
2568 * @param num_threads
2569 * Number of threads to use for compression (see wimlib_write()).
2570 * @param progress_func
2571 * If non-NULL, a function that will be called periodically with the
2572 * progress of the current operation.
2574 * @return 0 on success; nonzero on error. This function may return any value
2575 * returned by wimlib_write() as well as the following error codes:
2576 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2577 * The WIM was going to be modified in-place (with no temporary file), but
2578 * an exclusive advisory lock on the on-disk WIM file could not be acquired
2579 * because another thread or process has mounted an image from the WIM
2580 * read-write or is currently modifying the WIM in-place.
2581 * @retval ::WIMLIB_ERR_NO_FILENAME
2582 * @p wim corresponds to a WIM created with wimlib_create_new_wim() rather
2583 * than a WIM read with wimlib_open_wim().
2584 * @retval ::WIMLIB_ERR_RENAME
2585 * The temporary file that the WIM was written to could not be renamed to
2586 * the original filename of @p wim.
2587 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2588 * The WIM file is considered read-only because of any of the reasons
2589 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2593 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
2594 wimlib_progress_func_t progress_func);
2597 * Prints information about one image, or all images, contained in a WIM.
2600 * Pointer to the ::WIMStruct for a WIM file.
2602 * The image about which to print information. Can be the number of an
2603 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
2606 * @return This function has no return value. No error checking is done when
2607 * printing the information. If @p image is invalid, an error message is
2611 wimlib_print_available_images(const WIMStruct *wim, int image);
2614 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
2615 * in a way that can be accessed programatically.
2618 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
2621 * Deprecated in favor of wimlib_iterate_dir_tree(), which provides the
2622 * information in a way that can be accessed programatically.
2625 wimlib_print_metadata(WIMStruct *wim, int image) _wimlib_deprecated;
2628 * Translates a string specifying the name or number of an image in the WIM into
2629 * the number of the image. The images are numbered starting at 1.
2632 * Pointer to the ::WIMStruct for a WIM file.
2633 * @param image_name_or_num
2634 * A string specifying the name or number of an image in the WIM. If it
2635 * parses to a positive integer, this integer is taken to specify the
2636 * number of the image, indexed starting at 1. Otherwise, it is taken to
2637 * be the name of an image, as given in the XML data for the WIM file. It
2638 * also may be the keyword "all" or the string "*", both of which will
2639 * resolve to ::WIMLIB_ALL_IMAGES.
2641 * There is no way to search for an image actually named "all", "*", or an
2642 * integer number, or an image that has no name. However, you can use
2643 * wimlib_get_image_name() to get the name of any image.
2646 * If the string resolved to a single existing image, the number of that
2647 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
2648 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
2649 * ::WIMLIB_NO_IMAGE is returned. If @p image_name_or_num was @c NULL or
2650 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
2651 * images in @p wim has no name.
2654 wimlib_resolve_image(WIMStruct *wim,
2655 const wimlib_tchar *image_name_or_num);
2658 * Changes the description of an image in the WIM.
2661 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2662 * standalone WIM or part of a split WIM; however, you should set the same
2663 * description on all parts of a split WIM.
2665 * The number of the image for which to change the description.
2666 * @param description
2667 * The new description to give the image. It may be @c NULL, which
2668 * indicates that the image is to be given no description.
2670 * @return 0 on success; nonzero on error.
2671 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2672 * @p image does not specify a single existing image in @p wim.
2673 * @retval ::WIMLIB_ERR_NOMEM
2674 * Failed to allocate the memory needed to duplicate the @p description
2676 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2677 * @p wim is considered read-only because of any of the reasons mentioned
2678 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2681 wimlib_set_image_descripton(WIMStruct *wim, int image,
2682 const wimlib_tchar *description);
2685 * Set basic information about a WIM.
2688 * A WIMStruct for a standalone WIM file.
2690 * A struct ::wimlib_wim_info that contains the information to set. Only
2691 * the information explicitly specified in the @p which flags need be
2694 * Flags that specify which information to set. This is a bitwise OR of
2695 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
2696 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
2698 * @return 0 on success; nonzero on failure.
2699 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2700 * The WIM file is considered read-only because of any of the reasons
2701 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2702 * flag. However, as a special case, if you are using
2703 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
2704 * function will not fail due to the readonly flag being previously set.
2705 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2706 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
2707 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
2711 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
2715 * Changes what is written in the \<FLAGS\> element in the WIM XML data
2716 * (something like "Core" or "Ultimate")
2719 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2720 * standalone WIM or part of a split WIM; however, you should set the same
2721 * \<FLAGS\> element on all parts of a split WIM.
2723 * The number of the image for which to change the description.
2725 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
2726 * indicates that the image is to be given no \<FLAGS\> element.
2728 * @return 0 on success; nonzero on error.
2729 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2730 * @p image does not specify a single existing image in @p wim.
2731 * @retval ::WIMLIB_ERR_NOMEM
2732 * Failed to allocate the memory needed to duplicate the @p flags string.
2733 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2734 * @p wim is considered read-only because of any of the reasons mentioned
2735 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2738 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
2741 * Changes the name of an image in the WIM.
2744 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2745 * standalone WIM or part of a split WIM; however, you should set the same
2746 * name on all parts of a split WIM.
2748 * The number of the image for which to change the name.
2750 * New name to give the new image. If @c NULL or empty, the new image is
2751 * given no name. If nonempty, it must specify a name that does not
2752 * already exist in @p wim.
2754 * @return 0 on success; nonzero on error.
2755 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2756 * There is already an image named @p name in @p wim.
2757 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2758 * @p image does not specify a single existing image in @p wim.
2759 * @retval ::WIMLIB_ERR_NOMEM
2760 * Failed to allocate the memory needed to duplicate the @p name string.
2761 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2762 * @p wim is considered read-only because of any of the reasons mentioned
2763 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2765 extern int wimlib_set_image_name(WIMStruct *wim, int image,
2766 const wimlib_tchar *name);
2769 * Set the functions that wimlib uses to allocate and free memory.
2771 * These settings are global and not per-WIM.
2773 * The default is to use the default @c malloc() and @c free() from the C
2776 * Please note that some external functions, such as those in @c libntfs-3g, may
2777 * use the standard memory allocation functions.
2779 * @param malloc_func
2780 * A function equivalent to @c malloc() that wimlib will use to allocate
2781 * memory. If @c NULL, the allocator function is set back to the default
2782 * @c malloc() from the C library.
2784 * A function equivalent to @c free() that wimlib will use to free memory.
2785 * If @c NULL, the free function is set back to the default @c free() from
2787 * @param realloc_func
2788 * A function equivalent to @c realloc() that wimlib will use to reallocate
2789 * memory. If @c NULL, the free function is set back to the default @c
2790 * realloc() from the C library.
2791 * @return 0 on success; nonzero on error.
2792 * @retval ::WIMLIB_ERR_UNSUPPORTED
2793 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
2794 * so custom memory allocators are unsupported.
2797 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
2798 void (*free_func)(void *),
2799 void *(*realloc_func)(void *, size_t));
2802 * Sets whether wimlib is to print error messages to @c stderr when a function
2803 * fails. These error messages may provide information that cannot be
2804 * determined only from the error code that is returned. Not every error will
2805 * result in an error message being printed.
2807 * This setting is global and not per-WIM.
2809 * By default, error messages are not printed.
2811 * This can be called before wimlib_global_init().
2813 * @param show_messages
2814 * @c true if error messages are to be printed; @c false if error messages
2815 * are not to be printed.
2817 * @return 0 on success; nonzero on error.
2818 * @retval ::WIMLIB_ERR_UNSUPPORTED
2819 * @p show_messages was @c true, but wimlib was compiled with the @c
2820 * --without-error-messages option. Therefore, error messages cannot be
2824 wimlib_set_print_errors(bool show_messages);
2827 * Splits a WIM into multiple parts.
2830 * The ::WIMStruct for the WIM to split. It must be a standalone, one-part
2833 * Name of the SWM file to create. This will be the name of the first
2834 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
2835 * appended before the suffix.
2837 * The maximum size per part, in bytes. Unfortunately, it is not
2838 * guaranteed that this will really be the maximum size per part, because
2839 * some file resources in the WIM may be larger than this size, and the WIM
2840 * file format provides no way to split up file resources among multiple
2842 * @param write_flags
2843 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
2844 * flags will be used to write each split WIM part. Specify 0 here to get
2845 * the default behavior.
2846 * @param progress_func
2847 * If non-NULL, a function that will be called periodically with the
2848 * progress of the current operation
2849 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
2850 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
2852 * @return 0 on success; nonzero on error. This function may return most error
2853 * codes that can be returned by wimlib_write() as well as the following error
2856 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2857 * @p wim was not part 1 of a stand-alone WIM.
2858 * @retval ::WIMLIB_ERR_INVALID_PARAM
2859 * @p swm_name was not a nonempty string, or @p part_size was 0.
2861 * Note: the WIM's uncompressed and compressed resources are not checksummed
2862 * when they are copied from the joined WIM to the split WIM parts, nor are
2863 * compressed resources re-compressed (unless explicitly requested with
2864 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
2867 wimlib_split(WIMStruct *wim,
2868 const wimlib_tchar *swm_name,
2871 wimlib_progress_func_t progress_func);
2874 * Unmounts a WIM image that was mounted using wimlib_mount_image().
2876 * The image to unmount is specified by the path to the mountpoint, not the
2877 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
2878 * touched and also may have been allocated in a different process.
2880 * To unmount the image, the thread calling this function communicates with the
2881 * thread that is managing the mounted WIM image. This function blocks until it
2882 * is known whether the unmount succeeded or failed. In the case of a
2883 * read-write mounted WIM, the unmount is not considered to have succeeded until
2884 * all changes have been saved to the underlying WIM file.
2887 * The directory that the WIM image was mounted on.
2888 * @param unmount_flags
2889 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
2890 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
2891 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
2893 * @param progress_func
2894 * If non-NULL, a function that will be called periodically with the
2895 * progress of the current operation. Currently, only
2896 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS will be sent.
2898 * @return 0 on success; nonzero on error.
2900 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
2901 * The filesystem daemon was unable to remove the staging directory and the
2902 * temporary files that it contains.
2903 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
2904 * The filesystem daemon appears to have terminated before sending an exit
2906 * @retval ::WIMLIB_ERR_FORK
2907 * Could not @c fork() the process.
2908 * @retval ::WIMLIB_ERR_FUSERMOUNT
2909 * The @b fusermount program could not be executed or exited with a failure
2911 * @retval ::WIMLIB_ERR_MQUEUE
2912 * Could not open a POSIX message queue to communicate with the filesystem
2913 * daemon servicing the mounted filesystem, could not send a message
2914 * through the queue, or could not receive a message through the queue.
2915 * @retval ::WIMLIB_ERR_NOMEM
2916 * Failed to allocate needed memory.
2917 * @retval ::WIMLIB_ERR_OPEN
2918 * The filesystem daemon could not open a temporary file for writing the
2920 * @retval ::WIMLIB_ERR_READ
2921 * A read error occurred when the filesystem daemon tried to a file from
2922 * the staging directory
2923 * @retval ::WIMLIB_ERR_RENAME
2924 * The filesystem daemon failed to rename the newly written WIM file to the
2925 * original WIM file.
2926 * @retval ::WIMLIB_ERR_UNSUPPORTED
2927 * Mounting is not supported, either because the platform is Windows, or
2928 * because the platform is UNIX-like and wimlib was compiled with @c
2930 * @retval ::WIMLIB_ERR_WRITE
2931 * A write error occurred when the filesystem daemon was writing to the new
2932 * WIM file, or the filesystem daemon was unable to flush changes that had
2933 * been made to files in the staging directory.
2936 wimlib_unmount_image(const wimlib_tchar *dir,
2938 wimlib_progress_func_t progress_func);
2941 * Update a WIM image by adding, deleting, and/or renaming files or directories.
2944 * Pointer to the ::WIMStruct for the WIM file to update.
2946 * The 1-based index of the image in the WIM to update. It cannot be
2947 * ::WIMLIB_ALL_IMAGES.
2949 * An array of ::wimlib_update_command's that specify the update operations
2952 * Number of commands in @p cmds.
2953 * @param update_flags
2954 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
2955 * @param progress_func
2956 * If non-NULL, a function that will be called periodically with the
2957 * progress of the current operation.
2959 * @return 0 on success; nonzero on error. On failure, some but not all of the
2960 * update commands may have been executed. No individual update command will
2961 * have been partially executed. Possible error codes include:
2963 * @retval ::WIMLIB_ERR_DECOMPRESSION
2964 * Failed to decompress the metadata resource from @p image in @p wim.
2965 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
2966 * The capture configuration structure specified for an add command was
2968 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2969 * @p image did not specify a single, existing image in @p wim.
2970 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
2971 * Attempted to perform an add command that conflicted with previously
2972 * existing files in the WIM when an overlay was attempted.
2973 * @retval ::WIMLIB_ERR_INVALID_PARAM
2974 * An unknown operation type was specified in the update commands; or,
2975 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
2976 * in the @p add_flags, but the same image had previously already been
2977 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
2978 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @p add_flags for one add
2979 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
2980 * specified in the @p add_flags for an add command in which @p
2981 * wim_target_path was not the root directory of the WIM image.
2982 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
2983 * (Windows only): While executing an add command, tried to capture a
2984 * reparse point with invalid data.
2985 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2986 * The metadata resource for @p image in @p wim is invalid.
2987 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2988 * The security data for image @p image in @p wim is invalid.
2989 * @retval ::WIMLIB_ERR_IS_DIRECTORY
2990 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
2991 * for a WIM path that corresponded to a directory; or, a rename command
2992 * attempted to rename a directory to a non-directory.
2993 * @retval ::WIMLIB_ERR_NOMEM
2994 * Failed to allocate needed memory.
2995 * @retval ::WIMLIB_ERR_NOTDIR
2996 * A rename command attempted to rename a directory to a non-directory; or,
2997 * an add command was executed that attempted to set the root of the WIM
2998 * image as a non-directory; or, a path component used as a directory in a
2999 * rename command was not, in fact, a directory.
3000 * @retval ::WIMLIB_ERR_NOTEMPTY
3001 * A rename command attempted to rename a directory to a non-empty
3003 * @retval ::WIMLIB_ERR_NTFS_3G
3004 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
3005 * error occurred while reading data from the NTFS volume using libntfs-3g.
3006 * @retval ::WIMLIB_ERR_OPEN
3007 * Failed to open a file to be captured while executing an add command.
3008 * @retval ::WIMLIB_ERR_OPENDIR
3009 * Failed to open a directory to be captured while executing an add command.
3010 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
3011 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3012 * WIM path that did not exist; or, a rename command attempted to rename a
3013 * file that does not exist.
3014 * @retval ::WIMLIB_ERR_READ
3015 * Failed to read the metadata resource for @p image in @p wim; or, while
3016 * executing an add command, failed to read data from a file or directory
3018 * @retval ::WIMLIB_ERR_READLINK
3019 * While executing an add command, failed to read the target of a symbolic
3020 * link or junction point.
3021 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3022 * (Windows only) Failed to perform a reparse point fixup because of
3023 * problems with the data of a reparse point.
3024 * @retval ::WIMLIB_ERR_UNSUPPORTED_FILE
3025 * While executing an add command, attempted to capture a file that was not
3026 * a supported file type (e.g. a device file). Only if
3027 * ::WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE specified in @p the add_flags
3028 * for an update command.
3029 * @retval ::WIMLIB_ERR_STAT
3030 * While executing an add command, failed to get attributes for a file or
3032 * @retval ::WIMLIB_ERR_UNSUPPORTED
3033 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update
3034 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
3035 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3036 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @p
3037 * add_flags for an update command.
3038 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3039 * The WIM file is considered read-only because of any of the reasons
3040 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3044 wimlib_update_image(WIMStruct *wim,
3046 const struct wimlib_update_command *cmds,
3049 wimlib_progress_func_t progress_func);
3052 * Writes a standalone WIM to a file.
3054 * This brings in resources from any external locations, such as directory trees
3055 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3056 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3059 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
3060 * changes made to it, which are then reflected in the output file.
3062 * The path to the file to write the WIM to.
3064 * The 1-based index of the image inside the WIM to write. Use
3065 * ::WIMLIB_ALL_IMAGES to include all images.
3066 * @param write_flags
3067 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3068 * @param num_threads
3069 * Number of threads to use for compressing data. If 0, the number of
3070 * threads is taken to be the number of online processors. Note: if no
3071 * data compression needs to be done, no additional threads will be created
3072 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
3073 * exporting an image from a compressed WIM to another WIM of the same
3074 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @p
3076 * @param progress_func
3077 * If non-NULL, a function that will be called periodically with the
3078 * progress of the current operation. The possible messages are
3079 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3080 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3081 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3083 * @return 0 on success; nonzero on error.
3085 * @retval ::WIMLIB_ERR_DECOMPRESSION
3086 * Failed to decompress a metadata or file resource in @p wim.
3087 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3088 * @p image does not specify a single existing image in @p wim, and is not
3089 * ::WIMLIB_ALL_IMAGES.
3090 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3091 * A file that had previously been scanned for inclusion in the WIM by
3092 * wimlib_add_image() was concurrently modified, so it failed the SHA1
3093 * message digest check.
3094 * @retval ::WIMLIB_ERR_INVALID_PARAM
3095 * @p path was @c NULL.
3096 * @retval ::WIMLIB_ERR_INVALID_METADATA_RESOURCE
3097 * The metadata resource for @p image in @p wim is invalid.
3098 * @retval ::WIMLIB_ERR_NOMEM
3099 * Failed to allocate needed memory.
3100 * @retval ::WIMLIB_ERR_OPEN
3101 * Failed to open @p path for writing, or some file resources in @p wim
3102 * refer to files in the outside filesystem, and one of these files could
3103 * not be opened for reading.
3104 * @retval ::WIMLIB_ERR_READ
3105 * An error occurred when trying to read data from the WIM file associated
3106 * with @p wim, or some file resources in @p wim refer to files in the
3107 * outside filesystem, and a read error occurred when reading one of these
3109 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
3110 * @p wim is part of a split WIM, not a standalone WIM.
3111 * @retval ::WIMLIB_ERR_WRITE
3112 * An error occurred when trying to write data to the new WIM file.
3115 wimlib_write(WIMStruct *wim,
3116 const wimlib_tchar *path,
3119 unsigned num_threads,
3120 wimlib_progress_func_t progress_func);
3123 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
3124 * file descriptor, which need not be seekable if the write is done in a special
3125 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
3126 * write_flags. This can, for example, allow capturing a WIM image and
3127 * streaming it over the network. See the documentation for
3128 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
3130 * The file descriptor @p fd will @b not be closed when the write is complete;
3131 * the calling code is responsible for this.
3133 * Returns 0 on success; nonzero on failure. The possible error codes include
3134 * those that can be returned by wimlib_write() as well as the following:
3136 * @retval ::WIMLIB_ERR_INVALID_PARAM
3137 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
3138 * specified in @p write_flags.
3141 wimlib_write_to_fd(WIMStruct *wim,
3145 unsigned num_threads,
3146 wimlib_progress_func_t progress_func);
3149 * This function is equivalent to wimlib_lzx_compress(), but instead compresses
3150 * the data using "XPRESS" compression.
3153 wimlib_xpress_compress(const void *chunk, unsigned chunk_size, void *out);
3156 * This function is equivalent to wimlib_lzx_decompress(), but instead assumes
3157 * the data is compressed using "XPRESS" compression.
3160 wimlib_xpress_decompress(const void *compressed_data, unsigned compressed_len,
3161 void *uncompressed_data, unsigned uncompressed_len);
3163 #endif /* _WIMLIB_H */