4 * External header for wimlib.
8 * Copyright (C) 2012 Eric Biggers
10 * This file is part of wimlib, a library for working with WIM files.
12 * wimlib is free software; you can redistribute it and/or modify it under the
13 * terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 3 of the License, or (at your option)
17 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 * A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with wimlib; if not, see http://www.gnu.org/licenses/.
28 * \section intro Introduction
30 * wimlib is a C library to read, write, and mount archive files in the Windows
31 * Imaging Format (WIM files). These files are normally created using the @c
32 * imagex.exe utility on Windows, but this library provides a free
33 * implementetion of @c imagex for UNIX-based systems and an API to allow other
34 * programs to read, write, and mount WIM files. wimlib is comparable to
35 * Microsoft's WIMGAPI, but was designed independently and is not a clone of it.
37 * \section format WIM files
39 * A <b>Windows Imaging (WIM)</b> file is an archive. Like some other archive
40 * formats such as ZIP, files in WIM archives may be compressed. WIM archives
41 * support two Microsoft-specific compression formats: @b LZX and @b XPRESS.
42 * Both are based on LZ77 and Huffman encoding, and both are supported by
45 * Unlike ZIP files, WIM files can contain multiple independent toplevel
46 * directory trees known as @a images. While each image has its own metadata,
47 * files are not duplicated for each image; instead, each file is included only
48 * once in the entire WIM. Microsoft did this so that in one WIM file, they
49 * could do things like have 5 different versions of Windows that are almost
52 * Microsoft provides documentation for the WIM file format, XPRESS compression
53 * format, and LZX compression format. The XPRESS documentation is acceptable,
54 * but the LZX documentation is not entirely correct, and the WIM documentation
55 * itself is very incomplete and is of unacceptable quality.
57 * A WIM file may be either stand-alone or split into multiple parts.
59 * \section winpe Windows PE
61 * A major use for this library is to create customized images of Windows PE, the
62 * Windows Preinstallation Environment, without having to rely on Windows. Windows
63 * PE is a lightweight version of Windows that can run entirely from memory and can
64 * be used to install Windows from local media or a network drive or perform
65 * maintenance. Windows PE is the operating system that runs when you boot from
66 * the Windows installation media.
68 * You can find Windows PE on the installation DVD for Windows Vista, Windows 7,
69 * or Windows 8, in the file @c sources/boot.wim. Windows PE can also be found
70 * in the Windows Automated Installation Kit (WAIK), which is free to download
71 * from Microsoft, inside the @c WinPE.cab file, which you can extract if you
72 * install either the @c cabextract or @c p7zip programs.
74 * In addition, Windows installations and recovery partitions frequently contain a
75 * WIM containing an image of the Windows Recovery Environment, which is similar to
78 * \section ntfs NTFS support
80 * As of version 1.0.0, wimlib supports capturing and applying images directly
81 * to NTFS volumes. This was made possible with the help of libntfs-3g from the
82 * NTFS-3g project. This feature supports capturing and restoring NTFS-specific
83 * data such as security descriptors, alternate data streams, and reparse point
86 * The code for NTFS image capture and image application is complete enough that
87 * it is possible to apply an image from the "install.wim" contained in recent
88 * Windows installation media (Vista, Windows 7, or Windows 8) directly to a
89 * NTFS volume, and then boot Windows from it after preparing the Boot
90 * Configuration Data. In addition, a Windows installation can be captured (or
91 * backed up) into a WIM file, and then re-applied later.
93 * \section starting Getting Started
95 * wimlib uses the GNU autotools, so it should be easy to install with
96 * <code>configure && make && sudo make install</code>; however, please see the
97 * README for more information about installing it. To use wimlib in a program
98 * after installing it, include @c wimlib.h and link your program with @c -lwim.
100 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure. A ::WIMStruct
101 * may represent either a stand-alone WIM or one part of a split WIM.
103 * All functions in wimlib's public API are prefixed with @c wimlib. Most
104 * return an integer error code on failure. Use wimlib_get_error_string() to
105 * get a string that describes an error code. wimlib also can print error
106 * messages itself when an error happens, and these may be more informative than
107 * the error code; to enable this, call wimlib_set_print_errors(). Please note
108 * that this is for convenience only, and some errors can occur without a
109 * message being printed.
111 * wimlib is thread-safe as long as different ::WIMStruct's are used, except for
112 * the fact that wimlib_set_print_errors() and wimlib_set_memory_allocator()
113 * both apply globally.
115 * To open an existing WIM, use wimlib_open_wim().
117 * To create a new WIM that initially contains no images, use
118 * wimlib_create_new_wim().
120 * To add an image to a WIM file from a directory tree on your filesystem, call
121 * wimlib_add_image(). This can be done with a ::WIMStruct gotten from
122 * wimlib_open_wim() or from wimlib_create_new_wim(). Alternatively, you can
123 * capture a WIM directory from a NTFS volume if you provide the
124 * ::WIMLIB_ADD_IMAGE_FLAG_NTFS flag, provided that wimlib was not compiled with
125 * the <code>--without-ntfs-3g</code> flag.
127 * To extract an image from a WIM file, call wimlib_extract_image(). You may
128 * extract an image to a directory or directly to a NTFS volume, the latter of
129 * which will preserve NTFS-specific data such as security descriptors.
131 * wimlib supports mounting WIM files either read-only or read-write. Mounting
132 * is done using wimlib_mount_image() and unmounting is done using
133 * wimlib_unmount_image(). Mounting can be done without root privileges because
134 * it is implemented using FUSE (Filesystem in Userspace). If wimlib is
135 * compiled with the <code>--without-fuse</code> flag, these functions will be
136 * available but will fail.
138 * After creating or modifying a WIM file, you can write it to a file using
139 * wimlib_write(). Alternatively, if the WIM was originally read from a file,
140 * you can use wimlib_overwrite() to overwrite the original file.
142 * Please not: merely by calling wimlib_add_image() or many of the other
143 * functions in this library that operate on ::WIMStruct's, you are @b not
144 * modifying the WIM file on disk. Changes are not saved until you explicitly
145 * call wimlib_write() or wimlib_overwrite().
147 * After you are done with the WIM file, use wimlib_free() to free all memory
148 * associated with a ::WIMStruct and close all files associated with it.
150 * A number of functions take a pointer to a progress function of type
151 * ::wimlib_progress_func_t. This function will be called periodically during
152 * the WIM operation(s) to report on the progress of the operation (e.g. how
153 * many bytes have been written so far).
155 * To see an example of how to use wimlib, see the file @c programs/imagex.c in
156 * wimlib's source tree.
158 * \section imagex imagex
160 * wimlib comes with the <b>imagex</b> program, which is documented in man pages.
162 * \section mkwinpeimg mkwinpeimg
164 * wimlib comes with the <b>mkwinpeimg</b> script, which is documented in a man
167 * \section Limitations
169 * While wimlib supports the main features of WIM files, wimlib currently has
170 * the following limitations:
171 * - Different versions of the WIM file format are unsupported. There is one
172 * different version of the format from development versions of Windows Vista,
173 * but I'm not planning to support it.
174 * - Compressed resource chunk sizes other than 32768 are unsupported (except for
175 * uncompressed WIMs, for which the chunk size field is ignored). As far as I
176 * can tell, other chunk sizes are not used in compressed WIMs. Let me know
177 * if you find a WIM file with a different chunk size.
178 * - wimlib does not provide a clone of the @b PEImg tool that allows you to
179 * make certain Windows-specific modifications to a Windows PE image, such as
180 * adding a driver or Windows component. Such a tool could conceivably be
181 * implemented on top of wimlib, although it likely would be hard to implement
182 * because it would have to do very Windows-specific things such as
183 * manipulating the driver store. wimlib does provide the @b mkwinpeimg
184 * script for a similar purpose, however. With regards to adding drivers to
185 * Windows PE, you have the option of putting them anywhere in the Windows PE
186 * image, then loading them after boot using @b drvload.exe.
187 * - There is not yet a way to extract specific files or directories from a WIM
188 * file without mounting it, or to add, remove, or modify files in a WIM
189 * without mounting it, other than by adding or removing an entire image. I
190 * can implement this if requested, but I intend the FUSE mount feature to be
191 * used for this purpose, as it is easy to do these things in whatever way you
192 * want after the image is mounted.
193 * - Currently, Microsoft's @a image.exe can create slightly smaller WIM files
194 * than wimlib when using maximum (LZX) compression because it knows how to
195 * split up LZX compressed blocks, which is not yet implemented in wimlib.
196 * - wimlib is experimental and likely contains bugs; use Microsoft's @a
197 * imagex.exe if you want to make sure your WIM files are made "correctly".
199 * \section legal License
201 * The wimlib library, as well as the programs and scripts distributed with it
202 * (@b imagex and @b mkwinpeimg), is licensed under the GNU General Public
203 * License version 3 or later.
212 #include <inttypes.h>
215 * Opaque structure that represents a WIM file.
217 typedef struct WIMStruct WIMStruct;
220 * Specifies the compression type of a WIM file.
222 enum wimlib_compression_type {
223 /** An invalid compression type. */
224 WIMLIB_COMPRESSION_TYPE_INVALID = -1,
226 /** The WIM does not include any compressed resources. */
227 WIMLIB_COMPRESSION_TYPE_NONE = 0,
229 /** Compressed resources in the WIM use LZX compression. */
230 WIMLIB_COMPRESSION_TYPE_LZX = 1,
232 /** Compressed resources in the WIM use XPRESS compression. */
233 WIMLIB_COMPRESSION_TYPE_XPRESS = 2,
236 enum wimlib_progress_msg {
237 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
238 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN,
239 WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_END,
240 WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
241 WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS,
242 WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END,
244 WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
245 WIMLIB_PROGRESS_MSG_SCAN_END,
247 WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
248 WIMLIB_PROGRESS_MSG_WRITE_METADATA_BEGIN,
249 WIMLIB_PROGRESS_MSG_WRITE_METADATA_END,
250 WIMLIB_PROGRESS_MSG_RENAME,
252 WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY,
254 WIMLIB_PROGRESS_MSG_CALC_INTEGRITY,
256 WIMLIB_PROGRESS_MSG_JOIN_STREAMS,
258 WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
259 WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
262 union wimlib_progress_info {
264 uint64_t total_bytes;
265 uint64_t total_streams;
266 uint64_t completed_bytes;
267 uint64_t completed_streams;
268 unsigned num_threads;
269 int compression_type;
276 const char *image_name;
278 uint64_t total_bytes;
279 uint64_t completed_bytes;
280 uint64_t num_streams;
287 uint64_t total_bytes;
288 uint64_t completed_bytes;
289 uint32_t completed_chunks;
290 uint32_t total_chunks;
292 const char *filename;
295 uint64_t total_bytes;
296 uint64_t completed_bytes;
297 unsigned completed_parts;
298 unsigned total_parts;
299 const char *filename;
302 uint64_t completed_bytes;
303 unsigned cur_part_number;
304 const char *part_name;
305 uint64_t total_bytes;
309 /** A user-supplied function that will be called periodically during certain WIM
310 * operations. The first argument specifies the type of operation that is being
311 * performed or is about to be started or has been completed. The second
312 * argument is a pointer to one of a number of structures depending on the first
313 * argument. It may be @c NULL for some message types.
316 * is currently ignored, but it may do something in the future. (Set it to 0
319 typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
320 const union wimlib_progress_info *info);
322 /*****************************
323 * WIMLIB_ADD_IMAGE_FLAG_* *
324 *****************************/
326 /** Directly capture a NTFS volume, not a generic directory. */
327 #define WIMLIB_ADD_IMAGE_FLAG_NTFS 0x00000001
329 /** Follow symlinks; archive and dump the files they point to. Cannot be used
330 * with ::WIMLIB_ADD_IMAGE_FLAG_NTFS. */
331 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE 0x00000002
333 /** Print the name of each file or directory as it is scanned to be included in
335 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE 0x00000004
337 /** Mark the image being added as the bootable image of the WIM. */
338 #define WIMLIB_ADD_IMAGE_FLAG_BOOT 0x00000008
340 /******************************
341 * WIMLIB_EXPORT_FLAG_* *
342 ******************************/
344 /** See documentation for wimlib_export_image(). */
345 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
347 /******************************
348 * WIMLIB_EXTRACT_FLAG_* *
349 ******************************/
351 /** Apply the image directly to a NTFS volume, not a generic directory. */
352 #define WIMLIB_EXTRACT_FLAG_NTFS 0x00000001
354 /** When identical files are extracted from the WIM, always hard link them
355 * together. Not valid with ::WIMLIB_EXTRACT_FLAG_NTFS. */
356 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000002
358 /** When identical files are extracted from the WIM, always symlink them
359 * together. Not valid with ::WIMLIB_EXTRACT_FLAG_NTFS. */
360 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
362 /** Print the name of each file as it is extracted from the WIM image. */
363 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
365 /** Read the WIM file sequentially while extracting the image. */
366 #define WIMLIB_EXTRACT_FLAG_SEQUENTIAL 0x00000010
368 /******************************
369 * WIMLIB_MOUNT_FLAG_* *
370 ******************************/
372 /** Mount the WIM read-write. */
373 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
375 /** For debugging only. (This passes the @c -d flag to @c fuse_main()).*/
376 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
378 /** Do not allow accessing alternate data streams. */
379 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000004
381 /** Access alternate data streams through extended file attributes. This is the
383 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000008
385 /** Access alternate data streams by specifying the file name, a colon, then the
386 * alternate file stream name. */
387 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000010
389 /******************************
390 * WIMLIB_OPEN_FLAG_* *
391 ******************************/
393 /** See documentation for wimlib_open_wim(). */
394 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
396 /** See documentation for wimlib_open_wim(). */
397 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x00000002
399 /******************************
400 * WIMLIB_UNMOUNT_FLAG_* *
401 ******************************/
403 /** Include an integrity table in the new WIM being written during the unmount.
404 * Ignored for read-only mounts. */
405 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
407 /** Unless this flag is given, changes to a mounted WIM are discarded. Ignored
408 * for read-only mounts. */
409 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
411 /******************************
412 * WIMLIB_WRITE_FLAG_* *
413 ******************************/
415 /** Include an integrity table in the new WIM file. */
416 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
418 /** Re-build the entire WIM file rather than appending data to it, if possible.
419 * (Applies to wimlib_overwrite(), not wimlib_write()). */
420 #define WIMLIB_WRITE_FLAG_REBUILD 0x00000002
422 /** Do not copy compressed resources between WIMs if the compression type is the
423 * same. Instead, recompress them. */
424 #define WIMLIB_WRITE_FLAG_RECOMPRESS 0x00000004
426 /** Call fsync() when the WIM file is closed */
427 #define WIMLIB_WRITE_FLAG_FSYNC 0x00000008
429 /** Specifying this flag overrides the default behavior of wimlib_overwrite()
430 * after one or more calls to wimlib_delete_image(), which is to rebuild the
431 * entire WIM. If you specifiy this flag to wimlib_overwrite() instead, only
432 * minimal changes to correctly remove the image from the WIM will be taken. In
433 * particular, all streams will be left alone, even if they are no longer
434 * references. This is probably not what you want, because almost no space will
435 * be spaced by deleting an image in this way. */
436 #define WIMLIB_WRITE_FLAG_SOFT_DELETE 0x00000010
439 * Possible values of the error code returned by many functions in wimlib.
441 * See the documentation for each wimlib function to see specifically what error
442 * codes can be returned by a given function, and what they mean.
444 enum wimlib_error_code {
445 WIMLIB_ERR_SUCCESS = 0,
446 WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE,
447 WIMLIB_ERR_DECOMPRESSION,
448 WIMLIB_ERR_DELETE_STAGING_DIR,
451 WIMLIB_ERR_FUSERMOUNT,
452 WIMLIB_ERR_IMAGE_COUNT,
453 WIMLIB_ERR_IMAGE_NAME_COLLISION,
454 WIMLIB_ERR_INTEGRITY,
455 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
456 WIMLIB_ERR_INVALID_CHUNK_SIZE,
457 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
458 WIMLIB_ERR_INVALID_DENTRY,
459 WIMLIB_ERR_INVALID_HEADER_SIZE,
460 WIMLIB_ERR_INVALID_IMAGE,
461 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
462 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
463 WIMLIB_ERR_INVALID_PARAM,
464 WIMLIB_ERR_INVALID_RESOURCE_HASH,
465 WIMLIB_ERR_INVALID_RESOURCE_SIZE,
466 WIMLIB_ERR_INVALID_SECURITY_DATA,
472 WIMLIB_ERR_NOT_A_WIM_FILE,
473 WIMLIB_ERR_NO_FILENAME,
481 WIMLIB_ERR_RESOURCE_ORDER,
482 WIMLIB_ERR_SPECIAL_FILE,
483 WIMLIB_ERR_SPLIT_INVALID,
484 WIMLIB_ERR_SPLIT_UNSUPPORTED,
487 WIMLIB_ERR_UNKNOWN_VERSION,
488 WIMLIB_ERR_UNSUPPORTED,
494 /** Used to indicate that no WIM image is currently selected. */
495 #define WIMLIB_NO_IMAGE 0
497 /** Used to specify all images in the WIM. */
498 #define WIMLIB_ALL_IMAGES (-1)
501 * Adds an image to a WIM file from a directory tree on disk.
503 * The directory tree is read immediately for the purpose of constructing a
504 * directory entry tree in-memory. Also, all files are read to calculate their
505 * SHA1 message digests. However, because the directory tree may contain a very
506 * large amount of data, the files themselves are not read into memory
507 * permanently, and instead references to their paths saved. The files are then
508 * read on-demand if wimlib_write() or wimlib_overwrite() is called.
510 * Please note that @b no changes are committed to the underlying WIM file (if
511 * any) until wimlib_write() or wimlib_overwrite() is called.
514 * Pointer to the ::WIMStruct for a WIM file to which the image will be
517 * A path to a directory in the outside filesystem. It will become the
518 * root directory for the WIM image.
520 * The name to give the image. This must be non-@c NULL.
522 * Pointer to the contents of an image capture configuration file. If @c
523 * NULL, a default string is used. Please see the manual page for
524 * <b>imagex capture</b> for more information.
526 * Length of the string @a config in bytes. Ignored if @a config is @c
529 * @param add_image_flags
530 * Bitwise OR of flags prefixed with WIMLIB_ADD_IMAGE_FLAG. If
531 * ::WIMLIB_ADD_IMAGE_FLAG_BOOT is specified, the image in @a wim that is
532 * marked as bootable is changed to the one being added. If
533 * ::WIMLIB_ADD_IMAGE_FLAG_VERBOSE is specified, the name of each file is
534 * printed as it is scanned or captured. If
535 * ::WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE is specified, the files or
536 * directories pointed to by symbolic links are archived rather than the
537 * symbolic links themselves.
539 * @param progress_func
540 * If non-NULL, a function that will be called periodically with the
541 * progress of the current operation.
543 * @return 0 on success; nonzero on error. On error, changes to @a wim are
544 * discarded so that it appears to be in the same state as when this function
547 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
548 * There is already an image named @a name in @a w.
549 * @retval ::WIMLIB_ERR_INVALID_PARAM
550 * @a dir was @c NULL, @a name was @c NULL, or @a name was the empty string.
551 * @retval ::WIMLIB_ERR_NOMEM
552 * Failed to allocate needed memory.
553 * @retval ::WIMLIB_ERR_NOTDIR
554 * @a dir is not a directory.
555 * @retval ::WIMLIB_ERR_OPEN
556 * Failed to open a file or directory in the directory tree rooted at @a
558 * @retval ::WIMLIB_ERR_READ
559 * Failed to read a file in the directory tree rooted at @a dir.
560 * @retval ::WIMLIB_ERR_SPECIAL_FILE
561 * The directory tree rooted at @a dir contains a special file that is not
562 * a directory, regular file, or symbolic link.
563 * @retval ::WIMLIB_ERR_STAT
564 * Failed obtain the metadata for a file or directory in the directory tree
566 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
567 * @a wim is part of a split WIM. Adding an image to a split WIM is
570 extern int wimlib_add_image(WIMStruct *wim, const char *dir,
571 const char *name, const char *config,
572 size_t config_len, int add_image_flags,
573 wimlib_progress_func_t progress_func);
576 * Creates a WIMStruct for a new WIM file.
579 * The type of compression to be used in the new WIM file. Must be
580 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
581 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
583 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
584 * written to the memory location pointed to by this paramater. The
585 * ::WIMStruct must be freed using using wimlib_free() when finished with
587 * @return 0 on success; nonzero on error.
588 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
589 * @a ctype was not ::WIMLIB_COMPRESSION_TYPE_NONE,
590 * ::WIMLIB_COMPRESSION_TYPE_LZX, or ::WIMLIB_COMPRESSION_TYPE_XPRESS.
591 * @retval ::WIMLIB_ERR_NOMEM
592 * Failed to allocate needed memory.
594 extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
597 * Deletes an image, or all images, from a WIM file.
599 * All streams referenced by the image(s) being deleted are removed from the
600 * lookup table of the WIM if they are not referenced by any other images in the
603 * Please note that @b no changes are committed to the underlying WIM file (if
604 * any) until wimlib_write() or wimlib_overwrite() is called.
607 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
610 * The number of the image to delete, or ::WIMLIB_ALL_IMAGES to delete all
612 * @return 0 on success; nonzero on failure. On failure, @a wim is guaranteed
613 * to be left unmodified only if @a image specified a single image. If instead
614 * @a image was ::WIMLIB_ALL_IMAGES and @a wim contained more than one image, it's
615 * possible for some but not all of the images to have been deleted when a
616 * failure status is returned.
618 * @retval ::WIMLIB_ERR_DECOMPRESSION
619 * Could not decompress the metadata resource for @a image.
620 * @retval ::WIMLIB_ERR_INVALID_DENTRY
621 * A directory entry in the metadata resource for @a image in the WIM is
623 * @retval ::WIMLIB_ERR_INVALID_IMAGE
624 * @a image does not exist in the WIM and is not ::WIMLIB_ALL_IMAGES.
625 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
626 * The metadata resource for @a image in the WIM is invalid.
627 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
628 * The security data for @a image in the WIM is invalid.
629 * @retval ::WIMLIB_ERR_NOMEM
630 * Failed to allocate needed memory.
631 * @retval ::WIMLIB_ERR_READ
632 * Could not read the metadata resource for @a image from the WIM.
633 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
634 * @a wim is part of a split WIM. Deleting an image from a split WIM is
637 extern int wimlib_delete_image(WIMStruct *wim, int image);
640 * Exports an image, or all the images, from a WIM file, into another WIM file.
642 * The destination image is made to share the same dentry tree and security data
643 * structure as the source image. This places some restrictions on additional
644 * functions that may be called. wimlib_mount_image() may not be called on
645 * either the source image or the destination image without an intervening call
646 * to a function that un-shares the images, such as wimlib_free() on @a
647 * dest_wim, or wimlib_delete_image() on either the source or destination image.
648 * Furthermore, you may not call wimlib_free() or wimlib_overwrite() on @a
649 * src_wim before any calls to functions such as wimlib_write() on @a dest_wim
650 * because @a dest_wim will have references back to @a src_wim.
652 * Previous versions of this function left @a dest_wim in an indeterminate state
653 * on failure. This is no longer the case; all changes to @a dest_wim made by
654 * this function are rolled back on failure.
656 * Previous versions of this function did not allow exporting an image that had
657 * been added by wimlib_add_image(). This is no longer the case; you may now
658 * export an image regardless of how it was added.
660 * Regardless of whether this function succeeds or fails, no user-visible
661 * changes are made to @a src_wim.
663 * Please note that @b no changes are committed to the underlying WIM file (if
664 * any) until wimlib_write() or wimlib_overwrite() is called.
667 * Pointer to the ::WIMStruct for a stand-alone WIM or part 1 of a split
668 * WIM that contains the image(s) being exported.
670 * The image to export from @a src_wim. Can be the number of an image, or
671 * ::WIMLIB_ALL_IMAGES to export all images.
673 * Pointer to the ::WIMStruct for a WIM file that will receive the images
676 * The name to give the exported image in the new WIM file. If left @c NULL,
677 * the name from @a src_wim is used. This parameter must be left @c NULL
678 * if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains more than one
679 * image; in that case, the names are all taken from the @a src_wim.
680 * @param dest_description
681 * The description to give the exported image in the new WIM file. If left
682 * @c NULL, the description from the @a src_wim is used. This parameter must
683 * be left @c NULL if @a src_image is ::WIMLIB_ALL_IMAGES and @a src_wim contains
684 * more than one image; in that case, the descriptions are all taken from
686 * @param export_flags
687 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
688 * bootable, or 0 if which image is marked as bootable in the destination
689 * WIM is to be left unchanged. If @a src_image is ::WIMLIB_ALL_IMAGES and
690 * there are multiple images in @a src_wim, specifying
691 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
692 * currently marked as bootable in @a src_wim; if that is the case, then
693 * that image is marked as bootable in the destination WIM.
694 * @param additional_swms
695 * Array of pointers to the ::WIMStruct for each additional part in the
696 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
697 * need to be in any particular order, but they must include all parts of
698 * the split WIM other than the first part, which must be provided in the
700 * @param num_additional_swms
701 * Number of additional WIM parts provided in the @a additional_swms array.
702 * This number should be one less than the total number of parts in the
703 * split WIM. Set to 0 if the WIM is a standalone WIM.
704 * @param progress_func
705 * If non-NULL, a function that will be called periodically with the
706 * progress of the current operation.
708 * @return 0 on success; nonzero on error.
709 * @retval ::WIMLIB_ERR_DECOMPRESSION
710 * Could not decompress the metadata resource for @a src_image
712 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
713 * One or more of the names being given to an exported image was already in
714 * use in the destination WIM.
715 * @retval ::WIMLIB_ERR_INVALID_DENTRY
716 * A directory entry in the metadata resource for @a src_image in @a
717 * src_wim is invalid.
718 * @retval ::WIMLIB_ERR_INVALID_IMAGE
719 * @a src_image does not exist in @a src_wim.
720 * @retval ::WIMLIB_ERR_INVALID_PARAM
721 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
722 * ::WIMLIB_ALL_IMAGES, @a src_wim contains multiple images, and no images in
723 * @a src_wim are marked as bootable; or @a dest_name and/or @a
724 * dest_description were non-<code>NULL</code>, @a src_image was
725 * ::WIMLIB_ALL_IMAGES, and @a src_wim contains multiple images; or @a src_wim
726 * or @a dest_wim was @c NULL.
727 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
728 * The metadata resource for @a src_image in @a src_wim is invalid.
729 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
730 * The security data for @a src_image in @a src_wim is invalid.
731 * @retval ::WIMLIB_ERR_NOMEM
732 * Failed to allocate needed memory.
733 * @retval ::WIMLIB_ERR_READ
734 * Could not read the metadata resource for @a src_image from @a src_wim.
735 * @retval ::WIMLIB_ERR_SPLIT_INVALID
736 * The source WIM is a split WIM, but the parts specified do not form a
737 * complete split WIM because they do not include all the parts of the
738 * original WIM, there are duplicate parts, or not all the parts have the
739 * same GUID and compression type.
740 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
741 * @a dest_wim is part of a split WIM. Exporting an image to a split WIM
744 extern int wimlib_export_image(WIMStruct *src_wim, int src_image,
745 WIMStruct *dest_wim, const char *dest_name,
746 const char *dest_description, int export_flags,
747 WIMStruct **additional_swms,
748 unsigned num_additional_swms,
749 wimlib_progress_func_t progress_func);
752 * Extracts an image, or all images, from a standalone or split WIM file.
755 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
758 * The image to extract. Can be the number of an image, or ::WIMLIB_ALL_IMAGES
759 * to specify that all images are to be extracted. ::WIMLIB_ALL_IMAGES cannot
760 * be used if ::WIMLIB_EXTRACT_FLAG_NTFS is specified in @a extract_flags.
762 * Directory to extract the WIM image(s) to (created if it does not already
763 * exist); or, with ::WIMLIB_EXTRACT_FLAG_NTFS in @a extract_flags, the
764 * name of the NTFS volume to extract the image to.
765 * @param extract_flags
766 * Bitwise OR of the flags prefixed with WIMLIB_EXTRACT_FLAG.
768 * If ::WIMLIB_EXTRACT_FLAG_NTFS is specified, @a target is interpreted as
769 * a NTFS volume to extract the image to. The volume will be opened using
770 * NTFS-3g and the image will be extracted to the root of the NTFS volume.
771 * Otherwise, @a target is interpreted as a directory to extract the
774 * If ::WIMLIB_EXTRACT_FLAG_NTFS is not specified, one or none of
775 * ::WIMLIB_EXTRACT_FLAG_HARDLINK or ::WIMLIB_EXTRACT_FLAG_SYMLINK may be
776 * specified. These flags cause extracted files that are identical to be
777 * hardlinked or symlinked together, depending on the flag. These flags
778 * override the hard link groups that are specified in the WIM file itself.
779 * If ::WIMLIB_ALL_IMAGES is provided as the @a image parameter, files may be
780 * hardlinked or symlinked across images if a file is found to occur in
781 * more than one image.
783 * You may also specify the flag ::WIMLIB_EXTRACT_FLAG_VERBOSE to cause
784 * informational messages to be printed during the extraction, including
785 * the name of each extracted file or directory.
787 * If ::WIMLIB_EXTRACT_FLAG_SEQUENTIAL is specified, streams are read from
788 * the WIM sequentially, if possible. If ::WIMLIB_ALL_IMAGES is specified,
789 * each image is considered separately with regards to the sequential
790 * order. It is also possible for alternate data streams to break the
791 * sequential order (this only applies if ::WIMLIB_EXTRACT_FLAG_NTFS is
793 * @param additional_swms
794 * Array of pointers to the ::WIMStruct for each additional part in the
795 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
796 * need to be in any particular order, but they must include all parts of
797 * the split WIM other than the first part, which must be provided in the
799 * @param num_additional_swms
800 * Number of additional WIM parts provided in the @a additional_swms array.
801 * This number should be one less than the total number of parts in the
802 * split WIM. Set to 0 if the WIM is a standalone WIM.
804 * @param progress_func
805 * If non-NULL, a function that will be called periodically with the
806 * progress of the current operation.
808 * @return 0 on success; nonzero on error.
809 * @retval ::WIMLIB_ERR_DECOMPRESSION
810 * Could not decompress a resource (file or metadata) for @a image in @a
812 * @retval ::WIMLIB_ERR_INVALID_DENTRY
813 * A directory entry in the metadata resource for @a image in @a wim is
815 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
816 * The SHA1 message digest of an extracted stream did not match the SHA1
817 * message digest given in the WIM file.
818 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
819 * A resource (file or metadata) for @a image in @a wim is invalid.
820 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
821 * The security data for @a image in @a wim is invalid.
822 * @retval ::WIMLIB_ERR_LINK
823 * Failed to create a symbolic link or a hard link.
824 * @retval ::WIMLIB_ERR_MKDIR
825 * Failed create a needed directory.
826 * @retval ::WIMLIB_ERR_NOMEM
827 * Failed to allocate needed memory.
828 * @retval ::WIMLIB_ERR_OPEN
829 * Could not open one of the files being extracted for writing.
830 * @retval ::WIMLIB_ERR_READ
831 * A unexpected end-of-file or read error occurred when trying to read data
832 * from the WIM file associated with @a wim.
833 * @retval ::WIMLIB_ERR_SPLIT_INVALID
834 * The WIM is a split WIM, but the parts specified do not form a complete
835 * split WIM because they do not include all the parts of the original WIM,
836 * there are duplicate parts, or not all the parts have the same GUID and
838 * @retval ::WIMLIB_ERR_WRITE
839 * Failed to write a file being extracted.
841 extern int wimlib_extract_image(WIMStruct *wim, int image,
842 const char *target, int extract_flags,
843 WIMStruct **additional_swms,
844 unsigned num_additional_swms,
845 wimlib_progress_func_t progress_func);
848 * Extracts the XML data for a WIM file to a file stream. Every WIM file
849 * includes a string of XML that describes the images contained in the WIM.
850 * This function works on standalone WIMs as well as split WIM parts.
853 * Pointer to the ::WIMStruct for a WIM file.
855 * @c stdout, or a FILE* opened for writing, to extract the data to.
857 * @return 0 on success; nonzero on error.
858 * @retval ::WIMLIB_ERR_WRITE
859 * Failed to completely write the XML data to @a fp.
861 extern int wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
864 * Frees all memory allocated for a WIMStruct and closes all files associated
868 * Pointer to the ::WIMStruct for a WIM file.
870 * @return This function has no return value.
872 extern void wimlib_free(WIMStruct *wim);
875 * Finds which image in a WIM is bootable.
878 * Pointer to the ::WIMStruct for a WIM file.
881 * 0 if no image is marked as bootable, or the number of the image marked
882 * as bootable (numbered starting at 1).
884 extern int wimlib_get_boot_idx(const WIMStruct *wim);
887 * Gets the compression type used in the WIM.
890 * Pointer to the ::WIMStruct for a WIM file
893 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX, or
894 * ::WIMLIB_COMPRESSION_TYPE_XPRESS.
896 extern int wimlib_get_compression_type(const WIMStruct *wim);
899 * Converts a compression type enumeration value into a string.
902 * ::WIMLIB_COMPRESSION_TYPE_NONE, ::WIMLIB_COMPRESSION_TYPE_LZX,
903 * ::WIMLIB_COMPRESSION_TYPE_XPRESS, or another value.
906 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
909 extern const char *wimlib_get_compression_type_string(int ctype);
912 * Converts an error code into a string describing it.
915 * The error code returned by one of wimlib's functions.
918 * Pointer to a statically allocated string describing the error code,
919 * or @c NULL if the error code is not valid.
921 extern const char *wimlib_get_error_string(enum wimlib_error_code code);
924 * Returns the description of the specified image.
927 * Pointer to the ::WIMStruct for a WIM file. It may be either a
928 * standalone WIM or a split WIM part.
930 * The number of the image, numbered starting at 1.
933 * The description of the image, or @c NULL if there is no such image, or
934 * @c NULL if the specified image has no description. The description
935 * string is in library-internal memory and may not be modified or freed;
936 * in addition, the string will become invalid if the description of the
937 * image is changed, the image is deleted, or the ::WIMStruct is destroyed.
939 extern const char *wimlib_get_image_description(const WIMStruct *wim, int image);
942 * Returns the name of the specified image.
945 * Pointer to the ::WIMStruct for a WIM file. It may be either a
946 * standalone WIM or a split WIM part.
948 * The number of the image, numbered starting at 1.
951 * The name of the image, or @c NULL if there is no such image. The name
952 * string is in library-internal memory and may not be modified or freed;
953 * in addition, the string will become invalid if the name of the image is
954 * changed, the image is deleted, or the ::WIMStruct is destroyed.
956 extern const char *wimlib_get_image_name(const WIMStruct *wim, int image);
960 * Gets the number of images contained in the WIM.
963 * Pointer to the ::WIMStruct for a WIM file. It may be either a
964 * standalone WIM or a split WIM part.
967 * The number of images contained in the WIM file.
969 extern int wimlib_get_num_images(const WIMStruct *wim);
972 * Gets the part number of part of a split WIM.
975 * Pointer to the ::WIMStruct for a WIM file.
976 * @param total_parts_ret
977 * If non-@c NULL, the total number of parts in the split WIM (1 for
978 * non-split WIMs) is written to this location.
981 * The part number of the WIM (1 for non-split WIMs)
983 extern int wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret);
986 * Returns true if the WIM has an integrity table.
989 * Pointer to the ::WIMStruct for a WIM file.
991 * @c true if the WIM has an integrity table; @c false otherwise.
993 extern bool wimlib_has_integrity_table(const WIMStruct *wim);
997 * Determines if an image name is already used by some image in the WIM.
1000 * Pointer to the ::WIMStruct for a WIM file.
1002 * The name to check.
1005 * @c true if there is already an image in @a wim named @a name; @c false
1006 * if there is no image named @a name in @a wim. (If @a name is @c NULL,
1007 * @c false is returned.)
1009 extern bool wimlib_image_name_in_use(const WIMStruct *wim, const char *name);
1012 * Joins a set of split WIMs into a stand-alone one-part WIM.
1015 * An array of strings that give the filenames of all parts of the split
1018 * Number of filenames in @a swms.
1019 * @param swm_open_flags
1020 * Open flags to use when opening the split WIM pats.
1021 * @param wim_write_flags
1022 * Write flags to use when writing the joined WIM.
1023 * @param output_path
1024 * The path to write the one-part WIM to.
1025 * @param progress_func
1026 * If non-NULL, a function that will be called periodically with the
1027 * progress of the current operation.
1029 * @return 0 on success; nonzero on error. This function may return any value
1030 * returned by wimlib_open_wim() and wimlib_write() except
1031 * ::WIMLIB_ERR_SPLIT_UNSUPPORTED, as well as the following error code:
1033 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1034 * The split WIMs do not form a valid WIM because they do not include all
1035 * the parts of the original WIM, there are duplicate parts, or not all the
1036 * parts have the same GUID and compression type.
1038 * Note that this function merely copies the resources, so it will not check to
1039 * see if the resources, including the metadata resources, are valid or not
1040 * (unless ::WIMLIB_WRITE_FLAG_RECOMPRESS is specified).
1042 extern int wimlib_join(const char **swms, unsigned num_swms,
1043 const char *output_path, int swm_open_flags,
1044 int wim_write_flags,
1045 wimlib_progress_func_t progress_func);
1048 * Mounts an image in a WIM file on a directory read-only or read-write.
1050 * A daemon will be forked to service the filesystem. In other words, this
1051 * function returns @b before the image is unmounted.
1053 * If the mount is read-write, modifications to the WIM are staged in a staging
1056 * wimlib_mount_image() may be called from multiple threads without intervening calls
1057 * to wimlib_unmount_image(), provided that different ::WIMStruct's are used. (This
1058 * was not the case for versions of this library 1.0.3 and earlier.)
1060 * wimlib_mount_image() cannot be used on an image that was exported with
1061 * wimlib_export_image() while the dentry trees for both images are still in
1062 * memory. In addition, wimlib_mount_image() may not be used to mount an image that
1063 * has just been added with wimlib_add_image() or
1064 * wimlib_add_image_from_ntfs_volume(), unless the WIM has been written and read
1065 * into a new ::WIMStruct.
1068 * Pointer to the ::WIMStruct for the WIM file to be mounted.
1070 * The number of the image to mount, numbered from 1. It must be an
1071 * existing, single image.
1073 * The path to an existing directory to mount the image on.
1074 * @param mount_flags
1075 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG. If
1076 * ::WIMLIB_MOUNT_FLAG_READWRITE is given, the WIM is mounted read-write
1077 * rather than the default of read-only. The interface to the WIM named
1078 * data streams is specified by exactly one of
1079 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE,
1080 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR, or
1081 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS. The default interface is
1082 * the XATTR interface.
1083 * @param additional_swms
1084 * Array of pointers to the ::WIMStruct for each additional part in the
1085 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
1086 * need to be in any particular order, but they must include all parts of
1087 * the split WIM other than the first part, which must be provided in the
1089 * @param num_additional_swms
1090 * Number of additional WIM parts provided in the @a additional_swms array.
1091 * This number should be one less than the total number of parts in the
1092 * split WIM. Set to 0 if the WIM is a standalone WIM.
1094 * @return 0 on success; nonzero on error.
1095 * @retval ::WIMLIB_ERR_DECOMPRESSION
1096 * Could not decompress the metadata resource for @a image in @a wim.
1097 * @retval ::WIMLIB_ERR_FUSE
1098 * A non-zero status was returned by @c fuse_main().
1099 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1100 * A directory entry in the metadata resource for @a image in @a wim is
1102 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1103 * @a image does not specify an existing, single image in @a wim.
1104 * @retval ::WIMLIB_ERR_INVALID_PARAM
1105 * @a image is shared among multiple ::WIMStruct's as a result of a call to
1106 * wimlib_export_image(), or @a image has been added with
1107 * wimlib_add_image() or wimlib_add_image_from_ntfs_volume().
1108 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1109 * The metadata resource for @a image in @a wim is invalid.
1110 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1111 * The security data for @a image in @a wim is invalid.
1112 * @retval ::WIMLIB_ERR_MKDIR
1113 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a mount_flags, but the
1114 * staging directory could not be created.
1115 * @retval ::WIMLIB_ERR_NOMEM
1116 * Failed to allocate needed memory.
1117 * @retval ::WIMLIB_ERR_NOTDIR
1118 * Could not determine the current working directory.
1119 * @retval ::WIMLIB_ERR_READ
1120 * An unexpected end-of-file or read error occurred when trying to read
1121 * data from the WIM file associated with @a wim.
1122 * @retval ::WIMLIB_ERR_SPLIT_INVALID
1123 * The WIM is a split WIM, but the parts specified do not form a complete
1124 * split WIM because they do not include all the parts of the original WIM,
1125 * there are duplicate parts, or not all the parts have the same GUID and
1127 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1128 * The WIM is a split WIM and a read-write mount was requested. We only
1129 * support mounting a split WIM read-only.
1131 extern int wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
1132 int mount_flags, WIMStruct **additional_swms,
1133 unsigned num_additional_swms);
1136 * Opens a WIM file and creates a ::WIMStruct for it.
1139 * The path to the WIM file to open.
1141 * Bitwise OR of flags ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
1142 * ::WIMLIB_OPEN_FLAG_SPLIT_OK.
1144 * If ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is given, the integrity table of
1145 * the WIM, if it exists, is checked, and this function will fail with an
1146 * ::WIMLIB_ERR_INTEGRITY status if any of the computed SHA1 message
1147 * digests of the WIM do not exactly match the corresponding message
1148 * digests given in the integrity table.
1150 * If ::WIMLIB_OPEN_FLAG_SPLIT_OK is given, no error will be issued if the
1151 * WIM is part of a split WIM; otherwise ::WIMLIB_ERR_SPLIT_UNSUPPORTED is
1152 * returned. (This flag may be removed in the future, in which case no
1153 * error will be issued when opening a split WIM.)
1155 * @param progress_func
1156 * If non-NULL, a function that will be called periodically with the
1157 * progress of the current operation.
1160 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
1161 * is written to the memory location pointed to by this parameter. The
1162 * ::WIMStruct must be freed using using wimlib_free() when finished with
1165 * @return 0 on success; nonzero on error.
1166 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
1167 * The lookup table of @a wim_file is compressed. Support for this can be
1168 * added to wimlib if needed, but it appears to be the case that the lookup
1169 * table is never compressed.
1170 * @retval ::WIMLIB_ERR_IMAGE_COUNT
1171 * The WIM is not the non-first part of a split WIM, and the number of
1172 * metadata resources found in the WIM did not match the image count given
1173 * in the WIM header, or the number of <IMAGE> elements in the XML
1174 * data for the WIM did not match the image count given in the WIM header.
1175 * @retval ::WIMLIB_ERR_INTEGRITY
1176 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
1177 * wim_file contains an integrity table, but the SHA1 message digest for a
1178 * chunk of the WIM does not match the corresponding message digest given
1179 * in the integrity table.
1180 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
1181 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
1182 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
1183 * The header of @a wim_file says that resources in the WIM are compressed,
1184 * but the header flag indicating LZX or XPRESS compression is not set.
1185 * @retval ::WIMLIB_ERR_INVALID_HEADER_SIZE
1186 * The length field of the WIM header is not 208.
1187 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
1188 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a open_flags and @a
1189 * wim_file contains an integrity table, but the integrity table is
1191 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
1192 * The lookup table for the WIM contained duplicate entries, or it
1193 * contained an entry with a SHA1 message digest of all 0's.
1194 * @retval ::WIMLIB_ERR_NOMEM
1195 * Failed to allocated needed memory.
1196 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
1197 * @a wim_file does not begin with the expected magic characters.
1198 * @retval ::WIMLIB_ERR_OPEN
1199 * Failed to open the file @a wim_file for reading.
1200 * @retval ::WIMLIB_ERR_READ
1201 * An unexpected end-of-file or read error occurred when trying to read
1202 * data from @a wim_file.
1203 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1204 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
1205 * givin in @a open_flags.
1206 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
1207 * A number other than 0x10d00 is written in the version field of the WIM
1208 * header of @a wim_file.
1209 * @retval ::WIMLIB_ERR_XML
1210 * The XML data for @a wim_file is invalid.
1212 extern int wimlib_open_wim(const char *wim_file, int open_flags,
1213 WIMStruct **wim_ret,
1214 wimlib_progress_func_t progress_func);
1217 * Overwrites the file that the WIM was originally read from, with changes made.
1219 * There are two ways that a WIM may be overwritten. The first is to do a full
1220 * rebuild: the new WIM is written to a temporary file and then renamed to the
1221 * original file after it is has been completely written. The temporary file
1222 * currently is made in the same directory as the original WIM file. A full
1223 * rebuild may take a while, but can be used even if images have been modified
1224 * or deleted, will produce a WIM with no holes, and has little chance of
1225 * unintentional data loss because the temporary WIM is fsync()ed before being
1226 * renamed to the original WIM.
1228 * The second way to overwrite a WIM is by appending to the end of it. This can
1229 * be much faster than a full rebuild, but it only works if the only operations
1230 * on the WIM have been to change the header or XML data, or to add new images.
1231 * Writing a WIM in this mode begins with writing any new file resources *after*
1232 * everything in the old WIM, even though this will leave a hole where the old
1233 * lookup table, XML data, and integrity were. This is done so that the WIM
1234 * remains valid even if the operation is aborted mid-write.
1236 * By default, the overwrite mode is chosen based on the past operations
1237 * performed on the WIM. Use the flag ::WIMLIB_WRITE_FLAG_REBUILD to explicitly
1238 * request a full rebuild.
1240 * In the temporary-file overwrite mode, no changes are made to the WIM on
1241 * failure, and the temporary file is deleted (if possible). Abnormal
1242 * termination of the program will result in the temporary file being orphaned.
1243 * In the direct append mode, the WIM is truncated to the original length on
1244 * failure, while abnormal termination of the program will result in extra data
1245 * appended to the original WIM, but it should still be a valid WIM.
1248 * Pointer to the ::WIMStruct for the WIM file to write. There may have
1249 * been in-memory changes made to it, which are then reflected in the
1251 * @param write_flags
1252 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY,
1253 * ::WIMLIB_WRITE_FLAG_REBUILD, ::WIMLIB_WRITE_FLAG_RECOMPRESS, and/or
1254 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE.
1255 * @param num_threads
1256 * Number of threads to use for compression (see wimlib_write()).
1257 * @param progress_func
1258 * If non-NULL, a function that will be called periodically with the
1259 * progress of the current operation.
1261 * @return 0 on success; nonzero on error. This function may return any value
1262 * returned by wimlib_write() as well as the following error codes:
1263 * @retval ::WIMLIB_ERR_NO_FILENAME
1264 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
1265 * than a WIM read with wimlib_open_wim().
1266 * @retval ::WIMLIB_ERR_RENAME
1267 * The temporary file that the WIM was written to could not be renamed to
1268 * the original filename of @a wim.
1269 * @retval ::WIMLIB_ERR_REOPEN
1270 * The WIM was overwritten successfully, but it could not be re-opened
1271 * read-only. Therefore, the resources in the WIM can no longer be
1272 * accessed, so this limits the functions that can be called on @a wim
1273 * before calling wimlib_free().
1275 extern int wimlib_overwrite(WIMStruct *wim, int write_flags,
1276 unsigned num_threads,
1277 wimlib_progress_func_t progress_func);
1280 * Prints information about one image, or all images, contained in a WIM.
1283 * Pointer to the ::WIMStruct for a WIM file.
1285 * The image about which to print information. Can be the number of an
1286 * image, or ::WIMLIB_ALL_IMAGES to print information about all images in the
1289 * @return This function has no return value. No error checking is done when
1290 * printing the information. If @a image is invalid, an error message is
1293 extern void wimlib_print_available_images(const WIMStruct *wim, int image);
1296 * Prints the full paths to all files contained in an image, or all images, in a
1300 * Pointer to the ::WIMStruct for a WIM file.
1302 * Which image to print files for. Can be the number of an image, or
1303 * ::WIMLIB_ALL_IMAGES to print the files contained in all images.
1305 * @return 0 on success; nonzero on error.
1306 * @retval ::WIMLIB_ERR_DECOMPRESSION
1307 * The metadata resource for one of the specified images could not be
1309 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1310 * A directory entry in the metadata resource for one of the specified
1311 * images is invaled.
1312 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1313 * @a image does not specify a valid image in @a wim, and is not
1314 * ::WIMLIB_ALL_IMAGES.
1315 * @retval ::WIMLIB_ERR_INVALID_PARAM
1316 * @a wim was @c NULL.
1317 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1318 * The metadata resource for one of the specified images is invalid.
1319 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1320 * The security data for one of the specified images is invalid.
1321 * @retval ::WIMLIB_ERR_NOMEM
1322 * Failed to allocate needed memory.
1323 * @retval ::WIMLIB_ERR_READ
1324 * An unexpected read error or end-of-file occurred when reading the
1325 * metadata resource for one of the specified images.
1326 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1327 * @a wim was not a standalone WIM and was not the first part of a split
1330 extern int wimlib_print_files(WIMStruct *wim, int image);
1333 * Prints detailed information from the header of a WIM file.
1336 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1337 * standalone WIM or part of a split WIM.
1339 * @return This function has no return value.
1342 extern void wimlib_print_header(const WIMStruct *wim);
1345 * Prints the lookup table of a WIM file. The lookup table maps SHA1 message
1346 * digests, as found in the directory entry tree in the WIM file, to file
1347 * resources in the WIM file. This table includes one entry for each unique
1348 * file in the WIM, so it can be quite long. There is only one lookup table per
1352 * Pointer to the ::WIMStruct for a WIM file.
1354 * @return This function has no return value.
1356 extern void wimlib_print_lookup_table(WIMStruct *wim);
1359 * Prints the metadata of the specified image in a WIM file. The metadata
1360 * consists of the security data as well as the directory entry tree, and each
1361 * image has its own metadata.
1364 * Pointer to the ::WIMStruct for a WIM file.
1366 * Which image to print the metadata for. Can be the number of an image,
1367 * or ::WIMLIB_ALL_IMAGES to print the metadata for all images in the WIM.
1369 * @return 0 on success; nonzero on error.
1370 * @retval ::WIMLIB_ERR_DECOMPRESSION
1371 * The metadata resource for one of the specified images could not be
1373 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1374 * A directory entry in the metadata resource for one of the specified
1375 * images is invaled.
1376 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1377 * @a image does not specify a valid image in @a wim, and is not
1378 * ::WIMLIB_ALL_IMAGES.
1379 * @retval ::WIMLIB_ERR_INVALID_PARAM
1380 * @a wim was @c NULL.
1381 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1382 * The metadata resource for one of the specified images is invalid.
1383 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1384 * The security data for one of the specified images is invalid.
1385 * @retval ::WIMLIB_ERR_NOMEM
1386 * Failed to allocate needed memory.
1387 * @retval ::WIMLIB_ERR_READ
1388 * An unexpected read error or end-of-file occurred when reading the
1389 * metadata resource for one of the specified images.
1390 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1391 * @a wim was not a standalone WIM and was not the first part of a split
1394 extern int wimlib_print_metadata(WIMStruct *wim, int image);
1397 * Prints some basic information about a WIM file. All information printed by
1398 * this function is also printed by wimlib_print_header(), but
1399 * wimlib_print_wim_information() prints some of this information more concisely
1400 * and in a more readable form.
1403 * Pointer to the ::WIMStruct for a WIM file.
1405 * @return This function has no return value.
1407 extern void wimlib_print_wim_information(const WIMStruct *wim);
1410 * Translates a string specifying the name or number of an image in the WIM into
1411 * the number of the image. The images are numbered starting at 1.
1414 * Pointer to the ::WIMStruct for a WIM file.
1415 * @param image_name_or_num
1416 * A string specifying which image. If it begins with a number, it is
1417 * taken to be a string specifying the image number. Otherwise, it is
1418 * taken to be the name of an image, as specified in the XML data for the
1419 * WIM file. It also may be the keyword "all" or the string "*", both of
1420 * which will resolve to ::WIMLIB_ALL_IMAGES.
1423 * If the string resolved to a single existing image, the number of that
1424 * image, counting starting at 1, is returned. If the keyword "all" was
1425 * specified, ::WIMLIB_ALL_IMAGES is returned. Otherwise, ::WIMLIB_NO_IMAGE is
1428 extern int wimlib_resolve_image(WIMStruct *wim, const char *image_name_or_num);
1431 * Sets which image in the WIM is marked as bootable.
1434 * Pointer to the ::WIMStruct for a WIM file.
1436 * The number of the image to mark as bootable, or 0 to mark no image as
1438 * @return 0 on success; nonzero on error.
1439 * @retval ::WIMLIB_ERR_INVALID_PARAM
1440 * @a wim was @c NULL.
1441 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1442 * @a boot_idx does not specify an existing image in @a wim, and it was not
1444 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1445 * @a wim is part of a split WIM. We do not support changing the boot
1446 * index of a split WIM.
1448 extern int wimlib_set_boot_idx(WIMStruct *wim, int boot_idx);
1451 * Changes the description of an image in the WIM.
1454 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1455 * standalone WIM or part of a split WIM; however, you should set the same
1456 * description on all parts of a split WIM.
1458 * The number of the image for which to change the description.
1459 * @param description
1460 * The new description to give the image. It may be @c NULL, which
1461 * indicates that the image is to be given no description.
1463 * @return 0 on success; nonzero on error.
1464 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1465 * @a image does not specify a single existing image in @a wim.
1466 * @retval ::WIMLIB_ERR_INVALID_PARAM
1467 * @a wim was @c NULL.
1468 * @retval ::WIMLIB_ERR_NOMEM
1469 * Failed to allocate the memory needed to duplicate the @a description
1472 extern int wimlib_set_image_descripton(WIMStruct *wim, int image,
1473 const char *description);
1476 * Changes what is written in the \<FLAGS\> element in the WIM XML data
1477 * (something like "Core" or "Ultimate")
1480 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1481 * standalone WIM or part of a split WIM; however, you should set the same
1482 * \<FLAGS\> element on all parts of a split WIM.
1484 * The number of the image for which to change the description.
1486 * The new \<FLAGS\> element to give the image. It may be @c NULL, which
1487 * indicates that the image is to be given no \<FLAGS\> element.
1489 * @return 0 on success; nonzero on error.
1490 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1491 * @a image does not specify a single existing image in @a wim.
1492 * @retval ::WIMLIB_ERR_INVALID_PARAM
1493 * @a wim was @c NULL.
1494 * @retval ::WIMLIB_ERR_NOMEM
1495 * Failed to allocate the memory needed to duplicate the @a flags string.
1497 extern int wimlib_set_image_flags(WIMStruct *wim, int image, const char *flags);
1500 * Changes the name of an image in the WIM.
1503 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1504 * standalone WIM or part of a split WIM; however, you should set the same
1505 * name on all parts of a split WIM.
1507 * The number of the image for which to change the name.
1509 * The new name to give the image. It must not a nonempty string.
1511 * @return 0 on success; nonzero on error.
1512 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1513 * There is already an image named @a name in @a wim.
1514 * @retval ::WIMLIB_ERR_INVALID_PARAM
1515 * @a name was @c NULL or the empty string, or @a wim was @c NULL.
1516 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1517 * @a image does not specify a single existing image in @a wim.
1518 * @retval ::WIMLIB_ERR_NOMEM
1519 * Failed to allocate the memory needed to duplicate the @a name string.
1521 extern int wimlib_set_image_name(WIMStruct *wim, int image, const char *name);
1524 * Set the functions that wimlib uses to allocate and free memory.
1526 * These settings are global and not per-WIM.
1528 * The default is to use the default @c malloc() and @c free() from the C
1531 * Please note that some external functions we call still may use the standard
1532 * memory allocation functions.
1534 * @param malloc_func
1535 * A function equivalent to @c malloc() that wimlib will use to allocate
1536 * memory. If @c NULL, the allocator function is set back to the default
1537 * @c malloc() from the C library.
1539 * A function equivalent to @c free() that wimlib will use to free memory.
1540 * If @c NULL, the free function is set back to the default @c free() from
1542 * @param realloc_func
1543 * A function equivalent to @c realloc() that wimlib will use to reallocate
1544 * memory. If @c NULL, the free function is set back to the default @c
1545 * realloc() from the C library.
1546 * @return 0 on success; nonzero on error.
1547 * @retval ::WIMLIB_ERR_UNSUPPORTED
1548 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
1549 * so custom memory allocators are unsupported.
1551 int wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
1552 void (*free_func)(void *),
1553 void *(*realloc_func)(void *, size_t));
1556 * Sets whether wimlib is to print error messages to @c stderr when a function
1557 * fails. These error messages may provide information that cannot be
1558 * determined only from the error code that is returned. Not every error will
1559 * result in an error message being printed.
1561 * This setting is global and not per-WIM.
1563 * By default, error messages are not printed.
1565 * @param show_messages
1566 * @c true if error messages are to be printed; @c false if error messages
1567 * are not to be printed.
1569 * @return 0 on success; nonzero on error.
1570 * @retval ::WIMLIB_ERR_UNSUPPORTED
1571 * @a show_messages was @c true, but wimlib was compiled with the @c
1572 * --without-error-messages option. Therefore, error messages cannot be
1575 extern int wimlib_set_print_errors(bool show_messages);
1578 * Splits a WIM into multiple parts.
1581 * The ::WIMStruct for the WIM to split. It must be a standalone, one-part
1584 * Name of the SWM file to create. This will be the name of the first
1585 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
1586 * appended before the suffix.
1588 * The maximum size per part, in bytes. It is not guaranteed that this
1589 * will really be the maximum size per part, because some file resources in
1590 * the WIM may be larger than this size, and the WIM file format provides
1591 * no way to split up file resources among multiple WIMs.
1592 * @param write_flags
1593 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
1594 * ::WIMLIB_WRITE_FLAG_RECOMPRESS.
1595 * @param progress_func
1596 * If non-NULL, a function that will be called periodically with the
1597 * progress of the current operation.
1599 * @return 0 on success; nonzero on error. This function may return any value
1600 * returned by wimlib_write() as well as the following error codes:
1602 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED:
1603 * @a wim is not part 1 of a stand-alone WIM.
1604 * @retval ::WIMLIB_ERR_INVALID_PARAM
1605 * @a w was @c NULL, @a swm_name was @c NULL, or @a part_size was 0.
1607 extern int wimlib_split(WIMStruct *wim, const char *swm_name,
1608 size_t part_size, int write_flags,
1609 wimlib_progress_func_t progress_func);
1612 * Unmounts a WIM image that was mounted using wimlib_mount_image().
1614 * Blocks until it is known whether the mount succeeded or failed.
1616 * To perform this operation, the process calling wimlib_unmount_image()
1617 * communicates with the process that had called wimlib_mount_image().
1619 * There is currently a design problem with this function because it is hard to
1620 * know whether the filesystem daemon is still working or whether it has
1621 * crashed, has been killed, or has reached an infinite loop. However, ideally
1622 * there should be no infinite loops or crashes in the code, so this wouldn't be
1623 * much of a problem. Currently, a timeout of 600 seconds (so long because WIMs
1624 * can be very large) is implemented so that this function will not wait forever
1625 * before returning failure.
1628 * The directory that the WIM image was mounted on.
1629 * @param unmount_flags
1630 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY and/or
1631 * ::WIMLIB_UNMOUNT_FLAG_COMMIT. Neither of these flags affect read-only
1634 * @return 0 on success; nonzero on error.
1635 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
1636 * The filesystem daemon was unable to remove the staging directory and the
1637 * temporary files that it contains.
1638 * @retval ::WIMLIB_ERR_FORK
1639 * Could not @c fork() the process.
1640 * @retval ::WIMLIB_ERR_FUSERMOUNT
1641 * The @b fusermount program could not be executed or exited with a failure
1643 * @retval ::WIMLIB_ERR_MQUEUE
1644 * Could not open a POSIX message queue to communicate with the filesystem
1645 * daemon servicing the mounted filesystem, could not send a message
1646 * through the queue, or could not receive a message through the queue.
1647 * @retval ::WIMLIB_ERR_NOMEM
1648 * Failed to allocate needed memory.
1649 * @retval ::WIMLIB_ERR_OPEN
1650 * The filesystem daemon could not open a temporary file for writing the
1652 * @retval ::WIMLIB_ERR_TIMEOUT
1653 * 600 seconds elapsed while waiting for the filesystem daemon to notify
1654 * the process of its exit status, so the WIM file probably was not written
1656 * @retval ::WIMLIB_ERR_READ
1657 * A read error occurred when the filesystem daemon tried to a file from
1658 * the staging directory
1659 * @retval ::WIMLIB_ERR_RENAME
1660 * The filesystem daemon failed to rename the newly written WIM file to the
1661 * original WIM file.
1662 * @retval ::WIMLIB_ERR_WRITE
1663 * A write error occurred when the filesystem daemon was writing to the new
1664 * WIM file, or the filesystem daemon was unable to flush changes that had
1665 * been made to files in the staging directory.
1667 extern int wimlib_unmount_image(const char *dir, int unmount_flags);
1670 * Writes a standalone WIM to a file.
1673 * Pointer to the ::WIMStruct for a WIM. There may have been in-memory
1674 * changes made to it, which are then reflected in the output file.
1676 * The path to the file to write the WIM to.
1678 * The image inside the WIM to write. Use ::WIMLIB_ALL_IMAGES to include all
1680 * @param write_flags
1681 * Bitwise OR of the flags ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY,
1682 * ::WIMLIB_WRITE_FLAG_RECOMPRESS, ::WIMLIB_WRITE_FLAG_FSYNC, and/or
1683 * ::WIMLIB_WRITE_FLAG_SOFT_DELETE.
1684 * @param num_threads
1685 * Number of threads to use for compressing data. Autodetected if set to
1686 * 0. Note: if no data compression needs to be done, no additional threads
1687 * will be created regardless of this parameter (e.g. if writing an
1688 * uncompressed WIM, or exporting an image from a compressed WIM to another
1689 * WIM of the same compression type without ::WIMLIB_WRITE_FLAG_RECOMPRESS
1690 * specified in @a write_flags).
1691 * @param progress_func
1692 * If non-NULL, a function that will be called periodically with the
1693 * progress of the current operation.
1695 * @return 0 on success; nonzero on error.
1696 * @retval ::WIMLIB_ERR_DECOMPRESSION
1697 * Failed to decompress a metadata or file resource in @a wim.
1698 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1699 * A directory entry in the metadata resource for @a image in @a wim is
1701 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1702 * @a image does not specify a single existing image in @a wim, and is not
1703 * ::WIMLIB_ALL_IMAGES.
1704 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
1705 * A file that had previously been scanned for inclusion in the WIM by the
1706 * wimlib_add_image() or wimlib_add_image_from_ntfs_volume() functions was
1707 * concurrently modified, so it failed the SHA1 message digest check.
1708 * @retval ::WIMLIB_ERR_INVALID_PARAM
1709 * @a wim or @a path was @c NULL.
1710 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1711 * The metadata resource for @a image in @a wim is invalid.
1712 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1713 * The security data for @a image in @a wim is invalid.
1714 * @retval ::WIMLIB_ERR_NOMEM
1715 * Failed to allocate needed memory.
1716 * @retval ::WIMLIB_ERR_OPEN
1717 * Failed to open @a path for writing, or some file resources in @a
1718 * wim refer to files in the outside filesystem, and one of these files
1719 * could not be opened for reading.
1720 * @retval ::WIMLIB_ERR_READ
1721 * An error occurred when trying to read data from the WIM file associated
1722 * with @a wim, or some file resources in @a wim refer to files in the
1723 * outside filesystem, and a read error occurred when reading one of these
1725 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1726 * @a wim is part of a split WIM. You may not call this function on a
1728 * @retval ::WIMLIB_ERR_WRITE
1729 * An error occurred when trying to write data to the new WIM file at @a
1732 extern int wimlib_write(WIMStruct *wim, const char *path, int image,
1733 int write_flags, unsigned num_threads,
1734 wimlib_progress_func_t progress_func);
1736 #endif /* _WIMLIB_H */