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.4.1, 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.
40 * \section starting Getting Started
42 * wimlib uses the GNU autotools, so, on UNIX 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,
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, directly to a block device
75 * 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, wimlib supports mounting WIM files either read-only or read-write.
84 * Mounting is done using wimlib_mount_image() and unmounting is done using
85 * wimlib_unmount_image(). Mounting can be done without root privileges because
86 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
87 * compiled with the <code>--without-fuse</code> flag, these functions will be
88 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED.
90 * After creating or modifying a WIM file, you can write it to a file using
91 * wimlib_write(). Alternatively, if the WIM was originally read from a file
92 * (using wimlib_open_wim() rather than wimlib_create_new_wim()), you can use
93 * wimlib_overwrite() to overwrite the original file.
95 * Please note: merely by calling wimlib_add_image() or many of the other
96 * functions in this library that operate on ::WIMStruct's, you are @b not
97 * modifying the WIM file on disk. Changes are not saved until you explicitly
98 * call wimlib_write() or wimlib_overwrite().
100 * After you are done with the WIM file, use wimlib_free() to free all memory
101 * associated with a ::WIMStruct and close all files associated with it.
103 * When you are completely done with using wimlib in your program, you should
104 * call wimlib_global_cleanup().
106 * A number of functions take a pointer to a progress function of type
107 * ::wimlib_progress_func_t. This function will be called periodically during
108 * the WIM operation(s) to report on the progress of the operation (for example,
109 * how many bytes have been written so far).
111 * wimlib is thread-safe as long as different ::WIMStruct's are used, except for
112 * the following exceptions:
113 * - You must call wimlib_global_init() in one thread before calling any other
115 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
116 * race conditions with one-time allocations of memory.
117 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
118 * concurrently in the same process, will daemonize the entire process when it
119 * does so for the first time. This includes changing the working directory
120 * to the root directory.
122 * \section encodings Locales and character encodings
124 * To support Windows as well as UNIX, wimlib's API typically takes and returns
125 * strings of ::wimlib_tchar, which are in a platform-dependent encoding.
127 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
128 * and the encoding is UTF-16LE.
130 * On UNIX, each ::wimlib_tchar is 1 byte and is simply a "char", and the
131 * encoding is the locale-dependent multibyte encoding. I recommend you set
132 * your locale to a UTF-8 capable locale to avoid any issues. Also, by default,
133 * wimlib on UNIX will assume the locale is UTF-8 capable unless you call
134 * wimlib_global_init() after having set your desired locale.
136 * \section Limitations
138 * This section documents some technical limitations of wimlib not already
139 * documented in the man page for @b wimlib-imagex.
141 * - The old WIM format from Vista pre-releases is not supported.
142 * - Compressed resource chunk sizes other than 32768 are not supported. This
143 * doesn't seem to be a real problem because the chunk size always seems to be
145 * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
146 * functionality other than that already present in @b ImageX, that allows you
147 * to make certain Windows-specific modifications to a Windows PE image, such
148 * as adding a driver or Windows component. Such a tool possibly could be
149 * implemented on top of wimlib.
158 #include <inttypes.h>
161 /** Major version of the library (for example, the 1 in 1.2.5). */
162 #define WIMLIB_MAJOR_VERSION 1
164 /** Minor version of the library (for example, the 2 in 1.2.5). */
165 #define WIMLIB_MINOR_VERSION 4
167 /** Patch version of the library (for example, the 5 in 1.2.5). */
168 #define WIMLIB_PATCH_VERSION 1
171 * Opaque structure that represents a WIM file. This is an in-memory structure
172 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
173 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
174 * continuing to exist so that data can be read from it as needed.
176 * Most functions in this library will work the same way regardless of whether a
177 * given ::WIMStruct was obtained through wimlib_open_wim() or
178 * wimlib_create_new_wim(). Exceptions are documented.
180 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
181 * file from a ::WIMStruct.
183 #ifndef WIMLIB_WIMSTRUCT_DECLARED
184 typedef struct WIMStruct WIMStruct;
185 #define WIMLIB_WIMSTRUCT_DECLARED
189 typedef wchar_t wimlib_tchar;
191 /** See \ref encodings */
192 typedef char wimlib_tchar;
196 /** Path separator for WIM paths passed back to progress callbacks. */
197 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
198 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
200 /** Path separator for WIM paths passed back to progress callbacks. */
201 # define WIMLIB_WIM_PATH_SEPARATOR '/'
202 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
206 # define _wimlib_deprecated __attribute__((deprecated))
208 # define _wimlib_deprecated
212 * Specifies the compression type of a WIM file.
214 enum wimlib_compression_type {
215 /** An invalid compression type. */
216 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
218 /** The WIM does not include any compressed resources. */
219 WIMLIB_COMPRESSION_TYPE_NONE = 0,
221 /** Compressed resources in the WIM use LZX compression. */
222 WIMLIB_COMPRESSION_TYPE_LZX = 1,
224 /** Compressed resources in the WIM use XPRESS compression. */
225 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
228 /** Possible values of the first parameter to the user-supplied
229 * ::wimlib_progress_func_t progress function */
230 enum wimlib_progress_msg {
232 /** A WIM image is about to be extracted. @a info will point to
233 * ::wimlib_progress_info.extract. */
234 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
236 /** A file or directory tree within a WIM image (not the full image) is
237 * about to be extracted. @a info will point to
238 * ::wimlib_progress_info.extract. */
239 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
241 /** The directory structure of the WIM image is about to be extracted.
242 * @a info will point to ::wimlib_progress_info.extract. */
243 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
245 /** The directory structure of the WIM image has been successfully
246 * extracted. @a info will point to ::wimlib_progress_info.extract. */
247 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
249 /** The WIM image's files resources are currently being extracted. @a
250 * info will point to ::wimlib_progress_info.extract. */
251 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
253 /** A file or directory is being extracted. @a info will point to
254 * ::wimlib_progress_info.extract, and the @a cur_path member will be
256 WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY,
258 /** All the WIM files and directories have been extracted, and
259 * timestamps are about to be applied. @a info will point to
260 * ::wimlib_progress_info.extract. */
261 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
263 /** A WIM image has been successfully extracted. @a info will point to
264 * ::wimlib_progress_info.extract. */
265 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
267 /** A file or directory tree within a WIM image (not the full image) has
268 * been successfully extracted. @a info will point to
269 * ::wimlib_progress_info.extract. */
270 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
272 /** The directory or NTFS volume is about to be scanned to build a tree
273 * of WIM dentries in-memory. @a info will point to
274 * ::wimlib_progress_info.scan. */
275 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
277 /** A directory or file is being scanned. @a info will point to
278 * ::wimlib_progress_info.scan, and its @a cur_path member will be
279 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE
280 * is passed to wimlib_add_image(). */
281 WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
283 /** The directory or NTFS volume has been successfully scanned, and a
284 * tree of WIM dentries has been built in-memory. @a info will point to
285 * ::wimlib_progress_info.scan. */
286 WIMLIB_PROGRESS_MSG_SCAN_END,
289 * File resources are currently being written to the WIM.
290 * @a info will point to ::wimlib_progress_info.write_streams. */
291 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
294 * The metadata resource for each image is about to be written to the
295 * WIM. @a info will not be valid. */
296 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
299 * The metadata resource for each image has successfully been writen to
300 * the WIM. @a info will not be valid. */
301 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
304 * The temporary file has successfully been renamed to the original WIM
305 * file. Only happens when wimlib_overwrite() is called and the
306 * overwrite is not done in-place.
307 * @a info will point to ::wimlib_progress_info.rename. */
308 WIMLIB_PROGRESS_MSG_RENAME,
310 /** The contents of the WIM are being checked against the integrity
311 * table. Only happens when wimlib_open_wim() is called with the
312 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. @a info will point to
313 * ::wimlib_progress_info.integrity. */
314 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
316 /** An integrity table is being calculated for the WIM being written.
317 * Only happens when wimlib_write() or wimlib_overwrite() is called with
318 * the ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag. @a info will point to
319 * ::wimlib_progress_info.integrity. */
320 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
322 /** A wimlib_join() operation is in progress. @a info will point to
323 * ::wimlib_progress_info.join. */
324 WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
326 /** A wimlib_split() operation is in progress, and a new split part is
327 * about to be started. @a info will point to
328 * ::wimlib_progress_info.split. */
329 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
331 /** A wimlib_split() operation is in progress, and a split part has been
332 * finished. @a info will point to ::wimlib_progress_info.split. */
333 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
336 * A WIM update command is just about to be executed; @a info will point
337 * to ::wimlib_progress_info.update.
339 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
342 * A WIM update command has just been executed; @a info will point to
343 * ::wimlib_progress_info.update.
345 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
349 /** A pointer to this union is passed to the user-supplied
350 * ::wimlib_progress_func_t progress function. One (or none) of the structures
351 * contained in this union will be applicable for the operation
352 * (::wimlib_progress_msg) indicated in the first argument to the progress
354 union wimlib_progress_info {
356 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
357 * document them if they aren't given a name... */
359 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. */
360 struct wimlib_progress_info_write_streams {
361 /** Number of bytes that are going to be written for all the
362 * streams combined. This is the amount in uncompressed data.
363 * (The actual number of bytes will be less if the data is being
364 * written compressed.) */
365 uint64_t total_bytes;
366 /** Number of streams that are going to be written. */
367 uint64_t total_streams;
369 /** Number of uncompressed bytes that have been written so far.
370 * Will be 0 initially, and equal to @a total_bytes at the end.
372 uint64_t completed_bytes;
374 /** Number of streams that have been written. Will be 0
375 * initially, and equal to @a total_streams at the end. */
376 uint64_t completed_streams;
378 /** Number of threads that are being used to compress resources
379 * (if applicable). */
380 unsigned num_threads;
382 /** The compression type being used to write the streams; either
383 * ::WIMLIB_COMPRESSION_TYPE_NONE,
384 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or
385 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
386 int compression_type;
388 /** Library internal use only. */
392 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
393 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
394 struct wimlib_progress_info_scan {
395 /** Directory or NTFS volume that is being scanned. */
396 const wimlib_tchar *source;
398 /** Path to the file or directory that is about to be scanned,
399 * relative to the root of the image capture or the NTFS volume.
401 const wimlib_tchar *cur_path;
403 /** True iff @a cur_path is being excluded from the image
404 * capture due to the capture configuration file. */
407 /** Target path in the WIM. Only valid on messages
408 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
409 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
410 const wimlib_tchar *wim_target_path;
413 /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
414 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
415 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
416 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
417 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
418 struct wimlib_progress_info_extract {
419 /** Number of the image being extracted (1-based). */
422 /** Flags passed to to wimlib_extract_image() */
425 /** Full path to the WIM file being extracted. */
426 const wimlib_tchar *wimfile_name;
428 /** Name of the image being extracted. */
429 const wimlib_tchar *image_name;
431 /** Directory or NTFS volume to which the image is being
433 const wimlib_tchar *target;
435 /** Current dentry being extracted. (Valid only if message is
436 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY.) */
437 const wimlib_tchar *cur_path;
439 /** Number of bytes of uncompressed data that will be extracted.
440 * Takes into account hard links (they are not counted for each
443 uint64_t total_bytes;
445 /** Number of bytes that have been written so far. Will be 0
446 * initially, and equal to @a total_bytes at the end. */
447 uint64_t completed_bytes;
449 /** Number of streams that will be extracted. This may more or
450 * less than the number of "files" to be extracted due to
451 * special cases (hard links, symbolic links, and alternate data
453 uint64_t num_streams;
455 /** Path to the root dentry within the WIM for the tree that is
456 * being extracted. Will be the empty string when extracting a
458 const wimlib_tchar *extract_root_wim_source_path;
461 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
462 struct wimlib_progress_info_rename {
463 /** Name of the temporary file that the WIM was written to. */
464 const wimlib_tchar *from;
466 /** Name of the original WIM file to which the temporary file is
468 const wimlib_tchar *to;
471 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
472 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
473 struct wimlib_progress_info_update {
474 /** Pointer to the update command that will be executed or has
475 * just been executed. */
476 const struct wimlib_update_command *command;
478 /** Number of update commands that have been completed so far.
480 size_t completed_commands;
482 /** Number of update commands that are being executed as part of
483 * this call to wimlib_update_image(). */
484 size_t total_commands;
487 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
488 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
489 struct wimlib_progress_info_integrity {
490 /** Number of bytes from the end of the WIM header to the end of
491 * the lookup table (the area that is covered by the SHA1
492 * integrity checks.) */
493 uint64_t total_bytes;
495 /** Number of bytes that have been SHA1-summed so far. Will be
496 * 0 initially, and equal @a total_bytes at the end. */
497 uint64_t completed_bytes;
499 /** Number of chunks that the checksummed region is divided
501 uint32_t total_chunks;
503 /** Number of chunks that have been SHA1-summed so far. Will
504 * be 0 initially, and equal to @a total_chunks at the end. */
505 uint32_t completed_chunks;
507 /** Size of the chunks used for the integrity calculation. */
510 /** Filename of the WIM (only valid if the message is
511 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
512 const wimlib_tchar *filename;
515 /** Valid on messages ::WIMLIB_PROGRESS_MSG_JOIN_STREAMS. */
516 struct wimlib_progress_info_join {
517 /** Total number of bytes of compressed data contained in all
518 * the split WIM part's file and metadata resources. */
519 uint64_t total_bytes;
521 /** Number of bytes that have been copied to the joined WIM so
522 * far. Will be 0 initially, and equal to @a total_bytes at the
524 uint64_t completed_bytes;
526 /** Number of split WIM parts that have had all their file and
527 * metadata resources copied over to the joined WIM so far. */
528 unsigned completed_parts;
530 /** Number of split WIM parts. */
531 unsigned total_parts;
534 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
535 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
536 struct wimlib_progress_info_split {
537 /** Total size of the original WIM's file and metadata resources
539 uint64_t total_bytes;
541 /** Number of bytes of file and metadata resources that have
542 * been copied out of the original WIM so far. Will be 0
543 * initially, and equal to @a total_bytes at the end. */
544 uint64_t completed_bytes;
546 /** Number of the split WIM part that is about to be started
547 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
548 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
549 unsigned cur_part_number;
551 /** Name of the split WIM part that is about to be started
552 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
553 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
554 const wimlib_tchar *part_name;
558 /** A user-supplied function that will be called periodically during certain WIM
559 * operations. The first argument will be the type of operation that is being
560 * performed or is about to be started or has been completed. The second
561 * argument will be a pointer to one of a number of structures depending on the
562 * first argument. It may be @c NULL for some message types.
564 * The return value of the progress function is currently ignored, but it may do
565 * something in the future. (Set it to 0 for now.)
567 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
568 const union wimlib_progress_info *info);
570 /** An array of these structures is passed to wimlib_add_image_multisource() to
571 * specify the sources from which to create a WIM image. */
572 struct wimlib_capture_source {
573 /** Absolute or relative path to a file or directory on the external
574 * filesystem to be included in the WIM image. */
575 wimlib_tchar *fs_source_path;
577 /** Destination path in the WIM image. Leading and trailing slashes are
578 * ignored. The empty string or @c NULL means the root directory of the
580 wimlib_tchar *wim_target_path;
582 /** Reserved; set to 0. */
586 /** Structure that specifies a list of path patterns. */
587 struct wimlib_pattern_list {
588 /** Array of patterns. The patterns may be modified by library code,
589 * but the @a pats pointer itself will not. See the man page for
590 * <b>wimlib-imagex capture</b> for more information about allowed
594 /** Number of patterns in the @a pats array. */
597 /** Ignored; may be used by the calling code. */
598 size_t num_allocated_pats;
601 /** A structure that contains lists of wildcards that match paths to treat
602 * specially when capturing a WIM image. */
603 struct wimlib_capture_config {
604 /** Paths matching any pattern this list are excluded from being
605 * captured, except if the same path appears in @a
606 * exclusion_exception_pats. */
607 struct wimlib_pattern_list exclusion_pats;
609 /** Paths matching any pattern in this list are never excluded from
611 struct wimlib_pattern_list exclusion_exception_pats;
613 /** Reserved for future capture configuration options. */
614 struct wimlib_pattern_list reserved1;
616 /** Reserved for future capture configuration options. */
617 struct wimlib_pattern_list reserved2;
619 /** Library internal use only. */
620 const wimlib_tchar *_prefix;
622 /** Library internal use only. */
623 size_t _prefix_num_tchars;
626 /** Set or unset the WIM header flag that marks it read-only
627 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
628 * ::wimlib_wim_info.is_marked_readonly member of the @a info parameter. This
629 * is distinct from basic file permissions; this flag can be set on a WIM file
630 * that is physically writable. If this flag is set, all further operations to
631 * modify the WIM will fail, except calling wimlib_overwrite() with
632 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
633 * allows you to set this flag persistently on the underlying WIM file.
635 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
637 /** Set the GUID (globally unique identifier) of the WIM file to the value
638 * specified in ::wimlib_wim_info.guid of the @a info parameter. */
639 #define WIMLIB_CHANGE_GUID 0x00000002
641 /** Change the bootable image of the WIM to the value specified in
642 * ::wimlib_wim_info.boot_index of the @a info parameter. */
643 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
645 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
646 * in ::wimlib_wim_info.has_rpfix of the @a info parameter. This flag generally
647 * indicates whether an image in the WIM has been captured with reparse-point
648 * fixups enabled. wimlib also treats this flag as specifying whether to do
649 * reparse-point fixups by default when capturing or applying WIM images. */
650 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
652 #define WIMLIB_GUID_LEN 16
654 /** General information about a WIM file. */
655 struct wimlib_wim_info {
657 /** Globally unique identifier for the WIM file. Note: all parts of a
658 * split WIM should have an identical value in this field. */
659 uint8_t guid[WIMLIB_GUID_LEN];
661 /** Number of images in the WIM. */
662 uint32_t image_count;
664 /** 1-based index of the bootable image in the WIM, or 0 if no image is
668 /** Version of the WIM file. */
669 uint32_t wim_version;
671 /** Chunk size used for compression. */
674 /** 1-based index of this part within a split WIM, or 1 if the WIM is
676 uint16_t part_number;
678 /** Total number of parts in the split WIM, or 1 if the WIM is
680 uint16_t total_parts;
682 /** One of the ::wimlib_compression_type values that specifies the
683 * method used to compress resources in the WIM. */
684 int32_t compression_type;
686 /** Size of the WIM file in bytes, excluding the XML data and integrity
688 uint64_t total_bytes;
690 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
691 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
692 * this will always be 0, even if the ::WIMStruct was written to
693 * somewhere by calling wimlib_write() with the
694 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
695 uint32_t has_integrity_table : 1;
697 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
698 * wimlib_create_new_wim(). */
699 uint32_t opened_from_file : 1;
701 /** 1 if the WIM is considered readonly for any reason. */
702 uint32_t is_readonly : 1;
704 /** 1 if reparse-point fixups are supposedly enabled for one or more
705 * images in the WIM. */
706 uint32_t has_rpfix : 1;
708 /** 1 if the WIM is marked as read-only. */
709 uint32_t is_marked_readonly : 1;
711 /** 1 if the WIM is part of a spanned set. */
712 uint32_t spanned : 1;
714 uint32_t write_in_progress : 1;
715 uint32_t metadata_only : 1;
716 uint32_t resource_only : 1;
717 uint32_t reserved_flags : 23;
718 uint32_t reserved[9];
721 /** Iterate recursively on children rather than just on the specified path. */
722 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
724 /** Don't iterate on the file or directory itself; only its children (in the
725 * case of a non-empty directory) */
726 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
728 /** A stream of a file in the WIM. */
729 struct wimlib_stream_entry {
730 /** Name of the stream, or NULL if the stream is unnamed. */
731 const wimlib_tchar *stream_name;
733 /** Size of the stream (uncompressed) in bytes. */
734 uint64_t stream_size;
736 uint64_t reserved[10];
739 /** Roughly, the information about "file" in the WIM--- really a directory entry
740 * ("dentry") because hard links are allowed. The hard_link_group_id field
741 * can be used to distinguish actual file inodes. */
742 struct wimlib_wim_dentry {
743 /** Name of the file, or NULL if this file is unnamed (only possible for
744 * the root directory) */
745 const wimlib_tchar *filename;
747 /** 8.3 DOS name of this file, or NULL if this file has no such name.
749 const wimlib_tchar *dos_name;
751 /** Full path to this file within the WIM image. */
752 const wimlib_tchar *full_path;
754 /** Depth of this directory entry, where 0 is the root, 1 is the root's
755 * children, ..., etc. */
758 /** Pointer to the security descriptor for this file, in Windows
759 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
760 * security descriptor. */
761 const char *security_descriptor;
763 /** Length of the above security descriptor. */
764 size_t security_descriptor_size;
766 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
767 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
768 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
769 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
770 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
771 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
772 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
773 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
774 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
775 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
776 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
777 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
778 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
779 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
780 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
781 /** File attributes, such as whether the file is a directory or not.
782 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
783 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
784 * on other platforms. */
787 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
788 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
789 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
790 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
791 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
792 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
793 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
794 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
795 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
796 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
797 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
798 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
799 * attributes), this will give the reparse tag. This tells you whether
800 * the reparse point is a symbolic link, junction point, or some other,
801 * more unusual kind of reparse point. */
802 uint32_t reparse_tag;
804 /* Number of (hard) links to this file. */
807 /** Number of named data streams that this file has. Normally 0. */
808 uint32_t num_named_streams;
810 /** Roughly, the inode number of this file. However, it may be 0 if
812 uint64_t hard_link_group_id;
814 /** Time this file was created. */
815 struct timespec creation_time;
817 /** Time this file was last written to. */
818 struct timespec last_write_time;
820 /** Time this file was last accessed. */
821 struct timespec last_access_time;
822 uint64_t reserved[16];
824 /** Array of streams that make up this file. The first entry will
825 * always exist and will correspond to the unnamed data stream (default
826 * file contents), so it will have stream_name == NULL. There will then
827 * be num_named_streams additional entries that specify the named data
828 * streams, if any, each of which will have stream_name != NULL. */
829 struct wimlib_stream_entry streams[];
833 * Type of a callback function to wimlib_iterate_dir_tree().
835 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_wim_dentry *dentry,
839 /*****************************
841 *****************************/
843 /** Directly capture a NTFS volume rather than a generic directory. This flag
844 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
845 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
846 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
848 /** Follow symlinks; archive and dump the files they point to. Cannot be used
849 * with ::WIMLIB_ADD_FLAG_NTFS. */
850 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
852 /** Call the progress function with the message
853 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
855 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
857 /** Mark the image being added as the bootable image of the WIM. */
858 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
860 /** Store the UNIX owner, group, and mode. This is done by adding a special
861 * alternate data stream to each regular file, symbolic link, and directory to
862 * contain this information. Please note that this flag is for convenience
863 * only; Microsoft's @a imagex.exe will not understand this special information.
864 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
865 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
867 /** Do not capture security descriptors. Only has an effect in NTFS capture
868 * mode, or in Win32 native builds. */
869 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
871 /** Fail immediately if the full security descriptor of any file or directory
872 * cannot be accessed. Only has an effect in Win32 native builds. The default
873 * behavior without this flag is to first try omitting the SACL from the
874 * security descriptor, then to try omitting the security descriptor entirely.
876 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
878 /** Call the progress function with the message
879 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
880 * capture. This is a subset of the messages provided by
881 * ::WIMLIB_ADD_FLAG_VERBOSE. */
882 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
884 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
885 * in the case of Windows) that point inside the directory being captured to
886 * instead be absolute relative to the directory being captured, rather than the
887 * current root; also exclude absolute symbolic links that point outside the
888 * directory tree being captured.
890 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
891 * the WIM header or if this is the first image being added.
892 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
893 * reparse point fixups enabled and currently cannot be unset. */
894 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
896 /** Don't do reparse point fixups. The default behavior is described in the
897 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
898 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
900 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
901 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
902 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
903 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
904 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
905 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
906 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
907 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
908 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
909 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
911 /******************************
912 * WIMLIB_DELETE_FLAG_*
913 ******************************/
915 /** Do not issue an error if the path to delete does not exist. */
916 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
918 /** Delete the file or directory tree recursively; if not specified, an error is
919 * issued if the path to delete is a directory. */
920 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
922 /******************************
923 * WIMLIB_EXPORT_FLAG_*
924 ******************************/
926 /** See documentation for wimlib_export_image(). */
927 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
929 /******************************
930 * WIMLIB_EXTRACT_FLAG_*
931 ******************************/
933 /** Extract the image directly to a NTFS volume rather than a generic directory.
935 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
937 /** When identical files are extracted from the WIM, always hard link them
938 * together. Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
939 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
941 /** When identical files are extracted from the WIM, always symlink them
942 * together. Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
943 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
945 /** Call the progress function with the argument
946 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY each time a file or directory is
947 * extracted. Note: these calls will be interspersed with calls for the message
948 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. */
949 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
951 /** Read the WIM file sequentially while extracting the image. */
952 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
954 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA.
955 * Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
956 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
958 /** Do not extract security descriptors. Only has an effect in NTFS apply mode,
959 * or in Win32 native builds. */
960 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
962 /** Fail immediately if the full security descriptor of any file or directory
963 * cannot be set exactly as specified in the WIM file. The default behavior
964 * without this flag is to fall back to setting the security descriptor with the
965 * SACL omitted, then only the default inherited security descriptor, if we do
966 * not have permission to set the desired one. */
967 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
969 /* Extract equivalent to ::WIMLIB_ADD_FLAG_RPFIX; force reparse-point
970 * fixups on, so absolute symbolic links or junction points will be fixed to be
971 * absolute relative to the actual extraction root. Done by default if
972 * WIM_HDR_FLAG_RP_FIX is set in the WIM header. This flag may only be
973 * specified when extracting a full image. */
974 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
976 /** Force reparse-point fixups on extraction off, regardless of the state of the
977 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. */
978 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
980 /** Extract files to standard output rather than to the filesystem. */
981 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
983 /** Instead of ignoring files and directories with names that cannot be
984 * represented on the current platform (note: Windows has more restrictions on
985 * filenames than UNIX), try to replace characters or append junk to the names
986 * so that they can be extracted in some form. */
987 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
989 /** On Windows, when there exist two or more files with the same case
990 * insensitive name but different case sensitive names, try to extract them all
991 * by appending junk to the end of them, rather than arbitrarily extracting only
993 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
995 /******************************
996 * WIMLIB_MOUNT_FLAG_*
997 ******************************/
999 /** Mount the WIM image read-write rather than the default of read-only. */
1000 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1002 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1003 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1005 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1006 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1008 /** Access alternate data streams in the mounted WIM image through extended file
1009 * attributes. This is the default mode. */
1010 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1012 /** Access alternate data streams in the mounted WIM image by specifying the
1013 * file name, a colon, then the alternate file stream name. */
1014 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1016 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1017 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1018 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1020 /** Allow other users to see the mounted filesystem. (this passes the @c
1021 * allow_other option to FUSE mount) */
1022 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1024 /******************************
1025 * WIMLIB_OPEN_FLAG_*
1026 ******************************/
1028 /** Verify the WIM contents against the WIM's integrity table, if present. This
1029 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1030 * checksummed and checked against the SHA1 message digests specified in the
1031 * integrity table. WIMLIB_ERR_INTEGRITY is returned if there are any
1033 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1035 /** Do not issue an error if the WIM is part of a split WIM. */
1036 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x00000002
1038 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1039 * is not. A WIM is considered writable only if it is writable at the
1040 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1041 * header, and is not part of a spanned set. It is not required to provide this
1042 * flag to make changes to the WIM, but with this flag you get the error sooner
1043 * rather than later. */
1044 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1046 /******************************
1047 * WIMLIB_UNMOUNT_FLAG_*
1048 ******************************/
1050 /** Include an integrity table in the WIM after it's been unmounted. Ignored
1051 * for read-only mounts. */
1052 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1054 /** Unless this flag is given, changes to a read-write mounted WIM are
1055 * discarded. Ignored for read-only mounts. */
1056 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1058 /** See ::WIMLIB_WRITE_FLAG_REBUILD */
1059 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1061 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1062 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1064 /** Do a "lazy" unmount (detach filesystem immediately, even if busy) */
1065 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1067 /******************************
1068 * WIMLIB_UPDATE_FLAG_*
1069 ******************************/
1071 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1072 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1073 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1075 /******************************
1076 * WIMLIB_WRITE_FLAG_*
1077 ******************************/
1079 /** Include an integrity table in the new WIM file. */
1080 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1082 /** Re-build the entire WIM file rather than appending data to it, if possible.
1083 * (Applies to wimlib_overwrite(), not wimlib_write()). */
1084 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000002
1086 /** Recompress all resources, even if they could otherwise be copied from a
1087 * different WIM with the same compression type (in the case of
1088 * wimlib_export_image() being called previously). */
1089 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000004
1091 /** Call fsync() when the WIM file is closed */
1092 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000008
1094 /* Specifying this flag overrides the default behavior of wimlib_overwrite()
1095 * after one or more calls to wimlib_delete_image(), which is to rebuild the
1098 * If you specifiy this flag to wimlib_overwrite(), only minimal changes to
1099 * correctly remove the image from the WIM will be taken. In particular, all
1100 * streams will be left alone, even if they are no longer referenced. This is
1101 * probably not what you want, because almost no space will be spaced by
1102 * deleting an image in this way. */
1103 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000010
1105 /** With wimlib_overwrite(), allow overwriting the WIM even if the readonly flag
1106 * is set in the WIM header; this can be used in combination with
1107 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1108 * set the readonly flag on the on-disk WIM file. */
1109 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000020
1111 /******************************
1112 * WIMLIB_INIT_FLAG_*
1113 ******************************/
1115 /** Assume that strings are represented in UTF-8, even if this is not the
1116 * locale's character encoding. */
1117 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1119 /** Specification of an update to perform on a WIM image. */
1120 struct wimlib_update_command {
1122 /** The specific type of update to perform. */
1123 enum wimlib_update_op {
1124 /** Add a new file or directory tree to the WIM image in a
1125 * certain location. */
1126 WIMLIB_UPDATE_OP_ADD = 0,
1128 /** Delete a file or directory tree from the WIM image. */
1129 WIMLIB_UPDATE_OP_DELETE,
1131 /** Rename a file or directory tree in the WIM image. */
1132 WIMLIB_UPDATE_OP_RENAME,
1135 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1136 struct wimlib_add_command {
1137 /** Filesystem path to the file or directory tree to
1139 wimlib_tchar *fs_source_path;
1140 /** Path, specified from the root of the WIM image, at
1141 * which to add the file or directory tree within the
1143 wimlib_tchar *wim_target_path;
1145 /** Configuration for excluded files. @c NULL means
1146 * exclude no files. */
1147 struct wimlib_capture_config *config;
1149 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1152 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1153 struct wimlib_delete_command {
1154 /** Path, specified from the root of the WIM image, for
1155 * the file or directory tree within the WIM image to be
1157 wimlib_tchar *wim_path;
1158 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1161 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1162 struct wimlib_rename_command {
1163 /** Path, specified from the root of the WIM image, for
1164 * the source file or directory tree within the WIM
1166 wimlib_tchar *wim_source_path;
1167 /** Path, specified from the root of the WIM image, for
1168 * the destination file or directory tree within the WIM
1170 wimlib_tchar *wim_target_path;
1171 /** Reserved; set to 0. */
1177 /** Specification of a file or directory tree to extract from a WIM image. */
1178 struct wimlib_extract_command {
1179 /** Path to file or directory tree within the WIM image to extract. It
1180 * must be provided as an absolute path from the root of the WIM image.
1181 * The path separators may be either forward slashes or backslashes. */
1182 wimlib_tchar *wim_source_path;
1184 /** Filesystem path to extract the file or directory tree to. */
1185 wimlib_tchar *fs_dest_path;
1187 /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1192 * Possible values of the error code returned by many functions in wimlib.
1194 * See the documentation for each wimlib function to see specifically what error
1195 * codes can be returned by a given function, and what they mean.
1197 enum wimlib_error_code {
1198 WIMLIB_ERR_SUCCESS = 0,
1199 WIMLIB_ERR_ALREADY_LOCKED,
1200 WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE,
1201 WIMLIB_ERR_DECOMPRESSION,
1202 WIMLIB_ERR_DELETE_STAGING_DIR,
1203 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1206 WIMLIB_ERR_FUSERMOUNT,
1207 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1208 WIMLIB_ERR_IMAGE_COUNT,
1209 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1210 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES_TO_EXTRACT,
1211 WIMLIB_ERR_INTEGRITY,
1212 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1213 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1214 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1215 WIMLIB_ERR_INVALID_DENTRY,
1216 WIMLIB_ERR_INVALID_HEADER_SIZE,
1217 WIMLIB_ERR_INVALID_IMAGE,
1218 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1219 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1220 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1221 WIMLIB_ERR_INVALID_OVERLAY,
1222 WIMLIB_ERR_INVALID_PARAM,
1223 WIMLIB_ERR_INVALID_PART_NUMBER,
1224 WIMLIB_ERR_INVALID_REPARSE_DATA,
1225 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1226 WIMLIB_ERR_INVALID_RESOURCE_SIZE,
1227 WIMLIB_ERR_INVALID_SECURITY_DATA,
1228 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1229 WIMLIB_ERR_INVALID_UTF16_STRING,
1230 WIMLIB_ERR_INVALID_UTF8_STRING,
1231 WIMLIB_ERR_IS_DIRECTORY,
1232 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1238 WIMLIB_ERR_NOTEMPTY,
1239 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1240 WIMLIB_ERR_NOT_A_WIM_FILE,
1241 WIMLIB_ERR_NO_FILENAME,
1245 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1247 WIMLIB_ERR_READLINK,
1250 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1251 WIMLIB_ERR_RESOURCE_ORDER,
1252 WIMLIB_ERR_SPECIAL_FILE,
1253 WIMLIB_ERR_SPLIT_INVALID,
1254 WIMLIB_ERR_SPLIT_UNSUPPORTED,
1257 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1258 WIMLIB_ERR_UNKNOWN_VERSION,
1259 WIMLIB_ERR_UNSUPPORTED,
1260 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1263 WIMLIB_ERR_WIM_IS_READONLY,
1264 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1268 /** Used to indicate no WIM image or an invalid WIM image. */
1269 #define WIMLIB_NO_IMAGE 0
1271 /** Used to specify all images in the WIM. */
1272 #define WIMLIB_ALL_IMAGES (-1)
1275 * Appends an empty image to a WIM file. This empty image will initially
1276 * contain no files or directories, although if written without further
1277 * modifications, a root directory will be created automatically for it.
1280 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
1283 * Name to give the new image. If @c NULL or empty, the new image is given
1284 * no name. If nonempty, it must specify a name that does not already
1286 * @param new_idx_ret
1287 * If non-<code>NULL</code>, the index of the newly added image is returned
1290 * @return 0 on success; nonzero on failure. The possible error codes are:
1292 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1293 * There is already an image in @a wim named @a name.
1294 * @retval ::WIMLIB_ERR_NOMEM
1295 * Failed to allocate the memory needed to add the new image.
1296 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1297 * The WIM file is considered read-only because of any of the reasons
1298 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1302 wimlib_add_empty_image(WIMStruct *wim,
1303 const wimlib_tchar *name,
1307 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1309 * The directory tree or NTFS volume is scanned immediately to load the dentry
1310 * tree into memory, and file attributes and symbolic links are read. However,
1311 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1314 * See the manual page for the @b wimlib-imagex program for more information
1315 * about the "normal" capture mode versus the NTFS capture mode (entered by
1316 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1318 * Note that @b no changes are committed to the underlying WIM file (if
1319 * any) until wimlib_write() or wimlib_overwrite() is called.
1322 * Pointer to the ::WIMStruct for a WIM file to which the image will be
1325 * A path to a directory or unmounted NTFS volume that will be captured as
1328 * Name to give the new image. If @c NULL or empty, the new image is given
1329 * no name. If nonempty, it must specify a name that does not already
1332 * Capture configuration that specifies files, directories, or path globs
1333 * to exclude from being captured. If @c NULL, a dummy configuration where
1334 * no paths are treated specially is used.
1336 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1337 * @param progress_func
1338 * If non-NULL, a function that will be called periodically with the
1339 * progress of the current operation.
1341 * @return 0 on success; nonzero on error. On error, changes to @a wim are
1342 * discarded so that it appears to be in the same state as when this function
1345 * This function is implemented by calling wimlib_add_empty_image(), then
1346 * calling wimlib_update_image() with a single "add" command, so any error code
1347 * returned by wimlib_add_empty_image() may be returned, as well as any error
1348 * codes returned by wimlib_update_image() other than ones documented as only
1349 * being returned specifically by an update involving delete or rename commands.
1352 wimlib_add_image(WIMStruct *wim,
1353 const wimlib_tchar *source,
1354 const wimlib_tchar *name,
1355 const struct wimlib_capture_config *config,
1357 wimlib_progress_func_t progress_func);
1359 /** This function is equivalent to wimlib_add_image() except it allows for
1360 * multiple sources to be combined into a single WIM image. This is done by
1361 * specifying the @a sources and @a num_sources parameters instead of the @a
1362 * source parameter of wimlib_add_image(). The rest of the parameters are the
1363 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
1364 * capture</b> for full details on how this mode works.
1366 * In addition to the error codes that wimlib_add_image() can return,
1367 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1368 * when trying to overlay a non-directory on a directory or when otherwise
1369 * trying to overlay multiple conflicting files to the same location in the WIM
1370 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
1371 * ::WIMLIB_ADD_FLAG_NTFS was specified in @a add_flags but there
1372 * was not exactly one capture source with the target being the root directory.
1373 * (In this respect, there is no advantage to using
1374 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1377 wimlib_add_image_multisource(WIMStruct *wim,
1378 const struct wimlib_capture_source *sources,
1380 const wimlib_tchar *name,
1381 const struct wimlib_capture_config *config,
1383 wimlib_progress_func_t progress_func);
1386 * Creates a ::WIMStruct for a new WIM file.
1388 * This only creates an in-memory structure for a WIM that initially contains no
1389 * images. No on-disk file is created until wimlib_write() is called.
1392 * The type of compression to be used in the new WIM file. Must be
1393 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
1394 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1396 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
1397 * written to the memory location pointed to by this paramater. The
1398 * ::WIMStruct must be freed using using wimlib_free() when finished with
1400 * @return 0 on success; nonzero on error.
1401 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1402 * @a ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
1403 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1404 * @retval ::WIMLIB_ERR_NOMEM
1405 * Failed to allocate needed memory.
1408 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
1411 * Deletes an image, or all images, from a WIM file.
1413 * All streams referenced by the image(s) being deleted are removed from the
1414 * lookup table of the WIM if they are not referenced by any other images in the
1417 * Please note that @b no changes are committed to the underlying WIM file (if
1418 * any) until wimlib_write() or wimlib_overwrite() is called.
1421 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
1424 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
1426 * @return 0 on success; nonzero on failure. On failure, @a wim is guaranteed
1427 * to be left unmodified only if @a image specified a single image. If instead
1428 * @a image was ::WIMLIB_ALL_IMAGES and @a wim contained more than one image, it's
1429 * possible for some but not all of the images to have been deleted when a
1430 * failure status is returned.
1432 * @retval ::WIMLIB_ERR_DECOMPRESSION
1433 * Could not decompress the metadata resource for @a image.
1434 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1435 * A directory entry in the metadata resource for @a image in the WIM is
1437 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1438 * @a image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
1439 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1440 * The metadata resource for @a image in the WIM is invalid.
1441 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1442 * The security data for @a image in the WIM is invalid.
1443 * @retval ::WIMLIB_ERR_NOMEM
1444 * Failed to allocate needed memory.
1445 * @retval ::WIMLIB_ERR_READ
1446 * Could not read the metadata resource for @a image from the WIM.
1447 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1448 * The WIM file is considered read-only because of any of the reasons
1449 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1453 wimlib_delete_image(WIMStruct *wim, int image);
1456 * Exports an image, or all the images, from a WIM file, into another WIM file.
1458 * The destination image is made to share the same dentry tree and security data
1459 * structure as the source image. This places some restrictions on additional
1460 * functions that may be called. wimlib_mount_image() may not be called on
1461 * either the source image or the destination image without an intervening call
1462 * to a function that un-shares the images, such as wimlib_free() on @a
1463 * dest_wim, or wimlib_delete_image() on either the source or destination image.
1464 * Furthermore, you may not call wimlib_free() on @a src_wim before calling
1465 * wimlib_write() or wimlib_overwrite() on @a dest_wim because @a dest_wim will
1466 * have references back to @a src_wim.
1468 * If this function fails, all changes to @a dest_wim are rolled back.
1470 * No changes shall be made to @a src_wim by this function.
1472 * Please note that no changes are committed to the underlying WIM file of @a
1473 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
1476 * Pointer to the ::WIMStruct for a stand-alone WIM or part 1 of a split
1477 * WIM that contains the image(s) being exported.
1479 * The image to export from @a src_wim. Can be the number of an image, or
1480 * ::WIMLIB_ALL_IMAGES to export all images.
1482 * Pointer to the ::WIMStruct for a WIM file that will receive the images
1485 * The name to give the exported image in the new WIM file. If left @c
1486 * NULL, the name from @a src_wim is used. This parameter must be left @c
1487 * NULL if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains more
1488 * than one image; in that case, the names are all taken from the @a
1489 * src_wim. (This is allowed even if one or more images being exported has
1491 * @param dest_description
1492 * The description to give the exported image in the new WIM file. If left
1493 * @c NULL, the description from the @a src_wim is used. This parameter must
1494 * be left @c NULL if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains
1495 * more than one image; in that case, the descriptions are all taken from
1496 * @a src_wim. (This is allowed even if one or more images being exported
1497 * has no description.)
1498 * @param export_flags
1499 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
1500 * bootable, or 0 if which image is marked as bootable in the destination
1501 * WIM is to be left unchanged. If @a src_image is ::WIMLIB_ALL_IMAGES and
1502 * there are multiple images in @a src_wim, specifying
1503 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
1504 * currently marked as bootable in @a src_wim; if that is the case, then
1505 * that image is marked as bootable in the destination WIM.
1506 * @param additional_swms
1507 * Array of pointers to the ::WIMStruct for each additional part in the
1508 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1509 * need to be in any particular order, but they must include all parts of
1510 * the split WIM other than the first part, which must be provided in the
1512 * @param num_additional_swms
1513 * Number of additional WIM parts provided in the @a additional_swms array.
1514 * This number should be one less than the total number of parts in the
1515 * split WIM. Set to 0 if the WIM is a standalone WIM.
1516 * @param progress_func
1517 * If non-NULL, a function that will be called periodically with the
1518 * progress of the current operation.
1520 * @return 0 on success; nonzero on error.
1521 * @retval ::WIMLIB_ERR_DECOMPRESSION
1522 * Could not decompress the metadata resource for @a src_image
1524 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1525 * One or more of the names being given to an exported image was already in
1526 * use in the destination WIM.
1527 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1528 * A directory entry in the metadata resource for @a src_image in @a
1529 * src_wim is invalid.
1530 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1531 * @a src_image does not exist in @a src_wim.
1532 * @retval ::WIMLIB_ERR_INVALID_PARAM
1533 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
1534 * ::WIMLIB_ALL_IMAGES, @a src_wim contains multiple images, and no images in
1535 * @a src_wim are marked as bootable; or @a dest_name and/or @a
1536 * dest_description were non-<code>NULL</code>, @a src_image was
1537 * ::WIMLIB_ALL_IMAGES, and @a src_wim contains multiple images.
1538 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1539 * The metadata resource for @a src_image in @a src_wim is invalid.
1540 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1541 * The security data for @a src_image in @a src_wim is invalid.
1542 * @retval ::WIMLIB_ERR_NOMEM
1543 * Failed to allocate needed memory.
1544 * @retval ::WIMLIB_ERR_READ
1545 * Could not read the metadata resource for @a src_image from @a src_wim.
1546 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1547 * The source WIM is a split WIM, but the parts specified do not form a
1548 * complete split WIM because they do not include all the parts of the
1549 * original WIM, there are duplicate parts, or not all the parts have the
1550 * same GUID and compression type.
1551 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1552 * @a dest_wim is considered read-only because of any of the reasons
1553 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1557 wimlib_export_image(WIMStruct *src_wim, int src_image,
1558 WIMStruct *dest_wim,
1559 const wimlib_tchar *dest_name,
1560 const wimlib_tchar *dest_description,
1562 WIMStruct **additional_swms,
1563 unsigned num_additional_swms,
1564 wimlib_progress_func_t progress_func);
1567 * Extract zero or more files or directory trees from a WIM image.
1569 * This generalizes the single-image extraction functionality of
1570 * wimlib_extract_image() to allow extracting only the specified subsets of the
1574 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1578 * The 1-based number of the image in @a wim from which the files or
1579 * directory trees are to be extracted. It cannot be ::WIMLIB_ALL_IMAGES.
1582 * An array of ::wimlib_extract_command structures that specifies the
1583 * extractions to perform.
1586 * Number of commands in the @a cmds array.
1588 * @param default_extract_flags
1589 * Default extraction flags; the behavior shall be as if these flags had
1590 * been specified in the ::wimlib_extract_command.extract_flags member in
1591 * each extraction command, in combination with any flags already present.
1593 * @param additional_swms
1594 * Array of pointers to the ::WIMStruct for each additional part in the
1595 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1596 * need to be in any particular order, but they must include all parts of
1597 * the split WIM other than the first part, which must be provided in the
1600 * @param num_additional_swms
1601 * Number of additional WIM parts provided in the @a additional_swms array.
1602 * This number should be one less than the total number of parts in the
1603 * split WIM. Set to 0 if the WIM is a standalone WIM.
1605 * @param progress_func
1606 * If non-NULL, a function that will be called periodically with the
1607 * progress of the current operation.
1609 * @return 0 on success; nonzero on error. The possible error codes include
1610 * those documented as returned by wimlib_extract_image() as well as the
1611 * following additional error codes:
1613 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
1614 * The ::wimlib_extract_command.wim_source_path member in one of the
1615 * extract commands did not exist in the WIM.
1616 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
1617 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
1618 * in which ::wimlib_extract_command.wim_source_path existed but was not a
1619 * regular file or directory.
1620 * @retval ::WIMLIB_ERR_INVALID_PARAM
1621 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
1622 * specified for some commands but not all; or
1623 * ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
1624 * for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
1625 * for a command in which ::wimlib_extract_command.wim_source_path did not
1626 * specify the root directory of the WIM image.
1629 wimlib_extract_files(WIMStruct *wim,
1631 const struct wimlib_extract_command *cmds,
1633 int default_extract_flags,
1634 WIMStruct **additional_swms,
1635 unsigned num_additional_swms,
1636 wimlib_progress_func_t progress_func);
1639 * Extracts an image, or all images, from a standalone or split WIM file to a
1640 * directory or a NTFS volume.
1642 * Please see the manual page for the @c wimlib-imagex program for more
1643 * information about the "normal" extraction mode versus the NTFS extraction
1644 * mode (entered by providing flag ::WIMLIB_EXTRACT_FLAG_NTFS).
1646 * Extraction is done with one thread.
1648 * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
1649 * returned if any resulting SHA1 message digests do not match the values
1650 * provided in the WIM file. Therefore, if this function is successful, you can
1651 * be fairly sure that any compressed data in the WIM was uncompressed
1655 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1658 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
1659 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
1660 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @a extract_flags.
1662 * Directory to extract the WIM image(s) to (created if it does not already
1663 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @a extract_flags, the
1664 * path to the unmounted NTFS volume to extract the image to.
1665 * @param extract_flags
1666 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
1668 * If ::WIMLIB_EXTRACT_FLAG_NTFS is specified, @a target is interpreted as
1669 * a NTFS volume to extract the image to. The volume will be opened using
1670 * NTFS-3g and the image will be extracted to the root of the NTFS volume.
1671 * Otherwise, @a target is interpreted as a directory to extract the
1674 * If ::WIMLIB_EXTRACT_FLAG_NTFS is not specified, one or none of
1675 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK may be
1676 * specified. These flags cause extracted files that are identical to be
1677 * hardlinked or symlinked together, depending on the flag. These flags
1678 * override the hard link groups that are specified in the WIM file itself.
1679 * If ::WIMLIB_ALL_IMAGES is provided as the @a image parameter, files may be
1680 * hardlinked or symlinked across images if a file is found to occur in
1681 * more than one image.
1683 * You may also specify the flag ::WIMLIB_EXTRACT_FLAG_VERBOSE to print the
1684 * name of each file or directory as it is extracted.
1686 * If ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is specified, data is read from the
1687 * WIM sequentially, if possible. If ::WIMLIB_ALL_IMAGES is specified,
1688 * each image is considered separately with regards to the sequential
1689 * order. It is also possible for alternate data streams to break the
1690 * sequential order (this only applies if ::WIMLIB_EXTRACT_FLAG_NTFS is
1692 * @param additional_swms
1693 * Array of pointers to the ::WIMStruct for each additional part in the
1694 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1695 * need to be in any particular order, but they must include all parts of
1696 * the split WIM other than the first part, which must be provided in the
1698 * @param num_additional_swms
1699 * Number of additional WIM parts provided in the @a additional_swms array.
1700 * This number should be one less than the total number of parts in the
1701 * split WIM. Set to 0 if the WIM is a standalone WIM.
1703 * @param progress_func
1704 * If non-NULL, a function that will be called periodically with the
1705 * progress of the current operation.
1707 * @return 0 on success; nonzero on error.
1708 * @retval ::WIMLIB_ERR_DECOMPRESSION
1709 * Could not decompress a resource (file or metadata) for @a image in @a
1711 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1712 * A directory entry in the metadata resource for @a image in @a wim is
1714 * @retval ::WIMLIB_ERR_INVALID_PARAM
1715 * @a target was @c NULL, or both ::WIMLIB_EXTRACT_FLAG_HARDLINK and
1716 * ::WIMLIB_EXTRACT_FLAG_SYMLINK were specified in @a extract_flags; or
1717 * both ::WIMLIB_EXTRACT_FLAG_NTFS and either
1718 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK were
1719 * specified in @a extract_flags; or ::WIMLIB_EXTRACT_FLAG_NTFS was
1720 * specified in @a extract_flags and @a image was ::WIMLIB_ALL_IMAGES; or
1721 * both ::WIMLIB_EXTRACT_FLAG_NTFS and ::WIMLIB_EXTRACT_FLAG_UNIX_DATA were
1722 * specified in @a extract_flag.
1723 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
1724 * The SHA1 message digest of an extracted stream did not match the SHA1
1725 * message digest given in the WIM file.
1726 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1727 * A resource (file or metadata) for @a image in @a wim is invalid.
1728 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1729 * The security data for @a image in @a wim is invalid.
1730 * @retval ::WIMLIB_ERR_LINK
1731 * Failed to create a symbolic link or a hard link (only if
1732 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1733 * @retval ::WIMLIB_ERR_MKDIR
1734 * Failed create a needed directory (only if ::WIMLIB_EXTRACT_FLAG_NTFS was
1735 * not specified in @a extract_flags).
1736 * @retval ::WIMLIB_ERR_NOMEM
1737 * Failed to allocate needed memory.
1738 * @retval ::WIMLIB_ERR_NTFS_3G
1739 * An error was returned from a libntfs-3g function while the WIM image was
1740 * being extracted to the NTFS volume (only if ::WIMLIB_EXTRACT_FLAG_NTFS
1741 * was specified in @a extract_flags).
1742 * @retval ::WIMLIB_ERR_OPEN
1743 * Could not open one of the files being extracted for writing (only if
1744 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1745 * @retval ::WIMLIB_ERR_READ
1746 * A unexpected end-of-file or read error occurred when trying to read data
1747 * from the WIM file associated with @a wim.
1748 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
1749 * One of the dentries in the image referenced a stream not present in the
1750 * WIM's lookup table (or in any of the lookup tables of the split WIM
1752 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1753 * The WIM is a split WIM, but the parts specified do not form a complete
1754 * split WIM because they do not include all the parts of the original WIM,
1755 * there are duplicate parts, or not all the parts have the same GUID and
1757 * @retval ::WIMLIB_ERR_UNSUPPORTED
1758 * ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @a extract_flags, but wimlib
1759 * was configured with the @c --without-ntfs-3g flag.
1760 * @retval ::WIMLIB_ERR_WRITE
1761 * Failed to write a file being extracted (only if
1762 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1765 wimlib_extract_image(WIMStruct *wim, int image,
1766 const wimlib_tchar *target,
1768 WIMStruct **additional_swms,
1769 unsigned num_additional_swms,
1770 wimlib_progress_func_t progress_func);
1773 * Extracts the XML data of a WIM file to a file stream. Every WIM file
1774 * includes a string of XML that describes the images contained in the WIM.
1775 * This function works on standalone WIMs as well as split WIM parts.
1778 * Pointer to the ::WIMStruct for a WIM file.
1780 * @c stdout, or a FILE* opened for writing, to extract the data to.
1782 * @return 0 on success; nonzero on error.
1783 * @retval ::WIMLIB_ERR_INVALID_PARAM
1784 * @a wim is not a ::WIMStruct that was created by wimlib_open_wim().
1785 * @retval ::WIMLIB_ERR_NOMEM
1786 * Failed to allocate needed memory.
1787 * @retval ::WIMLIB_ERR_READ
1788 * Failed to read the XML data from the WIM.
1789 * @retval ::WIMLIB_ERR_WRITE
1790 * Failed to completely write the XML data to @a fp.
1793 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
1796 * Frees all memory allocated for a WIMStruct and closes all files associated
1800 * Pointer to the ::WIMStruct for a WIM file.
1802 * @return This function has no return value.
1805 wimlib_free(WIMStruct *wim);
1808 * Deprecated in favor of wimlib_get_wim_info().
1811 wimlib_get_boot_idx(const WIMStruct *wim) _wimlib_deprecated;
1814 * Deprecated in favor of wimlib_get_wim_info().
1817 wimlib_get_compression_type(const WIMStruct *wim) _wimlib_deprecated;
1820 * Converts a ::wimlib_compression_type value into a string.
1823 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
1824 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
1827 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
1830 extern const wimlib_tchar *
1831 wimlib_get_compression_type_string(int ctype);
1834 * Converts an error code into a string describing it.
1837 * The error code returned by one of wimlib's functions.
1840 * Pointer to a statically allocated string describing the error code,
1841 * or @c NULL if the error code is not valid.
1843 extern const wimlib_tchar *
1844 wimlib_get_error_string(enum wimlib_error_code code);
1847 * Returns the description of the specified image.
1850 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1851 * standalone WIM or a split WIM part.
1853 * The number of the image, numbered starting at 1.
1856 * The description of the image, or @c NULL if there is no such image, or
1857 * @c NULL if the specified image has no description. The description
1858 * string is in library-internal memory and may not be modified or freed;
1859 * in addition, the string will become invalid if the description of the
1860 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
1862 extern const wimlib_tchar *
1863 wimlib_get_image_description(const WIMStruct *wim, int image);
1866 * Returns the name of the specified image.
1869 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1870 * standalone WIM or a split WIM part.
1872 * The number of the image, numbered starting at 1.
1875 * The name of the image, or @c NULL if there is no such image. The name
1876 * string is in library-internal memory and may not be modified or freed;
1877 * in addition, the string will become invalid if the name of the image is
1878 * changed, the image is deleted, or the ::WIMStruct is destroyed.
1880 * If @a wim was read with wimlib_open_wim(), it is allowed for image(s) in
1881 * the WIM to be unnamed, in which case an empty string will be returned
1882 * when the corresponding name is requested.
1884 extern const wimlib_tchar *
1885 wimlib_get_image_name(const WIMStruct *wim, int image);
1889 * Deprecated in favor of wimlib_get_wim_info().
1892 wimlib_get_num_images(const WIMStruct *wim) _wimlib_deprecated;
1895 * Deprecated in favor of wimlib_get_wim_info().
1898 wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret) _wimlib_deprecated;
1901 * Get basic information about a WIM file.
1904 * Pointer to the ::WIMStruct for a WIM file. It may be for either a
1905 * standalone WIM or part of a split WIM.
1907 * A ::wimlib_wim_info structure that will be filled in with information
1908 * about the WIM file.
1913 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
1916 * Initialization function for wimlib. Call before using any other wimlib
1920 * On UNIX, specify ::WIMLIB_INIT_FLAG_ASSUME_UTF8 if wimlib should assume
1921 * that all input data, including filenames, are in UTF-8 rather than the
1922 * locale-dependent character encoding which may or may not be UTF-8, and
1923 * that UTF-8 data can be directly printed to the console. On Windows, use
1924 * 0 for this parameter.
1926 * @return 0; other error codes may be returned in future releases.
1929 wimlib_global_init(int init_flags);
1932 * Since wimlib 1.2.6: Cleanup function for wimlib. This is not re-entrant.
1933 * You are not required to call this function, but it will release any global
1934 * memory allocated by the library.
1937 wimlib_global_cleanup(void);
1940 * Deprecated in favor of wimlib_get_wim_info().
1943 wimlib_has_integrity_table(const WIMStruct *wim) _wimlib_deprecated;
1946 * Determines if an image name is already used by some image in the WIM.
1949 * Pointer to the ::WIMStruct for a WIM file.
1951 * The name to check.
1954 * @c true if there is already an image in @a wim named @a name; @c false
1955 * if there is no image named @a name in @a wim. If @a name is @c NULL or
1956 * the empty string, @c false is returned.
1959 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
1962 * Iterate through a file or directory tree in the WIM image. By specifying
1963 * appropriate flags and a callback function, you can get the attributes of a
1964 * file in the WIM, get a directory listing, or even get a listing of the entire
1968 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1972 * The 1-based number of the image in @a wim that contains the files or
1973 * directories to iterate over.
1976 * Path in the WIM image at which to do the iteration.
1979 * Bitwise OR of ::WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE and/or
1980 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN.
1983 * A callback function that will receive each directory entry.
1986 * An extra parameter that will always be passed to the callback function
1989 * @return 0 on success; nonzero on failure.
1992 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
1994 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
1997 * Joins a split WIM into a stand-alone one-part WIM.
2000 * An array of strings that gives the filenames of all parts of the split
2001 * WIM. No specific order is required, but all parts must be included with
2004 * Number of filenames in @a swms.
2005 * @param swm_open_flags
2006 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY if the integrity of each split WIM
2007 * part should be verified, if integrity tables are present. Otherwise,
2009 * @param wim_write_flags
2010 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY, and/or ::WIMLIB_WRITE_FLAG_FSYNC.
2011 * @param output_path
2012 * The path to write the one-part WIM to.
2013 * @param progress_func
2014 * If non-NULL, a function that will be called periodically with the
2015 * progress of the current operation.
2017 * @return 0 on success; nonzero on error. This function may return any value
2018 * returned by wimlib_open_wim() and wimlib_write() except
2019 * ::WIMLIB_ERR_WIM_IS_READONLY, as well as the following error code:
2021 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2022 * The split WIMs do not form a valid WIM because they do not include all
2023 * the parts of the original WIM, there are duplicate parts, or not all the
2024 * parts have the same GUID and compression type.
2026 * Note: the WIM's uncompressed and compressed resources are not checksummed
2027 * when they are copied from the split WIM parts to the joined WIM, nor are
2028 * compressed resources re-compressed.
2030 * Note: wimlib_export_image() can provide similar functionality to
2031 * wimlib_join(), since it is possible to export all images from a split WIM.
2034 wimlib_join(const wimlib_tchar * const *swms,
2036 const wimlib_tchar *output_path,
2038 int wim_write_flags,
2039 wimlib_progress_func_t progress_func);
2042 * Compress a chunk of a WIM resource using LZX compression.
2044 * This function is exported for convenience only and need not be used.
2047 * Uncompressed data of the chunk.
2049 * Size of the uncompressed chunk, in bytes.
2051 * Pointer to output buffer of size at least (@a chunk_size - 1) bytes.
2054 * The size of the compressed data written to @a out in bytes, or 0 if the
2055 * data could not be compressed to (@a chunk_size - 1) bytes or fewer.
2057 * As a special requirement, the compression code is optimized for the WIM
2058 * format and therefore requires (@a chunk_size <= 32768).
2061 wimlib_lzx_compress(const void *chunk, unsigned chunk_size, void *out);
2064 * Decompresses a block of LZX-compressed data as used in the WIM file format.
2066 * Note that this will NOT work unmodified for LZX as used in the cabinet
2067 * format, which is not the same as in the WIM format!
2069 * This function is exported for convenience only and need not be used.
2071 * @param compressed_data
2072 * Pointer to the compressed data.
2074 * @param compressed_len
2075 * Length of the compressed data, in bytes.
2077 * @param uncompressed_data
2078 * Pointer to the buffer into which to write the uncompressed data.
2080 * @param uncompressed_len
2081 * Length of the uncompressed data. It must be 32768 bytes or less.
2084 * 0 on success; non-zero on failure.
2087 wimlib_lzx_decompress(const void *compressed_data, unsigned compressed_len,
2088 void *uncompressed_data, unsigned uncompressed_len);
2092 * Mounts an image in a WIM file on a directory read-only or read-write.
2094 * This is not supported on Windows.
2096 * Unless ::WIMLIB_MOUNT_FLAG_DEBUG is specified or an early error occurs, the
2097 * process will be daemonized.
2099 * If the mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified),
2100 * modifications to the WIM are staged in a temporary directory.
2102 * It is safe to mount multiple images from the same WIM file read-only at the
2103 * same time, but only if different ::WIMStruct's are used. It is @b not safe
2104 * to mount multiple images from the same WIM file read-write at the same time.
2106 * wimlib_mount_image() cannot be used on an image that was exported with
2107 * wimlib_export_image() while the dentry trees for both images are still in
2108 * memory. In addition, wimlib_mount_image() may not be used to mount an image
2109 * that has just been added with wimlib_add_image(), unless the WIM has been
2110 * written and read into a new ::WIMStruct.
2113 * Pointer to the ::WIMStruct containing the image to be mounted.
2115 * The number of the image to mount, indexed starting from it. It must be
2116 * an existing, single image.
2118 * The path to an existing empty directory to mount the image on.
2119 * @param mount_flags
2120 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
2122 * If ::WIMLIB_MOUNT_FLAG_READWRITE is given, the WIM is mounted read-write
2123 * rather than the default of read-only.
2125 * WIMs may contain named (alternate) data streams, which are a somewhat
2126 * obscure NTFS feature. They can be read and written on a mounted WIM
2127 * through one of several interfaces. The interface to use if specified by
2128 * exactly one of ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE,
2129 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR, or
2130 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS. The default interface is
2131 * the XATTR interface.
2132 * @param additional_swms
2133 * Array of pointers to the ::WIMStruct for each additional part in the
2134 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
2135 * need to be in any particular order, but they must include all parts of
2136 * the split WIM other than the first part, which must be provided in the
2138 * @param num_additional_swms
2139 * Number of additional WIM parts provided in the @a additional_swms array.
2140 * This number should be one less than the total number of parts in the
2141 * split WIM. Set to 0 if the WIM is a standalone WIM.
2142 * @param staging_dir
2143 * If non-NULL, the name of a directory in which the staging directory will
2144 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2145 * in @a mount_flags. If left @c NULL, the staging directory is created in
2146 * the same directory as the WIM file that @a wim was originally read from.
2148 * @return 0 on success; nonzero on error.
2150 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2151 * A read-write mount was requested, but an an exclusive advisory lock on
2152 * the on-disk WIM file could not be acquired because another thread or
2153 * process has mounted an image from the WIM read-write or is currently
2154 * modifying the WIM in-place.
2155 * @retval ::WIMLIB_ERR_DECOMPRESSION
2156 * Could not decompress the metadata resource for @a image in @a wim.
2157 * @retval ::WIMLIB_ERR_FUSE
2158 * A non-zero status was returned by @c fuse_main().
2159 * @retval ::WIMLIB_ERR_INVALID_DENTRY
2160 * A directory entry in the metadata resource for @a image in @a wim is
2162 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2163 * @a image does not specify an existing, single image in @a wim.
2164 * @retval ::WIMLIB_ERR_INVALID_PARAM
2165 * @a image is shared among multiple ::WIMStruct's as a result of a call to
2166 * wimlib_export_image(), or @a image has been added with
2167 * wimlib_add_image().
2168 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2169 * The metadata resource for @a image in @a wim is invalid.
2170 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2171 * The security data for @a image in @a wim is invalid.
2172 * @retval ::WIMLIB_ERR_MKDIR
2173 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a mount_flags, but the
2174 * staging directory could not be created.
2175 * @retval ::WIMLIB_ERR_NOMEM
2176 * Failed to allocate needed memory.
2177 * @retval ::WIMLIB_ERR_NOTDIR
2178 * Could not determine the current working directory.
2179 * @retval ::WIMLIB_ERR_READ
2180 * An unexpected end-of-file or read error occurred when trying to read
2181 * data from the WIM file associated with @a wim.
2182 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2183 * One of the dentries in the image referenced a stream not present in the
2184 * WIM's lookup table (or in any of the lookup tables of the split WIM
2186 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2187 * The WIM is a split WIM, but the parts specified do not form a complete
2188 * split WIM because they do not include all the parts of the original WIM,
2189 * there are duplicate parts, or not all the parts have the same GUID and
2191 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2192 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a mount_flags, but @a
2193 * wim is considered read-only because of any of the reasons mentioned in
2194 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2195 * @retval ::WIMLIB_ERR_UNSUPPORTED
2196 * Mounting is not supported, either because the platform is Windows, or
2197 * because the platform is UNIX and wimlib was compiled with @c
2201 wimlib_mount_image(WIMStruct *wim,
2203 const wimlib_tchar *dir,
2205 WIMStruct **additional_swms,
2206 unsigned num_additional_swms,
2207 const wimlib_tchar *staging_dir);
2210 * Opens a WIM file and creates a ::WIMStruct for it.
2213 * The path to the WIM file to open.
2215 * Bitwise OR of flags ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
2216 * ::WIMLIB_OPEN_FLAG_SPLIT_OK and/or ::WIMLIB_OPEN_FLAG_WRITE_ACCESS.
2218 * @param progress_func
2219 * If non-NULL, a function that will be called periodically with the
2220 * progress of the current operation.
2223 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2224 * is written to the memory location pointed to by this parameter. The
2225 * ::WIMStruct must be freed using using wimlib_free() when finished with
2228 * @return 0 on success; nonzero on error.
2229 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
2230 * The lookup table of @a wim_file is compressed. Support for this can be
2231 * added to wimlib if needed, but it appears to be the case that the lookup
2232 * table is never compressed.
2233 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2234 * The WIM is not the non-first part of a split WIM, and the number of
2235 * metadata resources found in the WIM did not match the image count given
2236 * in the WIM header, or the number of <IMAGE> elements in the XML
2237 * data for the WIM did not match the image count given in the WIM header.
2238 * @retval ::WIMLIB_ERR_INTEGRITY
2239 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
2240 * wim_file contains an integrity table, but the SHA1 message digest for a
2241 * chunk of the WIM does not match the corresponding message digest given
2242 * in the integrity table.
2243 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2244 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
2245 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2246 * The header of @a wim_file says that resources in the WIM are compressed,
2247 * but the header flag indicating LZX or XPRESS compression is not set.
2248 * @retval ::WIMLIB_ERR_INVALID_HEADER_SIZE
2249 * The length field of the WIM header is not 208.
2250 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2251 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
2252 * wim_file contains an integrity table, but the integrity table is
2254 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2255 * The lookup table for the WIM contained duplicate entries that are not
2256 * for metadata resources, or it contained an entry with a SHA1 message
2257 * digest of all 0's.
2258 * @retval ::WIMLIB_ERR_NOMEM
2259 * Failed to allocated needed memory.
2260 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2261 * @a wim_file does not begin with the expected magic characters.
2262 * @retval ::WIMLIB_ERR_OPEN
2263 * Failed to open the file @a wim_file for reading.
2264 * @retval ::WIMLIB_ERR_READ
2265 * An unexpected end-of-file or read error occurred when trying to read
2266 * data from @a wim_file.
2267 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2268 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
2269 * specified in @a open_flags.
2270 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2271 * A number other than 0x10d00 is written in the version field of the WIM
2272 * header of @a wim_file. (Probably a pre-Vista WIM).
2273 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2274 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2275 * considered read-only because of any of the reasons mentioned in the
2276 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2277 * @retval ::WIMLIB_ERR_XML
2278 * The XML data for @a wim_file is invalid.
2281 wimlib_open_wim(const wimlib_tchar *wim_file,
2283 WIMStruct **wim_ret,
2284 wimlib_progress_func_t progress_func);
2287 * Overwrites the file that the WIM was originally read from, with changes made.
2288 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2289 * rather than wimlib_create_new_wim().
2291 * There are two ways that a WIM may be overwritten. The first is to do a full
2292 * rebuild. In this mode, the new WIM is written to a temporary file and then
2293 * renamed to the original file after it is has been completely written. The
2294 * temporary file is made in the same directory as the original WIM file. A
2295 * full rebuild may take a while, but can be used even if images have been
2296 * modified or deleted, will produce a WIM with no holes, and has little chance
2297 * of unintentional data loss because the temporary WIM is fsync()ed before
2298 * being renamed to the original WIM.
2300 * The second way to overwrite a WIM is by appending to the end of it and
2301 * overwriting the header. This can be much faster than a full rebuild, but the
2302 * disadvantage is that some space will be wasted. Writing a WIM in this mode
2303 * begins with writing any new file resources *after* everything in the old WIM,
2304 * even though this will leave a hole where the old lookup table, XML data, and
2305 * integrity were. This is done so that the WIM remains valid even if the
2306 * operation is aborted mid-write. The WIM header is only overwritten at the
2307 * very last moment, and up until that point the WIM will be seen as the old
2310 * By default, wimlib_overwrite() does the append-style overwrite described
2311 * above, unless resources in the WIM are arranged in an unusual way or if
2312 * images have been deleted from the WIM. Use the flag
2313 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
2314 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
2315 * images have been deleted from the WIM.
2317 * In the temporary-file overwrite mode, no changes are made to the WIM on
2318 * failure, and the temporary file is deleted if possible. Abnormal termination
2319 * of the program will result in the temporary file being orphaned. In the
2320 * direct append mode, the WIM is truncated to the original length on failure;
2321 * and while abnormal termination of the program will result in extra data
2322 * appended to the original WIM, it should still be a valid WIM.
2324 * If this function completes successfully, no more functions should be called
2325 * on @a wim other than wimlib_free(). You must use wimlib_open_wim() to read
2326 * the WIM file anew.
2329 * Pointer to the ::WIMStruct for the WIM file to write. There may have
2330 * been in-memory changes made to it, which are then reflected in the
2332 * @param write_flags
2333 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY,
2334 * ::WIMLIB_WRITE_FLAG_REBUILD, ::WIMLIB_WRITE_FLAG_RECOMPRESS, and/or
2335 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE.
2336 * @param num_threads
2337 * Number of threads to use for compression (see wimlib_write()).
2338 * @param progress_func
2339 * If non-NULL, a function that will be called periodically with the
2340 * progress of the current operation.
2342 * @return 0 on success; nonzero on error. This function may return any value
2343 * returned by wimlib_write() as well as the following error codes:
2344 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2345 * The WIM was going to be modified in-place (with no temporary file), but
2346 * an exclusive advisory lock on the on-disk WIM file could not be acquired
2347 * because another thread or process has mounted an image from the WIM
2348 * read-write or is currently modifying the WIM in-place.
2349 * @retval ::WIMLIB_ERR_NO_FILENAME
2350 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
2351 * than a WIM read with wimlib_open_wim().
2352 * @retval ::WIMLIB_ERR_RENAME
2353 * The temporary file that the WIM was written to could not be renamed to
2354 * the original filename of @a wim.
2355 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2356 * The WIM file is considered read-only because of any of the reasons
2357 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2361 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
2362 wimlib_progress_func_t progress_func);
2365 * Prints information about one image, or all images, contained in a WIM.
2368 * Pointer to the ::WIMStruct for a WIM file.
2370 * The image about which to print information. Can be the number of an
2371 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
2374 * @return This function has no return value. No error checking is done when
2375 * printing the information. If @a image is invalid, an error message is
2379 wimlib_print_available_images(const WIMStruct *wim, int image);
2381 /** TODO: wimlib-imagex uses this for the 'dir' command, but a better API is
2382 * needed for this. */
2384 wimlib_print_files(WIMStruct *wim, int image) _wimlib_deprecated;
2386 /** TODO: wimlib-imagex uses this for the 'info --header' command, but a better
2387 * API is needed for this. */
2389 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
2391 /** TODO: wimlib-imagex uses this for the 'info --lookup-table' command, but a
2392 * better API is needed for this. */
2394 wimlib_print_lookup_table(WIMStruct *wim) _wimlib_deprecated;
2396 /** TODO: wimlib-imagex uses this for the 'info --metadata' command, but a
2397 * better API is needed for this. */
2399 wimlib_print_metadata(WIMStruct *wim, int image) _wimlib_deprecated;
2402 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
2403 * in a way that can be accessed programatically.
2406 wimlib_print_wim_information(const WIMStruct *wim) _wimlib_deprecated;
2409 * Translates a string specifying the name or number of an image in the WIM into
2410 * the number of the image. The images are numbered starting at 1.
2413 * Pointer to the ::WIMStruct for a WIM file.
2414 * @param image_name_or_num
2415 * A string specifying the name or number of an image in the WIM. If it
2416 * parses to a positive integer, this integer is taken to specify the
2417 * number of the image, indexed starting at 1. Otherwise, it is taken to
2418 * be the name of an image, as given in the XML data for the WIM file. It
2419 * also may be the keyword "all" or the string "*", both of which will
2420 * resolve to ::WIMLIB_ALL_IMAGES.
2422 * There is no way to search for an image actually named "all", "*", or an
2423 * integer number, or an image that has no name. However, you can use
2424 * wimlib_get_image_name() to get the name of any image.
2427 * If the string resolved to a single existing image, the number of that
2428 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
2429 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
2430 * ::WIMLIB_NO_IMAGE is returned. If @a image_name_or_num was @c NULL or
2431 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
2432 * images in @a wim has no name.
2435 wimlib_resolve_image(WIMStruct *wim,
2436 const wimlib_tchar *image_name_or_num);
2439 * Deprecated in favor of wimlib_set_wim_info().
2442 wimlib_set_boot_idx(WIMStruct *wim, int boot_idx) _wimlib_deprecated;
2445 * Changes the description of an image in the WIM.
2448 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2449 * standalone WIM or part of a split WIM; however, you should set the same
2450 * description on all parts of a split WIM.
2452 * The number of the image for which to change the description.
2453 * @param description
2454 * The new description to give the image. It may be @c NULL, which
2455 * indicates that the image is to be given no description.
2457 * @return 0 on success; nonzero on error.
2458 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2459 * @a image does not specify a single existing image in @a wim.
2460 * @retval ::WIMLIB_ERR_NOMEM
2461 * Failed to allocate the memory needed to duplicate the @a description
2463 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2464 * @a wim is considered read-only because of any of the reasons mentioned
2465 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2468 wimlib_set_image_descripton(WIMStruct *wim, int image,
2469 const wimlib_tchar *description);
2472 * Set basic information about a WIM.
2475 * A WIMStruct for a standalone WIM file.
2477 * A struct ::wimlib_wim_info that contains the information to set. Only
2478 * the information explicitly specified in the @a which flags need be
2481 * Flags that specify which information to set. This is a bitwise OR of
2482 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
2483 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
2485 * @return 0 on success; nonzero on failure.
2486 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2487 * The WIM file is considered read-only because of any of the reasons
2488 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2489 * flag. However, as a special case, if you are using
2490 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
2491 * function will not fail due to the readonly flag being previously set.
2492 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2493 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
2494 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
2498 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
2502 * Changes what is written in the \<FLAGS\> element in the WIM XML data
2503 * (something like "Core" or "Ultimate")
2506 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2507 * standalone WIM or part of a split WIM; however, you should set the same
2508 * \<FLAGS\> element on all parts of a split WIM.
2510 * The number of the image for which to change the description.
2512 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
2513 * indicates that the image is to be given no \<FLAGS\> element.
2515 * @return 0 on success; nonzero on error.
2516 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2517 * @a image does not specify a single existing image in @a wim.
2518 * @retval ::WIMLIB_ERR_NOMEM
2519 * Failed to allocate the memory needed to duplicate the @a flags string.
2520 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2521 * @a wim is considered read-only because of any of the reasons mentioned
2522 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2525 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
2528 * Changes the name of an image in the WIM.
2531 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2532 * standalone WIM or part of a split WIM; however, you should set the same
2533 * name on all parts of a split WIM.
2535 * The number of the image for which to change the name.
2537 * New name to give the new image. If @c NULL or empty, the new image is
2538 * given no name. If nonempty, it must specify a name that does not
2539 * already exist in @a wim.
2541 * @return 0 on success; nonzero on error.
2542 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2543 * There is already an image named @a name in @a wim.
2544 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2545 * @a image does not specify a single existing image in @a wim.
2546 * @retval ::WIMLIB_ERR_NOMEM
2547 * Failed to allocate the memory needed to duplicate the @a name string.
2548 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2549 * @a wim is considered read-only because of any of the reasons mentioned
2550 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2552 extern int wimlib_set_image_name(WIMStruct *wim, int image,
2553 const wimlib_tchar *name);
2556 * Set the functions that wimlib uses to allocate and free memory.
2558 * These settings are global and not per-WIM.
2560 * The default is to use the default @c malloc() and @c free() from the C
2563 * Please note that some external functions, such as those in @c libntfs-3g, may
2564 * use the standard memory allocation functions.
2566 * @param malloc_func
2567 * A function equivalent to @c malloc() that wimlib will use to allocate
2568 * memory. If @c NULL, the allocator function is set back to the default
2569 * @c malloc() from the C library.
2571 * A function equivalent to @c free() that wimlib will use to free memory.
2572 * If @c NULL, the free function is set back to the default @c free() from
2574 * @param realloc_func
2575 * A function equivalent to @c realloc() that wimlib will use to reallocate
2576 * memory. If @c NULL, the free function is set back to the default @c
2577 * realloc() from the C library.
2578 * @return 0 on success; nonzero on error.
2579 * @retval ::WIMLIB_ERR_UNSUPPORTED
2580 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
2581 * so custom memory allocators are unsupported.
2584 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
2585 void (*free_func)(void *),
2586 void *(*realloc_func)(void *, size_t));
2589 * Sets whether wimlib is to print error messages to @c stderr when a function
2590 * fails. These error messages may provide information that cannot be
2591 * determined only from the error code that is returned. Not every error will
2592 * result in an error message being printed.
2594 * This setting is global and not per-WIM.
2596 * By default, error messages are not printed.
2598 * @param show_messages
2599 * @c true if error messages are to be printed; @c false if error messages
2600 * are not to be printed.
2602 * @return 0 on success; nonzero on error.
2603 * @retval ::WIMLIB_ERR_UNSUPPORTED
2604 * @a show_messages was @c true, but wimlib was compiled with the @c
2605 * --without-error-messages option. Therefore, error messages cannot be
2609 wimlib_set_print_errors(bool show_messages);
2612 * Splits a WIM into multiple parts.
2615 * The ::WIMStruct for the WIM to split. It must be a standalone, one-part
2618 * Name of the SWM file to create. This will be the name of the first
2619 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
2620 * appended before the suffix.
2622 * The maximum size per part, in bytes. It is not guaranteed that this
2623 * will really be the maximum size per part, because some file resources in
2624 * the WIM may be larger than this size, and the WIM file format provides
2625 * no way to split up file resources among multiple WIMs.
2626 * @param write_flags
2627 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY if integrity tables are to be
2628 * included in the split WIM parts.
2629 * @param progress_func
2630 * If non-NULL, a function that will be called periodically with the
2631 * progress of the current operation.
2633 * @return 0 on success; nonzero on error. This function may return any value
2634 * returned by wimlib_write() as well as the following error codes:
2636 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2637 * @a wim is not part 1 of a stand-alone WIM.
2638 * @retval ::WIMLIB_ERR_INVALID_PARAM
2639 * @a swm_name was @c NULL, or @a part_size was 0.
2641 * Note: the WIM's uncompressed and compressed resources are not checksummed
2642 * when they are copied from the joined WIM to the split WIM parts, nor are
2643 * compressed resources re-compressed.
2646 wimlib_split(WIMStruct *wim,
2647 const wimlib_tchar *swm_name,
2650 wimlib_progress_func_t progress_func);
2653 * Unmounts a WIM image that was mounted using wimlib_mount_image().
2655 * The image to unmount is specified by the path to the mountpoint, not the
2656 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
2657 * touched and also may have been allocated in a different process.
2659 * To unmount the image, the thread calling this function communicates with the
2660 * thread that is managing the mounted WIM image. This function blocks until it
2661 * is known whether the unmount succeeded or failed. In the case of a
2662 * read-write mounted WIM, the unmount is not considered to have succeeded until
2663 * all changes have been saved to the underlying WIM file.
2666 * The directory that the WIM image was mounted on.
2667 * @param unmount_flags
2668 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
2669 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
2670 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
2672 * @param progress_func
2673 * If non-NULL, a function that will be called periodically with the
2674 * progress of the current operation.
2676 * @return 0 on success; nonzero on error.
2678 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
2679 * The filesystem daemon was unable to remove the staging directory and the
2680 * temporary files that it contains.
2681 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
2682 * The filesystem daemon appears to have terminated before sending an exit
2684 * @retval ::WIMLIB_ERR_FORK
2685 * Could not @c fork() the process.
2686 * @retval ::WIMLIB_ERR_FUSERMOUNT
2687 * The @b fusermount program could not be executed or exited with a failure
2689 * @retval ::WIMLIB_ERR_MQUEUE
2690 * Could not open a POSIX message queue to communicate with the filesystem
2691 * daemon servicing the mounted filesystem, could not send a message
2692 * through the queue, or could not receive a message through the queue.
2693 * @retval ::WIMLIB_ERR_NOMEM
2694 * Failed to allocate needed memory.
2695 * @retval ::WIMLIB_ERR_OPEN
2696 * The filesystem daemon could not open a temporary file for writing the
2698 * @retval ::WIMLIB_ERR_READ
2699 * A read error occurred when the filesystem daemon tried to a file from
2700 * the staging directory
2701 * @retval ::WIMLIB_ERR_RENAME
2702 * The filesystem daemon failed to rename the newly written WIM file to the
2703 * original WIM file.
2704 * @retval ::WIMLIB_ERR_UNSUPPORTED
2705 * Mounting is not supported, either because the platform is Windows, or
2706 * because the platform is UNIX and wimlib was compiled with @c
2708 * @retval ::WIMLIB_ERR_WRITE
2709 * A write error occurred when the filesystem daemon was writing to the new
2710 * WIM file, or the filesystem daemon was unable to flush changes that had
2711 * been made to files in the staging directory.
2714 wimlib_unmount_image(const wimlib_tchar *dir,
2716 wimlib_progress_func_t progress_func);
2719 * Update a WIM image by adding, deleting, and/or renaming files or directories.
2722 * Pointer to the ::WIMStruct for the WIM file to update.
2724 * The 1-based index of the image in the WIM to update. It cannot be
2725 * ::WIMLIB_ALL_IMAGES.
2727 * An array of ::wimlib_update_command's that specify the update operations
2730 * Number of commands in @a cmds.
2731 * @param update_flags
2732 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
2733 * @param progress_func
2734 * If non-NULL, a function that will be called periodically with the
2735 * progress of the current operation.
2737 * @return 0 on success; nonzero on error. On failure, some but not all of the
2738 * update commands may have been executed. No individual update command will
2739 * have been partially executed. Possible error codes include:
2741 * @retval ::WIMLIB_ERR_DECOMPRESSION
2742 * Failed to decompress the metadata resource from @a image in @a wim.
2743 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
2744 * The capture configuration structure specified for an add command was
2746 * @retval ::WIMLIB_ERR_INVALID_DENTRY
2747 * A directory entry for @a image in @a wim is invalid.
2748 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2749 * @a image did not specify a single, existing image in @a wim.
2750 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
2751 * Attempted to perform an add command that conflicted with previously
2752 * existing files in the WIM when an overlay was attempted.
2753 * @retval ::WIMLIB_ERR_INVALID_PARAM
2754 * An unknown operation type was specified in the update commands; or,
2755 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
2756 * in the @a add_flags, but the same image had previously already been
2757 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
2758 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @a add_flags for one add
2759 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
2760 * specified in the @a add_flags for an add command in which @a
2761 * wim_target_path was not the root directory of the WIM image.
2762 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
2763 * (Windows only): While executing an add command, tried to capture a
2764 * reparse point with invalid data.
2765 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2766 * The metadata resource for @a image in @a wim is invalid.
2767 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2768 * The security data for image @a image in @a wim is invalid.
2769 * @retval ::WIMLIB_ERR_IS_DIRECTORY
2770 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
2771 * for a WIM path that corresponded to a directory; or, a rename command
2772 * attempted to rename a directory to a non-directory.
2773 * @retval ::WIMLIB_ERR_NOMEM
2774 * Failed to allocate needed memory.
2775 * @retval ::WIMLIB_ERR_NOTDIR
2776 * A rename command attempted to rename a directory to a non-directory; or,
2777 * an add command was executed that attempted to set the root of the WIM
2778 * image as a non-directory; or, a path component used as a directory in a
2779 * rename command was not, in fact, a directory.
2780 * @retval ::WIMLIB_ERR_NOTEMPTY
2781 * A rename command attempted to rename a directory to a non-empty
2783 * @retval ::WIMLIB_ERR_NTFS_3G
2784 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
2785 * error occurred while reading data from the NTFS volume using libntfs-3g.
2786 * @retval ::WIMLIB_ERR_OPEN
2787 * Failed to open a file to be captured while executing an add command.
2788 * @retval ::WIMLIB_ERR_OPENDIR
2789 * Failed to open a directory to be captured while executing an add command.
2790 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2791 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
2792 * WIM path that did not exist; or, a rename command attempted to rename a
2793 * file that does not exist.
2794 * @retval ::WIMLIB_ERR_READ
2795 * Failed to read the metadata resource for @a image in @a wim; or, while
2796 * executing an add command, failed to read data from a file or directory
2798 * @retval ::WIMLIB_ERR_READLINK
2799 * While executing an add command, failed to read the target of a symbolic
2800 * link or junction point.
2801 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2802 * (Windows only) Failed to perform a reparse point fixup because of
2803 * problems with the data of a reparse point.
2804 * @retval ::WIMLIB_ERR_SPECIAL_FILE
2805 * While executing an add command, attempted to capture a file that was not
2806 * a supported file type, such as a regular file, directory, symbolic link,
2807 * or (on Windows) a reparse point.
2808 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2809 * @a wim is part of a split WIM. Updating a split WIM is unsupported.
2810 * @retval ::WIMLIB_ERR_STAT
2811 * While executing an add command, failed to get attributes for a file or
2813 * @retval ::WIMLIB_ERR_UNSUPPORTED
2814 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @a add_flags for an update
2815 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
2816 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
2817 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @a
2818 * add_flags for an update command.
2819 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2820 * The WIM file is considered read-only because of any of the reasons
2821 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2825 wimlib_update_image(WIMStruct *wim,
2827 const struct wimlib_update_command *cmds,
2830 wimlib_progress_func_t progress_func);
2833 * Writes a standalone WIM to a file.
2835 * This brings in resources from any external locations, such as directory trees
2836 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
2837 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
2840 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
2841 * changes made to it, which are then reflected in the output file.
2843 * The path to the file to write the WIM to.
2845 * The image inside the WIM to write. Use ::WIMLIB_ALL_IMAGES to include all
2847 * @param write_flags
2848 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY,
2849 * ::WIMLIB_WRITE_FLAG_RECOMPRESS, ::WIMLIB_WRITE_FLAG_FSYNC, and/or
2850 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE.
2851 * @param num_threads
2852 * Number of threads to use for compressing data. If 0, the number of
2853 * threads is taken to be the number of online processors. Note: if no
2854 * data compression needs to be done, no additional threads will be created
2855 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
2856 * exporting an image from a compressed WIM to another WIM of the same
2857 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @a
2859 * @param progress_func
2860 * If non-NULL, a function that will be called periodically with the
2861 * progress of the current operation.
2863 * @return 0 on success; nonzero on error.
2864 * @retval ::WIMLIB_ERR_DECOMPRESSION
2865 * Failed to decompress a metadata or file resource in @a wim.
2866 * @retval ::WIMLIB_ERR_INVALID_DENTRY
2867 * A directory entry in the metadata resource for @a image in @a wim is
2869 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2870 * @a image does not specify a single existing image in @a wim, and is not
2871 * ::WIMLIB_ALL_IMAGES.
2872 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2873 * A file that had previously been scanned for inclusion in the WIM by
2874 * wimlib_add_image() was concurrently modified, so it failed the SHA1
2875 * message digest check.
2876 * @retval ::WIMLIB_ERR_INVALID_PARAM
2877 * @a path was @c NULL.
2878 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2879 * The metadata resource for @a image in @a wim is invalid.
2880 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2881 * The security data for @a image in @a wim is invalid.
2882 * @retval ::WIMLIB_ERR_NOMEM
2883 * Failed to allocate needed memory.
2884 * @retval ::WIMLIB_ERR_OPEN
2885 * Failed to open @a path for writing, or some file resources in @a
2886 * wim refer to files in the outside filesystem, and one of these files
2887 * could not be opened for reading.
2888 * @retval ::WIMLIB_ERR_READ
2889 * An error occurred when trying to read data from the WIM file associated
2890 * with @a wim, or some file resources in @a wim refer to files in the
2891 * outside filesystem, and a read error occurred when reading one of these
2893 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2894 * @a wim is part of a split WIM. You may not call this function on a
2896 * @retval ::WIMLIB_ERR_WRITE
2897 * An error occurred when trying to write data to the new WIM file at @a
2901 wimlib_write(WIMStruct *wim,
2902 const wimlib_tchar *path,
2905 unsigned num_threads,
2906 wimlib_progress_func_t progress_func);
2909 * This function is equivalent to wimlib_lzx_compress(), but instead compresses
2910 * the data using "XPRESS" compression.
2913 wimlib_xpress_compress(const void *chunk, unsigned chunk_size, void *out);
2916 * This function is equivalent to wimlib_lzx_decompress(), but instead assumes
2917 * the data is compressed using "XPRESS" compression.
2920 wimlib_xpress_decompress(const void *compressed_data, unsigned compressed_len,
2921 void *uncompressed_data, unsigned uncompressed_len);
2923 #endif /* _WIMLIB_H */