4 * External header for wimlib.
6 * This file contains extensive comments for generating documentation with
7 * Doxygen. The built HTML documentation can be viewed at
8 * http://wimlib.sourceforge.net.
12 * Copyright (C) 2012, 2013 Eric Biggers
14 * This file is part of wimlib, a library for working with WIM files.
16 * wimlib is free software; you can redistribute it and/or modify it under the
17 * terms of the GNU General Public License as published by the Free
18 * Software Foundation; either version 3 of the License, or (at your option)
21 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
22 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
23 * A PARTICULAR PURPOSE. See the GNU General Public License for more
26 * You should have received a copy of the GNU General Public License
27 * along with wimlib; if not, see http://www.gnu.org/licenses/.
32 * \section intro Introduction
34 * This is the documentation for the library interface of wimlib 1.5.0, a C
35 * library for creating, modifying, extracting, and mounting files in the
36 * Windows Imaging Format. This documentation is intended for developers only.
37 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
38 * program, please see the README file.
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. Still alternatively, you
94 * can write a WIM directly to a file descriptor by calling wimlib_write_to_fd()
97 * wimlib supports a special "pipable" WIM format (which unfortunately is @b not
98 * compatible with Microsoft's software). To create a pipable WIM, call
99 * wimlib_write(), wimlib_write_to_fd(), or wimlib_overwrite() with
100 * ::WIMLIB_WRITE_FLAG_PIPABLE specified. Pipable WIMs are pipable in both
101 * directions, so wimlib_write_to_fd() can be used to write a pipable WIM to a
102 * pipe, and wimlib_extract_image_from_pipe() can be used to apply an image from
105 * Please note: merely by calling wimlib_add_image() or many of the other
106 * functions in this library that operate on ::WIMStruct's, you are @b not
107 * modifying the WIM file on disk. Changes are not saved until you explicitly
108 * call wimlib_write() or wimlib_overwrite().
110 * After you are done with the WIM file, use wimlib_free() to free all memory
111 * associated with a ::WIMStruct and close all files associated with it.
113 * When you are completely done with using wimlib in your program, you should
114 * call wimlib_global_cleanup().
116 * A number of functions take a pointer to a progress function of type
117 * ::wimlib_progress_func_t. This function will be called periodically during
118 * the WIM operation(s) to report on the progress of the operation (for example,
119 * how many bytes have been written so far).
121 * wimlib is thread-safe as long as different ::WIMStruct's are used, except for
122 * the following exceptions:
123 * - You must call wimlib_global_init() in one thread before calling any other
125 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
126 * race conditions with one-time allocations of memory.
127 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
128 * concurrently in the same process, will daemonize the entire process when it
129 * does so for the first time. This includes changing the working directory
130 * to the root directory.
132 * \section encodings Locales and character encodings
134 * To support Windows as well as UNIX, wimlib's API typically takes and returns
135 * strings of ::wimlib_tchar, which are in a platform-dependent encoding.
137 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
138 * and the encoding is UTF-16LE.
140 * On UNIX, each ::wimlib_tchar is 1 byte and is simply a "char", and the
141 * encoding is the locale-dependent multibyte encoding. I recommend you set
142 * your locale to a UTF-8 capable locale to avoid any issues. Also, by default,
143 * wimlib on UNIX will assume the locale is UTF-8 capable unless you call
144 * wimlib_global_init() after having set your desired locale.
146 * \section Limitations
148 * This section documents some technical limitations of wimlib not already
149 * documented in the man page for @b wimlib-imagex.
151 * - The old WIM format from Vista pre-releases is not supported.
152 * - Compressed resource chunk sizes other than 32768 are not supported. This
153 * doesn't seem to be a real problem because the chunk size always seems to be
155 * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
156 * functionality other than that already present in @b ImageX, that allows you
157 * to make certain Windows-specific modifications to a Windows PE image, such
158 * as adding a driver or Windows component. Such a tool possibly could be
159 * implemented on top of wimlib.
168 #include <inttypes.h>
171 /** Major version of the library (for example, the 1 in 1.2.5). */
172 #define WIMLIB_MAJOR_VERSION 1
174 /** Minor version of the library (for example, the 2 in 1.2.5). */
175 #define WIMLIB_MINOR_VERSION 5
177 /** Patch version of the library (for example, the 5 in 1.2.5). */
178 #define WIMLIB_PATCH_VERSION 0
181 * Opaque structure that represents a WIM file. This is an in-memory structure
182 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
183 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
184 * continuing to exist so that data can be read from it as needed.
186 * Most functions in this library will work the same way regardless of whether a
187 * given ::WIMStruct was obtained through wimlib_open_wim() or
188 * wimlib_create_new_wim(). Exceptions are documented.
190 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
191 * file from a ::WIMStruct.
193 #ifndef WIMLIB_WIMSTRUCT_DECLARED
194 typedef struct WIMStruct WIMStruct;
195 #define WIMLIB_WIMSTRUCT_DECLARED
199 typedef wchar_t wimlib_tchar;
201 /** See \ref encodings */
202 typedef char wimlib_tchar;
206 /** Path separator for WIM paths passed back to progress callbacks. */
207 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
208 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
210 /** Path separator for WIM paths passed back to progress callbacks. */
211 # define WIMLIB_WIM_PATH_SEPARATOR '/'
212 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
216 # define _wimlib_deprecated __attribute__((deprecated))
218 # define _wimlib_deprecated
221 #define WIMLIB_GUID_LEN 16
224 * Specifies the compression type of a WIM file.
226 enum wimlib_compression_type {
227 /** An invalid compression type. */
228 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
230 /** The WIM does not include any compressed resources. */
231 WIMLIB_COMPRESSION_TYPE_NONE = 0,
233 /** Compressed resources in the WIM use LZX compression. */
234 WIMLIB_COMPRESSION_TYPE_LZX = 1,
236 /** Compressed resources in the WIM use XPRESS compression. */
237 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
240 /** Possible values of the first parameter to the user-supplied
241 * ::wimlib_progress_func_t progress function */
242 enum wimlib_progress_msg {
244 /** A WIM image is about to be extracted. @a info will point to
245 * ::wimlib_progress_info.extract. */
246 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
248 /** A file or directory tree within a WIM image (not the full image) is
249 * about to be extracted. @a info will point to
250 * ::wimlib_progress_info.extract. */
251 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
253 /** The directory structure of the WIM image is about to be extracted.
254 * @a info will point to ::wimlib_progress_info.extract. */
255 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
257 /** The directory structure of the WIM image has been successfully
258 * extracted. @a info will point to ::wimlib_progress_info.extract. */
259 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
261 /** The WIM image's files resources are currently being extracted. @a
262 * info will point to ::wimlib_progress_info.extract. */
263 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
265 /** Starting to read a new part of a split pipable WIM over the pipe.
266 * @a info will point to ::wimlib_progress_info.extract. */
267 WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN,
269 /** All the WIM files and directories have been extracted, and
270 * timestamps are about to be applied. @a info will point to
271 * ::wimlib_progress_info.extract. */
272 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
274 /** A WIM image has been successfully extracted. @a info will point to
275 * ::wimlib_progress_info.extract. */
276 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
278 /** A file or directory tree within a WIM image (not the full image) has
279 * been successfully extracted. @a info will point to
280 * ::wimlib_progress_info.extract. */
281 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
283 /** The directory or NTFS volume is about to be scanned to build a tree
284 * of WIM dentries in-memory. @a info will point to
285 * ::wimlib_progress_info.scan. */
286 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
288 /** A directory or file is being scanned. @a info will point to
289 * ::wimlib_progress_info.scan, and its @a cur_path member will be
290 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE
291 * is passed to wimlib_add_image(). */
292 WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
294 /** The directory or NTFS volume has been successfully scanned, and a
295 * tree of WIM dentries has been built in-memory. @a info will point to
296 * ::wimlib_progress_info.scan. */
297 WIMLIB_PROGRESS_MSG_SCAN_END,
300 * File resources are currently being written to the WIM.
301 * @a info will point to ::wimlib_progress_info.write_streams. */
302 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
305 * The metadata resource for each image is about to be written to the
306 * WIM. @a info will not be valid. */
307 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
310 * The metadata resource for each image has successfully been writen to
311 * the WIM. @a info will not be valid. */
312 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
315 * The temporary file has successfully been renamed to the original WIM
316 * file. Only happens when wimlib_overwrite() is called and the
317 * overwrite is not done in-place.
318 * @a info will point to ::wimlib_progress_info.rename. */
319 WIMLIB_PROGRESS_MSG_RENAME,
321 /** The contents of the WIM are being checked against the integrity
322 * table. Only happens when wimlib_open_wim() is called with the
323 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. @a info will point to
324 * ::wimlib_progress_info.integrity. */
325 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
327 /** An integrity table is being calculated for the WIM being written.
328 * Only happens when wimlib_write() or wimlib_overwrite() is called with
329 * the ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag. @a info will point to
330 * ::wimlib_progress_info.integrity. */
331 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
333 /** Reserved. (Previously used for WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
334 * but in wimlib v1.5.0 this was removed to simplify the code and now
335 * you'll get ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS messages instead.) */
336 WIMLIB_PROGRESS_MSG_RESERVED,
338 /** A wimlib_split() operation is in progress, and a new split part is
339 * about to be started. @a info will point to
340 * ::wimlib_progress_info.split. */
341 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
343 /** A wimlib_split() operation is in progress, and a split part has been
344 * finished. @a info will point to ::wimlib_progress_info.split. */
345 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
348 * A WIM update command is just about to be executed; @a info will point
349 * to ::wimlib_progress_info.update.
351 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
354 * A WIM update command has just been executed; @a info will point to
355 * ::wimlib_progress_info.update.
357 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
361 /** A pointer to this union is passed to the user-supplied
362 * ::wimlib_progress_func_t progress function. One (or none) of the structures
363 * contained in this union will be applicable for the operation
364 * (::wimlib_progress_msg) indicated in the first argument to the progress
366 union wimlib_progress_info {
368 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
369 * document them if they aren't given a name... */
371 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. */
372 struct wimlib_progress_info_write_streams {
373 /** Number of bytes that are going to be written for all the
374 * streams combined. This is the amount in uncompressed data.
375 * (The actual number of bytes will be less if the data is being
376 * written compressed.) */
377 uint64_t total_bytes;
379 /** Number of streams that are going to be written. */
380 uint64_t total_streams;
382 /** Number of uncompressed bytes that have been written so far.
383 * Will be 0 initially, and equal to @a total_bytes at the end.
385 uint64_t completed_bytes;
387 /** Number of streams that have been written. Will be 0
388 * initially, and equal to @a total_streams at the end. */
389 uint64_t completed_streams;
391 /** Number of threads that are being used to compress resources
392 * (if applicable). */
393 unsigned num_threads;
395 /** The compression type being used to write the streams; either
396 * ::WIMLIB_COMPRESSION_TYPE_NONE,
397 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or
398 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
399 int compression_type;
401 /** Number of split WIM parts from which streams are being
402 * written (may be 0 if irrelevant). */
403 unsigned total_parts;
405 /** Number of split WIM parts from which streams have been
406 * written (may be 0 if irrelevant). */
407 unsigned completed_parts;
410 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
411 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
412 struct wimlib_progress_info_scan {
413 /** Directory or NTFS volume that is being scanned. */
414 const wimlib_tchar *source;
416 /** Path to the file or directory that is about to be scanned,
417 * relative to the root of the image capture or the NTFS volume.
419 const wimlib_tchar *cur_path;
421 /** True iff @a cur_path is being excluded from the image
422 * capture due to the capture configuration file. */
425 /** Target path in the WIM. Only valid on messages
426 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
427 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
428 const wimlib_tchar *wim_target_path;
431 /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
432 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
433 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
434 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
435 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
436 struct wimlib_progress_info_extract {
437 /** Number of the image being extracted (1-based). */
440 /** Flags passed to to wimlib_extract_image() */
443 /** Full path to the WIM file being extracted. */
444 const wimlib_tchar *wimfile_name;
446 /** Name of the image being extracted. */
447 const wimlib_tchar *image_name;
449 /** Directory or NTFS volume to which the image is being
451 const wimlib_tchar *target;
454 const wimlib_tchar *cur_path;
456 /** Number of bytes of uncompressed data that will be extracted.
457 * Takes into account hard links (they are not counted for each
459 uint64_t total_bytes;
461 /** Number of bytes that have been written so far. Will be 0
462 * initially, and equal to @a total_bytes at the end. */
463 uint64_t completed_bytes;
465 /** Number of streams that will be extracted. This may more or
466 * less than the number of "files" to be extracted due to
467 * special cases (hard links, symbolic links, and alternate data
469 uint64_t num_streams;
471 /** Path to the root dentry within the WIM for the tree that is
472 * being extracted. Will be the empty string when extracting a
474 const wimlib_tchar *extract_root_wim_source_path;
476 /** Currently only used for
477 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
479 unsigned part_number;
481 /** Currently only used for
482 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
483 unsigned total_parts;
485 /** Currently only used for
486 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN. */
487 uint8_t guid[WIMLIB_GUID_LEN];
490 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
491 struct wimlib_progress_info_rename {
492 /** Name of the temporary file that the WIM was written to. */
493 const wimlib_tchar *from;
495 /** Name of the original WIM file to which the temporary file is
497 const wimlib_tchar *to;
500 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
501 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
502 struct wimlib_progress_info_update {
503 /** Pointer to the update command that will be executed or has
504 * just been executed. */
505 const struct wimlib_update_command *command;
507 /** Number of update commands that have been completed so far.
509 size_t completed_commands;
511 /** Number of update commands that are being executed as part of
512 * this call to wimlib_update_image(). */
513 size_t total_commands;
516 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
517 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
518 struct wimlib_progress_info_integrity {
519 /** Number of bytes from the end of the WIM header to the end of
520 * the lookup table (the area that is covered by the SHA1
521 * integrity checks.) */
522 uint64_t total_bytes;
524 /** Number of bytes that have been SHA1-summed so far. Will be
525 * 0 initially, and equal @a total_bytes at the end. */
526 uint64_t completed_bytes;
528 /** Number of chunks that the checksummed region is divided
530 uint32_t total_chunks;
532 /** Number of chunks that have been SHA1-summed so far. Will
533 * be 0 initially, and equal to @a total_chunks at the end. */
534 uint32_t completed_chunks;
536 /** Size of the chunks used for the integrity calculation. */
539 /** Filename of the WIM (only valid if the message is
540 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
541 const wimlib_tchar *filename;
544 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
545 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
546 struct wimlib_progress_info_split {
547 /** Total size of the original WIM's file and metadata resources
549 uint64_t total_bytes;
551 /** Number of bytes of file and metadata resources that have
552 * been copied out of the original WIM so far. Will be 0
553 * initially, and equal to @a total_bytes at the end. */
554 uint64_t completed_bytes;
556 /** Number of the split WIM part that is about to be started
557 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
558 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
559 unsigned cur_part_number;
561 /** Total number of split WIM parts that are being written. */
562 unsigned total_parts;
564 /** Name of the split WIM part that is about to be started
565 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
566 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
567 const wimlib_tchar *part_name;
571 /** A user-supplied function that will be called periodically during certain WIM
572 * operations. The first argument will be the type of operation that is being
573 * performed or is about to be started or has been completed. The second
574 * argument will be a pointer to one of a number of structures depending on the
575 * first argument. It may be @c NULL for some message types.
577 * The return value of the progress function is currently ignored, but it may do
578 * something in the future. (Set it to 0 for now.)
580 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
581 const union wimlib_progress_info *info);
583 /** An array of these structures is passed to wimlib_add_image_multisource() to
584 * specify the sources from which to create a WIM image. */
585 struct wimlib_capture_source {
586 /** Absolute or relative path to a file or directory on the external
587 * filesystem to be included in the WIM image. */
588 wimlib_tchar *fs_source_path;
590 /** Destination path in the WIM image. Leading and trailing slashes are
591 * ignored. The empty string or @c NULL means the root directory of the
593 wimlib_tchar *wim_target_path;
595 /** Reserved; set to 0. */
599 /** Structure that specifies a list of path patterns. */
600 struct wimlib_pattern_list {
601 /** Array of patterns. The patterns may be modified by library code,
602 * but the @a pats pointer itself will not. See the man page for
603 * <b>wimlib-imagex capture</b> for more information about allowed
607 /** Number of patterns in the @a pats array. */
610 /** Ignored; may be used by the calling code. */
611 size_t num_allocated_pats;
614 /** A structure that contains lists of wildcards that match paths to treat
615 * specially when capturing a WIM image. */
616 struct wimlib_capture_config {
617 /** Paths matching any pattern this list are excluded from being
618 * captured, except if the same path appears in @a
619 * exclusion_exception_pats. */
620 struct wimlib_pattern_list exclusion_pats;
622 /** Paths matching any pattern in this list are never excluded from
624 struct wimlib_pattern_list exclusion_exception_pats;
626 /** Reserved for future capture configuration options. */
627 struct wimlib_pattern_list reserved1;
629 /** Reserved for future capture configuration options. */
630 struct wimlib_pattern_list reserved2;
632 /** Library internal use only. */
633 wimlib_tchar *_prefix;
635 /** Library internal use only. */
636 size_t _prefix_num_tchars;
639 /** Set or unset the WIM header flag that marks it read-only
640 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
641 * ::wimlib_wim_info.is_marked_readonly member of the @a info parameter. This
642 * is distinct from basic file permissions; this flag can be set on a WIM file
643 * that is physically writable. If this flag is set, all further operations to
644 * modify the WIM will fail, except calling wimlib_overwrite() with
645 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
646 * allows you to set this flag persistently on the underlying WIM file.
648 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
650 /** Set the GUID (globally unique identifier) of the WIM file to the value
651 * specified in ::wimlib_wim_info.guid of the @a info parameter. */
652 #define WIMLIB_CHANGE_GUID 0x00000002
654 /** Change the bootable image of the WIM to the value specified in
655 * ::wimlib_wim_info.boot_index of the @a info parameter. */
656 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
658 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
659 * in ::wimlib_wim_info.has_rpfix of the @a info parameter. This flag generally
660 * indicates whether an image in the WIM has been captured with reparse-point
661 * fixups enabled. wimlib also treats this flag as specifying whether to do
662 * reparse-point fixups by default when capturing or applying WIM images. */
663 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
665 /** General information about a WIM file. */
666 struct wimlib_wim_info {
668 /** Globally unique identifier for the WIM file. Note: all parts of a
669 * split WIM should have an identical value in this field. */
670 uint8_t guid[WIMLIB_GUID_LEN];
672 /** Number of images in the WIM. */
673 uint32_t image_count;
675 /** 1-based index of the bootable image in the WIM, or 0 if no image is
679 /** Version of the WIM file. */
680 uint32_t wim_version;
682 /** Chunk size used for compression. */
685 /** 1-based index of this part within a split WIM, or 1 if the WIM is
687 uint16_t part_number;
689 /** Total number of parts in the split WIM, or 1 if the WIM is
691 uint16_t total_parts;
693 /** One of the ::wimlib_compression_type values that specifies the
694 * method used to compress resources in the WIM. */
695 int32_t compression_type;
697 /** Size of the WIM file in bytes, excluding the XML data and integrity
699 uint64_t total_bytes;
701 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
702 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
703 * this will always be 0, even if the ::WIMStruct was written to
704 * somewhere by calling wimlib_write() with the
705 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
706 uint32_t has_integrity_table : 1;
708 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
709 * wimlib_create_new_wim(). */
710 uint32_t opened_from_file : 1;
712 /** 1 if the WIM is considered readonly for any reason. */
713 uint32_t is_readonly : 1;
715 /** 1 if reparse-point fixups are supposedly enabled for one or more
716 * images in the WIM. */
717 uint32_t has_rpfix : 1;
719 /** 1 if the WIM is marked as read-only. */
720 uint32_t is_marked_readonly : 1;
722 /** 1 if the WIM is part of a spanned set. */
723 uint32_t spanned : 1;
725 uint32_t write_in_progress : 1;
726 uint32_t metadata_only : 1;
727 uint32_t resource_only : 1;
729 /** 1 if the WIM is pipable (see ::WIMLIB_WRITE_FLAG_PIPABLE). */
730 uint32_t pipable : 1;
731 uint32_t reserved_flags : 22;
732 uint32_t reserved[9];
735 /** Information about a unique resource in the WIM file.
737 struct wimlib_resource_entry {
738 /** Uncompressed size of the resource in bytes. */
739 uint64_t uncompressed_size;
741 /** Compressed size of the resource in bytes. This will be the same as
742 * @a uncompressed_size if the resource is uncompressed. */
743 uint64_t compressed_size;
745 /** Offset, in bytes, of this resource from the start of the WIM file.
749 /** SHA1 message digest of the resource's uncompressed contents. */
750 uint8_t sha1_hash[20];
752 /** Which part number of the split WIM this resource is in. This should
753 * be the same as the part number provided by wimlib_get_wim_info(). */
754 uint32_t part_number;
756 /** Number of times this resource is referenced over all WIM images. */
757 uint32_t reference_count;
759 /** 1 if this resource is compressed. */
760 uint32_t is_compressed : 1;
762 /** 1 if this resource is a metadata resource rather than a file
764 uint32_t is_metadata : 1;
766 uint32_t is_free : 1;
767 uint32_t is_spanned : 1;
768 uint32_t reserved_flags : 28;
769 uint64_t reserved[4];
772 /** A stream of a file in the WIM. */
773 struct wimlib_stream_entry {
774 /** Name of the stream, or NULL if the stream is unnamed. */
775 const wimlib_tchar *stream_name;
776 /** Location, size, etc. of the stream within the WIM file. */
777 struct wimlib_resource_entry resource;
778 uint64_t reserved[4];
781 /** Structure passed to the wimlib_iterate_dir_tree() callback function.
782 * Roughly, the information about a "file" in the WIM--- but really a directory
783 * entry ("dentry") because hard links are allowed. The hard_link_group_id
784 * field can be used to distinguish actual file inodes. */
785 struct wimlib_dir_entry {
786 /** Name of the file, or NULL if this file is unnamed (only possible for
787 * the root directory) */
788 const wimlib_tchar *filename;
790 /** 8.3 DOS name of this file, or NULL if this file has no such name.
792 const wimlib_tchar *dos_name;
794 /** Full path to this file within the WIM image. */
795 const wimlib_tchar *full_path;
797 /** Depth of this directory entry, where 0 is the root, 1 is the root's
798 * children, ..., etc. */
801 /** Pointer to the security descriptor for this file, in Windows
802 * SECURITY_DESCRIPTOR_RELATIVE format, or NULL if this file has no
803 * security descriptor. */
804 const char *security_descriptor;
806 /** Length of the above security descriptor. */
807 size_t security_descriptor_size;
809 #define WIMLIB_FILE_ATTRIBUTE_READONLY 0x00000001
810 #define WIMLIB_FILE_ATTRIBUTE_HIDDEN 0x00000002
811 #define WIMLIB_FILE_ATTRIBUTE_SYSTEM 0x00000004
812 #define WIMLIB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
813 #define WIMLIB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
814 #define WIMLIB_FILE_ATTRIBUTE_DEVICE 0x00000040
815 #define WIMLIB_FILE_ATTRIBUTE_NORMAL 0x00000080
816 #define WIMLIB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
817 #define WIMLIB_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
818 #define WIMLIB_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
819 #define WIMLIB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
820 #define WIMLIB_FILE_ATTRIBUTE_OFFLINE 0x00001000
821 #define WIMLIB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
822 #define WIMLIB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
823 #define WIMLIB_FILE_ATTRIBUTE_VIRTUAL 0x00010000
824 /** File attributes, such as whether the file is a directory or not.
825 * These are the "standard" Windows FILE_ATTRIBUTE_* values, although in
826 * wimlib.h they are defined as WIMLIB_FILE_ATTRIBUTE_* for convenience
827 * on other platforms. */
830 #define WIMLIB_REPARSE_TAG_RESERVED_ZERO 0x00000000
831 #define WIMLIB_REPARSE_TAG_RESERVED_ONE 0x00000001
832 #define WIMLIB_REPARSE_TAG_MOUNT_POINT 0xA0000003
833 #define WIMLIB_REPARSE_TAG_HSM 0xC0000004
834 #define WIMLIB_REPARSE_TAG_HSM2 0x80000006
835 #define WIMLIB_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
836 #define WIMLIB_REPARSE_TAG_SIS 0x80000007
837 #define WIMLIB_REPARSE_TAG_DFS 0x8000000A
838 #define WIMLIB_REPARSE_TAG_DFSR 0x80000012
839 #define WIMLIB_REPARSE_TAG_FILTER_MANAGER 0x8000000B
840 #define WIMLIB_REPARSE_TAG_SYMLINK 0xA000000C
841 /** If the file is a reparse point (FILE_ATTRIBUTE_DIRECTORY set in the
842 * attributes), this will give the reparse tag. This tells you whether
843 * the reparse point is a symbolic link, junction point, or some other,
844 * more unusual kind of reparse point. */
845 uint32_t reparse_tag;
847 /* Number of (hard) links to this file. */
850 /** Number of named data streams that this file has. Normally 0. */
851 uint32_t num_named_streams;
853 /** Roughly, the inode number of this file. However, it may be 0 if
854 * @a num_links == 1. */
855 uint64_t hard_link_group_id;
857 /** Time this file was created. */
858 struct timespec creation_time;
860 /** Time this file was last written to. */
861 struct timespec last_write_time;
863 /** Time this file was last accessed. */
864 struct timespec last_access_time;
865 uint64_t reserved[16];
867 /** Array of streams that make up this file. The first entry will
868 * always exist and will correspond to the unnamed data stream (default
869 * file contents), so it will have @a stream_name == @c NULL. There
870 * will then be @a num_named_streams additional entries that specify the
871 * named data streams, if any, each of which will have @a stream_name !=
873 struct wimlib_stream_entry streams[];
877 * Type of a callback function to wimlib_iterate_dir_tree(). Must return 0 on
880 typedef int (*wimlib_iterate_dir_tree_callback_t)(const struct wimlib_dir_entry *dentry,
884 * Type of a callback function to wimlib_iterate_lookup_table(). Must return 0
887 typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resource_entry *resource,
890 /** For wimlib_iterate_dir_tree(): Iterate recursively on children rather than
891 * just on the specified path. */
892 #define WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE 0x00000001
894 /** For wimlib_iterate_dir_tree(): Don't iterate on the file or directory
895 * itself; only its children (in the case of a non-empty directory) */
896 #define WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN 0x00000002
900 /*****************************
902 *****************************/
904 /** Directly capture a NTFS volume rather than a generic directory. This flag
905 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
906 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
907 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
909 /** Follow symlinks; archive and dump the files they point to. Cannot be used
910 * with ::WIMLIB_ADD_FLAG_NTFS. */
911 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
913 /** Call the progress function with the message
914 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
916 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
918 /** Mark the image being added as the bootable image of the WIM. */
919 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
921 /** Store the UNIX owner, group, and mode. This is done by adding a special
922 * alternate data stream to each regular file, symbolic link, and directory to
923 * contain this information. Please note that this flag is for convenience
924 * only; Microsoft's @a imagex.exe will not understand this special information.
925 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
926 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
928 /** Do not capture security descriptors. Only has an effect in NTFS capture
929 * mode, or in Win32 native builds. */
930 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
932 /** Fail immediately if the full security descriptor of any file or directory
933 * cannot be accessed. Only has an effect in Win32 native builds. The default
934 * behavior without this flag is to first try omitting the SACL from the
935 * security descriptor, then to try omitting the security descriptor entirely.
937 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
939 /** Call the progress function with the message
940 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
941 * capture. This is a subset of the messages provided by
942 * ::WIMLIB_ADD_FLAG_VERBOSE. */
943 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
945 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
946 * in the case of Windows) that point inside the directory being captured to
947 * instead be absolute relative to the directory being captured, rather than the
948 * current root; also exclude absolute symbolic links that point outside the
949 * directory tree being captured.
951 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
952 * the WIM header or if this is the first image being added.
953 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
954 * reparse point fixups enabled and currently cannot be unset. */
955 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
957 /** Don't do reparse point fixups. The default behavior is described in the
958 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
959 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
961 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
962 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
963 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
964 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
965 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
966 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
967 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
968 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
969 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
970 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
972 /******************************
973 * WIMLIB_DELETE_FLAG_*
974 ******************************/
976 /** Do not issue an error if the path to delete does not exist. */
977 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
979 /** Delete the file or directory tree recursively; if not specified, an error is
980 * issued if the path to delete is a directory. */
981 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
983 /******************************
984 * WIMLIB_EXPORT_FLAG_*
985 ******************************/
987 /** See documentation for wimlib_export_image(). */
988 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
990 /******************************
991 * WIMLIB_EXTRACT_FLAG_*
992 ******************************/
994 /** Extract the image directly to a NTFS volume rather than a generic directory.
996 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
998 /** When identical files are extracted from the WIM, always hard link them
999 * together. Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
1000 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
1002 /** When identical files are extracted from the WIM, always symlink them
1003 * together. Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
1004 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
1006 /** This flag no longer does anything but is reserved for future use. */
1007 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
1009 /** Read the WIM file sequentially while extracting the image. */
1010 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
1012 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA.
1013 * Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
1014 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
1016 /** Do not extract security descriptors. Only has an effect in NTFS apply mode,
1017 * or in Win32 native builds. */
1018 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
1020 /** Fail immediately if the full security descriptor of any file or directory
1021 * cannot be set exactly as specified in the WIM file. The default behavior
1022 * without this flag is to fall back to setting the security descriptor with the
1023 * SACL omitted, then only the default inherited security descriptor, if we do
1024 * not have permission to set the desired one. */
1025 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
1027 /* Extract equivalent to ::WIMLIB_ADD_FLAG_RPFIX; force reparse-point
1028 * fixups on, so absolute symbolic links or junction points will be fixed to be
1029 * absolute relative to the actual extraction root. Done by default if
1030 * WIM_HDR_FLAG_RP_FIX is set in the WIM header. This flag may only be
1031 * specified when extracting a full image. */
1032 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
1034 /** Force reparse-point fixups on extraction off, regardless of the state of the
1035 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. */
1036 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
1038 /** Extract files to standard output rather than to the filesystem. */
1039 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
1041 /** Instead of ignoring files and directories with names that cannot be
1042 * represented on the current platform (note: Windows has more restrictions on
1043 * filenames than UNIX), try to replace characters or append junk to the names
1044 * so that they can be extracted in some form. */
1045 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
1047 /** On Windows, when there exist two or more files with the same case
1048 * insensitive name but different case sensitive names, try to extract them all
1049 * by appending junk to the end of them, rather than arbitrarily extracting only
1051 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
1053 /** Do not ignore failure to set timestamps on extracted files. */
1054 #define WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS 0x00002000
1056 /** Do not ignore failure to set short names on extracted files. */
1057 #define WIMLIB_EXTRACT_FLAG_STRICT_SHORT_NAMES 0x00004000
1059 /** Do not ignore failure to extract symbolic links (and junction points, on
1060 * Windows) due to permissions problems. By default, such failures are ignored
1061 * since the default configuration of Windows only allows the Administrator to
1062 * create symbolic links. */
1063 #define WIMLIB_EXTRACT_FLAG_STRICT_SYMLINKS 0x00008000
1066 #define WIMLIB_EXTRACT_FLAG_RESUME 0x00010000
1069 /******************************
1070 * WIMLIB_MOUNT_FLAG_*
1071 ******************************/
1073 /** Mount the WIM image read-write rather than the default of read-only. */
1074 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
1076 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
1077 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
1079 /** Do not allow accessing alternate data streams in the mounted WIM image. */
1080 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
1082 /** Access alternate data streams in the mounted WIM image through extended file
1083 * attributes. This is the default mode. */
1084 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
1086 /** Access alternate data streams in the mounted WIM image by specifying the
1087 * file name, a colon, then the alternate file stream name. */
1088 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
1090 /** Use UNIX file owners, groups, and modes if available in the WIM (see
1091 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
1092 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
1094 /** Allow other users to see the mounted filesystem. (this passes the @c
1095 * allow_other option to FUSE mount) */
1096 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
1098 /******************************
1099 * WIMLIB_OPEN_FLAG_*
1100 ******************************/
1102 /** Verify the WIM contents against the WIM's integrity table, if present. This
1103 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
1104 * checksummed and checked against the SHA1 message digests specified in the
1105 * integrity table. WIMLIB_ERR_INTEGRITY is returned if there are any
1107 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
1109 /** Do not issue an error if the WIM is part of a split WIM. */
1110 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x00000002
1112 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
1113 * is not. A WIM is considered writable only if it is writable at the
1114 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
1115 * header, and is not part of a spanned set. It is not required to provide this
1116 * flag to make changes to the WIM, but with this flag you get the error sooner
1117 * rather than later. */
1118 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
1120 /******************************
1121 * WIMLIB_UNMOUNT_FLAG_*
1122 ******************************/
1124 /** Include an integrity table in the WIM after it's been unmounted. Ignored
1125 * for read-only mounts. */
1126 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
1128 /** Unless this flag is given, changes to a read-write mounted WIM are
1129 * discarded. Ignored for read-only mounts. */
1130 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
1132 /** See ::WIMLIB_WRITE_FLAG_REBUILD */
1133 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
1135 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
1136 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
1138 /** Do a "lazy" unmount (detach filesystem immediately, even if busy) */
1139 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
1141 /******************************
1142 * WIMLIB_UPDATE_FLAG_*
1143 ******************************/
1145 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
1146 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
1147 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
1149 /******************************
1150 * WIMLIB_WRITE_FLAG_*
1151 ******************************/
1153 /** Include an integrity table in the WIM.
1155 * For WIMs created with wimlib_open_wim(), the default behavior is to include
1156 * an integrity table if and only if one was present before. For WIMs created
1157 * with wimlib_create_new_wim(), the default behavior is to not include an
1158 * integrity table. */
1159 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
1161 /** Do not include an integrity table in the new WIM file. This is the default
1162 * behavior, unless the WIM already included an integrity table. */
1163 #define WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY 0x00000002
1165 /** Write the WIM as "pipable". After writing a WIM with this flag specified,
1166 * images from it can be applied directly from a pipe using
1167 * wimlib_extract_image_from_pipe(). See the documentation for the --pipable
1168 * flag of `wimlib-imagex capture' for more information. Beware: WIMs written
1169 * with this flag will not be compatible with Microsoft's software.
1171 * For WIMs created with wimlib_open_wim(), the default behavior is to write the
1172 * WIM as pipable if and only if it was pipable before. For WIMs created with
1173 * wimlib_create_new_wim(), the default behavior is to write the WIM as
1175 #define WIMLIB_WRITE_FLAG_PIPABLE 0x00000004
1177 /** Do not write the WIM as "pipable". This is the default behavior, unless the
1178 * WIM was pipable already. */
1179 #define WIMLIB_WRITE_FLAG_NOT_PIPABLE 0x00000008
1181 /** Recompress all resources, even if they could otherwise be copied from a
1182 * different WIM with the same compression type (in the case of
1183 * wimlib_export_image() being called previously). This flag is also valid in
1184 * the @p wim_write_flags of wimlib_join(), in which case all resources included
1185 * in the joined WIM file will be recompressed. */
1186 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000010
1188 /** Call fsync() just before the WIM file is closed. */
1189 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000020
1191 /** wimlib_overwrite() only: Re-build the entire WIM file rather than appending
1192 * data to it if possible. */
1193 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000040
1195 /** wimlib_overwrite() only: Specifying this flag overrides the default
1196 * behavior of wimlib_overwrite() after one or more calls to
1197 * wimlib_delete_image(), which is to rebuild the entire WIM. With this flag,
1198 * only minimal changes to correctly remove the image from the WIM will be
1199 * taken. In particular, all streams will be left alone, even if they are no
1200 * longer referenced. This is probably not what you want, because almost no
1201 * space will be saved by deleting an image in this way. */
1202 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000080
1204 /** wimlib_overwrite() only: Allow overwriting the WIM even if the readonly
1205 * flag is set in the WIM header. This can be used in combination with
1206 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
1207 * set the readonly flag on the on-disk WIM file. */
1208 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000100
1210 /******************************
1211 * WIMLIB_INIT_FLAG_*
1212 ******************************/
1214 /** Assume that strings are represented in UTF-8, even if this is not the
1215 * locale's character encoding. Not used on Windows. */
1216 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1218 /** Windows-only: do not attempt to acquire additional privileges (currently
1219 * SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege, and
1220 * SeTakeOwnershipPrivilege) when initializing the library. This is intended
1221 * for the case where the calling program manages these privileges itself.
1222 * Note: no error is issued if privileges cannot be acquired, although related
1223 * errors may be reported later, depending on if the operations performed
1224 * actually require additional privileges or not. */
1225 #define WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES 0x00000002
1227 /** Specification of an update to perform on a WIM image. */
1228 struct wimlib_update_command {
1230 /** The specific type of update to perform. */
1231 enum wimlib_update_op {
1232 /** Add a new file or directory tree to the WIM image in a
1233 * certain location. */
1234 WIMLIB_UPDATE_OP_ADD = 0,
1236 /** Delete a file or directory tree from the WIM image. */
1237 WIMLIB_UPDATE_OP_DELETE,
1239 /** Rename a file or directory tree in the WIM image. */
1240 WIMLIB_UPDATE_OP_RENAME,
1243 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1244 struct wimlib_add_command {
1245 /** Filesystem path to the file or directory tree to
1247 wimlib_tchar *fs_source_path;
1248 /** Path, specified from the root of the WIM image, at
1249 * which to add the file or directory tree within the
1251 wimlib_tchar *wim_target_path;
1253 /** Configuration for excluded files. @c NULL means
1254 * exclude no files. */
1255 struct wimlib_capture_config *config;
1257 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1260 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1261 struct wimlib_delete_command {
1262 /** Path, specified from the root of the WIM image, for
1263 * the file or directory tree within the WIM image to be
1265 wimlib_tchar *wim_path;
1266 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1269 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1270 struct wimlib_rename_command {
1271 /** Path, specified from the root of the WIM image, for
1272 * the source file or directory tree within the WIM
1274 wimlib_tchar *wim_source_path;
1275 /** Path, specified from the root of the WIM image, for
1276 * the destination file or directory tree within the WIM
1278 wimlib_tchar *wim_target_path;
1279 /** Reserved; set to 0. */
1285 /** Specification of a file or directory tree to extract from a WIM image. */
1286 struct wimlib_extract_command {
1287 /** Path to file or directory tree within the WIM image to extract. It
1288 * must be provided as an absolute path from the root of the WIM image.
1289 * The path separators may be either forward slashes or backslashes. */
1290 wimlib_tchar *wim_source_path;
1292 /** Filesystem path to extract the file or directory tree to. */
1293 wimlib_tchar *fs_dest_path;
1295 /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1300 * Possible values of the error code returned by many functions in wimlib.
1302 * See the documentation for each wimlib function to see specifically what error
1303 * codes can be returned by a given function, and what they mean.
1305 enum wimlib_error_code {
1306 WIMLIB_ERR_SUCCESS = 0,
1307 WIMLIB_ERR_ALREADY_LOCKED,
1308 WIMLIB_ERR_DECOMPRESSION,
1309 WIMLIB_ERR_DELETE_STAGING_DIR,
1310 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1313 WIMLIB_ERR_FUSERMOUNT,
1314 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1315 WIMLIB_ERR_IMAGE_COUNT,
1316 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1317 WIMLIB_ERR_INTEGRITY,
1318 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1319 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1320 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1321 WIMLIB_ERR_INVALID_HEADER,
1322 WIMLIB_ERR_INVALID_IMAGE,
1323 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1324 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1325 WIMLIB_ERR_INVALID_METADATA_RESOURCE,
1326 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1327 WIMLIB_ERR_INVALID_OVERLAY,
1328 WIMLIB_ERR_INVALID_PARAM,
1329 WIMLIB_ERR_INVALID_PART_NUMBER,
1330 WIMLIB_ERR_INVALID_PIPABLE_WIM,
1331 WIMLIB_ERR_INVALID_REPARSE_DATA,
1332 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1333 WIMLIB_ERR_INVALID_SECURITY_DATA,
1334 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1335 WIMLIB_ERR_INVALID_UTF16_STRING,
1336 WIMLIB_ERR_INVALID_UTF8_STRING,
1337 WIMLIB_ERR_IS_DIRECTORY,
1338 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1344 WIMLIB_ERR_NOTEMPTY,
1345 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1346 WIMLIB_ERR_NOT_A_WIM_FILE,
1347 WIMLIB_ERR_NOT_PIPABLE,
1348 WIMLIB_ERR_NO_FILENAME,
1352 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1354 WIMLIB_ERR_READLINK,
1357 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1358 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1359 WIMLIB_ERR_RESOURCE_ORDER,
1360 WIMLIB_ERR_SET_ATTRIBUTES,
1361 WIMLIB_ERR_SET_SECURITY,
1362 WIMLIB_ERR_SET_TIMESTAMPS,
1363 WIMLIB_ERR_SPECIAL_FILE,
1364 WIMLIB_ERR_SPLIT_INVALID,
1365 WIMLIB_ERR_SPLIT_UNSUPPORTED,
1368 WIMLIB_ERR_UNEXPECTED_END_OF_FILE,
1369 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1370 WIMLIB_ERR_UNKNOWN_VERSION,
1371 WIMLIB_ERR_UNSUPPORTED,
1372 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1373 WIMLIB_ERR_WIM_IS_READONLY,
1379 /** Used to indicate no WIM image or an invalid WIM image. */
1380 #define WIMLIB_NO_IMAGE 0
1382 /** Used to specify all images in the WIM. */
1383 #define WIMLIB_ALL_IMAGES (-1)
1386 * Appends an empty image to a WIM file. This empty image will initially
1387 * contain no files or directories, although if written without further
1388 * modifications, a root directory will be created automatically for it. After
1389 * calling this function, you can use wimlib_update_image() to add files to the
1390 * new WIM image. This gives you slightly more control over making the new
1391 * image compared to calling wimlib_add_image() or
1392 * wimlib_add_image_multisource() directly.
1395 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
1398 * Name to give the new image. If @c NULL or empty, the new image is given
1399 * no name. If nonempty, it must specify a name that does not already
1401 * @param new_idx_ret
1402 * If non-<code>NULL</code>, the index of the newly added image is returned
1405 * @return 0 on success; nonzero on failure. The possible error codes are:
1407 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1408 * There is already an image in @a wim named @a name.
1409 * @retval ::WIMLIB_ERR_NOMEM
1410 * Failed to allocate the memory needed to add the new image.
1411 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1412 * The WIM file is considered read-only because of any of the reasons
1413 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1417 wimlib_add_empty_image(WIMStruct *wim,
1418 const wimlib_tchar *name,
1422 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1424 * The directory tree or NTFS volume is scanned immediately to load the dentry
1425 * tree into memory, and file attributes and symbolic links are read. However,
1426 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1429 * See the manual page for the @b wimlib-imagex program for more information
1430 * about the "normal" capture mode versus the NTFS capture mode (entered by
1431 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1433 * Note that @b no changes are committed to the underlying WIM file (if
1434 * any) until wimlib_write() or wimlib_overwrite() is called.
1437 * Pointer to the ::WIMStruct for a WIM file to which the image will be
1440 * A path to a directory or unmounted NTFS volume that will be captured as
1443 * Name to give the new image. If @c NULL or empty, the new image is given
1444 * no name. If nonempty, it must specify a name that does not already
1447 * Capture configuration that specifies files, directories, or path globs
1448 * to exclude from being captured. If @c NULL, a dummy configuration where
1449 * no paths are treated specially is used.
1451 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1452 * @param progress_func
1453 * If non-NULL, a function that will be called periodically with the
1454 * progress of the current operation.
1456 * @return 0 on success; nonzero on error. On error, changes to @a wim are
1457 * discarded so that it appears to be in the same state as when this function
1460 * This function is implemented by calling wimlib_add_empty_image(), then
1461 * calling wimlib_update_image() with a single "add" command, so any error code
1462 * returned by wimlib_add_empty_image() may be returned, as well as any error
1463 * codes returned by wimlib_update_image() other than ones documented as only
1464 * being returned specifically by an update involving delete or rename commands.
1467 wimlib_add_image(WIMStruct *wim,
1468 const wimlib_tchar *source,
1469 const wimlib_tchar *name,
1470 const struct wimlib_capture_config *config,
1472 wimlib_progress_func_t progress_func);
1474 /** This function is equivalent to wimlib_add_image() except it allows for
1475 * multiple sources to be combined into a single WIM image. This is done by
1476 * specifying the @a sources and @a num_sources parameters instead of the @a
1477 * source parameter of wimlib_add_image(). The rest of the parameters are the
1478 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
1479 * capture</b> for full details on how this mode works.
1481 * In addition to the error codes that wimlib_add_image() can return,
1482 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1483 * when trying to overlay a non-directory on a directory or when otherwise
1484 * trying to overlay multiple conflicting files to the same location in the WIM
1485 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
1486 * ::WIMLIB_ADD_FLAG_NTFS was specified in @a add_flags but there
1487 * was not exactly one capture source with the target being the root directory.
1488 * (In this respect, there is no advantage to using
1489 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1492 wimlib_add_image_multisource(WIMStruct *wim,
1493 const struct wimlib_capture_source *sources,
1495 const wimlib_tchar *name,
1496 const struct wimlib_capture_config *config,
1498 wimlib_progress_func_t progress_func);
1501 * Creates a ::WIMStruct for a new WIM file.
1503 * This only creates an in-memory structure for a WIM that initially contains no
1504 * images. No on-disk file is created until wimlib_write() is called.
1507 * The type of compression to be used in the new WIM file. Must be
1508 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
1509 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1511 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
1512 * written to the memory location pointed to by this paramater. The
1513 * ::WIMStruct must be freed using using wimlib_free() when finished with
1515 * @return 0 on success; nonzero on error.
1516 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1517 * @a ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
1518 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1519 * @retval ::WIMLIB_ERR_NOMEM
1520 * Failed to allocate needed memory.
1523 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
1526 * Deletes an image, or all images, from a WIM file.
1528 * All streams referenced by the image(s) being deleted are removed from the
1529 * lookup table of the WIM if they are not referenced by any other images in the
1532 * Please note that @b no changes are committed to the underlying WIM file (if
1533 * any) until wimlib_write() or wimlib_overwrite() is called.
1536 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
1539 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
1541 * @return 0 on success; nonzero on failure. On failure, @a wim is guaranteed
1542 * to be left unmodified only if @a image specified a single image. If instead
1543 * @a image was ::WIMLIB_ALL_IMAGES and @a wim contained more than one image, it's
1544 * possible for some but not all of the images to have been deleted when a
1545 * failure status is returned.
1547 * @retval ::WIMLIB_ERR_DECOMPRESSION
1548 * Could not decompress the metadata resource for @a image.
1549 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1550 * @a image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
1551 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1552 * The metadata resource for @a image in the WIM is invalid.
1553 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1554 * The security data for @a image in the WIM is invalid.
1555 * @retval ::WIMLIB_ERR_NOMEM
1556 * Failed to allocate needed memory.
1557 * @retval ::WIMLIB_ERR_READ
1558 * Could not read the metadata resource for @a image from the WIM.
1559 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1560 * The WIM file is considered read-only because of any of the reasons
1561 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1565 wimlib_delete_image(WIMStruct *wim, int image);
1568 * Exports an image, or all the images, from a WIM file, into another WIM file.
1570 * The destination image is made to share the same dentry tree and security data
1571 * structure as the source image. This places some restrictions on additional
1572 * functions that may be called. wimlib_mount_image() may not be called on
1573 * either the source image or the destination image without an intervening call
1574 * to a function that un-shares the images, such as wimlib_free() on @a
1575 * dest_wim, or wimlib_delete_image() on either the source or destination image.
1576 * Furthermore, you may not call wimlib_free() on @a src_wim before calling
1577 * wimlib_write() or wimlib_overwrite() on @a dest_wim because @a dest_wim will
1578 * have references back to @a src_wim.
1580 * If this function fails, all changes to @a dest_wim are rolled back.
1582 * No changes shall be made to @a src_wim by this function.
1584 * Please note that no changes are committed to the underlying WIM file of @a
1585 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
1588 * Pointer to the ::WIMStruct for a stand-alone WIM or part 1 of a split
1589 * WIM that contains the image(s) being exported.
1591 * The image to export from @a src_wim. Can be the number of an image, or
1592 * ::WIMLIB_ALL_IMAGES to export all images.
1594 * Pointer to the ::WIMStruct for a WIM file that will receive the images
1597 * The name to give the exported image in the new WIM file. If left @c
1598 * NULL, the name from @a src_wim is used. This parameter must be left @c
1599 * NULL if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains more
1600 * than one image; in that case, the names are all taken from the @a
1601 * src_wim. (This is allowed even if one or more images being exported has
1603 * @param dest_description
1604 * The description to give the exported image in the new WIM file. If left
1605 * @c NULL, the description from the @a src_wim is used. This parameter must
1606 * be left @c NULL if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains
1607 * more than one image; in that case, the descriptions are all taken from
1608 * @a src_wim. (This is allowed even if one or more images being exported
1609 * has no description.)
1610 * @param export_flags
1611 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
1612 * bootable, or 0 if which image is marked as bootable in the destination
1613 * WIM is to be left unchanged. If @a src_image is ::WIMLIB_ALL_IMAGES and
1614 * there are multiple images in @a src_wim, specifying
1615 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
1616 * currently marked as bootable in @a src_wim; if that is the case, then
1617 * that image is marked as bootable in the destination WIM.
1618 * @param additional_swms
1619 * Array of pointers to the ::WIMStruct for each additional part in the
1620 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1621 * need to be in any particular order, but they must include all parts of
1622 * the split WIM other than the first part, which must be provided in the
1624 * @param num_additional_swms
1625 * Number of additional WIM parts provided in the @a additional_swms array.
1626 * This number should be one less than the total number of parts in the
1627 * split WIM. Set to 0 if the WIM is a standalone WIM.
1628 * @param progress_func
1629 * If non-NULL, a function that will be called periodically with the
1630 * progress of the current operation.
1632 * @return 0 on success; nonzero on error.
1633 * @retval ::WIMLIB_ERR_DECOMPRESSION
1634 * Could not decompress the metadata resource for @a src_image
1636 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1637 * One or more of the names being given to an exported image was already in
1638 * use in the destination WIM.
1639 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1640 * @a src_image does not exist in @a src_wim.
1641 * @retval ::WIMLIB_ERR_INVALID_PARAM
1642 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
1643 * ::WIMLIB_ALL_IMAGES, @a src_wim contains multiple images, and no images in
1644 * @a src_wim are marked as bootable; or @a dest_name and/or @a
1645 * dest_description were non-<code>NULL</code>, @a src_image was
1646 * ::WIMLIB_ALL_IMAGES, and @a src_wim contains multiple images.
1647 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1648 * The metadata resource for @a src_image in @a src_wim is invalid.
1649 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1650 * The security data for @a src_image in @a src_wim is invalid.
1651 * @retval ::WIMLIB_ERR_NOMEM
1652 * Failed to allocate needed memory.
1653 * @retval ::WIMLIB_ERR_READ
1654 * Could not read the metadata resource for @a src_image from @a src_wim.
1655 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1656 * The source WIM is a split WIM, but the parts specified do not form a
1657 * complete split WIM because they do not include all the parts of the
1658 * original WIM, there are duplicate parts, or not all the parts have the
1659 * same GUID and compression type.
1660 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1661 * @a dest_wim is considered read-only because of any of the reasons
1662 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1666 wimlib_export_image(WIMStruct *src_wim, int src_image,
1667 WIMStruct *dest_wim,
1668 const wimlib_tchar *dest_name,
1669 const wimlib_tchar *dest_description,
1671 WIMStruct **additional_swms,
1672 unsigned num_additional_swms,
1673 wimlib_progress_func_t progress_func);
1676 * Extract zero or more files or directory trees from a WIM image.
1678 * This generalizes the single-image extraction functionality of
1679 * wimlib_extract_image() to allow extracting only the specified subsets of the
1683 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1687 * The 1-based number of the image in @a wim from which the files or
1688 * directory trees are to be extracted. It cannot be ::WIMLIB_ALL_IMAGES.
1691 * An array of ::wimlib_extract_command structures that specifies the
1692 * extractions to perform.
1695 * Number of commands in the @a cmds array.
1697 * @param default_extract_flags
1698 * Default extraction flags; the behavior shall be as if these flags had
1699 * been specified in the ::wimlib_extract_command.extract_flags member in
1700 * each extraction command, in combination with any flags already present.
1702 * @param additional_swms
1703 * Array of pointers to the ::WIMStruct for each additional part in the
1704 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1705 * need to be in any particular order, but they must include all parts of
1706 * the split WIM other than the first part, which must be provided in the
1709 * @param num_additional_swms
1710 * Number of additional WIM parts provided in the @a additional_swms array.
1711 * This number should be one less than the total number of parts in the
1712 * split WIM. Set to 0 if the WIM is a standalone WIM.
1714 * @param progress_func
1715 * If non-NULL, a function that will be called periodically with the
1716 * progress of the current operation.
1718 * @return 0 on success; nonzero on error. The possible error codes include
1719 * those documented as returned by wimlib_extract_image() as well as the
1720 * following additional error codes:
1722 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
1723 * The ::wimlib_extract_command.wim_source_path member in one of the
1724 * extract commands did not exist in the WIM.
1725 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
1726 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
1727 * in which ::wimlib_extract_command.wim_source_path existed but was not a
1728 * regular file or directory.
1729 * @retval ::WIMLIB_ERR_INVALID_PARAM
1730 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
1731 * specified for some commands but not all; or
1732 * ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
1733 * for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
1734 * for a command in which ::wimlib_extract_command.wim_source_path did not
1735 * specify the root directory of the WIM image.
1738 wimlib_extract_files(WIMStruct *wim,
1740 const struct wimlib_extract_command *cmds,
1742 int default_extract_flags,
1743 WIMStruct **additional_swms,
1744 unsigned num_additional_swms,
1745 wimlib_progress_func_t progress_func);
1748 * Extracts an image, or all images, from a standalone or split WIM file to a
1749 * directory or a NTFS volume.
1751 * Please see the manual page for the @c wimlib-imagex program for more
1752 * information about the "normal" extraction mode versus the NTFS extraction
1753 * mode (entered by providing flag ::WIMLIB_EXTRACT_FLAG_NTFS).
1755 * Extraction is done with one thread.
1757 * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
1758 * returned if any resulting SHA1 message digests do not match the values
1759 * provided in the WIM file. Therefore, if this function is successful, you can
1760 * be fairly sure that any compressed data in the WIM was uncompressed
1764 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1767 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
1768 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
1769 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @a extract_flags.
1771 * Directory to extract the WIM image(s) to (created if it does not already
1772 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @a extract_flags, the
1773 * path to the unmounted NTFS volume to extract the image to.
1774 * @param extract_flags
1775 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
1777 * If ::WIMLIB_EXTRACT_FLAG_NTFS is specified, @a target is interpreted as
1778 * a NTFS volume to extract the image to. The volume will be opened using
1779 * NTFS-3g and the image will be extracted to the root of the NTFS volume.
1780 * Otherwise, @a target is interpreted as a directory to extract the
1783 * If ::WIMLIB_EXTRACT_FLAG_NTFS is not specified, one or none of
1784 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK may be
1785 * specified. These flags cause extracted files that are identical to be
1786 * hardlinked or symlinked together, depending on the flag. These flags
1787 * override the hard link groups that are specified in the WIM file itself.
1788 * If ::WIMLIB_ALL_IMAGES is provided as the @a image parameter, files may be
1789 * hardlinked or symlinked across images if a file is found to occur in
1790 * more than one image.
1792 * You may also specify the flag ::WIMLIB_EXTRACT_FLAG_VERBOSE to print the
1793 * name of each file or directory as it is extracted.
1795 * If ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is specified, data is read from the
1796 * WIM sequentially, if possible. If ::WIMLIB_ALL_IMAGES is specified,
1797 * each image is considered separately with regards to the sequential
1798 * order. It is also possible for alternate data streams to break the
1799 * sequential order (this only applies if ::WIMLIB_EXTRACT_FLAG_NTFS is
1801 * @param additional_swms
1802 * Array of pointers to the ::WIMStruct for each additional part in the
1803 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1804 * need to be in any particular order, but they must include all parts of
1805 * the split WIM other than the first part, which must be provided in the
1807 * @param num_additional_swms
1808 * Number of additional WIM parts provided in the @a additional_swms array.
1809 * This number should be one less than the total number of parts in the
1810 * split WIM. Set to 0 if the WIM is a standalone WIM.
1812 * @param progress_func
1813 * If non-NULL, a function that will be called periodically with the
1814 * progress of the current operation.
1816 * @return 0 on success; nonzero on error.
1817 * @retval ::WIMLIB_ERR_DECOMPRESSION
1818 * Could not decompress a resource (file or metadata) for @a image in @a
1820 * @retval ::WIMLIB_ERR_INVALID_PARAM
1821 * @a target was @c NULL, or both ::WIMLIB_EXTRACT_FLAG_HARDLINK and
1822 * ::WIMLIB_EXTRACT_FLAG_SYMLINK were specified in @a extract_flags; or
1823 * both ::WIMLIB_EXTRACT_FLAG_NTFS and either
1824 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK were
1825 * specified in @a extract_flags; or ::WIMLIB_EXTRACT_FLAG_NTFS was
1826 * specified in @a extract_flags and @a image was ::WIMLIB_ALL_IMAGES; or
1827 * both ::WIMLIB_EXTRACT_FLAG_NTFS and ::WIMLIB_EXTRACT_FLAG_UNIX_DATA were
1828 * specified in @a extract_flag.
1829 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
1830 * The SHA1 message digest of an extracted stream did not match the SHA1
1831 * message digest given in the WIM file.
1832 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1833 * A resource (file or metadata) for @a image in @a wim is invalid.
1834 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1835 * The security data for @a image in @a wim is invalid.
1836 * @retval ::WIMLIB_ERR_LINK
1837 * Failed to create a symbolic link or a hard link (only if
1838 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1839 * @retval ::WIMLIB_ERR_MKDIR
1840 * Failed create a needed directory (only if ::WIMLIB_EXTRACT_FLAG_NTFS was
1841 * not specified in @a extract_flags).
1842 * @retval ::WIMLIB_ERR_NOMEM
1843 * Failed to allocate needed memory.
1844 * @retval ::WIMLIB_ERR_NTFS_3G
1845 * An error was returned from a libntfs-3g function while the WIM image was
1846 * being extracted to the NTFS volume (only if ::WIMLIB_EXTRACT_FLAG_NTFS
1847 * was specified in @a extract_flags).
1848 * @retval ::WIMLIB_ERR_OPEN
1849 * Could not open one of the files being extracted for writing (only if
1850 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1851 * @retval ::WIMLIB_ERR_READ
1852 * A unexpected end-of-file or read error occurred when trying to read data
1853 * from the WIM file associated with @a wim.
1854 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
1855 * One of the dentries in the image referenced a stream not present in the
1856 * WIM's lookup table (or in any of the lookup tables of the split WIM
1858 * @retval ::WIMLIB_ERR_SET_ATTRIBUTES
1859 * Failed to set attributes on a file.
1860 * @retval ::WIMLIB_ERR_SET_SECURITY
1861 * Failed to set security descriptor on a file
1862 * (only if ::WIMLIB_EXTRACT_FLAG_STRICT_ACLS) specified in @p
1864 * @retval ::WIMLIB_ERR_SET_TIMESTAMPS
1865 * Failed to set timestamps on a file (only if
1866 * ::WIMLIB_EXTRACT_FLAG_STRICT_TIMESTAMPS) specified in @p extract_flags.
1867 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1868 * The WIM is a split WIM, but the parts specified do not form a complete
1869 * split WIM because they do not include all the parts of the original WIM,
1870 * there are duplicate parts, or not all the parts have the same GUID and
1872 * @retval ::WIMLIB_ERR_UNSUPPORTED
1873 * ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @a extract_flags, but wimlib
1874 * was configured with the @c --without-ntfs-3g flag.
1875 * @retval ::WIMLIB_ERR_WRITE
1876 * Failed to write a file being extracted (only if
1877 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1880 wimlib_extract_image(WIMStruct *wim, int image,
1881 const wimlib_tchar *target,
1883 WIMStruct **additional_swms,
1884 unsigned num_additional_swms,
1885 wimlib_progress_func_t progress_func);
1888 * Since wimlib v1.5.0: Extract one or more images from a pipe on which a
1889 * pipable WIM is being sent.
1891 * See the documentation for ::WIMLIB_WRITE_FLAG_PIPABLE for more information
1892 * about pipable WIMs.
1894 * This function operates in a special way to read the WIM fully sequentially.
1895 * As a result, there is no ::WIMStruct is made visible to library users, and
1896 * you cannot call wimlib_open_wim() on the pipe. (You can, however, use
1897 * wimlib_open_wim() to transparently open a pipable WIM if it's available as a
1898 * seekable file, not a pipe.)
1901 * File descriptor, which may be a pipe, opened for reading and positioned
1902 * at the start of the pipable WIM.
1903 * @param image_num_or_name
1904 * String that specifies the 1-based index or name of the image to extract.
1905 * It is translated to an image index using the same rules that
1906 * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(),
1907 * only a single image (not all images) can be specified. Alternatively,
1908 * specify @p NULL here to use the first image in the WIM if it contains
1909 * exactly one image but otherwise return @p WIMLIB_ERR_INVALID_IMAGE.
1911 * Same as the corresponding parameter to wimlib_extract_image().
1912 * @param extract_flags
1913 * Same as the corresponding parameter to wimlib_extract_image(), except
1914 * for the following exceptions: ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is
1915 * always implied, since data is always read from @p pipe_fd sequentially
1916 * in this mode; also, ::WIMLIB_EXTRACT_FLAG_TO_STDOUT is invalid and will
1917 * result in ::WIMLIB_ERR_INVALID_PARAM being returned.
1918 * @param progress_func
1919 * Same as the corresponding parameter to wimlib_extract_image(), except
1920 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN messages will also be
1923 * @return 0 on success; nonzero on error. The possible error codes include
1924 * those returned by wimlib_extract_image() as well as the following:
1926 * @retval ::WIMLIB_ERR_NOT_PIPABLE
1927 * The WIM being piped in a @p pipe_fd is a normal WIM, not a pipable WIM.
1930 wimlib_extract_image_from_pipe(int pipe_fd,
1931 const wimlib_tchar *image_num_or_name,
1932 const wimlib_tchar *target, int extract_flags,
1933 wimlib_progress_func_t progress_func);
1936 * Extracts the XML data of a WIM file to a file stream. Every WIM file
1937 * includes a string of XML that describes the images contained in the WIM.
1938 * This function works on standalone WIMs as well as split WIM parts.
1941 * Pointer to the ::WIMStruct for a WIM file.
1943 * @c stdout, or a FILE* opened for writing, to extract the data to.
1945 * @return 0 on success; nonzero on error.
1946 * @retval ::WIMLIB_ERR_INVALID_PARAM
1947 * @a wim is not a ::WIMStruct that was created by wimlib_open_wim().
1948 * @retval ::WIMLIB_ERR_NOMEM
1949 * Failed to allocate needed memory.
1950 * @retval ::WIMLIB_ERR_READ
1951 * Failed to read the XML data from the WIM.
1952 * @retval ::WIMLIB_ERR_WRITE
1953 * Failed to completely write the XML data to @a fp.
1956 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
1959 * Frees all memory allocated for a WIMStruct and closes all files associated
1963 * Pointer to the ::WIMStruct for a WIM file.
1965 * @return This function has no return value.
1968 wimlib_free(WIMStruct *wim);
1971 * Deprecated in favor of wimlib_get_wim_info().
1974 wimlib_get_boot_idx(const WIMStruct *wim) _wimlib_deprecated;
1977 * Deprecated in favor of wimlib_get_wim_info().
1980 wimlib_get_compression_type(const WIMStruct *wim) _wimlib_deprecated;
1983 * Converts a ::wimlib_compression_type value into a string.
1986 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
1987 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
1990 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
1993 extern const wimlib_tchar *
1994 wimlib_get_compression_type_string(int ctype);
1997 * Converts an error code into a string describing it.
2000 * The error code returned by one of wimlib's functions.
2003 * Pointer to a statically allocated string describing the error code,
2004 * or @c NULL if the error code is not valid.
2006 extern const wimlib_tchar *
2007 wimlib_get_error_string(enum wimlib_error_code code);
2010 * Returns the description of the specified image.
2013 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2014 * standalone WIM or a split WIM part.
2016 * The number of the image, numbered starting at 1.
2019 * The description of the image, or @c NULL if there is no such image, or
2020 * @c NULL if the specified image has no description. The description
2021 * string is in library-internal memory and may not be modified or freed;
2022 * in addition, the string will become invalid if the description of the
2023 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
2025 extern const wimlib_tchar *
2026 wimlib_get_image_description(const WIMStruct *wim, int image);
2029 * Returns the name of the specified image.
2032 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2033 * standalone WIM or a split WIM part.
2035 * The number of the image, numbered starting at 1.
2038 * The name of the image, or @c NULL if there is no such image. The name
2039 * string is in library-internal memory and may not be modified or freed;
2040 * in addition, the string will become invalid if the name of the image is
2041 * changed, the image is deleted, or the ::WIMStruct is destroyed.
2043 * If @a wim was read with wimlib_open_wim(), it is allowed for image(s) in
2044 * the WIM to be unnamed, in which case an empty string will be returned
2045 * when the corresponding name is requested.
2047 extern const wimlib_tchar *
2048 wimlib_get_image_name(const WIMStruct *wim, int image);
2052 * Deprecated in favor of wimlib_get_wim_info().
2055 wimlib_get_num_images(const WIMStruct *wim) _wimlib_deprecated;
2058 * Deprecated in favor of wimlib_get_wim_info().
2061 wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret) _wimlib_deprecated;
2064 * Get basic information about a WIM file.
2067 * Pointer to the ::WIMStruct for a WIM file. It may be for either a
2068 * standalone WIM or part of a split WIM.
2070 * A ::wimlib_wim_info structure that will be filled in with information
2071 * about the WIM file.
2076 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
2079 * Initialization function for wimlib. Call before using any other wimlib
2080 * function except wimlib_set_print_errors(). (However, currently this is not
2081 * strictly necessary and it will be called automatically if not done manually,
2082 * but you should not rely on this behavior.)
2085 * Bitwise OR of ::WIMLIB_INIT_FLAG_ASSUME_UTF8 and/or
2086 * ::WIMLIB_INIT_FLAG_DONT_ACQUIRE_PRIVILEGES.
2088 * @return 0; other error codes may be returned in future releases.
2091 wimlib_global_init(int init_flags);
2094 * Since wimlib 1.2.6: Cleanup function for wimlib. This is not re-entrant.
2095 * You are not required to call this function, but it will release any global
2096 * resources allocated by the library.
2099 wimlib_global_cleanup(void);
2102 * Deprecated in favor of wimlib_get_wim_info().
2105 wimlib_has_integrity_table(const WIMStruct *wim) _wimlib_deprecated;
2108 * Determines if an image name is already used by some image in the WIM.
2111 * Pointer to the ::WIMStruct for a WIM file.
2113 * The name to check.
2116 * @c true if there is already an image in @a wim named @a name; @c false
2117 * if there is no image named @a name in @a wim. If @a name is @c NULL or
2118 * the empty string, @c false is returned.
2121 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
2124 * Iterate through a file or directory tree in the WIM image. By specifying
2125 * appropriate flags and a callback function, you can get the attributes of a
2126 * file in the WIM, get a directory listing, or even get a listing of the entire
2130 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
2134 * The 1-based number of the image in @a wim that contains the files or
2135 * directories to iterate over.
2138 * Path in the WIM image at which to do the iteration.
2141 * Bitwise OR of ::WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE and/or
2142 * ::WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN.
2145 * A callback function that will receive each directory entry.
2148 * An extra parameter that will always be passed to the callback function
2151 * @return Normally, returns 0 if all calls to @a cb returned 0; otherwise the
2152 * first nonzero value that was returned from @a cb. However, additional error
2153 * codes may be returned, including the following:
2155 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2156 * @a path did not exist in the WIM image.
2157 * @retval ::WIMLIB_ERR_NOMEM
2158 * Failed to allocate memory needed to create a ::wimlib_dir_entry.
2161 wimlib_iterate_dir_tree(WIMStruct *wim, int image, const wimlib_tchar *path,
2163 wimlib_iterate_dir_tree_callback_t cb, void *user_ctx);
2166 * Iterate through the lookup table of a WIM file. This can be used to directly
2167 * get a listing of the unique resources contained in a WIM file. Both file
2168 * resources and metadata resources are included.
2171 * Pointer to the ::WIMStruct of a standalone WIM file or a split WIM part.
2172 * Note: metadata resources will only be included if the WIM is standalone
2173 * or the first part of the split WIM.
2176 * Reserved; set to 0.
2179 * A callback function that will receive each resource.
2182 * An extra parameter that will always be passed to the callback function
2185 * @return 0 if all calls to @a cb returned 0; otherwise the first nonzero value
2186 * that was returned from @a cb.
2189 wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
2190 wimlib_iterate_lookup_table_callback_t cb,
2194 * Joins a split WIM into a stand-alone one-part WIM.
2197 * An array of strings that gives the filenames of all parts of the split
2198 * WIM. No specific order is required, but all parts must be included with
2201 * Number of filenames in @a swms.
2202 * @param swm_open_flags
2203 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY if the integrity of each split WIM
2204 * part should be verified, if integrity tables are present. Otherwise,
2206 * @param wim_write_flags
2207 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY, and/or ::WIMLIB_WRITE_FLAG_FSYNC.
2208 * @param output_path
2209 * The path to write the one-part WIM to.
2210 * @param progress_func
2211 * If non-NULL, a function that will be called periodically with the
2212 * progress of the current operation.
2214 * @return 0 on success; nonzero on error. This function may return any value
2215 * returned by wimlib_open_wim() and wimlib_write() except
2216 * ::WIMLIB_ERR_WIM_IS_READONLY, as well as the following error code:
2218 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2219 * The split WIMs do not form a valid WIM because they do not include all
2220 * the parts of the original WIM, there are duplicate parts, or not all the
2221 * parts have the same GUID and compression type.
2223 * Note: the WIM's uncompressed and compressed resources are not checksummed
2224 * when they are copied from the split WIM parts to the joined WIM, nor are
2225 * compressed resources re-compressed.
2227 * Note: wimlib_export_image() can provide similar functionality to
2228 * wimlib_join(), since it is possible to export all images from a split WIM.
2231 wimlib_join(const wimlib_tchar * const *swms,
2233 const wimlib_tchar *output_path,
2235 int wim_write_flags,
2236 wimlib_progress_func_t progress_func);
2239 * Compress a chunk of a WIM resource using LZX compression.
2241 * This function is exported for convenience only and need not be used.
2244 * Uncompressed data of the chunk.
2246 * Size of the uncompressed chunk, in bytes.
2248 * Pointer to output buffer of size at least (@a chunk_size - 1) bytes.
2251 * The size of the compressed data written to @a out in bytes, or 0 if the
2252 * data could not be compressed to (@a chunk_size - 1) bytes or fewer.
2254 * As a special requirement, the compression code is optimized for the WIM
2255 * format and therefore requires (@a chunk_size <= 32768).
2258 wimlib_lzx_compress(const void *chunk, unsigned chunk_size, void *out);
2261 * Decompresses a block of LZX-compressed data as used in the WIM file format.
2263 * Note that this will NOT work unmodified for LZX as used in the cabinet
2264 * format, which is not the same as in the WIM format!
2266 * This function is exported for convenience only and need not be used.
2268 * @param compressed_data
2269 * Pointer to the compressed data.
2271 * @param compressed_len
2272 * Length of the compressed data, in bytes.
2274 * @param uncompressed_data
2275 * Pointer to the buffer into which to write the uncompressed data.
2277 * @param uncompressed_len
2278 * Length of the uncompressed data. It must be 32768 bytes or less.
2281 * 0 on success; non-zero on failure.
2284 wimlib_lzx_decompress(const void *compressed_data, unsigned compressed_len,
2285 void *uncompressed_data, unsigned uncompressed_len);
2289 * Mounts an image in a WIM file on a directory read-only or read-write.
2291 * This is not supported on Windows.
2293 * Unless ::WIMLIB_MOUNT_FLAG_DEBUG is specified or an early error occurs, the
2294 * process will be daemonized.
2296 * If the mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified),
2297 * modifications to the WIM are staged in a temporary directory.
2299 * It is safe to mount multiple images from the same WIM file read-only at the
2300 * same time, but only if different ::WIMStruct's are used. It is @b not safe
2301 * to mount multiple images from the same WIM file read-write at the same time.
2303 * wimlib_mount_image() cannot be used on an image that was exported with
2304 * wimlib_export_image() while the dentry trees for both images are still in
2305 * memory. In addition, wimlib_mount_image() may not be used to mount an image
2306 * that has just been added with wimlib_add_image(), unless the WIM has been
2307 * written and read into a new ::WIMStruct.
2310 * Pointer to the ::WIMStruct containing the image to be mounted.
2312 * The number of the image to mount, indexed starting from it. It must be
2313 * an existing, single image.
2315 * The path to an existing empty directory to mount the image on.
2316 * @param mount_flags
2317 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
2319 * If ::WIMLIB_MOUNT_FLAG_READWRITE is given, the WIM is mounted read-write
2320 * rather than the default of read-only.
2322 * WIMs may contain named (alternate) data streams, which are a somewhat
2323 * obscure NTFS feature. They can be read and written on a mounted WIM
2324 * through one of several interfaces. The interface to use if specified by
2325 * exactly one of ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE,
2326 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR, or
2327 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS. The default interface is
2328 * the XATTR interface.
2329 * @param additional_swms
2330 * Array of pointers to the ::WIMStruct for each additional part in the
2331 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
2332 * need to be in any particular order, but they must include all parts of
2333 * the split WIM other than the first part, which must be provided in the
2335 * @param num_additional_swms
2336 * Number of additional WIM parts provided in the @a additional_swms array.
2337 * This number should be one less than the total number of parts in the
2338 * split WIM. Set to 0 if the WIM is a standalone WIM.
2339 * @param staging_dir
2340 * If non-NULL, the name of a directory in which the staging directory will
2341 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
2342 * in @a mount_flags. If left @c NULL, the staging directory is created in
2343 * the same directory as the WIM file that @a wim was originally read from.
2345 * @return 0 on success; nonzero on error.
2347 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2348 * A read-write mount was requested, but an an exclusive advisory lock on
2349 * the on-disk WIM file could not be acquired because another thread or
2350 * process has mounted an image from the WIM read-write or is currently
2351 * modifying the WIM in-place.
2352 * @retval ::WIMLIB_ERR_DECOMPRESSION
2353 * Could not decompress the metadata resource for @a image in @a wim.
2354 * @retval ::WIMLIB_ERR_FUSE
2355 * A non-zero status was returned by @c fuse_main().
2356 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2357 * @a image does not specify an existing, single image in @a wim.
2358 * @retval ::WIMLIB_ERR_INVALID_PARAM
2359 * @a image is shared among multiple ::WIMStruct's as a result of a call to
2360 * wimlib_export_image(), or @a image has been added with
2361 * wimlib_add_image().
2362 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2363 * The metadata resource for @a image in @a wim is invalid.
2364 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2365 * The security data for @a image in @a wim is invalid.
2366 * @retval ::WIMLIB_ERR_MKDIR
2367 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a mount_flags, but the
2368 * staging directory could not be created.
2369 * @retval ::WIMLIB_ERR_NOMEM
2370 * Failed to allocate needed memory.
2371 * @retval ::WIMLIB_ERR_NOTDIR
2372 * Could not determine the current working directory.
2373 * @retval ::WIMLIB_ERR_READ
2374 * An unexpected end-of-file or read error occurred when trying to read
2375 * data from the WIM file associated with @a wim.
2376 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2377 * One of the dentries in the image referenced a stream not present in the
2378 * WIM's lookup table (or in any of the lookup tables of the split WIM
2380 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2381 * The WIM is a split WIM, but the parts specified do not form a complete
2382 * split WIM because they do not include all the parts of the original WIM,
2383 * there are duplicate parts, or not all the parts have the same GUID and
2385 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2386 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a mount_flags, but @a
2387 * wim is considered read-only because of any of the reasons mentioned in
2388 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2389 * @retval ::WIMLIB_ERR_UNSUPPORTED
2390 * Mounting is not supported, either because the platform is Windows, or
2391 * because the platform is UNIX and wimlib was compiled with @c
2395 wimlib_mount_image(WIMStruct *wim,
2397 const wimlib_tchar *dir,
2399 WIMStruct **additional_swms,
2400 unsigned num_additional_swms,
2401 const wimlib_tchar *staging_dir);
2404 * Opens a WIM file and creates a ::WIMStruct for it.
2407 * The path to the WIM file to open.
2409 * Bitwise OR of flags ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
2410 * ::WIMLIB_OPEN_FLAG_SPLIT_OK and/or ::WIMLIB_OPEN_FLAG_WRITE_ACCESS.
2412 * @param progress_func
2413 * If non-NULL, a function that will be called periodically with the
2414 * progress of the current operation.
2417 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2418 * is written to the memory location pointed to by this parameter. The
2419 * ::WIMStruct must be freed using using wimlib_free() when finished with
2422 * @return 0 on success; nonzero on error.
2423 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
2424 * The lookup table of @a wim_file is compressed. Support for this can be
2425 * added to wimlib if needed, but it appears to be the case that the lookup
2426 * table is never compressed.
2427 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2428 * The WIM is not the non-first part of a split WIM, and the number of
2429 * metadata resources found in the WIM did not match the image count given
2430 * in the WIM header, or the number of <IMAGE> elements in the XML
2431 * data for the WIM did not match the image count given in the WIM header.
2432 * @retval ::WIMLIB_ERR_INTEGRITY
2433 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
2434 * wim_file contains an integrity table, but the SHA1 message digest for a
2435 * chunk of the WIM does not match the corresponding message digest given
2436 * in the integrity table.
2437 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2438 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
2439 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2440 * The header of @a wim_file says that resources in the WIM are compressed,
2441 * but the header flag indicating LZX or XPRESS compression is not set.
2442 * @retval ::WIMLIB_ERR_INVALID_HEADER
2443 * The length field of the WIM header is not 208.
2444 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2445 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
2446 * wim_file contains an integrity table, but the integrity table is
2448 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2449 * The lookup table for the WIM contained duplicate entries that are not
2450 * for metadata resources, or it contained an entry with a SHA1 message
2451 * digest of all 0's.
2452 * @retval ::WIMLIB_ERR_INVALID_PARAM
2453 * @p wim_ret was @c NULL.
2454 * @retval ::WIMLIB_ERR_NOMEM
2455 * Failed to allocated needed memory.
2456 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2457 * @a wim_file does not begin with the expected magic characters.
2458 * @retval ::WIMLIB_ERR_OPEN
2459 * Failed to open the file @a wim_file for reading.
2460 * @retval ::WIMLIB_ERR_READ
2461 * An unexpected end-of-file or read error occurred when trying to read
2462 * data from @a wim_file.
2463 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2464 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
2465 * specified in @a open_flags.
2466 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2467 * A number other than 0x10d00 is written in the version field of the WIM
2468 * header of @a wim_file. (Probably a pre-Vista WIM).
2469 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2470 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2471 * considered read-only because of any of the reasons mentioned in the
2472 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2473 * @retval ::WIMLIB_ERR_XML
2474 * The XML data for @a wim_file is invalid.
2477 wimlib_open_wim(const wimlib_tchar *wim_file,
2479 WIMStruct **wim_ret,
2480 wimlib_progress_func_t progress_func);
2483 * Overwrites the file that the WIM was originally read from, with changes made.
2484 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2485 * rather than wimlib_create_new_wim().
2487 * There are two ways that a WIM may be overwritten. The first is to do a full
2488 * rebuild. In this mode, the new WIM is written to a temporary file and then
2489 * renamed to the original file after it is has been completely written. The
2490 * temporary file is made in the same directory as the original WIM file. A
2491 * full rebuild may take a while, but can be used even if images have been
2492 * modified or deleted, will produce a WIM with no holes, and has little chance
2493 * of unintentional data loss because the temporary WIM is fsync()ed before
2494 * being renamed to the original WIM.
2496 * The second way to overwrite a WIM is by appending to the end of it and
2497 * overwriting the header. This can be much faster than a full rebuild, but the
2498 * disadvantage is that some space will be wasted. Writing a WIM in this mode
2499 * begins with writing any new file resources *after* everything in the old WIM,
2500 * even though this will leave a hole where the old lookup table, XML data, and
2501 * integrity were. This is done so that the WIM remains valid even if the
2502 * operation is aborted mid-write. The WIM header is only overwritten at the
2503 * very last moment, and up until that point the WIM will be seen as the old
2506 * By default, wimlib_overwrite() does the append-style overwrite described
2507 * above, unless resources in the WIM are arranged in an unusual way or if
2508 * images have been deleted from the WIM. Use the flag
2509 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
2510 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
2511 * images have been deleted from the WIM.
2513 * In the temporary-file overwrite mode, no changes are made to the WIM on
2514 * failure, and the temporary file is deleted if possible. Abnormal termination
2515 * of the program will result in the temporary file being orphaned. In the
2516 * direct append mode, the WIM is truncated to the original length on failure;
2517 * and while abnormal termination of the program will result in extra data
2518 * appended to the original WIM, it should still be a valid WIM.
2520 * If this function completes successfully, no more functions should be called
2521 * on @a wim other than wimlib_free(). You must use wimlib_open_wim() to read
2522 * the WIM file anew.
2525 * Pointer to the ::WIMStruct for the WIM file to write. There may have
2526 * been in-memory changes made to it, which are then reflected in the
2528 * @param write_flags
2529 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY,
2530 * ::WIMLIB_WRITE_FLAG_REBUILD, ::WIMLIB_WRITE_FLAG_RECOMPRESS, and/or
2531 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE.
2532 * @param num_threads
2533 * Number of threads to use for compression (see wimlib_write()).
2534 * @param progress_func
2535 * If non-NULL, a function that will be called periodically with the
2536 * progress of the current operation.
2538 * @return 0 on success; nonzero on error. This function may return any value
2539 * returned by wimlib_write() as well as the following error codes:
2540 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2541 * The WIM was going to be modified in-place (with no temporary file), but
2542 * an exclusive advisory lock on the on-disk WIM file could not be acquired
2543 * because another thread or process has mounted an image from the WIM
2544 * read-write or is currently modifying the WIM in-place.
2545 * @retval ::WIMLIB_ERR_NO_FILENAME
2546 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
2547 * than a WIM read with wimlib_open_wim().
2548 * @retval ::WIMLIB_ERR_RENAME
2549 * The temporary file that the WIM was written to could not be renamed to
2550 * the original filename of @a wim.
2551 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2552 * The WIM file is considered read-only because of any of the reasons
2553 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2557 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
2558 wimlib_progress_func_t progress_func);
2561 * Prints information about one image, or all images, contained in a WIM.
2564 * Pointer to the ::WIMStruct for a WIM file.
2566 * The image about which to print information. Can be the number of an
2567 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
2570 * @return This function has no return value. No error checking is done when
2571 * printing the information. If @a image is invalid, an error message is
2575 wimlib_print_available_images(const WIMStruct *wim, int image);
2578 * Deprecated in favor of wimlib_iterate_dir_tree(), which provides the
2579 * information in a way that can be accessed programatically.
2582 wimlib_print_files(WIMStruct *wim, int image) _wimlib_deprecated;
2585 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
2586 * in a way that can be accessed programatically.
2589 wimlib_print_header(const WIMStruct *wim) _wimlib_deprecated;
2592 * Deprecated in favor of wimlib_iterate_lookup_table(), which provides the
2593 * information in a way that can be accessed programatically.
2596 wimlib_print_lookup_table(WIMStruct *wim) _wimlib_deprecated;
2599 * Deprecated in favor of wimlib_iterate_dir_tree(), which provides the
2600 * information in a way that can be accessed programatically.
2603 wimlib_print_metadata(WIMStruct *wim, int image) _wimlib_deprecated;
2606 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
2607 * in a way that can be accessed programatically.
2610 wimlib_print_wim_information(const WIMStruct *wim) _wimlib_deprecated;
2613 * Translates a string specifying the name or number of an image in the WIM into
2614 * the number of the image. The images are numbered starting at 1.
2617 * Pointer to the ::WIMStruct for a WIM file.
2618 * @param image_name_or_num
2619 * A string specifying the name or number of an image in the WIM. If it
2620 * parses to a positive integer, this integer is taken to specify the
2621 * number of the image, indexed starting at 1. Otherwise, it is taken to
2622 * be the name of an image, as given in the XML data for the WIM file. It
2623 * also may be the keyword "all" or the string "*", both of which will
2624 * resolve to ::WIMLIB_ALL_IMAGES.
2626 * There is no way to search for an image actually named "all", "*", or an
2627 * integer number, or an image that has no name. However, you can use
2628 * wimlib_get_image_name() to get the name of any image.
2631 * If the string resolved to a single existing image, the number of that
2632 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
2633 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
2634 * ::WIMLIB_NO_IMAGE is returned. If @a image_name_or_num was @c NULL or
2635 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
2636 * images in @a wim has no name.
2639 wimlib_resolve_image(WIMStruct *wim,
2640 const wimlib_tchar *image_name_or_num);
2643 * Deprecated in favor of wimlib_set_wim_info().
2646 wimlib_set_boot_idx(WIMStruct *wim, int boot_idx) _wimlib_deprecated;
2649 * Changes the description of an image in the WIM.
2652 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2653 * standalone WIM or part of a split WIM; however, you should set the same
2654 * description on all parts of a split WIM.
2656 * The number of the image for which to change the description.
2657 * @param description
2658 * The new description to give the image. It may be @c NULL, which
2659 * indicates that the image is to be given no description.
2661 * @return 0 on success; nonzero on error.
2662 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2663 * @a image does not specify a single existing image in @a wim.
2664 * @retval ::WIMLIB_ERR_NOMEM
2665 * Failed to allocate the memory needed to duplicate the @a description
2667 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2668 * @a wim is considered read-only because of any of the reasons mentioned
2669 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2672 wimlib_set_image_descripton(WIMStruct *wim, int image,
2673 const wimlib_tchar *description);
2676 * Set basic information about a WIM.
2679 * A WIMStruct for a standalone WIM file.
2681 * A struct ::wimlib_wim_info that contains the information to set. Only
2682 * the information explicitly specified in the @a which flags need be
2685 * Flags that specify which information to set. This is a bitwise OR of
2686 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
2687 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
2689 * @return 0 on success; nonzero on failure.
2690 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2691 * The WIM file is considered read-only because of any of the reasons
2692 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2693 * flag. However, as a special case, if you are using
2694 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
2695 * function will not fail due to the readonly flag being previously set.
2696 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2697 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
2698 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
2702 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
2706 * Changes what is written in the \<FLAGS\> element in the WIM XML data
2707 * (something like "Core" or "Ultimate")
2710 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2711 * standalone WIM or part of a split WIM; however, you should set the same
2712 * \<FLAGS\> element on all parts of a split WIM.
2714 * The number of the image for which to change the description.
2716 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
2717 * indicates that the image is to be given no \<FLAGS\> element.
2719 * @return 0 on success; nonzero on error.
2720 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2721 * @a image does not specify a single existing image in @a wim.
2722 * @retval ::WIMLIB_ERR_NOMEM
2723 * Failed to allocate the memory needed to duplicate the @a flags string.
2724 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2725 * @a wim is considered read-only because of any of the reasons mentioned
2726 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2729 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
2732 * Changes the name of an image in the WIM.
2735 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2736 * standalone WIM or part of a split WIM; however, you should set the same
2737 * name on all parts of a split WIM.
2739 * The number of the image for which to change the name.
2741 * New name to give the new image. If @c NULL or empty, the new image is
2742 * given no name. If nonempty, it must specify a name that does not
2743 * already exist in @a wim.
2745 * @return 0 on success; nonzero on error.
2746 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2747 * There is already an image named @a name in @a wim.
2748 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2749 * @a image does not specify a single existing image in @a wim.
2750 * @retval ::WIMLIB_ERR_NOMEM
2751 * Failed to allocate the memory needed to duplicate the @a name string.
2752 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2753 * @a wim is considered read-only because of any of the reasons mentioned
2754 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2756 extern int wimlib_set_image_name(WIMStruct *wim, int image,
2757 const wimlib_tchar *name);
2760 * Set the functions that wimlib uses to allocate and free memory.
2762 * These settings are global and not per-WIM.
2764 * The default is to use the default @c malloc() and @c free() from the C
2767 * Please note that some external functions, such as those in @c libntfs-3g, may
2768 * use the standard memory allocation functions.
2770 * @param malloc_func
2771 * A function equivalent to @c malloc() that wimlib will use to allocate
2772 * memory. If @c NULL, the allocator function is set back to the default
2773 * @c malloc() from the C library.
2775 * A function equivalent to @c free() that wimlib will use to free memory.
2776 * If @c NULL, the free function is set back to the default @c free() from
2778 * @param realloc_func
2779 * A function equivalent to @c realloc() that wimlib will use to reallocate
2780 * memory. If @c NULL, the free function is set back to the default @c
2781 * realloc() from the C library.
2782 * @return 0 on success; nonzero on error.
2783 * @retval ::WIMLIB_ERR_UNSUPPORTED
2784 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
2785 * so custom memory allocators are unsupported.
2788 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
2789 void (*free_func)(void *),
2790 void *(*realloc_func)(void *, size_t));
2793 * Sets whether wimlib is to print error messages to @c stderr when a function
2794 * fails. These error messages may provide information that cannot be
2795 * determined only from the error code that is returned. Not every error will
2796 * result in an error message being printed.
2798 * This setting is global and not per-WIM.
2800 * By default, error messages are not printed.
2802 * This can be called before wimlib_global_init().
2804 * @param show_messages
2805 * @c true if error messages are to be printed; @c false if error messages
2806 * are not to be printed.
2808 * @return 0 on success; nonzero on error.
2809 * @retval ::WIMLIB_ERR_UNSUPPORTED
2810 * @a show_messages was @c true, but wimlib was compiled with the @c
2811 * --without-error-messages option. Therefore, error messages cannot be
2815 wimlib_set_print_errors(bool show_messages);
2818 * Splits a WIM into multiple parts.
2821 * The ::WIMStruct for the WIM to split. It must be a standalone, one-part
2824 * Name of the SWM file to create. This will be the name of the first
2825 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
2826 * appended before the suffix.
2828 * The maximum size per part, in bytes. It is not guaranteed that this
2829 * will really be the maximum size per part, because some file resources in
2830 * the WIM may be larger than this size, and the WIM file format provides
2831 * no way to split up file resources among multiple WIMs.
2832 * @param write_flags
2833 * Bitwise OR of relevant flags prefixed with @c WIMLIB_WRITE_FLAG. These
2834 * flags will be used to write each split WIM part. Specify 0 here to get
2835 * the default behavior.
2836 * @param progress_func
2837 * If non-NULL, a function that will be called periodically with the
2838 * progress of the current operation
2839 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
2840 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART).
2842 * @return 0 on success; nonzero on error. This function may return any value
2843 * returned by wimlib_write() as well as the following error codes:
2845 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2846 * @a wim was not part 1 of a stand-alone WIM.
2847 * @retval ::WIMLIB_ERR_INVALID_PARAM
2848 * @a swm_name was not a nonempty string, or @a part_size was 0.
2850 * Note: the WIM's uncompressed and compressed resources are not checksummed
2851 * when they are copied from the joined WIM to the split WIM parts, nor are
2852 * compressed resources re-compressed (unless explicitly requested with
2853 * ::WIMLIB_WRITE_FLAG_RECOMPRESS).
2856 wimlib_split(WIMStruct *wim,
2857 const wimlib_tchar *swm_name,
2860 wimlib_progress_func_t progress_func);
2863 * Unmounts a WIM image that was mounted using wimlib_mount_image().
2865 * The image to unmount is specified by the path to the mountpoint, not the
2866 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
2867 * touched and also may have been allocated in a different process.
2869 * To unmount the image, the thread calling this function communicates with the
2870 * thread that is managing the mounted WIM image. This function blocks until it
2871 * is known whether the unmount succeeded or failed. In the case of a
2872 * read-write mounted WIM, the unmount is not considered to have succeeded until
2873 * all changes have been saved to the underlying WIM file.
2876 * The directory that the WIM image was mounted on.
2877 * @param unmount_flags
2878 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
2879 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
2880 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
2882 * @param progress_func
2883 * If non-NULL, a function that will be called periodically with the
2884 * progress of the current operation.
2886 * @return 0 on success; nonzero on error.
2888 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
2889 * The filesystem daemon was unable to remove the staging directory and the
2890 * temporary files that it contains.
2891 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
2892 * The filesystem daemon appears to have terminated before sending an exit
2894 * @retval ::WIMLIB_ERR_FORK
2895 * Could not @c fork() the process.
2896 * @retval ::WIMLIB_ERR_FUSERMOUNT
2897 * The @b fusermount program could not be executed or exited with a failure
2899 * @retval ::WIMLIB_ERR_MQUEUE
2900 * Could not open a POSIX message queue to communicate with the filesystem
2901 * daemon servicing the mounted filesystem, could not send a message
2902 * through the queue, or could not receive a message through the queue.
2903 * @retval ::WIMLIB_ERR_NOMEM
2904 * Failed to allocate needed memory.
2905 * @retval ::WIMLIB_ERR_OPEN
2906 * The filesystem daemon could not open a temporary file for writing the
2908 * @retval ::WIMLIB_ERR_READ
2909 * A read error occurred when the filesystem daemon tried to a file from
2910 * the staging directory
2911 * @retval ::WIMLIB_ERR_RENAME
2912 * The filesystem daemon failed to rename the newly written WIM file to the
2913 * original WIM file.
2914 * @retval ::WIMLIB_ERR_UNSUPPORTED
2915 * Mounting is not supported, either because the platform is Windows, or
2916 * because the platform is UNIX and wimlib was compiled with @c
2918 * @retval ::WIMLIB_ERR_WRITE
2919 * A write error occurred when the filesystem daemon was writing to the new
2920 * WIM file, or the filesystem daemon was unable to flush changes that had
2921 * been made to files in the staging directory.
2924 wimlib_unmount_image(const wimlib_tchar *dir,
2926 wimlib_progress_func_t progress_func);
2929 * Update a WIM image by adding, deleting, and/or renaming files or directories.
2932 * Pointer to the ::WIMStruct for the WIM file to update.
2934 * The 1-based index of the image in the WIM to update. It cannot be
2935 * ::WIMLIB_ALL_IMAGES.
2937 * An array of ::wimlib_update_command's that specify the update operations
2940 * Number of commands in @a cmds.
2941 * @param update_flags
2942 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
2943 * @param progress_func
2944 * If non-NULL, a function that will be called periodically with the
2945 * progress of the current operation.
2947 * @return 0 on success; nonzero on error. On failure, some but not all of the
2948 * update commands may have been executed. No individual update command will
2949 * have been partially executed. Possible error codes include:
2951 * @retval ::WIMLIB_ERR_DECOMPRESSION
2952 * Failed to decompress the metadata resource from @a image in @a wim.
2953 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
2954 * The capture configuration structure specified for an add command was
2956 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2957 * @a image did not specify a single, existing image in @a wim.
2958 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
2959 * Attempted to perform an add command that conflicted with previously
2960 * existing files in the WIM when an overlay was attempted.
2961 * @retval ::WIMLIB_ERR_INVALID_PARAM
2962 * An unknown operation type was specified in the update commands; or,
2963 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
2964 * in the @a add_flags, but the same image had previously already been
2965 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
2966 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @a add_flags for one add
2967 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
2968 * specified in the @a add_flags for an add command in which @a
2969 * wim_target_path was not the root directory of the WIM image.
2970 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
2971 * (Windows only): While executing an add command, tried to capture a
2972 * reparse point with invalid data.
2973 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2974 * The metadata resource for @a image in @a wim is invalid.
2975 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2976 * The security data for image @a image in @a wim is invalid.
2977 * @retval ::WIMLIB_ERR_IS_DIRECTORY
2978 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
2979 * for a WIM path that corresponded to a directory; or, a rename command
2980 * attempted to rename a directory to a non-directory.
2981 * @retval ::WIMLIB_ERR_NOMEM
2982 * Failed to allocate needed memory.
2983 * @retval ::WIMLIB_ERR_NOTDIR
2984 * A rename command attempted to rename a directory to a non-directory; or,
2985 * an add command was executed that attempted to set the root of the WIM
2986 * image as a non-directory; or, a path component used as a directory in a
2987 * rename command was not, in fact, a directory.
2988 * @retval ::WIMLIB_ERR_NOTEMPTY
2989 * A rename command attempted to rename a directory to a non-empty
2991 * @retval ::WIMLIB_ERR_NTFS_3G
2992 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
2993 * error occurred while reading data from the NTFS volume using libntfs-3g.
2994 * @retval ::WIMLIB_ERR_OPEN
2995 * Failed to open a file to be captured while executing an add command.
2996 * @retval ::WIMLIB_ERR_OPENDIR
2997 * Failed to open a directory to be captured while executing an add command.
2998 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2999 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
3000 * WIM path that did not exist; or, a rename command attempted to rename a
3001 * file that does not exist.
3002 * @retval ::WIMLIB_ERR_READ
3003 * Failed to read the metadata resource for @a image in @a wim; or, while
3004 * executing an add command, failed to read data from a file or directory
3006 * @retval ::WIMLIB_ERR_READLINK
3007 * While executing an add command, failed to read the target of a symbolic
3008 * link or junction point.
3009 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
3010 * (Windows only) Failed to perform a reparse point fixup because of
3011 * problems with the data of a reparse point.
3012 * @retval ::WIMLIB_ERR_SPECIAL_FILE
3013 * While executing an add command, attempted to capture a file that was not
3014 * a supported file type, such as a regular file, directory, symbolic link,
3015 * or (on Windows) a reparse point.
3016 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
3017 * @a wim is part of a split WIM. Updating a split WIM is unsupported.
3018 * @retval ::WIMLIB_ERR_STAT
3019 * While executing an add command, failed to get attributes for a file or
3021 * @retval ::WIMLIB_ERR_UNSUPPORTED
3022 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @a add_flags for an update
3023 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
3024 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
3025 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @a
3026 * add_flags for an update command.
3027 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
3028 * The WIM file is considered read-only because of any of the reasons
3029 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
3033 wimlib_update_image(WIMStruct *wim,
3035 const struct wimlib_update_command *cmds,
3038 wimlib_progress_func_t progress_func);
3041 * Writes a standalone WIM to a file.
3043 * This brings in resources from any external locations, such as directory trees
3044 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
3045 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
3048 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
3049 * changes made to it, which are then reflected in the output file.
3051 * The path to the file to write the WIM to.
3053 * The 1-based index of the image inside the WIM to write. Use
3054 * ::WIMLIB_ALL_IMAGES to include all images.
3055 * @param write_flags
3056 * Bitwise OR of any of the flags prefixed with @c WIMLIB_WRITE_FLAG.
3057 * @param num_threads
3058 * Number of threads to use for compressing data. If 0, the number of
3059 * threads is taken to be the number of online processors. Note: if no
3060 * data compression needs to be done, no additional threads will be created
3061 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
3062 * exporting an image from a compressed WIM to another WIM of the same
3063 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @a
3065 * @param progress_func
3066 * If non-NULL, a function that will be called periodically with the
3067 * progress of the current operation. The possible messages are
3068 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
3069 * ::WIMLIB_PROGRESS_MSG_WRITE_METADATA_END, and
3070 * ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS.
3072 * @return 0 on success; nonzero on error.
3073 * @retval ::WIMLIB_ERR_DECOMPRESSION
3074 * Failed to decompress a metadata or file resource in @a wim.
3075 * @retval ::WIMLIB_ERR_INVALID_IMAGE
3076 * @a image does not specify a single existing image in @a wim, and is not
3077 * ::WIMLIB_ALL_IMAGES.
3078 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
3079 * A file that had previously been scanned for inclusion in the WIM by
3080 * wimlib_add_image() was concurrently modified, so it failed the SHA1
3081 * message digest check.
3082 * @retval ::WIMLIB_ERR_INVALID_PARAM
3083 * @p path was @c NULL.
3084 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
3085 * The metadata resource for @a image in @a wim is invalid.
3086 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
3087 * The security data for @a image in @a wim is invalid.
3088 * @retval ::WIMLIB_ERR_NOMEM
3089 * Failed to allocate needed memory.
3090 * @retval ::WIMLIB_ERR_OPEN
3091 * Failed to open @a path for writing, or some file resources in @a wim
3092 * refer to files in the outside filesystem, and one of these files could
3093 * not be opened for reading.
3094 * @retval ::WIMLIB_ERR_READ
3095 * An error occurred when trying to read data from the WIM file associated
3096 * with @a wim, or some file resources in @a wim refer to files in the
3097 * outside filesystem, and a read error occurred when reading one of these
3099 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
3100 * @a wim is part of a split WIM, not a standalone WIM.
3101 * @retval ::WIMLIB_ERR_WRITE
3102 * An error occurred when trying to write data to the new WIM file.
3105 wimlib_write(WIMStruct *wim,
3106 const wimlib_tchar *path,
3109 unsigned num_threads,
3110 wimlib_progress_func_t progress_func);
3113 * Since wimlib v1.5.0: Same as wimlib_write(), but write the WIM directly to a
3114 * file descriptor, which need not be seekable if the write is done in a special
3115 * pipable WIM format by providing ::WIMLIB_WRITE_FLAG_PIPABLE in @p
3116 * write_flags. This can, for example, allow capturing a WIM image and
3117 * streaming it over the network. See the documentation for
3118 * ::WIMLIB_WRITE_FLAG_PIPABLE for more information about pipable WIMs.
3120 * The file descriptor @p fd will not be closed when the write is complete; the
3121 * calling code is responsible for this.
3123 * Return values are mostly the same as wimlib_write(), but also:
3125 * @retval ::WIMLIB_ERR_INVALID_PARAM
3126 * @p fd was not seekable, but ::WIMLIB_WRITE_FLAG_PIPABLE was not
3127 * specified in @p write_flags.
3130 wimlib_write_to_fd(WIMStruct *wim,
3134 unsigned num_threads,
3135 wimlib_progress_func_t progress_func);
3138 * This function is equivalent to wimlib_lzx_compress(), but instead compresses
3139 * the data using "XPRESS" compression.
3142 wimlib_xpress_compress(const void *chunk, unsigned chunk_size, void *out);
3145 * This function is equivalent to wimlib_lzx_decompress(), but instead assumes
3146 * the data is compressed using "XPRESS" compression.
3149 wimlib_xpress_decompress(const void *compressed_data, unsigned compressed_len,
3150 void *uncompressed_data, unsigned uncompressed_len);
3152 #endif /* _WIMLIB_H */