4 * External header for wimlib.
6 * Copyright (C) 2012 Eric Biggers
8 * wimlib - Library for working with WIM files
10 * This library is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU Lesser General Public License as published by the Free
12 * Software Foundation; either version 2.1 of the License, or (at your option) any
15 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
16 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License along
20 * with this library; if not, write to the Free Software Foundation, Inc., 59
21 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * \section intro Introduction
28 * wimlib is a C library to read, write, and mount archive files in the Windows
29 * Imaging Format (WIM files). These files are normally created using the @c
30 * imagex.exe utility on Windows, but this library provides a free
31 * implementetion of @c imagex for UNIX-based systems and an API to allow other
32 * programs to read, write, and mount WIM files. wimlib is comparable to
33 * Microsoft's WIMGAPI, but was designed independently and is not a clone of it.
35 * The main intended use of wimlib is to create customized images of Windows PE,
36 * the Windows Preinstallation Environment, without having to rely on Windows.
37 * Windows PE, which is the operating system that runs when you boot from the
38 * Windows Vista or Windows 7 DVD, is a lightweight version of Windows that can
39 * run entirely from memory. It can be used to install Windows from local media
40 * or a network drive or perform maintenance.
42 * You can find Windows PE on the installation media for Windows Vista, Windows
43 * 7, and Windows 8. The Windows PE image itself is a WIM file, @c
44 * sources/boot.wim, on the ISO filesystem. Windows PE can also be found in the
45 * Windows Automated Installation Kit (WAIK) inside the @c WinPE.cab file, which
46 * you can extract if you install the @c cabextract program.
48 * \section format WIM files
50 * A <b>Windows Imaging (WIM)</b> file is an archive. Like some other archive
51 * formats such as ZIP, files in WIM archives may be compressed. WIM archives
52 * support two Microsoft-specific compression formats: @b LZX and @b XPRESS.
53 * Both are based on LZ77 and Huffman encoding, and both are supported by
56 * Unlike ZIP files, WIM files can contain multiple independent toplevel
57 * directory trees known as @a images. While each image has its own metadata,
58 * files are not duplicated for each image; instead, each file is included only
59 * once in the entire WIM. Microsoft did this so that in one WIM file, they
60 * could do things like have 5 different versions of Windows that are almost
63 * WIM files may contain a integrity table. The integrity table, if it exists,
64 * is located at the end of the WIM file and contains SHA1 message digests of
65 * 10MB chunks of the WIM.
67 * Microsoft provides documentation for the WIM file format, XPRESS compression
68 * format, and LZX compression format. However, there are errors and omissions
69 * in some places in their documentation.
71 * \section starting Getting Started
73 * wimlib uses the GNU autotools, so it should be easy to install with
74 * <code>configure && make && sudo make install</code>, provided that you have
75 * @c libxml2 and @c libfuse installed. To use wimlib in a program after
76 * installing it, include @c wimlib.h and link your program with @c -lwim.
78 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure.
80 * All functions in wimlib's public API are prefixed with @c wimlib. Most
81 * return an integer error code on failure. Use wimlib_get_error_string() to
82 * get a string that describes an error code. wimlib also can print error
83 * messages itself when an error happens, and these may be more informative than
84 * the error code; to enable this, call wimlib_set_print_errors().
86 * wimlib is thread-safe as long as different ::WIMStruct's are used, with the
87 * following exceptions: wimlib_set_print_errors() and
88 * wimlib_set_memory_allocator() apply globally, and wimlib_mount() can only be
89 * used by one ::WIMStruct at a time.
91 * To open an existing WIM, use wimlib_open_wim().
93 * To create a new WIM that initially contains no images, use
94 * wimlib_create_new_wim().
96 * To add an image to a WIM file from a directory tree on your filesystem, call
97 * wimlib_add_image(). This can be done with a ::WIMStruct gotten from
98 * wimlib_open_wim() or from wimlib_create_new_wim().
100 * To extract an image from a WIM file, call wimlib_set_output_dir() to set the
101 * output directory, then call wimlib_extract_image().
103 * wimlib supports mounting WIM files either read-only or read-write. Mounting
104 * is done using wimlib_mount() and unmounting is done using wimlib_unmount().
105 * Mounting can be done without root privileges because it is implemented using
106 * FUSE (Filesystem in Userspace). If wimlib is compiled with the
107 * <code>--without-fuse</code> flag, these functions will be available but will
110 * After creating or modifying a WIM file, you can write it to a file using
111 * wimlib_write(). Alternatively, if the WIM was originally read from a file,
112 * you can use wimlib_overwrite() to overwrite the original file. In some
113 * cases, wimlib_overwrite_xml_and_header() can be used instead.
115 * After you are done with the WIM file, use wimlib_free() to free all memory
116 * associated with a ::WIMStruct and close all files associated with it.
118 * To see an example of how to use wimlib, see the file
119 * @c programs/imagex.c in wimlib's source tree.
121 * wimlib supports custom memory allocators; use wimlib_set_memory_allocator()
124 * \section imagex imagex
126 * wimlib comes with the <b>imagex</b> program, which is documented in man pages.
128 * \section mkwinpeimg mkwinpeimg
130 * wimlib comes with the <b>mkwinpeimg</b> script, which is documented in a man
133 * \section Limitations
135 * While wimlib supports the main features of WIM files, wimlib currently has
136 * the following limitations:
137 * - wimlib does not support "security data", which describes the access rights
138 * of the files in the WIM. This data is very Windows-specific, and it would
139 * be difficult to do anything with it. Microsoft's software can still read a
140 * WIM without security data, including a boot.wim for Windows PE, but <b>do
141 * not expect to be able to use wimlib to image a Windows installation and
142 * preserve file attributes</b>.
143 * - There is no way to create split WIMs.
144 * - There is not yet any code to verify that there are no collisions between
145 * different files that happen to have the same SHA1 message digest.
146 * This is extremely unlikely, but could result in something bad such as a
147 * file going missing.
148 * - Alternate stream entries for directory entries are ignored. I'm not sure
149 * if these are ever used for anything important.
150 * - Different versions of the WIM file format, if they even exist, are
151 * unsupported. Let me know if you notice WIM files with a different version.
152 * - Chunk sizes other than 32768 are unsupported (except for uncompressed WIMs,
153 * for which the chunk size field is ignored). As far as I can tell, other
154 * chunk sizes are not used in compressed WIMs. Let me know if you find a WIM
155 * file with a different chunk size.
156 * - wimlib does not provide a clone of the @b PEImg tool that allows you to
157 * make certain Windows-specific modifications to a Windows PE image, such as
158 * adding a driver or Windows component. Such a tool could conceivably be
159 * implemented on top of wimlib, although it likely would be hard to implement
160 * because it would have to do very Windows-specific things such as
161 * manipulating the driver store. wimlib does provide the @b mkwinpeimg
162 * script for a similar purpose, however. With regards to adding drivers to
163 * Windows PE, you have the option of putting them anywhere in the Windows PE
164 * image, then loading them after boot using @b drvload.exe.
165 * - There is not yet a way to extract specific files or directories from a WIM
166 * file without mounting it, or to add, remove, or modify files in a WIM
167 * without mounting it, other than by adding or removing an entire image. I
168 * can implement this if requested, but I intend the FUSE mount feature to be
169 * used for this purpose, as it is easy to do these things in whatever way you
170 * want after the image is mounted.
172 * Currently, Microsoft's @a image.exe can create slightly smaller WIM files
173 * than wimlib when using maximum (LZX) compression because it knows how to
174 * split up LZX compressed blocks, which is not yet implemented in wimlib.
176 * wimlib is experimental and likely contains bugs; use Microsoft's @a
177 * imagex.exe if you want to make sure your WIM files are made correctly.
179 * \section legal License
181 * The wimlib library is licensed under the GNU Lesser General Public License
182 * version 2.1 or later.
184 * @b imagex and @b mkwinpeiso are licensed under the GNU General Public License
185 * version 3 or later.
195 #ifndef _WIMLIB_INTERNAL_H
197 * Opaque structure that represents a WIM file.
199 typedef struct WIMStruct WIMStruct;
203 * Specifies the way in which identical files are linked when extracting
204 * image(s) from the WIM.
207 /** Hard link identical files when extracting files from the WIM. */
208 WIM_LINK_TYPE_HARD = 0,
209 /** Symbolic link identical files when extracting files from the WIM. */
210 WIM_LINK_TYPE_SYMBOLIC = 1,
211 /** Do not create links when extracting identical files from the WIM (default).
213 WIM_LINK_TYPE_NONE = 2,
217 * Specifies the compression type of a WIM file.
220 enum wim_compression_type {
221 /** An invalid compression type. */
222 WIM_COMPRESSION_TYPE_INVALID = -1,
224 /** The WIM does not include any compressed resources. */
225 WIM_COMPRESSION_TYPE_NONE = 0,
227 /** Compressed resources in the WIM use LZX compression. */
228 WIM_COMPRESSION_TYPE_LZX = 1,
230 /** Compressed resources in the WIM use XPRESS compression. */
231 WIM_COMPRESSION_TYPE_XPRESS = 2,
234 /** Mount the WIM read-write. */
235 #define WIMLIB_MOUNT_FLAG_READWRITE 0x1
237 /** For debugging only. (This passes the @c -d flag to @c fuse_main()).*/
238 #define WIMLIB_MOUNT_FLAG_DEBUG 0x2
240 /** Include an integrity table in the new WIM being written during the unmount.
241 * Ignored for read-only mounts. */
242 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x1
244 /** Unless this flag is given, changes to a mounted WIM are discarded. Ignored
245 * for read-only mounts. */
246 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x2
248 /** Include an integrity table in the new WIM file. */
249 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x1
251 /** Print progress information when writing the integrity table. */
252 #define WIMLIB_WRITE_FLAG_SHOW_PROGRESS 0x2
254 /** Mark the image being added as the bootable image of the WIM. */
255 #define WIMLIB_ADD_IMAGE_FLAG_BOOT 0x1
257 /** See documentation for wimlib_export_image(). */
258 #define WIMLIB_EXPORT_FLAG_BOOT 0x1
260 /** Verify the integrity of the WIM if an integrity table is present. */
261 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x1
263 /** Print progress information when verifying integrity table. */
264 #define WIMLIB_OPEN_FLAG_SHOW_PROGRESS 0x2
266 /** If this flag is not given, an error is issued if the WIM is part of a split
268 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x4
271 * Possible values of the error code returned by many functions in wimlib.
273 * See the documentation for each wimlib function to see specifically what error
274 * codes can be returned by a given function, and what they mean.
276 enum wimlib_error_code {
277 WIMLIB_ERR_SUCCESS = 0,
278 WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE,
279 WIMLIB_ERR_DECOMPRESSION,
280 WIMLIB_ERR_DELETE_STAGING_DIR,
283 WIMLIB_ERR_FUSERMOUNT,
284 WIMLIB_ERR_IMAGE_COUNT,
285 WIMLIB_ERR_IMAGE_NAME_COLLISION,
286 WIMLIB_ERR_INTEGRITY,
287 WIMLIB_ERR_INVALID_CHUNK_SIZE,
288 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
289 WIMLIB_ERR_INVALID_DENTRY,
290 WIMLIB_ERR_INVALID_HEADER_SIZE,
291 WIMLIB_ERR_INVALID_IMAGE,
292 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
293 WIMLIB_ERR_INVALID_PARAM,
294 WIMLIB_ERR_INVALID_RESOURCE_SIZE,
300 WIMLIB_ERR_NOT_A_WIM_FILE,
301 WIMLIB_ERR_NO_FILENAME,
306 WIMLIB_ERR_SPLIT_INVALID,
307 WIMLIB_ERR_SPLIT_UNSUPPORTED,
310 WIMLIB_ERR_UNKNOWN_VERSION,
311 WIMLIB_ERR_UNSUPPORTED,
317 /** Used to indicate that no WIM image is currently selected. */
318 #define WIM_NO_IMAGE 0
320 /** Used to specify all images in the WIM. */
321 #define WIM_ALL_IMAGES (-1)
325 * Adds an image to a WIM file from a directory tree on disk.
327 * The directory tree is read immediately for the purpose of constructing a
328 * directory entry tree in-memory. Also, all files are read to calculate their
329 * SHA1 message digests. However, because the directory tree may contain a very
330 * large amount of data, the files themselves are not read into memory
331 * permanently, and instead references to their paths saved. This means that
332 * the directory tree must not be modified, other than by adding entirely new
333 * files or directories, before executing a call to wimlib_write() or
334 * wimlib_overwrite(). Otherwise, wimlib_write() may fail or incorrect files may
335 * be included in the WIM written by wimlib_write().
338 * Pointer to the ::WIMStruct for a WIM file to which the image will be
341 * A path to a directory in the outside filesystem. It will become the
342 * root directory for the WIM image.
344 * The name to give the image. This must be non-@c NULL.
346 * The description to give the image. This parameter may be left @c
347 * NULL, in which case no description is given to the image.
348 * @param flags_element
349 * What to put in the <FLAGS> element for the image's XML data. This
350 * parameter may be left @c NULL, in which case no <FLAGS> element is
351 * given to the image.
353 * If set to ::WIMLIB_ADD_IMAGE_FLAG_BOOT, change the image in @a wim
354 * marked as bootable to the one being added. Otherwise, leave the boot
357 * @return 0 on success; nonzero on error.
358 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
359 * There is already an image named @a name in @a w.
360 * @retval ::WIMLIB_ERR_INVALID_PARAM
361 * @a dir was @c NULL, @a name was @c NULL, or @a name was the empty string.
362 * @retval ::WIMLIB_ERR_NOMEM
363 * Failed to allocate needed memory.
364 * @retval ::WIMLIB_ERR_NOTDIR
365 * @a dir is not a directory.
366 * @retval ::WIMLIB_ERR_OPEN
367 * Failed to open a file or directory in the directory tree rooted at @a
369 * @retval ::WIMLIB_ERR_READ
370 * Failed to read a file in the directory tree rooted at @a dir.
371 * @retval ::WIMLIB_ERR_STAT
372 * Failed obtain the metadata for a file or directory in the directory tree
376 extern int wimlib_add_image(WIMStruct *wim, const char *dir,
377 const char *name, const char *description,
378 const char *flags_element, int flags);
381 * Creates a WIMStruct for a new WIM file.
384 * The type of compression to be used in the new WIM file. Must be
385 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
386 * ::WIM_COMPRESSION_TYPE_XPRESS.
388 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
389 * written to the memory location pointed to by this paramater. The
390 * ::WIMStruct must be freed using using wimlib_free() when finished with
392 * @return 0 on success; nonzero on error.
393 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
394 * @a ctype was not ::WIM_COMPRESSION_TYPE_NONE,
395 * ::WIM_COMPRESSION_TYPE_LZX, or ::WIM_COMPRESSION_TYPE_XPRESS.
396 * @retval ::WIMLIB_ERR_NOMEM
397 * Failed to allocate needed memory.
399 extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
402 * Deletes an image, or all images, from a WIM file.
404 * All file resources referenced by the image(s) being deleted are removed from
405 * the WIM if they are not referenced by any other images in the WIM.
408 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
411 * The number of the image to delete, or ::WIM_ALL_IMAGES to delete all
413 * @return 0 on success; nonzero on error.
414 * @retval ::WIMLIB_ERR_DECOMPRESSION
415 * Could not decompress the metadata resource for @a image.
416 * @retval ::WIMLIB_ERR_INVALID_DENTRY
417 * A directory entry in the metadata resource for @a image in the WIM is
419 * @retval ::WIMLIB_ERR_INVALID_IMAGE
420 * @a image does not exist in the WIM and is not ::WIM_ALL_IMAGES.
421 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
422 * The metadata resource for @a image in the WIM is invalid.
423 * @retval ::WIMLIB_ERR_NOMEM Failed to allocate needed memory.
424 * @retval ::WIMLIB_ERR_READ
425 * Could not read the metadata resource for @a image from the WIM.
427 extern int wimlib_delete_image(WIMStruct *wim, int image);
430 * Copies an image, or all the images, from a WIM file, into another WIM file.
433 * Pointer to the ::WIMStruct for a WIM file that contains the image(s)
436 * The image to export from @a src_wim. Can be the number of an image, or
437 * ::WIM_ALL_IMAGES to export all images.
439 * Pointer to the ::WIMStruct for a WIM filethat will receive the images being
442 * The name to give the exported image in the new WIM file. If left @c NULL,
443 * the name from @a src_wim is used. This parameter must be left @c NULL
444 * if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains more than one
445 * image; in that case, the names are all taken from the @a src_wim.
446 * @param dest_description
447 * The description to give the exported image in the new WIM file. If left
448 * @c NULL, the description from the @a src_wim is used. This parameter must
449 * be left @c NULL if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains
450 * more than one image; in that case, the descriptions are all taken from
453 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
454 * bootable, or 0 if which image is marked as bootable in the destination
455 * WIM is to be left unchanged. If @a src_image is ::WIM_ALL_IMAGES and
456 * there are multiple images in @a src_wim, specifying
457 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
458 * currently marked as bootable in @a src_wim; if that is the case, then
459 * that image is marked as bootable in the destination WIM.
461 * @return 0 on success; nonzero on error.
462 * @retval ::WIMLIB_ERR_DECOMPRESSION
463 * Could not decompress the metadata resource for @a src_image
465 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
466 * One or more of the names being given to an exported image was already in
467 * use in the destination WIM.
468 * @retval ::WIMLIB_ERR_INVALID_DENTRY
469 * A directory entry in the metadata resource for @a src_image in @a
470 * src_wim is invalid.
471 * @retval ::WIMLIB_ERR_INVALID_IMAGE
472 * @a src_image does not exist in @a src_wim.
473 * @retval ::WIMLIB_ERR_INVALID_PARAM
474 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
475 * ::WIM_ALL_IMAGES, @a src_wim contains multiple images, and no images in
476 * @a src_wim are marked as bootable; or @a dest_name and/or @a
477 * dest_description were non-<code>NULL</code>, @a src_image was
478 * ::WIM_ALL_IMAGES, and @a src_wim contains multiple images.
479 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
480 * The metadata resource for @a src_image in @a src_wim is invalid.
481 * @retval ::WIMLIB_ERR_NOMEM
482 * Failed to allocate needed memory.
483 * @retval ::WIMLIB_ERR_READ
484 * Could not read the metadata resource for @a src_image from @a src_wim.
486 extern int wimlib_export_image(WIMStruct *src_wim, int src_image,
487 WIMStruct *dest_wim, const char *dest_name,
488 const char *dest_description, int flags);
491 * Extracts an image, or all images, from a WIM file.
493 * The output directory must have been previously set with
494 * wimlib_set_output_dir().
496 * The link type used for extracted files is that specified by a previous call
497 * to wimlib_set_link_type(), or ::WIM_LINK_TYPE_NONE by default.
500 * Pointer to the ::WIMStruct for a WIM file.
502 * The image to extract. Can be the number of an image, or ::WIM_ALL_IMAGES
503 * to specify that all images are to be extracted.
505 * @return 0 on success; nonzero on error.
506 * @retval ::WIMLIB_ERR_DECOMPRESSION
507 * Could not decompress a resource (file or metadata) for @a image in @a
509 * @retval ::WIMLIB_ERR_INVALID_DENTRY
510 * A directory entry in the metadata resource for @a image in @a wim is
512 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
513 * A resource (file or metadata) for @a image in @a wim is invalid.
514 * @retval ::WIMLIB_ERR_LINK
515 * Failed to create a symbolic link or a hard link.
516 * @retval ::WIMLIB_ERR_MKDIR
517 * Failed create a needed directory.
518 * @retval ::WIMLIB_ERR_NOMEM
519 * Failed to allocate needed memory.
520 * @retval ::WIMLIB_ERR_NOTDIR
521 * wimlib_set_output_dir() has not been successfully called on @a wim.
522 * @retval ::WIMLIB_ERR_OPEN
523 * Could not open one of the files being extracted for writing.
524 * @retval ::WIMLIB_ERR_READ
525 * A unexpected end-of-file or read error occurred when trying to read data
526 * from the WIM file associated with @a wim.
527 * @retval ::WIMLIB_ERR_WRITE
528 * Failed to write a file being extracted.
530 extern int wimlib_extract_image(WIMStruct *wim, int image);
533 * Extracts the XML data for a WIM file to a file stream. Every WIM file
534 * includes a string of XML that describes the images contained in the WIM.
537 * Pointer to the ::WIMStruct for a WIM file.
539 * @c stdout, or a FILE* opened for writing, to extract the data to.
541 * @return 0 on success; nonzero on error.
542 * @retval ::WIMLIB_ERR_WRITE
543 * Failed to completely write the XML data to @a fp.
545 extern int wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
548 * Frees all memory allocated for a WIMStruct and closes all files associated
552 * Pointer to the ::WIMStruct for a WIM file.
554 * @return This function has no return value.
556 extern void wimlib_free(WIMStruct *wim);
559 * Finds which image in a WIM is bootable.
562 * Pointer to the ::WIMStruct for a WIM file.
565 * 0 if no image is marked as bootable, or the number of the image marked
566 * as bootable (numbered starting at 1).
568 extern int wimlib_get_boot_idx(const WIMStruct *wim);
571 * Gets the compression type used in the WIM.
574 * Pointer to the ::WIMStruct for a WIM file
577 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
578 * ::WIM_COMPRESSION_TYPE_XPRESS.
580 extern int wimlib_get_compression_type(const WIMStruct *wim);
583 * Converts a compression type enumeration value into a string.
586 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX,
587 * ::WIM_COMPRESSION_TYPE_XPRESS, or another value.
590 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
593 extern const char *wimlib_get_compression_type_string(int ctype);
596 * Converts an error code into a string describing it.
599 * The error code returned by one of wimlib's functions.
602 * Pointer to a statically allocated string describing the error code,
603 * or @c NULL if the error code is not valid.
605 extern const char *wimlib_get_error_string(enum wimlib_error_code code);
608 * Returns the description of the specified image.
611 * Pointer to the ::WIMStruct for a WIM file.
613 * The number of the image, numbered starting at 1.
616 * The description of the image, or @c NULL if there is no such image, or @c NULL
617 * if the specified image has no description.
619 extern const char *wimlib_get_image_description(const WIMStruct *wim, int image);
622 * Returns the name of the specified image.
625 * Pointer to the ::WIMStruct for a WIM file.
627 * The number of the image, numbered starting at 1.
630 * The name of the image, or @c NULL if there is no such image.
632 extern const char *wimlib_get_image_name(const WIMStruct *wim, int image);
636 * Gets the number of images contained in the WIM.
639 * Pointer to the ::WIMStruct for a WIM file.
642 * The number of images contained in the WIM file.
644 extern int wimlib_get_num_images(const WIMStruct *wim);
647 * Gets the part number of the wim (in a split WIM).
650 * Pointer to the ::WIMStruct for a WIM file.
651 * @param total_parts_ret
652 * If non-@c NULL, the total number of parts in the split WIM (1 for
653 * non-split WIMs) is written to this location.
656 * The part number of the WIM (1 for non-split WIMs)
658 extern int wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret);
661 * Returns true if the WIM has an integrity table.
664 * Pointer to the ::WIMStruct for a WIM file.
666 * @c true if the WIM has an integrity table; false otherwise.
668 extern bool wimlib_has_integrity_table(const WIMStruct *wim);
672 * Determines if an image name is already used by some image in the WIM.
675 * Pointer to the ::WIMStruct for a WIM file.
680 * @c true if there is already an image in @a wim named @a name; @c
681 * false if there is no image named @a name in @a wim.
683 extern bool wimlib_image_name_in_use(const WIMStruct *wim, const char *name);
686 * Joins a set of split WIMs into a one-part WIM.
689 * An array of strings that give the filenames of all parts of the split
692 * Number of filenames in @a swms.
694 * The path to write the one-part WIM to.
696 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY to check the split WIMs' integrity
697 * tables (if present) when opening them, and include an integrity table in
700 * @return 0 on success; nonzero on error. This function may return any value
701 * returned by wimlib_open_wim() except ::WIMLIB_ERR_SPLIT_UNSUPPORTED, as well
702 * as the following error codes:
704 * @retval ::WIMLIB_ERR_SPLIT_INVALID
705 * The split WIMs do not form a valid WIM because they do not include all
706 * the parts of the original WIM, there are duplicate parts, or not all the
707 * parts have the same GUID and compression type.
708 * @retval ::WIMLIB_ERR_WRITE
709 * An error occurred when trying to write data to to the new WIM at @a output_path.
711 * Note that this function merely copies the resources, so it will not check to
712 * see if the resources, including the metadata resource, are valid or not.
714 extern int wimlib_join(const char **swms, int num_swms,
715 const char *output_path, int flags);
718 * Mounts an image in a WIM file on a directory read-only or read-write.
720 * A daemon will be forked to service the filesystem.
722 * If the mount is read-write, modifications to the WIM are staged in a staging
725 * wimlib_mount() currently cannot be used with multiple ::WIMStruct's without
726 * intervening wimlib_unmount()s. If there was a way to have libfuse pass a
727 * pointer to user data to each FUSE callback, then this would be possible, but
728 * there doesn't seem to be a way to do this currently.
731 * Pointer to the ::WIMStruct for the WIM file to be mounted.
733 * The number of the image to mount, numbered from 1. It must be an
734 * existing, single image.
736 * The path to an existing directory to mount the image on.
738 * Bitwise OR of the flags ::WIMLIB_MOUNT_FLAG_READWRITE or
739 * ::WIMLIB_MOUNT_FLAG_DEBUG. If ::WIMLIB_MOUNT_FLAG_READWRITE is not
740 * given, the WIM is mounted read-only.
742 * @return 0 on success; nonzero on error.
743 * @retval ::WIMLIB_ERR_DECOMPRESSION
744 * Could not decompress the metadata resource for @a image in @a wim.
745 * @retval ::WIMLIB_ERR_FUSE
746 * A non-zero status was returned by @c fuse_main().
747 * @retval ::WIMLIB_ERR_INVALID_DENTRY
748 * A directory entry in the metadata resource for @a image in @a wim is
750 * @retval ::WIMLIB_ERR_INVALID_IMAGE
751 * @a image does not specify an existing, single image in @a wim.
752 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
753 * The metadata resource for @a image in @a wim is invalid.
754 * @retval ::WIMLIB_ERR_MKDIR
755 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a flags, but the staging
756 * directory could not be created.
757 * @retval ::WIMLIB_ERR_NOMEM
758 * Failed to allocate needed memory.
759 * @retval ::WIMLIB_ERR_NOTDIR
760 * Could not determine the current working directory.
761 * @retval ::WIMLIB_ERR_READ
762 * An unexpected end-of-file or read error occurred when trying to read
763 * data from the WIM file associated with @a wim.
766 extern int wimlib_mount(WIMStruct *wim, int image, const char *dir, int flags);
769 * Opens a WIM file and creates a ::WIMStruct for it.
772 * The path to the WIM file to open.
774 * Bitwise OR of ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
775 * ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS.
776 * If ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is given, the integrity table
777 * of the WIM, if it exists, is checked, and the function will fail with an
778 * ::WIMLIB_ERR_INTEGRITY status if any of the computed SHA1 message
779 * digests of the WIM do not exactly match the corresponding message
780 * digests given in the integrity table.
781 * If ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS is given, progress information will
782 * be shown if the integrity of the WIM is checked.
783 * If ::WIMLIB_OPEN_FLAG_SPLIT_OK is given, no error will be issued if the
784 * WIM is part of a split WIM. However, wimlib does not fully support
785 * split WIMs, so not all functions will work correctly after opening a
786 * split WIM. For example, you cannot use wimlib_mount() or
787 * wimlib_extract_image() on a split WIM.
790 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
791 * is written to the memory location pointed to by this parameter. The
792 * ::WIMStruct must be freed using using wimlib_free() when finished with
795 * @return 0 on success; nonzero on error.
796 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
797 * The lookup table of @a wim_file is compressed. Support for this can be
798 * added to wimlib if needed, but it appears to be the case that the lookup
799 * table is never compressed.
800 * @retval ::WIMLIB_ERR_IMAGE_COUNT
801 * The WIM is not the non-first part of a split WIM, and the number of
802 * metadata resources found in the WIM did not match the image count given
803 * in the WIM header, or the number of <IMAGE> elements in the XML
804 * data for the WIM did not match the image count given in the WIM header.
805 * @retval ::WIMLIB_ERR_INTEGRITY
806 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
807 * wim_file contains an integrity table, but the SHA1 message digest for a
808 * chunk of the WIM does not match the corresponding message digest given
809 * in the integrity table.
810 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
811 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
812 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
813 * The header of @a wim_file says that resources in the WIM are compressed,
814 * but the header flag indicating LZX or XPRESS compression is not set.
815 * @retval ::WIMLIB_ERR_INVALID_HEADER_SIZE
816 * The length field of the WIM header is not 208.
817 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
818 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
819 * wim_file contains an integrity table, but the integrity table is
821 * @retval ::WIMLIB_ERR_NOMEM
822 * Failed to allocated needed memory.
823 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
824 * @a wim_file does not begin with the expected magic characters.
825 * @retval ::WIMLIB_ERR_OPEN
826 * Failed to open the file @a wim_file for reading.
827 * @retval ::WIMLIB_ERR_READ
828 * An unexpected end-of-file or read error occurred when trying to read
829 * data from @a wim_file.
830 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
831 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
833 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
834 * A number other than 0x10d00 is written in the version field of the WIM
835 * header of @a wim_file.
836 * @retval ::WIMLIB_ERR_XML
837 * The XML data for @a wim_file is invalid.
839 extern int wimlib_open_wim(const char *wim_file, int flags,
840 WIMStruct **wim_ret);
843 * Overwrites the file that the WIM was originally read from, with changes made.
845 * The new WIM is written to a temporary file and then renamed to the original
846 * file after it is has been completely written. The temporary file currently
847 * is made in the same directory as the original WIM file.
849 * Note that it is not possible for this function to delete the original file
850 * before having written the new file because it is very likely that file
851 * resources in the new WIM file need to be retrieved from the old WIM file.
853 * After this function returns, @a wim must be freed using wimlib_free(). Any
854 * further actions on @a wim before doing this are undefined.
857 * Pointer to the ::WIMStruct for the WIM file to write. There may have
858 * been in-memory changes made to it, which are then reflected in the
861 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
862 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
864 * @return 0 on success; nonzero on error. This function may return any value
865 * returned by wimlib_write() as well as the following error codes:
866 * @retval ::WIMLIB_ERR_NO_FILENAME
867 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
868 * than a WIM read with wimlib_open_wim().
869 * @retval ::WIMLIB_ERR_RENAME
870 * The temporary file that the WIM was written to could not be renamed to
871 * the original filename of @a wim.
873 extern int wimlib_overwrite(WIMStruct *wim, int flags);
876 * Updates the header and XML data of the WIM file, without the need to write
877 * out the entire WIM to a temporary file as in wimlib_write().
879 * This function must only be used if no files, directories, or images have been
880 * added, removed, or changed in the WIM. It must be used when only the boot
881 * index or the name or description of image(s) has been changed.
883 * After this function returns, @a wim must be freed using wimlib_free(). Any
884 * further actions on @a wim before doing this are undefined.
887 * Pointer to the ::WIMStruct for the WIM file to overwrite.
889 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
890 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
892 * @return 0 on success; nonzero on error.
894 * @retval ::WIMLIB_ERR_NO_FILENAME
895 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
896 * than a WIM read with wimlib_open_wim().
897 * @retval ::WIMLIB_ERR_NOMEM
898 * Failed to allocate needed memory.
899 * @retval ::WIMLIB_ERR_OPEN
900 * The WIM file associated with @a wim could not be re-opened read-write.
901 * @retval ::WIMLIB_ERR_READ
902 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY was specified in @a flags, but data
903 * from the WIM file associated with @a wim could not be read to compute
904 * the SHA1 message digests, or the old integrity table (if it existed)
906 * @retval ::WIMLIB_ERR_WRITE
907 * Failed to write the WIM header, the XML data, or the integrity table to
908 * the WIM file associated with @a wim.
910 extern int wimlib_overwrite_xml_and_header(WIMStruct *wim, int flags);
913 * Prints information about one image, or all images, contained in a WIM.
916 * Pointer to the ::WIMStruct for a WIM file.
918 * The image about which to print information. Can be the number of an
919 * image, or ::WIM_ALL_IMAGES to print information about all images in the
922 * @return This function has no return value.
924 extern void wimlib_print_available_images(const WIMStruct *wim, int image);
927 * Prints the full paths to all files contained in an image, or all images, in a
931 * Pointer to the ::WIMStruct for a WIM file.
933 * Which image to print files for. Can be the number of an image, or
934 * ::WIM_ALL_IMAGES to print the files contained in all images.
936 * @return 0 on success; nonzero on error.
937 * @retval ::WIMLIB_ERR_DECOMPRESSION
938 * The metadata resource for one of the specified images could not be
940 * @retval ::WIMLIB_ERR_INVALID_DENTRY
941 * A directory entry in the metadata resource for one of the specified
943 * @retval ::WIMLIB_ERR_INVALID_IMAGE
944 * @a image does not specify a valid image in @a wim, and is not
946 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
947 * The metadata resource for one of the specified images is invalid.
948 * @retval ::WIMLIB_ERR_NOMEM
949 * Failed to allocate needed memory.
950 * @retval ::WIMLIB_ERR_READ
951 * An unexpected read error or end-of-file occurred when reading the
952 * metadata resource for one of the specified images.
954 extern int wimlib_print_files(WIMStruct *wim, int image);
957 * Prints detailed information from the header of a WIM file.
960 * Pointer to the ::WIMStruct for a WIM file.
962 * @return This function has no return value.
965 extern void wimlib_print_header(const WIMStruct *wim);
968 * Prints the lookup table of a WIM file. The lookup table maps SHA1 message
969 * digests, as found in the directory entry tree in the WIM file, to file
970 * resources in the WIM file. This table includes one entry for each unique
971 * file in the WIM, so it can be quite long. There is only one lookup table per
975 * Pointer to the ::WIMStruct for a WIM file.
977 * @return This function has no return value.
979 extern void wimlib_print_lookup_table(WIMStruct *wim);
982 * Prints the metadata of the specified image in a WIM file. The metadata
983 * consists of the security data as well as the directory entry tree, and each
984 * image has its own metadata.
987 * Pointer to the ::WIMStruct for a WIM file.
989 * Which image to print the metadata for. Can be the number of an image,
990 * or ::WIM_ALL_IMAGES to print the metadata for all images in the WIM.
992 * @return 0 on success; nonzero on error.
993 * @retval ::WIMLIB_ERR_DECOMPRESSION
994 * The metadata resource for one of the specified images could not be
996 * @retval ::WIMLIB_ERR_INVALID_DENTRY
997 * A directory entry in the metadata resource for one of the specified
999 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1000 * @a image does not specify a valid image in @a wim, and is not
1002 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1003 * The metadata resource for one of the specified images is invalid.
1004 * @retval ::WIMLIB_ERR_NOMEM
1005 * Failed to allocate needed memory.
1006 * @retval ::WIMLIB_ERR_READ
1007 * An unexpected read error or end-of-file occurred when reading the
1008 * metadata resource for one of the specified images.
1010 extern int wimlib_print_metadata(WIMStruct *wim, int image);
1013 * Prints some basic information about a WIM file. All information printed by
1014 * this function is also printed by wimlib_print_header(), but
1015 * wimlib_print_wim_information() prints some of this information more concisely
1016 * and in a more readable form.
1019 * Pointer to the ::WIMStruct for a WIM file.
1021 * @return This function has no return value.
1023 extern void wimlib_print_wim_information(const WIMStruct *wim);
1026 * Translates a string specifying the name or number of an image in the WIM into
1027 * the number of the image. The images are numbered starting at 1.
1030 * Pointer to the ::WIMStruct for a WIM file.
1031 * @param image_name_or_num
1032 * A string specifying which image. If it begins with a number, it is
1033 * taken to be a string specifying the image number. Otherwise, it is
1034 * taken to be the name of an image, as specified in the XML data for the
1035 * WIM file. It also may be the keyword "all", which will resolve to
1039 * If the string resolved to a single existing image, the number of that
1040 * image, counting starting at 1, is returned. If the keyword "all" was
1041 * specified, ::WIM_ALL_IMAGES is returned. Otherwise, ::WIM_NO_IMAGE is
1044 extern int wimlib_resolve_image(WIMStruct *wim, const char *image_name_or_num);
1047 * Sets which image in the WIM is marked as bootable.
1050 * Pointer to the ::WIMStruct for a WIM file.
1052 * The number of the image to mark as bootable, or 0 to mark no image as
1054 * @return 0 on success; nonzero on error.
1055 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1056 * @a boot_idx does not specify an existing image in @a wim, and it was not
1059 extern int wimlib_set_boot_idx(WIMStruct *wim, int boot_idx);
1062 * Changes the description of an image in the WIM.
1065 * Pointer to the ::WIMStruct for a WIM file.
1067 * The number of the image for which to change the description.
1068 * @param description
1069 * The new description to give the image. It may be @c NULL, which
1070 * indicates that the image is to be given no description.
1072 * @return 0 on success; nonzero on error.
1073 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1074 * @a image does not specify a single existing image in @a wim.
1075 * @retval ::WIMLIB_ERR_NOMEM
1076 * Failed to allocate the memory needed to duplicate the @a description
1079 extern int wimlib_set_image_descripton(WIMStruct *wim, int image,
1080 const char *description);
1083 * Changes the name of an image in the WIM.
1086 * Pointer to the ::WIMStruct for a WIM file.
1088 * The number of the image for which to change the name.
1090 * The new name to give the image. It must not be @c NULL.
1092 * @return 0 on success; nonzero on error.
1093 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1094 * There is already an image named @a name in @a wim.
1095 * @retval ::WIMLIB_ERR_INVALID_PARAM
1096 * @a name was @c NULL or the empty string.
1097 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1098 * @a image does not specify a single existing image in @a wim.
1099 * @retval ::WIMLIB_ERR_NOMEM
1100 * Failed to allocate the memory needed to duplicate the @a name string.
1102 extern int wimlib_set_image_name(WIMStruct *wim, int image, const char *name);
1105 * Sets the link type to use when extracting files from a WIM. This applies
1106 * when extracting one image as well as when extracting all images. Cross-image
1107 * links may save a lot of space because it is common for files to be referenced
1108 * multiple times in WIM files. By default, the link type used for extraction
1109 * is ::WIM_LINK_TYPE_NONE, meaning that links are not created.
1112 * Pointer to the ::WIMStruct for a WIM file
1114 * ::WIM_LINK_TYPE_NONE, ::WIM_LINK_TYPE_SYMBOLIC, or ::WIM_LINK_TYPE_HARD.
1116 * @return 0 on success; nonzero on error.
1117 * @retval ::WIMLIB_ERR_INVALID_PARAM
1118 * @a link_type was not ::WIM_LINK_TYPE_NONE, ::WIM_LINK_TYPE_SYMBOLIC,
1119 * or ::WIM_LINK_TYPE_HARD.
1121 extern int wimlib_set_link_type(WIMStruct *wim, int link_type);
1124 * Set the functions that wimlib uses to allocate and free memory.
1126 * These settings are global and not per-WIM.
1128 * The default is to use the default @c malloc() and @c free() from the C
1131 * @param malloc_func
1132 * A function equivalent to @c malloc() that wimlib will use to allocate
1133 * memory. If @c NULL, the allocator function is set back to the default
1134 * @c malloc() from the C library.
1136 * A function equivalent to @c free() that wimlib will use to free memory.
1137 * If @c NULL, the free function is set back to the default @c free() from
1139 * @param realloc_func
1140 * A function equivalent to @c realloc() that wimlib will use to reallocate
1141 * memory. If @c NULL, the free function is set back to the default @c
1142 * realloc() from the C library.
1143 * @return 0 on success; nonzero on error.
1144 * @retval ::WIMLIB_ERR_UNSUPPORTED
1145 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
1146 * so custom memory allocators are unsupported.
1148 int wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
1149 void (*free_func)(void *),
1150 void *(*realloc_func)(void *, size_t));
1153 * Sets whether wimlib is to print error messages to @c stderr when a function
1154 * fails or not. These error messages may provide information that cannot be
1155 * determined only from the error code that is returned.
1157 * This setting is global and not per-WIM.
1159 * By default, error messages are not printed.
1161 * @param show_messages
1162 * @c true if error messages are to be printed; @c false if error messages
1163 * are not to be printed.
1165 * @return 0 on success; nonzero on error.
1166 * @retval ::WIMLIB_ERR_UNSUPPORTED
1167 * @a show_messages was @c true, but wimlib was compiled with the @c
1168 * --without-error-messages option. Therefore, error messages cannot be
1171 extern int wimlib_set_print_errors(bool show_messages);
1174 * Sets whether wimlib is to be verbose when extracting files from a WIM or when
1175 * creating an image from a directory (i.e. whether it will print all affected
1176 * files or not.) This is a per-WIM parameter.
1179 * Pointer to the ::WIMStruct for the WIM file.
1181 * Whether wimlib is to be verbose when extracting files from @a wim using
1182 * wimlib_extract_image() or when adding an image to @a wim using
1183 * wimlib_add_image().
1185 * @return This function has no return value.
1187 extern void wimlib_set_verbose(WIMStruct *wim, bool verbose);
1190 * Sets and creates the directory to which files are to be extracted when
1191 * extracting files from the WIM.
1194 * Pointer to the ::WIMStruct for the WIM file.
1196 * The name of the directory to extract files to.
1198 * @return 0 on success; nonzero on error.
1199 * @retval ::WIMLIB_ERR_INVALID_PARAM
1200 * @a dir was @c NULL.
1201 * @retval ::WIMLIB_ERR_MKDIR
1202 * @a dir does not already exist and it could not created.
1203 * @retval ::WIMLIB_ERR_NOMEM
1204 * Failed to allocate the memory needed to duplicate the @a dir string.
1206 extern int wimlib_set_output_dir(WIMStruct *wim, const char *dir);
1209 * Unmounts a WIM image that was mounted using wimlib_mount().
1211 * Blocks until it is known whether the mount succeeded or failed.
1213 * To perform this operation, the process calling wimlib_unmount() communicates
1214 * with the process that had called wimlib_mount().
1216 * There is currently a design problem with this function because it is hard to
1217 * know whether the filesystem daemon is still working or whether it has
1218 * crashed, has been killed, or has reached an infinite loop. However, ideally
1219 * there should be no infinite loops or crashes in the code, so this wouldn't be
1220 * much of a problem. Currently, a timeout of 600 seconds (so long because WIMs
1221 * can be very large) is implemented so that this function will not wait forever
1222 * before returning failure.
1225 * The directory that the WIM image was mounted on.
1227 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY or
1228 * ::WIMLIB_UNMOUNT_FLAG_COMMIT. Neither of these flags affect read-only
1231 * @return 0 on success; nonzero on error.
1232 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
1233 * The filesystem daemon was unable to remove the staging directory and the
1234 * temporary files that it contains.
1235 * @retval ::WIMLIB_ERR_FORK
1236 * Could not @c fork() the process.
1237 * @retval ::WIMLIB_ERR_FUSERMOUNT
1238 * The @b fusermount program could not be executed or exited with a failure
1240 * @retval ::WIMLIB_ERR_MQUEUE
1241 * Could not open a POSIX message queue to communicate with the filesystem
1242 * daemon servicing the mounted filesystem, could not send a message
1243 * through the queue, or could not receive a message through the queue.
1244 * @retval ::WIMLIB_ERR_NOMEM
1245 * Failed to allocate needed memory.
1246 * @retval ::WIMLIB_ERR_OPEN
1247 * The filesystem daemon could not open a temporary file for writing the
1249 * @retval ::WIMLIB_ERR_TIMEOUT
1250 * 600 seconds elapsed while waiting for the filesystem daemon to notify
1251 * the process of its exit status, so the WIM file probably was not written
1253 * @retval ::WIMLIB_ERR_READ
1254 * A read error occurred when the filesystem daemon tried to a file from
1255 * the staging directory
1256 * @retval ::WIMLIB_ERR_RENAME
1257 * The filesystem daemon failed to rename the newly written WIM file to the
1258 * original WIM file.
1259 * @retval ::WIMLIB_ERR_WRITE
1260 * A write error occurred when the filesystem daemon was writing to the new
1261 * WIM file, or the filesystem daemon was unable to flush changes that had
1262 * been made to files in the staging directory.
1264 extern int wimlib_unmount(const char *dir, int flags);
1267 * Writes the WIM to a file.
1270 * Pointer to the ::WIMStruct for a WIM file. There may have been
1271 * in-memory changes made to it, which are then reflected in the output
1274 * The path to the file to write the WIM to.
1276 * The image inside the WIM to write. Use ::WIM_ALL_IMAGES to include all
1279 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
1280 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS. If
1281 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY is given, an integrity table is
1282 * included in the WIM being written. If ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS
1283 * is given, the progress of the calculation of the integrity table is
1286 * @return 0 on success; nonzero on error.
1287 * @retval ::WIMLIB_ERR_DECOMPRESSION
1288 * Failed to decompress a metadata or file resource in @a wim.
1289 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1290 * A directory entry in the metadata resource for @a image in @a wim is
1292 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1293 * @a image does not specify a single existing image in @a wim, and is not
1295 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1296 * The metadata resource for @a image in @a wim is invalid.
1297 * @retval ::WIMLIB_ERR_NOMEM
1298 * Failed to allocate needed memory.
1299 * @retval ::WIMLIB_ERR_OPEN
1300 * Failed to open @a path for writing, or some file resources in @a
1301 * wim refer to files in the outside filesystem, and one of these files
1302 * could not be opened for reading.
1303 * @retval ::WIMLIB_ERR_READ
1304 * An error occurred when trying to read data from the WIM file associated
1305 * with @a wim, or some file resources in @a wim refer to files in the
1306 * outside filesystem, and a read error occurred when reading one of these
1308 * @retval ::WIMLIB_ERR_WRITE
1309 * An error occurred when trying to write data to the new WIM file at @a
1312 extern int wimlib_write(WIMStruct *wim, const char *path, int image, int flags);
1316 #endif /* _WIMLIB_H */