4 * External header for wimlib.
6 * This file contains extensive comments for generating documentation with
7 * Doxygen. The built HTML documentation can be viewed at
8 * http://wimlib.sourceforge.net.
12 * Copyright (C) 2012, 2013 Eric Biggers
14 * This file is part of wimlib, a library for working with WIM files.
16 * wimlib is free software; you can redistribute it and/or modify it under the
17 * terms of the GNU General Public License as published by the Free
18 * Software Foundation; either version 3 of the License, or (at your option)
21 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
22 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
23 * A PARTICULAR PURPOSE. See the GNU General Public License for more
26 * You should have received a copy of the GNU General Public License
27 * along with wimlib; if not, see http://www.gnu.org/licenses/.
32 * \section intro Introduction
34 * This is the documentation for the library interface of wimlib 1.4.1, a C
35 * library for creating, modifying, extracting, and mounting files in the
36 * Windows Imaging Format. This documentation is intended for developers only.
37 * If you have installed wimlib and want to know how to use the @b wimlib-imagex
38 * program, please see the README file.
40 * \section starting Getting Started
42 * wimlib uses the GNU autotools, so, on UNIX systems, it should be easy to
43 * install with <code>configure && make && sudo make install</code>; however,
44 * please see the README for more information about installing it. To use
45 * wimlib in a program after installing it, include @c wimlib.h and link your
46 * program with @c -lwim.
48 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. A ::WIMStruct
49 * may represent either a stand-alone WIM or one part of a split WIM.
51 * All functions in wimlib's public API are prefixed with @c wimlib. Most
52 * return 0 on success and a positive error code on failure. Use
53 * wimlib_get_error_string() to get a string that describes an error code.
54 * wimlib also can print error messages itself when an error happens, and these
55 * may be more informative than the error code; to enable this, call
56 * wimlib_set_print_errors(). Please note that this is for convenience only,
57 * and some errors can occur without a message being printed.
59 * First before calling any other functions, you should call
60 * wimlib_global_init() to initialize the library.
62 * To open an existing WIM, use wimlib_open_wim().
64 * To create a new WIM that initially contains no images, use
65 * wimlib_create_new_wim().
67 * To add an image to a WIM file from a directory tree on your filesystem, call
68 * wimlib_add_image(). This can be done with a ::WIMStruct gotten from
69 * wimlib_open_wim() or from wimlib_create_new_wim(). On UNIX,
70 * wimlib_add_image() can also capture a WIM image directly from a block device
71 * containing a NTFS filesystem.
73 * To extract an image from a WIM file, call wimlib_extract_image(). This can
74 * be done either to a directory, or, on UNIX, directly to a block device
75 * containing a NTFS filesystem.
77 * To extract individual files or directories from a WIM image, rather than a
78 * full image, call wimlib_extract_files().
80 * To programatically make changes to a WIM image without mounting it, call
81 * wimlib_update_image().
83 * On UNIX, wimlib supports mounting WIM files either read-only or read-write.
84 * Mounting is done using wimlib_mount_image() and unmounting is done using
85 * wimlib_unmount_image(). Mounting can be done without root privileges because
86 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
87 * compiled with the <code>--without-fuse</code> flag, these functions will be
88 * available but will fail with ::WIMLIB_ERR_UNSUPPORTED.
90 * After creating or modifying a WIM file, you can write it to a file using
91 * wimlib_write(). Alternatively, if the WIM was originally read from a file
92 * (using wimlib_open_wim() rather than wimlib_create_new_wim()), you can use
93 * wimlib_overwrite() to overwrite the original file.
95 * Please note: merely by calling wimlib_add_image() or many of the other
96 * functions in this library that operate on ::WIMStruct's, you are @b not
97 * modifying the WIM file on disk. Changes are not saved until you explicitly
98 * call wimlib_write() or wimlib_overwrite().
100 * After you are done with the WIM file, use wimlib_free() to free all memory
101 * associated with a ::WIMStruct and close all files associated with it.
103 * When you are completely done with using wimlib in your program, you should
104 * call wimlib_global_cleanup().
106 * A number of functions take a pointer to a progress function of type
107 * ::wimlib_progress_func_t. This function will be called periodically during
108 * the WIM operation(s) to report on the progress of the operation (for example,
109 * how many bytes have been written so far).
111 * wimlib is thread-safe as long as different ::WIMStruct's are used, except for
112 * the following exceptions:
113 * - You must call wimlib_global_init() in one thread before calling any other
115 * - wimlib_set_print_errors() and wimlib_set_memory_allocator() both apply globally.
116 * race conditions with one-time allocations of memory.
117 * - wimlib_mount_image(), while it can be used to mount multiple WIMs
118 * concurrently in the same process, will daemonize the entire process when it
119 * does so for the first time. This includes changing the working directory
120 * to the root directory.
122 * \section encodings Locales and character encodings
124 * To support Windows as well as UNIX, wimlib's API typically takes and returns
125 * strings of ::wimlib_tchar, which are in a platform-dependent encoding.
127 * On Windows, each ::wimlib_tchar is 2 bytes and is the same as a "wchar_t",
128 * and the encoding is UTF-16LE.
130 * On UNIX, each ::wimlib_tchar is 1 byte and is simply a "char", and the
131 * encoding is the locale-dependent multibyte encoding. I recommend you set
132 * your locale to a UTF-8 capable locale to avoid any issues. Also, by default,
133 * wimlib on UNIX will assume the locale is UTF-8 capable unless you call
134 * wimlib_global_init() after having set your desired locale.
136 * \section Limitations
138 * This section documents some technical limitations of wimlib not already
139 * documented in the man page for @b wimlib-imagex.
141 * - The old WIM format from Vista pre-releases is not supported.
142 * - Compressed resource chunk sizes other than 32768 are not supported. This
143 * doesn't seem to be a real problem because the chunk size always seems to be
145 * - wimlib does not provide a clone of the @b PEImg tool, or the @b Dism
146 * functionality other than that already present in @b ImageX, that allows you
147 * to make certain Windows-specific modifications to a Windows PE image, such
148 * as adding a driver or Windows component. Such a tool possibly could be
149 * implemented on top of wimlib.
158 #include <inttypes.h>
160 /** Major version of the library (for example, the 1 in 1.2.5). */
161 #define WIMLIB_MAJOR_VERSION 1
163 /** Minor version of the library (for example, the 2 in 1.2.5). */
164 #define WIMLIB_MINOR_VERSION 4
166 /** Patch version of the library (for example, the 5 in 1.2.5). */
167 #define WIMLIB_PATCH_VERSION 1
170 * Opaque structure that represents a WIM file. This is an in-memory structure
171 * and need not correspond to a specific on-disk file. However, a ::WIMStruct
172 * obtained from wimlib_open_wim() depends on the underlying on-disk WIM file
173 * continuing to exist so that data can be read from it as needed.
175 * Most functions in this library will work the same way regardless of whether a
176 * given ::WIMStruct was obtained through wimlib_open_wim() or
177 * wimlib_create_new_wim(). Exceptions are documented.
179 * Use wimlib_write() or wimlib_overwrite() to actually write an on-disk WIM
180 * file from a ::WIMStruct.
182 #ifndef WIMLIB_WIMSTRUCT_DECLARED
183 typedef struct WIMStruct WIMStruct;
184 #define WIMLIB_WIMSTRUCT_DECLARED
188 typedef wchar_t wimlib_tchar;
190 /** See \ref encodings */
191 typedef char wimlib_tchar;
195 /** Path separator for WIM paths passed back to progress callbacks. */
196 # define WIMLIB_WIM_PATH_SEPARATOR '\\'
197 # define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
199 /** Path separator for WIM paths passed back to progress callbacks. */
200 # define WIMLIB_WIM_PATH_SEPARATOR '/'
201 # define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
205 # define _wimlib_deprecated __attribute__((deprecated))
207 # define _wimlib_deprecated
211 * Specifies the compression type of a WIM file.
213 enum wimlib_compression_type {
214 /** An invalid compression type. */
215 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
217 /** The WIM does not include any compressed resources. */
218 WIMLIB_COMPRESSION_TYPE_NONE = 0,
220 /** Compressed resources in the WIM use LZX compression. */
221 WIMLIB_COMPRESSION_TYPE_LZX = 1,
223 /** Compressed resources in the WIM use XPRESS compression. */
224 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
227 /** Possible values of the first parameter to the user-supplied
228 * ::wimlib_progress_func_t progress function */
229 enum wimlib_progress_msg {
231 /** A WIM image is about to be extracted. @a info will point to
232 * ::wimlib_progress_info.extract. */
233 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN = 0,
235 /** A file or directory tree within a WIM image (not the full image) is
236 * about to be extracted. @a info will point to
237 * ::wimlib_progress_info.extract. */
238 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN,
240 /** The directory structure of the WIM image is about to be extracted.
241 * @a info will point to ::wimlib_progress_info.extract. */
242 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
244 /** The directory structure of the WIM image has been successfully
245 * extracted. @a info will point to ::wimlib_progress_info.extract. */
246 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
248 /** The WIM image's files resources are currently being extracted. @a
249 * info will point to ::wimlib_progress_info.extract. */
250 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
252 /** A file or directory is being extracted. @a info will point to
253 * ::wimlib_progress_info.extract, and the @a cur_path member will be
255 WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY,
257 /** All the WIM files and directories have been extracted, and
258 * timestamps are about to be applied. @a info will point to
259 * ::wimlib_progress_info.extract. */
260 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
262 /** A WIM image has been successfully extracted. @a info will point to
263 * ::wimlib_progress_info.extract. */
264 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
266 /** A file or directory tree within a WIM image (not the full image) has
267 * been successfully extracted. @a info will point to
268 * ::wimlib_progress_info.extract. */
269 WIMLIB_PROGRESS_MSG_EXTRACT_TREE_END,
271 /** The directory or NTFS volume is about to be scanned to build a tree
272 * of WIM dentries in-memory. @a info will point to
273 * ::wimlib_progress_info.scan. */
274 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
276 /** A directory or file is being scanned. @a info will point to
277 * ::wimlib_progress_info.scan, and its @a cur_path member will be
278 * valid. This message is only sent if ::WIMLIB_ADD_FLAG_VERBOSE
279 * is passed to wimlib_add_image(). */
280 WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
282 /** The directory or NTFS volume has been successfully scanned, and a
283 * tree of WIM dentries has been built in-memory. @a info will point to
284 * ::wimlib_progress_info.scan. */
285 WIMLIB_PROGRESS_MSG_SCAN_END,
288 * File resources are currently being written to the WIM.
289 * @a info will point to ::wimlib_progress_info.write_streams. */
290 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
293 * The metadata resource for each image is about to be written to the
294 * WIM. @a info will not be valid. */
295 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
298 * The metadata resource for each image has successfully been writen to
299 * the WIM. @a info will not be valid. */
300 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
303 * The temporary file has successfully been renamed to the original WIM
304 * file. Only happens when wimlib_overwrite() is called and the
305 * overwrite is not done in-place.
306 * @a info will point to ::wimlib_progress_info.rename. */
307 WIMLIB_PROGRESS_MSG_RENAME,
309 /** The contents of the WIM are being checked against the integrity
310 * table. Only happens when wimlib_open_wim() is called with the
311 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. @a info will point to
312 * ::wimlib_progress_info.integrity. */
313 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
315 /** An integrity table is being calculated for the WIM being written.
316 * Only happens when wimlib_write() or wimlib_overwrite() is called with
317 * the ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag. @a info will point to
318 * ::wimlib_progress_info.integrity. */
319 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
321 /** A wimlib_join() operation is in progress. @a info will point to
322 * ::wimlib_progress_info.join. */
323 WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
325 /** A wimlib_split() operation is in progress, and a new split part is
326 * about to be started. @a info will point to
327 * ::wimlib_progress_info.split. */
328 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
330 /** A wimlib_split() operation is in progress, and a split part has been
331 * finished. @a info will point to ::wimlib_progress_info.split. */
332 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
335 * A WIM update command is just about to be executed; @a info will point
336 * to ::wimlib_progress_info.update.
338 WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
341 * A WIM update command has just been executed; @a info will point to
342 * ::wimlib_progress_info.update.
344 WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
348 /** A pointer to this union is passed to the user-supplied
349 * ::wimlib_progress_func_t progress function. One (or none) of the structures
350 * contained in this union will be applicable for the operation
351 * (::wimlib_progress_msg) indicated in the first argument to the progress
353 union wimlib_progress_info {
355 /* N.B. I wanted these to be anonymous structs, but Doxygen won't
356 * document them if they aren't given a name... */
358 /** Valid on messages ::WIMLIB_PROGRESS_MSG_WRITE_STREAMS. */
359 struct wimlib_progress_info_write_streams {
360 /** Number of bytes that are going to be written for all the
361 * streams combined. This is the amount in uncompressed data.
362 * (The actual number of bytes will be less if the data is being
363 * written compressed.) */
364 uint64_t total_bytes;
365 /** Number of streams that are going to be written. */
366 uint64_t total_streams;
368 /** Number of uncompressed bytes that have been written so far.
369 * Will be 0 initially, and equal to @a total_bytes at the end.
371 uint64_t completed_bytes;
373 /** Number of streams that have been written. Will be 0
374 * initially, and equal to @a total_streams at the end. */
375 uint64_t completed_streams;
377 /** Number of threads that are being used to compress resources
378 * (if applicable). */
379 unsigned num_threads;
381 /** The compression type being used to write the streams; either
382 * ::WIMLIB_COMPRESSION_TYPE_NONE,
383 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or
384 * ::WIMLIB_COMPRESSION_TYPE_LZX. */
385 int compression_type;
387 /** Library internal use only. */
391 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
392 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
393 struct wimlib_progress_info_scan {
394 /** Directory or NTFS volume that is being scanned. */
395 const wimlib_tchar *source;
397 /** Path to the file or directory that is about to be scanned,
398 * relative to the root of the image capture or the NTFS volume.
400 const wimlib_tchar *cur_path;
402 /** True iff @a cur_path is being excluded from the image
403 * capture due to the capture configuration file. */
406 /** Target path in the WIM. Only valid on messages
407 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
408 * ::WIMLIB_PROGRESS_MSG_SCAN_END. */
409 const wimlib_tchar *wim_target_path;
412 /** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
413 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
414 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
415 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS, and
416 * ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END. */
417 struct wimlib_progress_info_extract {
418 /** Number of the image being extracted (1-based). */
421 /** Flags passed to to wimlib_extract_image() */
424 /** Full path to the WIM file being extracted. */
425 const wimlib_tchar *wimfile_name;
427 /** Name of the image being extracted. */
428 const wimlib_tchar *image_name;
430 /** Directory or NTFS volume to which the image is being
432 const wimlib_tchar *target;
434 /** Current dentry being extracted. (Valid only if message is
435 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY.) */
436 const wimlib_tchar *cur_path;
438 /** Number of bytes of uncompressed data that will be extracted.
439 * Takes into account hard links (they are not counted for each
442 uint64_t total_bytes;
444 /** Number of bytes that have been written so far. Will be 0
445 * initially, and equal to @a total_bytes at the end. */
446 uint64_t completed_bytes;
448 /** Number of streams that will be extracted. This may more or
449 * less than the number of "files" to be extracted due to
450 * special cases (hard links, symbolic links, and alternate data
452 uint64_t num_streams;
454 /** Path to the root dentry within the WIM for the tree that is
455 * being extracted. Will be the empty string when extracting a
457 const wimlib_tchar *extract_root_wim_source_path;
460 /** Valid on messages ::WIMLIB_PROGRESS_MSG_RENAME. */
461 struct wimlib_progress_info_rename {
462 /** Name of the temporary file that the WIM was written to. */
463 const wimlib_tchar *from;
465 /** Name of the original WIM file to which the temporary file is
467 const wimlib_tchar *to;
470 /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
471 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
472 struct wimlib_progress_info_update {
473 /** Pointer to the update command that will be executed or has
474 * just been executed. */
475 const struct wimlib_update_command *command;
477 /** Number of update commands that have been completed so far.
479 size_t completed_commands;
481 /** Number of update commands that are being executed as part of
482 * this call to wimlib_update_image(). */
483 size_t total_commands;
486 /** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
487 * ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
488 struct wimlib_progress_info_integrity {
489 /** Number of bytes from the end of the WIM header to the end of
490 * the lookup table (the area that is covered by the SHA1
491 * integrity checks.) */
492 uint64_t total_bytes;
494 /** Number of bytes that have been SHA1-summed so far. Will be
495 * 0 initially, and equal @a total_bytes at the end. */
496 uint64_t completed_bytes;
498 /** Number of chunks that the checksummed region is divided
500 uint32_t total_chunks;
502 /** Number of chunks that have been SHA1-summed so far. Will
503 * be 0 initially, and equal to @a total_chunks at the end. */
504 uint32_t completed_chunks;
506 /** Size of the chunks used for the integrity calculation. */
509 /** Filename of the WIM (only valid if the message is
510 * ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY). */
511 const wimlib_tchar *filename;
514 /** Valid on messages ::WIMLIB_PROGRESS_MSG_JOIN_STREAMS. */
515 struct wimlib_progress_info_join {
516 /** Total number of bytes of compressed data contained in all
517 * the split WIM part's file and metadata resources. */
518 uint64_t total_bytes;
520 /** Number of bytes that have been copied to the joined WIM so
521 * far. Will be 0 initially, and equal to @a total_bytes at the
523 uint64_t completed_bytes;
525 /** Number of split WIM parts that have had all their file and
526 * metadata resources copied over to the joined WIM so far. */
527 unsigned completed_parts;
529 /** Number of split WIM parts. */
530 unsigned total_parts;
533 /** Valid on messages ::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART and
534 * ::WIMLIB_PROGRESS_MSG_SPLIT_END_PART. */
535 struct wimlib_progress_info_split {
536 /** Total size of the original WIM's file and metadata resources
538 uint64_t total_bytes;
540 /** Number of bytes of file and metadata resources that have
541 * been copied out of the original WIM so far. Will be 0
542 * initially, and equal to @a total_bytes at the end. */
543 uint64_t completed_bytes;
545 /** Number of the split WIM part that is about to be started
546 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
547 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
548 unsigned cur_part_number;
550 /** Name of the split WIM part that is about to be started
551 * (::WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART) or has just been
552 * finished (::WIMLIB_PROGRESS_MSG_SPLIT_END_PART). */
553 const wimlib_tchar *part_name;
557 /** A user-supplied function that will be called periodically during certain WIM
558 * operations. The first argument will be the type of operation that is being
559 * performed or is about to be started or has been completed. The second
560 * argument will be a pointer to one of a number of structures depending on the
561 * first argument. It may be @c NULL for some message types.
563 * The return value of the progress function is currently ignored, but it may do
564 * something in the future. (Set it to 0 for now.)
566 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
567 const union wimlib_progress_info *info);
569 /** An array of these structures is passed to wimlib_add_image_multisource() to
570 * specify the sources from which to create a WIM image. */
571 struct wimlib_capture_source {
572 /** Absolute or relative path to a file or directory on the external
573 * filesystem to be included in the WIM image. */
574 wimlib_tchar *fs_source_path;
576 /** Destination path in the WIM image. Leading and trailing slashes are
577 * ignored. The empty string or @c NULL means the root directory of the
579 wimlib_tchar *wim_target_path;
581 /** Reserved; set to 0. */
585 /** Structure that specifies a list of path patterns. */
586 struct wimlib_pattern_list {
587 /** Array of patterns. The patterns may be modified by library code,
588 * but the @a pats pointer itself will not. See the man page for
589 * <b>wimlib-imagex capture</b> for more information about allowed
593 /** Number of patterns in the @a pats array. */
596 /** Ignored; may be used by the calling code. */
597 size_t num_allocated_pats;
600 /** A structure that contains lists of wildcards that match paths to treat
601 * specially when capturing a WIM image. */
602 struct wimlib_capture_config {
603 /** Paths matching any pattern this list are excluded from being
604 * captured, except if the same path appears in @a
605 * exclusion_exception_pats. */
606 struct wimlib_pattern_list exclusion_pats;
608 /** Paths matching any pattern in this list are never excluded from
610 struct wimlib_pattern_list exclusion_exception_pats;
612 /** Reserved for future capture configuration options. */
613 struct wimlib_pattern_list reserved1;
615 /** Reserved for future capture configuration options. */
616 struct wimlib_pattern_list reserved2;
618 /** Library internal use only. */
619 const wimlib_tchar *_prefix;
621 /** Library internal use only. */
622 size_t _prefix_num_tchars;
625 /** Set or unset the WIM header flag that marks it read-only
626 * (WIM_HDR_FLAG_READONLY in Microsoft's documentation), based on the
627 * ::wimlib_wim_info.is_marked_readonly member of the @a info parameter. This
628 * is distinct from basic file permissions; this flag can be set on a WIM file
629 * that is physically writable. If this flag is set, all further operations to
630 * modify the WIM will fail, except calling wimlib_overwrite() with
631 * ::WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG specified, which is a loophole that
632 * allows you to set this flag persistently on the underlying WIM file.
634 #define WIMLIB_CHANGE_READONLY_FLAG 0x00000001
636 /** Set the GUID (globally unique identifier) of the WIM file to the value
637 * specified in ::wimlib_wim_info.guid of the @a info parameter. */
638 #define WIMLIB_CHANGE_GUID 0x00000002
640 /** Change the bootable image of the WIM to the value specified in
641 * ::wimlib_wim_info.boot_index of the @a info parameter. */
642 #define WIMLIB_CHANGE_BOOT_INDEX 0x00000004
644 /** Change the WIM_HDR_FLAG_RP_FIX flag of the WIM file to the value specified
645 * in ::wimlib_wim_info.has_rpfix of the @a info parameter. This flag generally
646 * indicates whether an image in the WIM has been captured with reparse-point
647 * fixups enabled. wimlib also treats this flag as specifying whether to do
648 * reparse-point fixups by default when capturing or applying WIM images. */
649 #define WIMLIB_CHANGE_RPFIX_FLAG 0x00000008
651 #define WIMLIB_GUID_LEN 16
653 /** General information about a WIM file. */
654 struct wimlib_wim_info {
656 /** Globally unique identifier for the WIM file. Note: all parts of a
657 * split WIM should have an identical value in this field. */
658 uint8_t guid[WIMLIB_GUID_LEN];
660 /** Number of images in the WIM. */
661 uint32_t image_count;
663 /** 1-based index of the bootable image in the WIM, or 0 if no image is
667 /** Version of the WIM file. */
668 uint32_t wim_version;
670 /** Chunk size used for compression. */
673 /** 1-based index of this part within a split WIM, or 1 if the WIM is
675 uint16_t part_number;
677 /** Total number of parts in the split WIM, or 1 if the WIM is
679 uint16_t total_parts;
681 /** One of the ::wimlib_compression_type values that specifies the
682 * method used to compress resources in the WIM. */
683 int32_t compression_type;
685 /** Size of the WIM file in bytes, excluding the XML data and integrity
687 uint64_t total_bytes;
689 /** 1 if the WIM has an integrity table. Note: if the ::WIMStruct was
690 * created via wimlib_create_new_wim() rather than wimlib_open_wim(),
691 * this will always be 0, even if the ::WIMStruct was written to
692 * somewhere by calling wimlib_write() with the
693 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY flag specified. */
694 uint32_t has_integrity_table : 1;
696 /** 1 if the ::WIMStruct was created via wimlib_open_wim() rather than
697 * wimlib_create_new_wim(). */
698 uint32_t opened_from_file : 1;
700 /** 1 if the WIM is considered readonly for any reason. */
701 uint32_t is_readonly : 1;
703 /** 1 if reparse-point fixups are supposedly enabled for one or more
704 * images in the WIM. */
705 uint32_t has_rpfix : 1;
707 /** 1 if the WIM is marked as read-only. */
708 uint32_t is_marked_readonly : 1;
710 /** 1 if the WIM is part of a spanned set. */
711 uint32_t spanned : 1;
713 uint32_t write_in_progress : 1;
714 uint32_t metadata_only : 1;
715 uint32_t resource_only : 1;
716 uint32_t reserved_flags : 23;
717 uint32_t reserved[9];
721 /*****************************
723 *****************************/
725 /** Directly capture a NTFS volume rather than a generic directory. This flag
726 * cannot be combined with ::WIMLIB_ADD_FLAG_DEREFERENCE or
727 * ::WIMLIB_ADD_FLAG_UNIX_DATA. */
728 #define WIMLIB_ADD_FLAG_NTFS 0x00000001
730 /** Follow symlinks; archive and dump the files they point to. Cannot be used
731 * with ::WIMLIB_ADD_FLAG_NTFS. */
732 #define WIMLIB_ADD_FLAG_DEREFERENCE 0x00000002
734 /** Call the progress function with the message
735 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
737 #define WIMLIB_ADD_FLAG_VERBOSE 0x00000004
739 /** Mark the image being added as the bootable image of the WIM. */
740 #define WIMLIB_ADD_FLAG_BOOT 0x00000008
742 /** Store the UNIX owner, group, and mode. This is done by adding a special
743 * alternate data stream to each regular file, symbolic link, and directory to
744 * contain this information. Please note that this flag is for convenience
745 * only; Microsoft's @a imagex.exe will not understand this special information.
746 * This flag cannot be combined with ::WIMLIB_ADD_FLAG_NTFS. */
747 #define WIMLIB_ADD_FLAG_UNIX_DATA 0x00000010
749 /** Do not capture security descriptors. Only has an effect in NTFS capture
750 * mode, or in Win32 native builds. */
751 #define WIMLIB_ADD_FLAG_NO_ACLS 0x00000020
753 /** Fail immediately if the full security descriptor of any file or directory
754 * cannot be accessed. Only has an effect in Win32 native builds. The default
755 * behavior without this flag is to first try omitting the SACL from the
756 * security descriptor, then to try omitting the security descriptor entirely.
758 #define WIMLIB_ADD_FLAG_STRICT_ACLS 0x00000040
760 /** Call the progress function with the message
761 * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when a directory or file is excluded from
762 * capture. This is a subset of the messages provided by
763 * ::WIMLIB_ADD_FLAG_VERBOSE. */
764 #define WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE 0x00000080
766 /** Reparse-point fixups: Modify absolute symbolic links (or junction points,
767 * in the case of Windows) that point inside the directory being captured to
768 * instead be absolute relative to the directory being captured, rather than the
769 * current root; also exclude absolute symbolic links that point outside the
770 * directory tree being captured.
772 * Without this flag, the default is to do this if WIM_HDR_FLAG_RP_FIX is set in
773 * the WIM header or if this is the first image being added.
774 * WIM_HDR_FLAG_RP_FIX is set if the first image in a WIM is captured with
775 * reparse point fixups enabled and currently cannot be unset. */
776 #define WIMLIB_ADD_FLAG_RPFIX 0x00000100
778 /** Don't do reparse point fixups. The default behavior is described in the
779 * documentation for ::WIMLIB_ADD_FLAG_RPFIX. */
780 #define WIMLIB_ADD_FLAG_NORPFIX 0x00000200
782 #define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
783 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
784 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE WIMLIB_ADD_FLAG_VERBOSE
785 #define WIMLIB_ADD_IMAGE_FLAG_BOOT WIMLIB_ADD_FLAG_BOOT
786 #define WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA WIMLIB_ADD_FLAG_UNIX_DATA
787 #define WIMLIB_ADD_IMAGE_FLAG_NO_ACLS WIMLIB_ADD_FLAG_NO_ACLS
788 #define WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS WIMLIB_ADD_FLAG_STRICT_ACLS
789 #define WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE
790 #define WIMLIB_ADD_IMAGE_FLAG_RPFIX WIMLIB_ADD_FLAG_RPFIX
791 #define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
793 /******************************
794 * WIMLIB_DELETE_FLAG_*
795 ******************************/
797 /** Do not issue an error if the path to delete does not exist. */
798 #define WIMLIB_DELETE_FLAG_FORCE 0x00000001
800 /** Delete the file or directory tree recursively; if not specified, an error is
801 * issued if the path to delete is a directory. */
802 #define WIMLIB_DELETE_FLAG_RECURSIVE 0x00000002
804 /******************************
805 * WIMLIB_EXPORT_FLAG_*
806 ******************************/
808 /** See documentation for wimlib_export_image(). */
809 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
811 /******************************
812 * WIMLIB_EXTRACT_FLAG_*
813 ******************************/
815 /** Extract the image directly to a NTFS volume rather than a generic directory.
817 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
819 /** When identical files are extracted from the WIM, always hard link them
820 * together. Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
821 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
823 /** When identical files are extracted from the WIM, always symlink them
824 * together. Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
825 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
827 /** Call the progress function with the argument
828 * ::WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY each time a file or directory is
829 * extracted. Note: these calls will be interspersed with calls for the message
830 * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. */
831 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
833 /** Read the WIM file sequentially while extracting the image. */
834 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
836 /** Extract special UNIX data captured with ::WIMLIB_ADD_FLAG_UNIX_DATA.
837 * Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
838 #define WIMLIB_EXTRACT_FLAG_UNIX_DATA 0x00000020
840 /** Do not extract security descriptors. Only has an effect in NTFS apply mode,
841 * or in Win32 native builds. */
842 #define WIMLIB_EXTRACT_FLAG_NO_ACLS 0x00000040
844 /** Fail immediately if the full security descriptor of any file or directory
845 * cannot be set exactly as specified in the WIM file. The default behavior
846 * without this flag is to fall back to setting the security descriptor with the
847 * SACL omitted, then only the default inherited security descriptor, if we do
848 * not have permission to set the desired one. */
849 #define WIMLIB_EXTRACT_FLAG_STRICT_ACLS 0x00000080
851 /* Extract equivalent to ::WIMLIB_ADD_FLAG_RPFIX; force reparse-point
852 * fixups on, so absolute symbolic links or junction points will be fixed to be
853 * absolute relative to the actual extraction root. Done by default if
854 * WIM_HDR_FLAG_RP_FIX is set in the WIM header. This flag may only be
855 * specified when extracting a full image. */
856 #define WIMLIB_EXTRACT_FLAG_RPFIX 0x00000100
858 /** Force reparse-point fixups on extraction off, regardless of the state of the
859 * WIM_HDR_FLAG_RP_FIX flag in the WIM header. */
860 #define WIMLIB_EXTRACT_FLAG_NORPFIX 0x00000200
862 /** Extract files to standard output rather than to the filesystem. */
863 #define WIMLIB_EXTRACT_FLAG_TO_STDOUT 0x00000400
865 /** Instead of ignoring files and directories with names that cannot be
866 * represented on the current platform (note: Windows has more restrictions on
867 * filenames than UNIX), try to replace characters or append junk to the names
868 * so that they can be extracted in some form. */
869 #define WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES 0x00000800
871 /** On Windows, when there exist two or more files with the same case
872 * insensitive name but different case sensitive names, try to extract them all
873 * by appending junk to the end of them, rather than arbitrarily extracting only
875 #define WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS 0x00001000
877 /******************************
878 * WIMLIB_MOUNT_FLAG_*
879 ******************************/
881 /** Mount the WIM image read-write rather than the default of read-only. */
882 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
884 /** Enable FUSE debugging by passing the @c -d flag to @c fuse_main().*/
885 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
887 /** Do not allow accessing alternate data streams in the mounted WIM image. */
888 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
890 /** Access alternate data streams in the mounted WIM image through extended file
891 * attributes. This is the default mode. */
892 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
894 /** Access alternate data streams in the mounted WIM image by specifying the
895 * file name, a colon, then the alternate file stream name. */
896 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
898 /** Use UNIX file owners, groups, and modes if available in the WIM (see
899 * ::WIMLIB_ADD_FLAG_UNIX_DATA). */
900 #define WIMLIB_MOUNT_FLAG_UNIX_DATA 0x00000020
902 /** Allow other users to see the mounted filesystem. (this passes the @c
903 * allow_other option to FUSE mount) */
904 #define WIMLIB_MOUNT_FLAG_ALLOW_OTHER 0x00000040
906 /******************************
908 ******************************/
910 /** Verify the WIM contents against the WIM's integrity table, if present. This
911 * causes the raw data of the WIM file, divided into 10 MB chunks, to be
912 * checksummed and checked against the SHA1 message digests specified in the
913 * integrity table. WIMLIB_ERR_INTEGRITY is returned if there are any
915 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
917 /** Do not issue an error if the WIM is part of a split WIM. */
918 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x00000002
920 /** Check if the WIM is writable and return ::WIMLIB_ERR_WIM_IS_READONLY if it
921 * is not. A WIM is considered writable only if it is writable at the
922 * filesystem level, does not have the WIM_HDR_FLAG_READONLY flag set in its
923 * header, and is not part of a spanned set. It is not required to provide this
924 * flag to make changes to the WIM, but with this flag you get the error sooner
925 * rather than later. */
926 #define WIMLIB_OPEN_FLAG_WRITE_ACCESS 0x00000004
928 /******************************
929 * WIMLIB_UNMOUNT_FLAG_*
930 ******************************/
932 /** Include an integrity table in the WIM after it's been unmounted. Ignored
933 * for read-only mounts. */
934 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
936 /** Unless this flag is given, changes to a read-write mounted WIM are
937 * discarded. Ignored for read-only mounts. */
938 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
940 /** See ::WIMLIB_WRITE_FLAG_REBUILD */
941 #define WIMLIB_UNMOUNT_FLAG_REBUILD 0x00000004
943 /** See ::WIMLIB_WRITE_FLAG_RECOMPRESS */
944 #define WIMLIB_UNMOUNT_FLAG_RECOMPRESS 0x00000008
946 /** Do a "lazy" unmount (detach filesystem immediately, even if busy) */
947 #define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
949 /******************************
950 * WIMLIB_UPDATE_FLAG_*
951 ******************************/
953 /** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
954 * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
955 #define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
957 /******************************
958 * WIMLIB_WRITE_FLAG_*
959 ******************************/
961 /** Include an integrity table in the new WIM file. */
962 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
964 /** Re-build the entire WIM file rather than appending data to it, if possible.
965 * (Applies to wimlib_overwrite(), not wimlib_write()). */
966 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000002
968 /** Recompress all resources, even if they could otherwise be copied from a
969 * different WIM with the same compression type (in the case of
970 * wimlib_export_image() being called previously). */
971 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000004
973 /** Call fsync() when the WIM file is closed */
974 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000008
976 /* Specifying this flag overrides the default behavior of wimlib_overwrite()
977 * after one or more calls to wimlib_delete_image(), which is to rebuild the
980 * If you specifiy this flag to wimlib_overwrite(), only minimal changes to
981 * correctly remove the image from the WIM will be taken. In particular, all
982 * streams will be left alone, even if they are no longer referenced. This is
983 * probably not what you want, because almost no space will be spaced by
984 * deleting an image in this way. */
985 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000010
987 /** With wimlib_overwrite(), allow overwriting the WIM even if the readonly flag
988 * is set in the WIM header; this can be used in combination with
989 * wimlib_set_wim_info() with the ::WIMLIB_CHANGE_READONLY_FLAG flag to actually
990 * set the readonly flag on the on-disk WIM file. */
991 #define WIMLIB_WRITE_FLAG_IGNORE_READONLY_FLAG 0x00000020
993 /******************************
995 ******************************/
997 /** Assume that strings are represented in UTF-8, even if this is not the
998 * locale's character encoding. */
999 #define WIMLIB_INIT_FLAG_ASSUME_UTF8 0x00000001
1001 /** Specification of an update to perform on a WIM image. */
1002 struct wimlib_update_command {
1004 /** The specific type of update to perform. */
1005 enum wimlib_update_op {
1006 /** Add a new file or directory tree to the WIM image in a
1007 * certain location. */
1008 WIMLIB_UPDATE_OP_ADD = 0,
1010 /** Delete a file or directory tree from the WIM image. */
1011 WIMLIB_UPDATE_OP_DELETE,
1013 /** Rename a file or directory tree in the WIM image. */
1014 WIMLIB_UPDATE_OP_RENAME,
1017 /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
1018 struct wimlib_add_command {
1019 /** Filesystem path to the file or directory tree to
1021 wimlib_tchar *fs_source_path;
1022 /** Path, specified from the root of the WIM image, at
1023 * which to add the file or directory tree within the
1025 wimlib_tchar *wim_target_path;
1027 /** Configuration for excluded files. @c NULL means
1028 * exclude no files. */
1029 struct wimlib_capture_config *config;
1031 /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
1034 /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
1035 struct wimlib_delete_command {
1036 /** Path, specified from the root of the WIM image, for
1037 * the file or directory tree within the WIM image to be
1039 wimlib_tchar *wim_path;
1040 /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
1043 /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
1044 struct wimlib_rename_command {
1045 /** Path, specified from the root of the WIM image, for
1046 * the source file or directory tree within the WIM
1048 wimlib_tchar *wim_source_path;
1049 /** Path, specified from the root of the WIM image, for
1050 * the destination file or directory tree within the WIM
1052 wimlib_tchar *wim_target_path;
1053 /** Reserved; set to 0. */
1059 /** Specification of a file or directory tree to extract from a WIM image. */
1060 struct wimlib_extract_command {
1061 /** Path to file or directory tree within the WIM image to extract. It
1062 * must be provided as an absolute path from the root of the WIM image.
1063 * The path separators may be either forward slashes or backslashes. */
1064 wimlib_tchar *wim_source_path;
1066 /** Filesystem path to extract the file or directory tree to. */
1067 wimlib_tchar *fs_dest_path;
1069 /** Bitwise or of zero or more of the WIMLIB_EXTRACT_FLAG_* flags. */
1074 * Possible values of the error code returned by many functions in wimlib.
1076 * See the documentation for each wimlib function to see specifically what error
1077 * codes can be returned by a given function, and what they mean.
1079 enum wimlib_error_code {
1080 WIMLIB_ERR_SUCCESS = 0,
1081 WIMLIB_ERR_ALREADY_LOCKED,
1082 WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE,
1083 WIMLIB_ERR_DECOMPRESSION,
1084 WIMLIB_ERR_DELETE_STAGING_DIR,
1085 WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED,
1088 WIMLIB_ERR_FUSERMOUNT,
1089 WIMLIB_ERR_ICONV_NOT_AVAILABLE,
1090 WIMLIB_ERR_IMAGE_COUNT,
1091 WIMLIB_ERR_IMAGE_NAME_COLLISION,
1092 WIMLIB_ERR_INSUFFICIENT_PRIVILEGES_TO_EXTRACT,
1093 WIMLIB_ERR_INTEGRITY,
1094 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
1095 WIMLIB_ERR_INVALID_CHUNK_SIZE,
1096 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
1097 WIMLIB_ERR_INVALID_DENTRY,
1098 WIMLIB_ERR_INVALID_HEADER_SIZE,
1099 WIMLIB_ERR_INVALID_IMAGE,
1100 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
1101 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
1102 WIMLIB_ERR_INVALID_MULTIBYTE_STRING,
1103 WIMLIB_ERR_INVALID_OVERLAY,
1104 WIMLIB_ERR_INVALID_PARAM,
1105 WIMLIB_ERR_INVALID_PART_NUMBER,
1106 WIMLIB_ERR_INVALID_REPARSE_DATA,
1107 WIMLIB_ERR_INVALID_RESOURCE_HASH,
1108 WIMLIB_ERR_INVALID_RESOURCE_SIZE,
1109 WIMLIB_ERR_INVALID_SECURITY_DATA,
1110 WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE,
1111 WIMLIB_ERR_INVALID_UTF16_STRING,
1112 WIMLIB_ERR_INVALID_UTF8_STRING,
1113 WIMLIB_ERR_IS_DIRECTORY,
1114 WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE,
1120 WIMLIB_ERR_NOTEMPTY,
1121 WIMLIB_ERR_NOT_A_REGULAR_FILE,
1122 WIMLIB_ERR_NOT_A_WIM_FILE,
1123 WIMLIB_ERR_NO_FILENAME,
1127 WIMLIB_ERR_PATH_DOES_NOT_EXIST,
1129 WIMLIB_ERR_READLINK,
1132 WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED,
1133 WIMLIB_ERR_RESOURCE_ORDER,
1134 WIMLIB_ERR_SPECIAL_FILE,
1135 WIMLIB_ERR_SPLIT_INVALID,
1136 WIMLIB_ERR_SPLIT_UNSUPPORTED,
1139 WIMLIB_ERR_UNICODE_STRING_NOT_REPRESENTABLE,
1140 WIMLIB_ERR_UNKNOWN_VERSION,
1141 WIMLIB_ERR_UNSUPPORTED,
1142 WIMLIB_ERR_VOLUME_LACKS_FEATURES,
1145 WIMLIB_ERR_WIM_IS_READONLY,
1146 WIMLIB_ERR_RESOURCE_NOT_FOUND,
1150 /** Used to indicate no WIM image or an invalid WIM image. */
1151 #define WIMLIB_NO_IMAGE 0
1153 /** Used to specify all images in the WIM. */
1154 #define WIMLIB_ALL_IMAGES (-1)
1157 * Appends an empty image to a WIM file. This empty image will initially
1158 * contain no files or directories, although if written without further
1159 * modifications, a root directory will be created automatically for it.
1162 * Pointer to the ::WIMStruct for the WIM file to which the image is to be
1165 * Name to give the new image. If @c NULL or empty, the new image is given
1166 * no name. If nonempty, it must specify a name that does not already
1168 * @param new_idx_ret
1169 * If non-<code>NULL</code>, the index of the newly added image is returned
1172 * @return 0 on success; nonzero on failure. The possible error codes are:
1174 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1175 * There is already an image in @a wim named @a name.
1176 * @retval ::WIMLIB_ERR_NOMEM
1177 * Failed to allocate the memory needed to add the new image.
1178 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1179 * The WIM file is considered read-only because of any of the reasons
1180 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1184 wimlib_add_empty_image(WIMStruct *wim,
1185 const wimlib_tchar *name,
1189 * Adds an image to a WIM file from an on-disk directory tree or NTFS volume.
1191 * The directory tree or NTFS volume is scanned immediately to load the dentry
1192 * tree into memory, and file attributes and symbolic links are read. However,
1193 * actual file data is not read until wimlib_write() or wimlib_overwrite() is
1196 * See the manual page for the @b wimlib-imagex program for more information
1197 * about the "normal" capture mode versus the NTFS capture mode (entered by
1198 * providing the flag ::WIMLIB_ADD_FLAG_NTFS).
1200 * Note that @b no changes are committed to the underlying WIM file (if
1201 * any) until wimlib_write() or wimlib_overwrite() is called.
1204 * Pointer to the ::WIMStruct for a WIM file to which the image will be
1207 * A path to a directory or unmounted NTFS volume that will be captured as
1210 * Name to give the new image. If @c NULL or empty, the new image is given
1211 * no name. If nonempty, it must specify a name that does not already
1214 * Capture configuration that specifies files, directories, or path globs
1215 * to exclude from being captured. If @c NULL, a dummy configuration where
1216 * no paths are treated specially is used.
1218 * Bitwise OR of flags prefixed with WIMLIB_ADD_FLAG.
1219 * @param progress_func
1220 * If non-NULL, a function that will be called periodically with the
1221 * progress of the current operation.
1223 * @return 0 on success; nonzero on error. On error, changes to @a wim are
1224 * discarded so that it appears to be in the same state as when this function
1227 * This function is implemented by calling wimlib_add_empty_image(), then
1228 * calling wimlib_update_image() with a single "add" command, so any error code
1229 * returned by wimlib_add_empty_image() may be returned, as well as any error
1230 * codes returned by wimlib_update_image() other than ones documented as only
1231 * being returned specifically by an update involving delete or rename commands.
1234 wimlib_add_image(WIMStruct *wim,
1235 const wimlib_tchar *source,
1236 const wimlib_tchar *name,
1237 const struct wimlib_capture_config *config,
1239 wimlib_progress_func_t progress_func);
1241 /** This function is equivalent to wimlib_add_image() except it allows for
1242 * multiple sources to be combined into a single WIM image. This is done by
1243 * specifying the @a sources and @a num_sources parameters instead of the @a
1244 * source parameter of wimlib_add_image(). The rest of the parameters are the
1245 * same as wimlib_add_image(). See the documentation for <b>wimlib-imagex
1246 * capture</b> for full details on how this mode works.
1248 * In addition to the error codes that wimlib_add_image() can return,
1249 * wimlib_add_image_multisource() can return ::WIMLIB_ERR_INVALID_OVERLAY
1250 * when trying to overlay a non-directory on a directory or when otherwise
1251 * trying to overlay multiple conflicting files to the same location in the WIM
1252 * image. It will also return ::WIMLIB_ERR_INVALID_PARAM if
1253 * ::WIMLIB_ADD_FLAG_NTFS was specified in @a add_flags but there
1254 * was not exactly one capture source with the target being the root directory.
1255 * (In this respect, there is no advantage to using
1256 * wimlib_add_image_multisource() instead of wimlib_add_image() when requesting
1259 wimlib_add_image_multisource(WIMStruct *wim,
1260 const struct wimlib_capture_source *sources,
1262 const wimlib_tchar *name,
1263 const struct wimlib_capture_config *config,
1265 wimlib_progress_func_t progress_func);
1268 * Creates a ::WIMStruct for a new WIM file.
1270 * This only creates an in-memory structure for a WIM that initially contains no
1271 * images. No on-disk file is created until wimlib_write() is called.
1274 * The type of compression to be used in the new WIM file. Must be
1275 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
1276 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1278 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
1279 * written to the memory location pointed to by this paramater. The
1280 * ::WIMStruct must be freed using using wimlib_free() when finished with
1282 * @return 0 on success; nonzero on error.
1283 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1284 * @a ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
1285 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
1286 * @retval ::WIMLIB_ERR_NOMEM
1287 * Failed to allocate needed memory.
1290 wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
1293 * Deletes an image, or all images, from a WIM file.
1295 * All streams referenced by the image(s) being deleted are removed from the
1296 * lookup table of the WIM if they are not referenced by any other images in the
1299 * Please note that @b no changes are committed to the underlying WIM file (if
1300 * any) until wimlib_write() or wimlib_overwrite() is called.
1303 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
1306 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
1308 * @return 0 on success; nonzero on failure. On failure, @a wim is guaranteed
1309 * to be left unmodified only if @a image specified a single image. If instead
1310 * @a image was ::WIMLIB_ALL_IMAGES and @a wim contained more than one image, it's
1311 * possible for some but not all of the images to have been deleted when a
1312 * failure status is returned.
1314 * @retval ::WIMLIB_ERR_DECOMPRESSION
1315 * Could not decompress the metadata resource for @a image.
1316 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1317 * A directory entry in the metadata resource for @a image in the WIM is
1319 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1320 * @a image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
1321 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1322 * The metadata resource for @a image in the WIM is invalid.
1323 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1324 * The security data for @a image in the WIM is invalid.
1325 * @retval ::WIMLIB_ERR_NOMEM
1326 * Failed to allocate needed memory.
1327 * @retval ::WIMLIB_ERR_READ
1328 * Could not read the metadata resource for @a image from the WIM.
1329 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1330 * The WIM file is considered read-only because of any of the reasons
1331 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1335 wimlib_delete_image(WIMStruct *wim, int image);
1338 * Exports an image, or all the images, from a WIM file, into another WIM file.
1340 * The destination image is made to share the same dentry tree and security data
1341 * structure as the source image. This places some restrictions on additional
1342 * functions that may be called. wimlib_mount_image() may not be called on
1343 * either the source image or the destination image without an intervening call
1344 * to a function that un-shares the images, such as wimlib_free() on @a
1345 * dest_wim, or wimlib_delete_image() on either the source or destination image.
1346 * Furthermore, you may not call wimlib_free() on @a src_wim before calling
1347 * wimlib_write() or wimlib_overwrite() on @a dest_wim because @a dest_wim will
1348 * have references back to @a src_wim.
1350 * If this function fails, all changes to @a dest_wim are rolled back.
1352 * No changes shall be made to @a src_wim by this function.
1354 * Please note that no changes are committed to the underlying WIM file of @a
1355 * dest_wim (if any) until wimlib_write() or wimlib_overwrite() is called.
1358 * Pointer to the ::WIMStruct for a stand-alone WIM or part 1 of a split
1359 * WIM that contains the image(s) being exported.
1361 * The image to export from @a src_wim. Can be the number of an image, or
1362 * ::WIMLIB_ALL_IMAGES to export all images.
1364 * Pointer to the ::WIMStruct for a WIM file that will receive the images
1367 * The name to give the exported image in the new WIM file. If left @c
1368 * NULL, the name from @a src_wim is used. This parameter must be left @c
1369 * NULL if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains more
1370 * than one image; in that case, the names are all taken from the @a
1371 * src_wim. (This is allowed even if one or more images being exported has
1373 * @param dest_description
1374 * The description to give the exported image in the new WIM file. If left
1375 * @c NULL, the description from the @a src_wim is used. This parameter must
1376 * be left @c NULL if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains
1377 * more than one image; in that case, the descriptions are all taken from
1378 * @a src_wim. (This is allowed even if one or more images being exported
1379 * has no description.)
1380 * @param export_flags
1381 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
1382 * bootable, or 0 if which image is marked as bootable in the destination
1383 * WIM is to be left unchanged. If @a src_image is ::WIMLIB_ALL_IMAGES and
1384 * there are multiple images in @a src_wim, specifying
1385 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
1386 * currently marked as bootable in @a src_wim; if that is the case, then
1387 * that image is marked as bootable in the destination WIM.
1388 * @param additional_swms
1389 * Array of pointers to the ::WIMStruct for each additional part in the
1390 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1391 * need to be in any particular order, but they must include all parts of
1392 * the split WIM other than the first part, which must be provided in the
1394 * @param num_additional_swms
1395 * Number of additional WIM parts provided in the @a additional_swms array.
1396 * This number should be one less than the total number of parts in the
1397 * split WIM. Set to 0 if the WIM is a standalone WIM.
1398 * @param progress_func
1399 * If non-NULL, a function that will be called periodically with the
1400 * progress of the current operation.
1402 * @return 0 on success; nonzero on error.
1403 * @retval ::WIMLIB_ERR_DECOMPRESSION
1404 * Could not decompress the metadata resource for @a src_image
1406 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1407 * One or more of the names being given to an exported image was already in
1408 * use in the destination WIM.
1409 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1410 * A directory entry in the metadata resource for @a src_image in @a
1411 * src_wim is invalid.
1412 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1413 * @a src_image does not exist in @a src_wim.
1414 * @retval ::WIMLIB_ERR_INVALID_PARAM
1415 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
1416 * ::WIMLIB_ALL_IMAGES, @a src_wim contains multiple images, and no images in
1417 * @a src_wim are marked as bootable; or @a dest_name and/or @a
1418 * dest_description were non-<code>NULL</code>, @a src_image was
1419 * ::WIMLIB_ALL_IMAGES, and @a src_wim contains multiple images.
1420 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1421 * The metadata resource for @a src_image in @a src_wim is invalid.
1422 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1423 * The security data for @a src_image in @a src_wim is invalid.
1424 * @retval ::WIMLIB_ERR_NOMEM
1425 * Failed to allocate needed memory.
1426 * @retval ::WIMLIB_ERR_READ
1427 * Could not read the metadata resource for @a src_image from @a src_wim.
1428 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1429 * The source WIM is a split WIM, but the parts specified do not form a
1430 * complete split WIM because they do not include all the parts of the
1431 * original WIM, there are duplicate parts, or not all the parts have the
1432 * same GUID and compression type.
1433 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
1434 * @a dest_wim is considered read-only because of any of the reasons
1435 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
1439 wimlib_export_image(WIMStruct *src_wim, int src_image,
1440 WIMStruct *dest_wim,
1441 const wimlib_tchar *dest_name,
1442 const wimlib_tchar *dest_description,
1444 WIMStruct **additional_swms,
1445 unsigned num_additional_swms,
1446 wimlib_progress_func_t progress_func);
1449 * Extract zero or more files or directory trees from a WIM image.
1451 * This generalizes the single-image extraction functionality of
1452 * wimlib_extract_image() to allow extracting only the specified subsets of the
1456 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1460 * The 1-based number of the image in @a wim from which the files or
1461 * directory trees are to be extracted. It cannot be ::WIMLIB_ALL_IMAGES.
1464 * An array of ::wimlib_extract_command structures that specifies the
1465 * extractions to perform.
1468 * Number of commands in the @a cmds array.
1470 * @param default_extract_flags
1471 * Default extraction flags; the behavior shall be as if these flags had
1472 * been specified in the ::wimlib_extract_command.extract_flags member in
1473 * each extraction command, in combination with any flags already present.
1475 * @param additional_swms
1476 * Array of pointers to the ::WIMStruct for each additional part in the
1477 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1478 * need to be in any particular order, but they must include all parts of
1479 * the split WIM other than the first part, which must be provided in the
1482 * @param num_additional_swms
1483 * Number of additional WIM parts provided in the @a additional_swms array.
1484 * This number should be one less than the total number of parts in the
1485 * split WIM. Set to 0 if the WIM is a standalone WIM.
1487 * @param progress_func
1488 * If non-NULL, a function that will be called periodically with the
1489 * progress of the current operation.
1491 * @return 0 on success; nonzero on error. The possible error codes include
1492 * those documented as returned by wimlib_extract_image() as well as the
1493 * following additional error codes:
1495 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
1496 * The ::wimlib_extract_command.wim_source_path member in one of the
1497 * extract commands did not exist in the WIM.
1498 * @retval ::WIMLIB_ERR_NOT_A_REGULAR_FILE
1499 * ::WIMLIB_EXTRACT_FLAG_TO_STDOUT was specified for an extraction command
1500 * in which ::wimlib_extract_command.wim_source_path existed but was not a
1501 * regular file or directory.
1502 * @retval ::WIMLIB_ERR_INVALID_PARAM
1503 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK was
1504 * specified for some commands but not all; or
1505 * ::wimlib_extract_command.fs_dest_path was @c NULL or the empty string
1506 * for one or more commands; or ::WIMLIB_EXTRACT_FLAG_RPFIX was specified
1507 * for a command in which ::wimlib_extract_command.wim_source_path did not
1508 * specify the root directory of the WIM image.
1511 wimlib_extract_files(WIMStruct *wim,
1513 const struct wimlib_extract_command *cmds,
1515 int default_extract_flags,
1516 WIMStruct **additional_swms,
1517 unsigned num_additional_swms,
1518 wimlib_progress_func_t progress_func);
1521 * Extracts an image, or all images, from a standalone or split WIM file to a
1522 * directory or a NTFS volume.
1524 * Please see the manual page for the @c wimlib-imagex program for more
1525 * information about the "normal" extraction mode versus the NTFS extraction
1526 * mode (entered by providing flag ::WIMLIB_EXTRACT_FLAG_NTFS).
1528 * Extraction is done with one thread.
1530 * All extracted data is SHA1-summed, and ::WIMLIB_ERR_INVALID_RESOURCE_HASH is
1531 * returned if any resulting SHA1 message digests do not match the values
1532 * provided in the WIM file. Therefore, if this function is successful, you can
1533 * be fairly sure that any compressed data in the WIM was uncompressed
1537 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
1540 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
1541 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
1542 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @a extract_flags.
1544 * Directory to extract the WIM image(s) to (created if it does not already
1545 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @a extract_flags, the
1546 * path to the unmounted NTFS volume to extract the image to.
1547 * @param extract_flags
1548 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
1550 * If ::WIMLIB_EXTRACT_FLAG_NTFS is specified, @a target is interpreted as
1551 * a NTFS volume to extract the image to. The volume will be opened using
1552 * NTFS-3g and the image will be extracted to the root of the NTFS volume.
1553 * Otherwise, @a target is interpreted as a directory to extract the
1556 * If ::WIMLIB_EXTRACT_FLAG_NTFS is not specified, one or none of
1557 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK may be
1558 * specified. These flags cause extracted files that are identical to be
1559 * hardlinked or symlinked together, depending on the flag. These flags
1560 * override the hard link groups that are specified in the WIM file itself.
1561 * If ::WIMLIB_ALL_IMAGES is provided as the @a image parameter, files may be
1562 * hardlinked or symlinked across images if a file is found to occur in
1563 * more than one image.
1565 * You may also specify the flag ::WIMLIB_EXTRACT_FLAG_VERBOSE to print the
1566 * name of each file or directory as it is extracted.
1568 * If ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is specified, data is read from the
1569 * WIM sequentially, if possible. If ::WIMLIB_ALL_IMAGES is specified,
1570 * each image is considered separately with regards to the sequential
1571 * order. It is also possible for alternate data streams to break the
1572 * sequential order (this only applies if ::WIMLIB_EXTRACT_FLAG_NTFS is
1574 * @param additional_swms
1575 * Array of pointers to the ::WIMStruct for each additional part in the
1576 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1577 * need to be in any particular order, but they must include all parts of
1578 * the split WIM other than the first part, which must be provided in the
1580 * @param num_additional_swms
1581 * Number of additional WIM parts provided in the @a additional_swms array.
1582 * This number should be one less than the total number of parts in the
1583 * split WIM. Set to 0 if the WIM is a standalone WIM.
1585 * @param progress_func
1586 * If non-NULL, a function that will be called periodically with the
1587 * progress of the current operation.
1589 * @return 0 on success; nonzero on error.
1590 * @retval ::WIMLIB_ERR_DECOMPRESSION
1591 * Could not decompress a resource (file or metadata) for @a image in @a
1593 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1594 * A directory entry in the metadata resource for @a image in @a wim is
1596 * @retval ::WIMLIB_ERR_INVALID_PARAM
1597 * @a target was @c NULL, or both ::WIMLIB_EXTRACT_FLAG_HARDLINK and
1598 * ::WIMLIB_EXTRACT_FLAG_SYMLINK were specified in @a extract_flags; or
1599 * both ::WIMLIB_EXTRACT_FLAG_NTFS and either
1600 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK were
1601 * specified in @a extract_flags; or ::WIMLIB_EXTRACT_FLAG_NTFS was
1602 * specified in @a extract_flags and @a image was ::WIMLIB_ALL_IMAGES; or
1603 * both ::WIMLIB_EXTRACT_FLAG_NTFS and ::WIMLIB_EXTRACT_FLAG_UNIX_DATA were
1604 * specified in @a extract_flag.
1605 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
1606 * The SHA1 message digest of an extracted stream did not match the SHA1
1607 * message digest given in the WIM file.
1608 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1609 * A resource (file or metadata) for @a image in @a wim is invalid.
1610 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1611 * The security data for @a image in @a wim is invalid.
1612 * @retval ::WIMLIB_ERR_LINK
1613 * Failed to create a symbolic link or a hard link (only if
1614 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1615 * @retval ::WIMLIB_ERR_MKDIR
1616 * Failed create a needed directory (only if ::WIMLIB_EXTRACT_FLAG_NTFS was
1617 * not specified in @a extract_flags).
1618 * @retval ::WIMLIB_ERR_NOMEM
1619 * Failed to allocate needed memory.
1620 * @retval ::WIMLIB_ERR_NTFS_3G
1621 * An error was returned from a libntfs-3g function while the WIM image was
1622 * being extracted to the NTFS volume (only if ::WIMLIB_EXTRACT_FLAG_NTFS
1623 * was specified in @a extract_flags).
1624 * @retval ::WIMLIB_ERR_OPEN
1625 * Could not open one of the files being extracted for writing (only if
1626 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1627 * @retval ::WIMLIB_ERR_READ
1628 * A unexpected end-of-file or read error occurred when trying to read data
1629 * from the WIM file associated with @a wim.
1630 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
1631 * One of the dentries in the image referenced a stream not present in the
1632 * WIM's lookup table (or in any of the lookup tables of the split WIM
1634 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1635 * The WIM is a split WIM, but the parts specified do not form a complete
1636 * split WIM because they do not include all the parts of the original WIM,
1637 * there are duplicate parts, or not all the parts have the same GUID and
1639 * @retval ::WIMLIB_ERR_UNSUPPORTED
1640 * ::WIMLIB_EXTRACT_FLAG_NTFS was specified in @a extract_flags, but wimlib
1641 * was configured with the @c --without-ntfs-3g flag.
1642 * @retval ::WIMLIB_ERR_WRITE
1643 * Failed to write a file being extracted (only if
1644 * ::WIMLIB_EXTRACT_FLAG_NTFS was not specified in @a extract_flags).
1647 wimlib_extract_image(WIMStruct *wim, int image,
1648 const wimlib_tchar *target,
1650 WIMStruct **additional_swms,
1651 unsigned num_additional_swms,
1652 wimlib_progress_func_t progress_func);
1655 * Extracts the XML data of a WIM file to a file stream. Every WIM file
1656 * includes a string of XML that describes the images contained in the WIM.
1657 * This function works on standalone WIMs as well as split WIM parts.
1660 * Pointer to the ::WIMStruct for a WIM file.
1662 * @c stdout, or a FILE* opened for writing, to extract the data to.
1664 * @return 0 on success; nonzero on error.
1665 * @retval ::WIMLIB_ERR_INVALID_PARAM
1666 * @a wim is not a ::WIMStruct that was created by wimlib_open_wim().
1667 * @retval ::WIMLIB_ERR_NOMEM
1668 * Failed to allocate needed memory.
1669 * @retval ::WIMLIB_ERR_READ
1670 * Failed to read the XML data from the WIM.
1671 * @retval ::WIMLIB_ERR_WRITE
1672 * Failed to completely write the XML data to @a fp.
1675 wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
1678 * Frees all memory allocated for a WIMStruct and closes all files associated
1682 * Pointer to the ::WIMStruct for a WIM file.
1684 * @return This function has no return value.
1687 wimlib_free(WIMStruct *wim);
1690 * Deprecated in favor of wimlib_get_wim_info().
1693 wimlib_get_boot_idx(const WIMStruct *wim) _wimlib_deprecated;
1696 * Deprecated in favor of wimlib_get_wim_info().
1699 wimlib_get_compression_type(const WIMStruct *wim) _wimlib_deprecated;
1702 * Converts a ::wimlib_compression_type value into a string.
1705 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
1706 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
1709 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
1712 extern const wimlib_tchar *
1713 wimlib_get_compression_type_string(int ctype);
1716 * Converts an error code into a string describing it.
1719 * The error code returned by one of wimlib's functions.
1722 * Pointer to a statically allocated string describing the error code,
1723 * or @c NULL if the error code is not valid.
1725 extern const wimlib_tchar *
1726 wimlib_get_error_string(enum wimlib_error_code code);
1729 * Returns the description of the specified image.
1732 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1733 * standalone WIM or a split WIM part.
1735 * The number of the image, numbered starting at 1.
1738 * The description of the image, or @c NULL if there is no such image, or
1739 * @c NULL if the specified image has no description. The description
1740 * string is in library-internal memory and may not be modified or freed;
1741 * in addition, the string will become invalid if the description of the
1742 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
1744 extern const wimlib_tchar *
1745 wimlib_get_image_description(const WIMStruct *wim, int image);
1748 * Returns the name of the specified image.
1751 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1752 * standalone WIM or a split WIM part.
1754 * The number of the image, numbered starting at 1.
1757 * The name of the image, or @c NULL if there is no such image. The name
1758 * string is in library-internal memory and may not be modified or freed;
1759 * in addition, the string will become invalid if the name of the image is
1760 * changed, the image is deleted, or the ::WIMStruct is destroyed.
1762 * If @a wim was read with wimlib_open_wim(), it is allowed for image(s) in
1763 * the WIM to be unnamed, in which case an empty string will be returned
1764 * when the corresponding name is requested.
1766 extern const wimlib_tchar *
1767 wimlib_get_image_name(const WIMStruct *wim, int image);
1771 * Deprecated in favor of wimlib_get_wim_info().
1774 wimlib_get_num_images(const WIMStruct *wim) _wimlib_deprecated;
1777 * Deprecated in favor of wimlib_get_wim_info().
1780 wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret) _wimlib_deprecated;
1783 * Get basic information about a WIM file.
1786 * Pointer to the ::WIMStruct for a WIM file. It may be for either a
1787 * standalone WIM or part of a split WIM.
1789 * A ::wimlib_wim_info structure that will be filled in with information
1790 * about the WIM file.
1795 wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info);
1798 * Initialization function for wimlib. Call before using any other wimlib
1802 * On UNIX, specify ::WIMLIB_INIT_FLAG_ASSUME_UTF8 if wimlib should assume
1803 * that all input data, including filenames, are in UTF-8 rather than the
1804 * locale-dependent character encoding which may or may not be UTF-8, and
1805 * that UTF-8 data can be directly printed to the console. On Windows, use
1806 * 0 for this parameter.
1808 * @return 0; other error codes may be returned in future releases.
1811 wimlib_global_init(int init_flags);
1814 * Since wimlib 1.2.6: Cleanup function for wimlib. This is not re-entrant.
1815 * You are not required to call this function, but it will release any global
1816 * memory allocated by the library.
1819 wimlib_global_cleanup(void);
1822 * Deprecated in favor of wimlib_get_wim_info().
1825 wimlib_has_integrity_table(const WIMStruct *wim) _wimlib_deprecated;
1828 * Determines if an image name is already used by some image in the WIM.
1831 * Pointer to the ::WIMStruct for a WIM file.
1833 * The name to check.
1836 * @c true if there is already an image in @a wim named @a name; @c false
1837 * if there is no image named @a name in @a wim. If @a name is @c NULL or
1838 * the empty string, @c false is returned.
1841 wimlib_image_name_in_use(const WIMStruct *wim, const wimlib_tchar *name);
1844 * Joins a split WIM into a stand-alone one-part WIM.
1847 * An array of strings that gives the filenames of all parts of the split
1848 * WIM. No specific order is required, but all parts must be included with
1851 * Number of filenames in @a swms.
1852 * @param swm_open_flags
1853 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY if the integrity of each split WIM
1854 * part should be verified, if integrity tables are present. Otherwise,
1856 * @param wim_write_flags
1857 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY, and/or ::WIMLIB_WRITE_FLAG_FSYNC.
1858 * @param output_path
1859 * The path to write the one-part WIM to.
1860 * @param progress_func
1861 * If non-NULL, a function that will be called periodically with the
1862 * progress of the current operation.
1864 * @return 0 on success; nonzero on error. This function may return any value
1865 * returned by wimlib_open_wim() and wimlib_write() except
1866 * ::WIMLIB_ERR_WIM_IS_READONLY, as well as the following error code:
1868 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1869 * The split WIMs do not form a valid WIM because they do not include all
1870 * the parts of the original WIM, there are duplicate parts, or not all the
1871 * parts have the same GUID and compression type.
1873 * Note: the WIM's uncompressed and compressed resources are not checksummed
1874 * when they are copied from the split WIM parts to the joined WIM, nor are
1875 * compressed resources re-compressed.
1877 * Note: wimlib_export_image() can provide similar functionality to
1878 * wimlib_join(), since it is possible to export all images from a split WIM.
1881 wimlib_join(const wimlib_tchar * const *swms,
1883 const wimlib_tchar *output_path,
1885 int wim_write_flags,
1886 wimlib_progress_func_t progress_func);
1889 * Compress a chunk of a WIM resource using LZX compression.
1891 * This function is exported for convenience only and need not be used.
1894 * Uncompressed data of the chunk.
1896 * Size of the uncompressed chunk, in bytes.
1898 * Pointer to output buffer of size at least (@a chunk_size - 1) bytes.
1901 * The size of the compressed data written to @a out in bytes, or 0 if the
1902 * data could not be compressed to (@a chunk_size - 1) bytes or fewer.
1904 * As a special requirement, the compression code is optimized for the WIM
1905 * format and therefore requires (@a chunk_size <= 32768).
1908 wimlib_lzx_compress(const void *chunk, unsigned chunk_size, void *out);
1911 * Decompresses a block of LZX-compressed data as used in the WIM file format.
1913 * Note that this will NOT work unmodified for LZX as used in the cabinet
1914 * format, which is not the same as in the WIM format!
1916 * This function is exported for convenience only and need not be used.
1918 * @param compressed_data
1919 * Pointer to the compressed data.
1921 * @param compressed_len
1922 * Length of the compressed data, in bytes.
1924 * @param uncompressed_data
1925 * Pointer to the buffer into which to write the uncompressed data.
1927 * @param uncompressed_len
1928 * Length of the uncompressed data. It must be 32768 bytes or less.
1931 * 0 on success; non-zero on failure.
1934 wimlib_lzx_decompress(const void *compressed_data, unsigned compressed_len,
1935 void *uncompressed_data, unsigned uncompressed_len);
1939 * Mounts an image in a WIM file on a directory read-only or read-write.
1941 * This is not supported on Windows.
1943 * Unless ::WIMLIB_MOUNT_FLAG_DEBUG is specified or an early error occurs, the
1944 * process will be daemonized.
1946 * If the mount is read-write (::WIMLIB_MOUNT_FLAG_READWRITE specified),
1947 * modifications to the WIM are staged in a temporary directory.
1949 * It is safe to mount multiple images from the same WIM file read-only at the
1950 * same time, but only if different ::WIMStruct's are used. It is @b not safe
1951 * to mount multiple images from the same WIM file read-write at the same time.
1953 * wimlib_mount_image() cannot be used on an image that was exported with
1954 * wimlib_export_image() while the dentry trees for both images are still in
1955 * memory. In addition, wimlib_mount_image() may not be used to mount an image
1956 * that has just been added with wimlib_add_image(), unless the WIM has been
1957 * written and read into a new ::WIMStruct.
1960 * Pointer to the ::WIMStruct containing the image to be mounted.
1962 * The number of the image to mount, indexed starting from it. It must be
1963 * an existing, single image.
1965 * The path to an existing empty directory to mount the image on.
1966 * @param mount_flags
1967 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG.
1969 * If ::WIMLIB_MOUNT_FLAG_READWRITE is given, the WIM is mounted read-write
1970 * rather than the default of read-only.
1972 * WIMs may contain named (alternate) data streams, which are a somewhat
1973 * obscure NTFS feature. They can be read and written on a mounted WIM
1974 * through one of several interfaces. The interface to use if specified by
1975 * exactly one of ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE,
1976 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR, or
1977 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS. The default interface is
1978 * the XATTR interface.
1979 * @param additional_swms
1980 * Array of pointers to the ::WIMStruct for each additional part in the
1981 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1982 * need to be in any particular order, but they must include all parts of
1983 * the split WIM other than the first part, which must be provided in the
1985 * @param num_additional_swms
1986 * Number of additional WIM parts provided in the @a additional_swms array.
1987 * This number should be one less than the total number of parts in the
1988 * split WIM. Set to 0 if the WIM is a standalone WIM.
1989 * @param staging_dir
1990 * If non-NULL, the name of a directory in which the staging directory will
1991 * be created. Ignored if ::WIMLIB_MOUNT_FLAG_READWRITE is not specified
1992 * in @a mount_flags. If left @c NULL, the staging directory is created in
1993 * the same directory as the WIM file that @a wim was originally read from.
1995 * @return 0 on success; nonzero on error.
1997 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
1998 * A read-write mount was requested, but an an exclusive advisory lock on
1999 * the on-disk WIM file could not be acquired because another thread or
2000 * process has mounted an image from the WIM read-write or is currently
2001 * modifying the WIM in-place.
2002 * @retval ::WIMLIB_ERR_DECOMPRESSION
2003 * Could not decompress the metadata resource for @a image in @a wim.
2004 * @retval ::WIMLIB_ERR_FUSE
2005 * A non-zero status was returned by @c fuse_main().
2006 * @retval ::WIMLIB_ERR_INVALID_DENTRY
2007 * A directory entry in the metadata resource for @a image in @a wim is
2009 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2010 * @a image does not specify an existing, single image in @a wim.
2011 * @retval ::WIMLIB_ERR_INVALID_PARAM
2012 * @a image is shared among multiple ::WIMStruct's as a result of a call to
2013 * wimlib_export_image(), or @a image has been added with
2014 * wimlib_add_image().
2015 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2016 * The metadata resource for @a image in @a wim is invalid.
2017 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2018 * The security data for @a image in @a wim is invalid.
2019 * @retval ::WIMLIB_ERR_MKDIR
2020 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a mount_flags, but the
2021 * staging directory could not be created.
2022 * @retval ::WIMLIB_ERR_NOMEM
2023 * Failed to allocate needed memory.
2024 * @retval ::WIMLIB_ERR_NOTDIR
2025 * Could not determine the current working directory.
2026 * @retval ::WIMLIB_ERR_READ
2027 * An unexpected end-of-file or read error occurred when trying to read
2028 * data from the WIM file associated with @a wim.
2029 * @retval ::WIMLIB_ERR_RESOURCE_NOT_FOUND
2030 * One of the dentries in the image referenced a stream not present in the
2031 * WIM's lookup table (or in any of the lookup tables of the split WIM
2033 * @retval ::WIMLIB_ERR_SPLIT_INVALID
2034 * The WIM is a split WIM, but the parts specified do not form a complete
2035 * split WIM because they do not include all the parts of the original WIM,
2036 * there are duplicate parts, or not all the parts have the same GUID and
2038 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2039 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a mount_flags, but @a
2040 * wim is considered read-only because of any of the reasons mentioned in
2041 * the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2042 * @retval ::WIMLIB_ERR_UNSUPPORTED
2043 * Mounting is not supported, either because the platform is Windows, or
2044 * because the platform is UNIX and wimlib was compiled with @c
2048 wimlib_mount_image(WIMStruct *wim,
2050 const wimlib_tchar *dir,
2052 WIMStruct **additional_swms,
2053 unsigned num_additional_swms,
2054 const wimlib_tchar *staging_dir);
2057 * Opens a WIM file and creates a ::WIMStruct for it.
2060 * The path to the WIM file to open.
2062 * Bitwise OR of flags ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
2063 * ::WIMLIB_OPEN_FLAG_SPLIT_OK and/or ::WIMLIB_OPEN_FLAG_WRITE_ACCESS.
2065 * @param progress_func
2066 * If non-NULL, a function that will be called periodically with the
2067 * progress of the current operation.
2070 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
2071 * is written to the memory location pointed to by this parameter. The
2072 * ::WIMStruct must be freed using using wimlib_free() when finished with
2075 * @return 0 on success; nonzero on error.
2076 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
2077 * The lookup table of @a wim_file is compressed. Support for this can be
2078 * added to wimlib if needed, but it appears to be the case that the lookup
2079 * table is never compressed.
2080 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2081 * The WIM is not the non-first part of a split WIM, and the number of
2082 * metadata resources found in the WIM did not match the image count given
2083 * in the WIM header, or the number of <IMAGE> elements in the XML
2084 * data for the WIM did not match the image count given in the WIM header.
2085 * @retval ::WIMLIB_ERR_INTEGRITY
2086 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
2087 * wim_file contains an integrity table, but the SHA1 message digest for a
2088 * chunk of the WIM does not match the corresponding message digest given
2089 * in the integrity table.
2090 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
2091 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
2092 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
2093 * The header of @a wim_file says that resources in the WIM are compressed,
2094 * but the header flag indicating LZX or XPRESS compression is not set.
2095 * @retval ::WIMLIB_ERR_INVALID_HEADER_SIZE
2096 * The length field of the WIM header is not 208.
2097 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
2098 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
2099 * wim_file contains an integrity table, but the integrity table is
2101 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
2102 * The lookup table for the WIM contained duplicate entries that are not
2103 * for metadata resources, or it contained an entry with a SHA1 message
2104 * digest of all 0's.
2105 * @retval ::WIMLIB_ERR_NOMEM
2106 * Failed to allocated needed memory.
2107 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
2108 * @a wim_file does not begin with the expected magic characters.
2109 * @retval ::WIMLIB_ERR_OPEN
2110 * Failed to open the file @a wim_file for reading.
2111 * @retval ::WIMLIB_ERR_READ
2112 * An unexpected end-of-file or read error occurred when trying to read
2113 * data from @a wim_file.
2114 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2115 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
2116 * specified in @a open_flags.
2117 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
2118 * A number other than 0x10d00 is written in the version field of the WIM
2119 * header of @a wim_file. (Probably a pre-Vista WIM).
2120 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2121 * ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
2122 * considered read-only because of any of the reasons mentioned in the
2123 * documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2124 * @retval ::WIMLIB_ERR_XML
2125 * The XML data for @a wim_file is invalid.
2128 wimlib_open_wim(const wimlib_tchar *wim_file,
2130 WIMStruct **wim_ret,
2131 wimlib_progress_func_t progress_func);
2134 * Overwrites the file that the WIM was originally read from, with changes made.
2135 * This only makes sense for ::WIMStruct's obtained from wimlib_open_wim()
2136 * rather than wimlib_create_new_wim().
2138 * There are two ways that a WIM may be overwritten. The first is to do a full
2139 * rebuild. In this mode, the new WIM is written to a temporary file and then
2140 * renamed to the original file after it is has been completely written. The
2141 * temporary file is made in the same directory as the original WIM file. A
2142 * full rebuild may take a while, but can be used even if images have been
2143 * modified or deleted, will produce a WIM with no holes, and has little chance
2144 * of unintentional data loss because the temporary WIM is fsync()ed before
2145 * being renamed to the original WIM.
2147 * The second way to overwrite a WIM is by appending to the end of it and
2148 * overwriting the header. This can be much faster than a full rebuild, but the
2149 * disadvantage is that some space will be wasted. Writing a WIM in this mode
2150 * begins with writing any new file resources *after* everything in the old WIM,
2151 * even though this will leave a hole where the old lookup table, XML data, and
2152 * integrity were. This is done so that the WIM remains valid even if the
2153 * operation is aborted mid-write. The WIM header is only overwritten at the
2154 * very last moment, and up until that point the WIM will be seen as the old
2157 * By default, wimlib_overwrite() does the append-style overwrite described
2158 * above, unless resources in the WIM are arranged in an unusual way or if
2159 * images have been deleted from the WIM. Use the flag
2160 * ::WIMLIB_WRITE_FLAG_REBUILD to explicitly request a full rebuild, and use the
2161 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE to request the in-place overwrite even if
2162 * images have been deleted from the WIM.
2164 * In the temporary-file overwrite mode, no changes are made to the WIM on
2165 * failure, and the temporary file is deleted if possible. Abnormal termination
2166 * of the program will result in the temporary file being orphaned. In the
2167 * direct append mode, the WIM is truncated to the original length on failure;
2168 * and while abnormal termination of the program will result in extra data
2169 * appended to the original WIM, it should still be a valid WIM.
2171 * If this function completes successfully, no more functions should be called
2172 * on @a wim other than wimlib_free(). You must use wimlib_open_wim() to read
2173 * the WIM file anew.
2176 * Pointer to the ::WIMStruct for the WIM file to write. There may have
2177 * been in-memory changes made to it, which are then reflected in the
2179 * @param write_flags
2180 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY,
2181 * ::WIMLIB_WRITE_FLAG_REBUILD, ::WIMLIB_WRITE_FLAG_RECOMPRESS, and/or
2182 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE.
2183 * @param num_threads
2184 * Number of threads to use for compression (see wimlib_write()).
2185 * @param progress_func
2186 * If non-NULL, a function that will be called periodically with the
2187 * progress of the current operation.
2189 * @return 0 on success; nonzero on error. This function may return any value
2190 * returned by wimlib_write() as well as the following error codes:
2191 * @retval ::WIMLIB_ERR_ALREADY_LOCKED
2192 * The WIM was going to be modified in-place (with no temporary file), but
2193 * an exclusive advisory lock on the on-disk WIM file could not be acquired
2194 * because another thread or process has mounted an image from the WIM
2195 * read-write or is currently modifying the WIM in-place.
2196 * @retval ::WIMLIB_ERR_NO_FILENAME
2197 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
2198 * than a WIM read with wimlib_open_wim().
2199 * @retval ::WIMLIB_ERR_RENAME
2200 * The temporary file that the WIM was written to could not be renamed to
2201 * the original filename of @a wim.
2202 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2203 * The WIM file is considered read-only because of any of the reasons
2204 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2208 wimlib_overwrite(WIMStruct *wim, int write_flags, unsigned num_threads,
2209 wimlib_progress_func_t progress_func);
2212 * Prints information about one image, or all images, contained in a WIM.
2215 * Pointer to the ::WIMStruct for a WIM file.
2217 * The image about which to print information. Can be the number of an
2218 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
2221 * @return This function has no return value. No error checking is done when
2222 * printing the information. If @a image is invalid, an error message is
2226 wimlib_print_available_images(const WIMStruct *wim, int image);
2228 /** TODO: wimlib-imagex uses this for the 'dir' command, but a better API is
2229 * needed for this. */
2231 wimlib_print_files(WIMStruct *wim, int image);
2233 /** TODO: wimlib-imagex uses this for the 'info --header' command, but a better
2234 * API is needed for this. */
2236 wimlib_print_header(const WIMStruct *wim);
2238 /** TODO: wimlib-imagex uses this for the 'info --lookup-table' command, but a
2239 * better API is needed for this. */
2241 wimlib_print_lookup_table(WIMStruct *wim);
2243 /** TODO: wimlib-imagex uses this for the 'info --metadata' command, but a
2244 * better API is needed for this. */
2246 wimlib_print_metadata(WIMStruct *wim, int image);
2249 * Deprecated in favor of wimlib_get_wim_info(), which provides the information
2250 * in a way that can be accessed programatically.
2253 wimlib_print_wim_information(const WIMStruct *wim) _wimlib_deprecated;
2256 * Translates a string specifying the name or number of an image in the WIM into
2257 * the number of the image. The images are numbered starting at 1.
2260 * Pointer to the ::WIMStruct for a WIM file.
2261 * @param image_name_or_num
2262 * A string specifying the name or number of an image in the WIM. If it
2263 * parses to a positive integer, this integer is taken to specify the
2264 * number of the image, indexed starting at 1. Otherwise, it is taken to
2265 * be the name of an image, as given in the XML data for the WIM file. It
2266 * also may be the keyword "all" or the string "*", both of which will
2267 * resolve to ::WIMLIB_ALL_IMAGES.
2269 * There is no way to search for an image actually named "all", "*", or an
2270 * integer number, or an image that has no name. However, you can use
2271 * wimlib_get_image_name() to get the name of any image.
2274 * If the string resolved to a single existing image, the number of that
2275 * image, indexed starting at 1, is returned. If the keyword "all" or "*"
2276 * was specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise,
2277 * ::WIMLIB_NO_IMAGE is returned. If @a image_name_or_num was @c NULL or
2278 * the empty string, ::WIMLIB_NO_IMAGE is returned, even if one or more
2279 * images in @a wim has no name.
2282 wimlib_resolve_image(WIMStruct *wim,
2283 const wimlib_tchar *image_name_or_num);
2286 * Deprecated in favor of wimlib_set_wim_info().
2289 wimlib_set_boot_idx(WIMStruct *wim, int boot_idx) _wimlib_deprecated;
2292 * Changes the description of an image in the WIM.
2295 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2296 * standalone WIM or part of a split WIM; however, you should set the same
2297 * description on all parts of a split WIM.
2299 * The number of the image for which to change the description.
2300 * @param description
2301 * The new description to give the image. It may be @c NULL, which
2302 * indicates that the image is to be given no description.
2304 * @return 0 on success; nonzero on error.
2305 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2306 * @a image does not specify a single existing image in @a wim.
2307 * @retval ::WIMLIB_ERR_NOMEM
2308 * Failed to allocate the memory needed to duplicate the @a description
2310 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2311 * @a wim is considered read-only because of any of the reasons mentioned
2312 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2315 wimlib_set_image_descripton(WIMStruct *wim, int image,
2316 const wimlib_tchar *description);
2319 * Set basic information about a WIM.
2322 * A WIMStruct for a standalone WIM file.
2324 * A struct ::wimlib_wim_info that contains the information to set. Only
2325 * the information explicitly specified in the @a which flags need be
2328 * Flags that specify which information to set. This is a bitwise OR of
2329 * ::WIMLIB_CHANGE_READONLY_FLAG, ::WIMLIB_CHANGE_GUID,
2330 * ::WIMLIB_CHANGE_BOOT_INDEX, and/or ::WIMLIB_CHANGE_RPFIX_FLAG.
2332 * @return 0 on success; nonzero on failure.
2333 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2334 * The WIM file is considered read-only because of any of the reasons
2335 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2336 * flag. However, as a special case, if you are using
2337 * ::WIMLIB_CHANGE_READONLY_FLAG to unset the readonly flag, then this
2338 * function will not fail due to the readonly flag being previously set.
2339 * @retval ::WIMLIB_ERR_IMAGE_COUNT
2340 * ::WIMLIB_CHANGE_BOOT_INDEX was specified, but
2341 * ::wimlib_wim_info.boot_index did not specify 0 or a valid 1-based image
2345 wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info,
2349 * Changes what is written in the \<FLAGS\> element in the WIM XML data
2350 * (something like "Core" or "Ultimate")
2353 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2354 * standalone WIM or part of a split WIM; however, you should set the same
2355 * \<FLAGS\> element on all parts of a split WIM.
2357 * The number of the image for which to change the description.
2359 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
2360 * indicates that the image is to be given no \<FLAGS\> element.
2362 * @return 0 on success; nonzero on error.
2363 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2364 * @a image does not specify a single existing image in @a wim.
2365 * @retval ::WIMLIB_ERR_NOMEM
2366 * Failed to allocate the memory needed to duplicate the @a flags string.
2367 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2368 * @a wim is considered read-only because of any of the reasons mentioned
2369 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2372 wimlib_set_image_flags(WIMStruct *wim, int image, const wimlib_tchar *flags);
2375 * Changes the name of an image in the WIM.
2378 * Pointer to the ::WIMStruct for a WIM file. It may be either a
2379 * standalone WIM or part of a split WIM; however, you should set the same
2380 * name on all parts of a split WIM.
2382 * The number of the image for which to change the name.
2384 * New name to give the new image. If @c NULL or empty, the new image is
2385 * given no name. If nonempty, it must specify a name that does not
2386 * already exist in @a wim.
2388 * @return 0 on success; nonzero on error.
2389 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
2390 * There is already an image named @a name in @a wim.
2391 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2392 * @a image does not specify a single existing image in @a wim.
2393 * @retval ::WIMLIB_ERR_NOMEM
2394 * Failed to allocate the memory needed to duplicate the @a name string.
2395 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2396 * @a wim is considered read-only because of any of the reasons mentioned
2397 * in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS flag.
2399 extern int wimlib_set_image_name(WIMStruct *wim, int image,
2400 const wimlib_tchar *name);
2403 * Set the functions that wimlib uses to allocate and free memory.
2405 * These settings are global and not per-WIM.
2407 * The default is to use the default @c malloc() and @c free() from the C
2410 * Please note that some external functions, such as those in @c libntfs-3g, may
2411 * use the standard memory allocation functions.
2413 * @param malloc_func
2414 * A function equivalent to @c malloc() that wimlib will use to allocate
2415 * memory. If @c NULL, the allocator function is set back to the default
2416 * @c malloc() from the C library.
2418 * A function equivalent to @c free() that wimlib will use to free memory.
2419 * If @c NULL, the free function is set back to the default @c free() from
2421 * @param realloc_func
2422 * A function equivalent to @c realloc() that wimlib will use to reallocate
2423 * memory. If @c NULL, the free function is set back to the default @c
2424 * realloc() from the C library.
2425 * @return 0 on success; nonzero on error.
2426 * @retval ::WIMLIB_ERR_UNSUPPORTED
2427 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
2428 * so custom memory allocators are unsupported.
2431 wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
2432 void (*free_func)(void *),
2433 void *(*realloc_func)(void *, size_t));
2436 * Sets whether wimlib is to print error messages to @c stderr when a function
2437 * fails. These error messages may provide information that cannot be
2438 * determined only from the error code that is returned. Not every error will
2439 * result in an error message being printed.
2441 * This setting is global and not per-WIM.
2443 * By default, error messages are not printed.
2445 * @param show_messages
2446 * @c true if error messages are to be printed; @c false if error messages
2447 * are not to be printed.
2449 * @return 0 on success; nonzero on error.
2450 * @retval ::WIMLIB_ERR_UNSUPPORTED
2451 * @a show_messages was @c true, but wimlib was compiled with the @c
2452 * --without-error-messages option. Therefore, error messages cannot be
2456 wimlib_set_print_errors(bool show_messages);
2459 * Splits a WIM into multiple parts.
2462 * The ::WIMStruct for the WIM to split. It must be a standalone, one-part
2465 * Name of the SWM file to create. This will be the name of the first
2466 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
2467 * appended before the suffix.
2469 * The maximum size per part, in bytes. It is not guaranteed that this
2470 * will really be the maximum size per part, because some file resources in
2471 * the WIM may be larger than this size, and the WIM file format provides
2472 * no way to split up file resources among multiple WIMs.
2473 * @param write_flags
2474 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY if integrity tables are to be
2475 * included in the split WIM parts.
2476 * @param progress_func
2477 * If non-NULL, a function that will be called periodically with the
2478 * progress of the current operation.
2480 * @return 0 on success; nonzero on error. This function may return any value
2481 * returned by wimlib_write() as well as the following error codes:
2483 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2484 * @a wim is not part 1 of a stand-alone WIM.
2485 * @retval ::WIMLIB_ERR_INVALID_PARAM
2486 * @a swm_name was @c NULL, or @a part_size was 0.
2488 * Note: the WIM's uncompressed and compressed resources are not checksummed
2489 * when they are copied from the joined WIM to the split WIM parts, nor are
2490 * compressed resources re-compressed.
2493 wimlib_split(WIMStruct *wim,
2494 const wimlib_tchar *swm_name,
2497 wimlib_progress_func_t progress_func);
2500 * Unmounts a WIM image that was mounted using wimlib_mount_image().
2502 * The image to unmount is specified by the path to the mountpoint, not the
2503 * original ::WIMStruct passed to wimlib_mount_image(), which should not be
2504 * touched and also may have been allocated in a different process.
2506 * To unmount the image, the thread calling this function communicates with the
2507 * thread that is managing the mounted WIM image. This function blocks until it
2508 * is known whether the unmount succeeded or failed. In the case of a
2509 * read-write mounted WIM, the unmount is not considered to have succeeded until
2510 * all changes have been saved to the underlying WIM file.
2513 * The directory that the WIM image was mounted on.
2514 * @param unmount_flags
2515 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY,
2516 * ::WIMLIB_UNMOUNT_FLAG_COMMIT, ::WIMLIB_UNMOUNT_FLAG_REBUILD, and/or
2517 * ::WIMLIB_UNMOUNT_FLAG_RECOMPRESS. None of these flags affect read-only
2519 * @param progress_func
2520 * If non-NULL, a function that will be called periodically with the
2521 * progress of the current operation.
2523 * @return 0 on success; nonzero on error.
2525 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
2526 * The filesystem daemon was unable to remove the staging directory and the
2527 * temporary files that it contains.
2528 * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
2529 * The filesystem daemon appears to have terminated before sending an exit
2531 * @retval ::WIMLIB_ERR_FORK
2532 * Could not @c fork() the process.
2533 * @retval ::WIMLIB_ERR_FUSERMOUNT
2534 * The @b fusermount program could not be executed or exited with a failure
2536 * @retval ::WIMLIB_ERR_MQUEUE
2537 * Could not open a POSIX message queue to communicate with the filesystem
2538 * daemon servicing the mounted filesystem, could not send a message
2539 * through the queue, or could not receive a message through the queue.
2540 * @retval ::WIMLIB_ERR_NOMEM
2541 * Failed to allocate needed memory.
2542 * @retval ::WIMLIB_ERR_OPEN
2543 * The filesystem daemon could not open a temporary file for writing the
2545 * @retval ::WIMLIB_ERR_READ
2546 * A read error occurred when the filesystem daemon tried to a file from
2547 * the staging directory
2548 * @retval ::WIMLIB_ERR_RENAME
2549 * The filesystem daemon failed to rename the newly written WIM file to the
2550 * original WIM file.
2551 * @retval ::WIMLIB_ERR_UNSUPPORTED
2552 * Mounting is not supported, either because the platform is Windows, or
2553 * because the platform is UNIX and wimlib was compiled with @c
2555 * @retval ::WIMLIB_ERR_WRITE
2556 * A write error occurred when the filesystem daemon was writing to the new
2557 * WIM file, or the filesystem daemon was unable to flush changes that had
2558 * been made to files in the staging directory.
2561 wimlib_unmount_image(const wimlib_tchar *dir,
2563 wimlib_progress_func_t progress_func);
2566 * Update a WIM image by adding, deleting, and/or renaming files or directories.
2569 * Pointer to the ::WIMStruct for the WIM file to update.
2571 * The 1-based index of the image in the WIM to update. It cannot be
2572 * ::WIMLIB_ALL_IMAGES.
2574 * An array of ::wimlib_update_command's that specify the update operations
2577 * Number of commands in @a cmds.
2578 * @param update_flags
2579 * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
2580 * @param progress_func
2581 * If non-NULL, a function that will be called periodically with the
2582 * progress of the current operation.
2584 * @return 0 on success; nonzero on error. On failure, some but not all of the
2585 * update commands may have been executed. No individual update command will
2586 * have been partially executed. Possible error codes include:
2588 * @retval ::WIMLIB_ERR_DECOMPRESSION
2589 * Failed to decompress the metadata resource from @a image in @a wim.
2590 * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG
2591 * The capture configuration structure specified for an add command was
2593 * @retval ::WIMLIB_ERR_INVALID_DENTRY
2594 * A directory entry for @a image in @a wim is invalid.
2595 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2596 * @a image did not specify a single, existing image in @a wim.
2597 * @retval ::WIMLIB_ERR_INVALID_OVERLAY
2598 * Attempted to perform an add command that conflicted with previously
2599 * existing files in the WIM when an overlay was attempted.
2600 * @retval ::WIMLIB_ERR_INVALID_PARAM
2601 * An unknown operation type was specified in the update commands; or,
2602 * attempted to execute an add command where ::WIMLIB_ADD_FLAG_NTFS was set
2603 * in the @a add_flags, but the same image had previously already been
2604 * added from a NTFS volume; or, both ::WIMLIB_ADD_FLAG_RPFIX and
2605 * ::WIMLIB_ADD_FLAG_NORPFIX were specified in the @a add_flags for one add
2606 * command; or, ::WIMLIB_ADD_FLAG_NTFS or ::WIMLIB_ADD_FLAG_RPFIX were
2607 * specified in the @a add_flags for an add command in which @a
2608 * wim_target_path was not the root directory of the WIM image.
2609 * @retval ::WIMLIB_ERR_INVALID_REPARSE_DATA
2610 * (Windows only): While executing an add command, tried to capture a
2611 * reparse point with invalid data.
2612 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2613 * The metadata resource for @a image in @a wim is invalid.
2614 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2615 * The security data for image @a image in @a wim is invalid.
2616 * @retval ::WIMLIB_ERR_IS_DIRECTORY
2617 * A delete command without ::WIMLIB_DELETE_FLAG_RECURSIVE specified was
2618 * for a WIM path that corresponded to a directory; or, a rename command
2619 * attempted to rename a directory to a non-directory.
2620 * @retval ::WIMLIB_ERR_NOMEM
2621 * Failed to allocate needed memory.
2622 * @retval ::WIMLIB_ERR_NOTDIR
2623 * A rename command attempted to rename a directory to a non-directory; or,
2624 * an add command was executed that attempted to set the root of the WIM
2625 * image as a non-directory; or, a path component used as a directory in a
2626 * rename command was not, in fact, a directory.
2627 * @retval ::WIMLIB_ERR_NOTEMPTY
2628 * A rename command attempted to rename a directory to a non-empty
2630 * @retval ::WIMLIB_ERR_NTFS_3G
2631 * While executing an add command with ::WIMLIB_ADD_FLAG_NTFS specified, an
2632 * error occurred while reading data from the NTFS volume using libntfs-3g.
2633 * @retval ::WIMLIB_ERR_OPEN
2634 * Failed to open a file to be captured while executing an add command.
2635 * @retval ::WIMLIB_ERR_OPENDIR
2636 * Failed to open a directory to be captured while executing an add command.
2637 * @retval ::WIMLIB_ERR_PATH_DOES_NOT_EXIST
2638 * A delete command without ::WIMLIB_DELETE_FLAG_FORCE specified was for a
2639 * WIM path that did not exist; or, a rename command attempted to rename a
2640 * file that does not exist.
2641 * @retval ::WIMLIB_ERR_READ
2642 * Failed to read the metadata resource for @a image in @a wim; or, while
2643 * executing an add command, failed to read data from a file or directory
2645 * @retval ::WIMLIB_ERR_READLINK
2646 * While executing an add command, failed to read the target of a symbolic
2647 * link or junction point.
2648 * @retval ::WIMLIB_ERR_REPARSE_POINT_FIXUP_FAILED
2649 * (Windows only) Failed to perform a reparse point fixup because of
2650 * problems with the data of a reparse point.
2651 * @retval ::WIMLIB_ERR_SPECIAL_FILE
2652 * While executing an add command, attempted to capture a file that was not
2653 * a supported file type, such as a regular file, directory, symbolic link,
2654 * or (on Windows) a reparse point.
2655 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2656 * @a wim is part of a split WIM. Updating a split WIM is unsupported.
2657 * @retval ::WIMLIB_ERR_STAT
2658 * While executing an add command, failed to get attributes for a file or
2660 * @retval ::WIMLIB_ERR_UNSUPPORTED
2661 * ::WIMLIB_ADD_FLAG_NTFS was specified in the @a add_flags for an update
2662 * command, but wimlib was configured with the @c --without-ntfs-3g flag;
2663 * or, the platform is Windows and either the ::WIMLIB_ADD_FLAG_UNIX_DATA
2664 * or the ::WIMLIB_ADD_FLAG_DEREFERENCE flags were specified in the @a
2665 * add_flags for an update command.
2666 * @retval ::WIMLIB_ERR_WIM_IS_READONLY
2667 * The WIM file is considered read-only because of any of the reasons
2668 * mentioned in the documentation for the ::WIMLIB_OPEN_FLAG_WRITE_ACCESS
2672 wimlib_update_image(WIMStruct *wim,
2674 const struct wimlib_update_command *cmds,
2677 wimlib_progress_func_t progress_func);
2680 * Writes a standalone WIM to a file.
2682 * This brings in resources from any external locations, such as directory trees
2683 * or NTFS volumes scanned with wimlib_add_image(), or other WIM files via
2684 * wimlib_export_image(), and incorporates them into a new on-disk WIM file.
2687 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
2688 * changes made to it, which are then reflected in the output file.
2690 * The path to the file to write the WIM to.
2692 * The image inside the WIM to write. Use ::WIMLIB_ALL_IMAGES to include all
2694 * @param write_flags
2695 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY,
2696 * ::WIMLIB_WRITE_FLAG_RECOMPRESS, ::WIMLIB_WRITE_FLAG_FSYNC, and/or
2697 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE.
2698 * @param num_threads
2699 * Number of threads to use for compressing data. If 0, the number of
2700 * threads is taken to be the number of online processors. Note: if no
2701 * data compression needs to be done, no additional threads will be created
2702 * regardless of this parameter (e.g. if writing an uncompressed WIM, or
2703 * exporting an image from a compressed WIM to another WIM of the same
2704 * compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS specified in @a
2706 * @param progress_func
2707 * If non-NULL, a function that will be called periodically with the
2708 * progress of the current operation.
2710 * @return 0 on success; nonzero on error.
2711 * @retval ::WIMLIB_ERR_DECOMPRESSION
2712 * Failed to decompress a metadata or file resource in @a wim.
2713 * @retval ::WIMLIB_ERR_INVALID_DENTRY
2714 * A directory entry in the metadata resource for @a image in @a wim is
2716 * @retval ::WIMLIB_ERR_INVALID_IMAGE
2717 * @a image does not specify a single existing image in @a wim, and is not
2718 * ::WIMLIB_ALL_IMAGES.
2719 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
2720 * A file that had previously been scanned for inclusion in the WIM by
2721 * wimlib_add_image() was concurrently modified, so it failed the SHA1
2722 * message digest check.
2723 * @retval ::WIMLIB_ERR_INVALID_PARAM
2724 * @a path was @c NULL.
2725 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
2726 * The metadata resource for @a image in @a wim is invalid.
2727 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
2728 * The security data for @a image in @a wim is invalid.
2729 * @retval ::WIMLIB_ERR_NOMEM
2730 * Failed to allocate needed memory.
2731 * @retval ::WIMLIB_ERR_OPEN
2732 * Failed to open @a path for writing, or some file resources in @a
2733 * wim refer to files in the outside filesystem, and one of these files
2734 * could not be opened for reading.
2735 * @retval ::WIMLIB_ERR_READ
2736 * An error occurred when trying to read data from the WIM file associated
2737 * with @a wim, or some file resources in @a wim refer to files in the
2738 * outside filesystem, and a read error occurred when reading one of these
2740 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
2741 * @a wim is part of a split WIM. You may not call this function on a
2743 * @retval ::WIMLIB_ERR_WRITE
2744 * An error occurred when trying to write data to the new WIM file at @a
2748 wimlib_write(WIMStruct *wim,
2749 const wimlib_tchar *path,
2752 unsigned num_threads,
2753 wimlib_progress_func_t progress_func);
2756 * This function is equivalent to wimlib_lzx_compress(), but instead compresses
2757 * the data using "XPRESS" compression.
2760 wimlib_xpress_compress(const void *chunk, unsigned chunk_size, void *out);
2763 * This function is equivalent to wimlib_lzx_decompress(), but instead assumes
2764 * the data is compressed using "XPRESS" compression.
2767 wimlib_xpress_decompress(const void *compressed_data, unsigned compressed_len,
2768 void *uncompressed_data, unsigned uncompressed_len);
2770 #endif /* _WIMLIB_H */