#define WIMLIB_WRITE_FLAG_RESERVED 0x00000800
-/** When writing streams in the resulting WIM file, pack multiple streams into a
+/**
+ * When writing streams in the resulting WIM file, pack multiple streams into a
* single WIM resource instead of compressing them independently. This tends to
* produce a better compression ratio at the cost of less random access.
- * Furthermore, WIMs created with this flag are only compatible with wimlib
- * v1.6.0 or later and WIMGAPI Windows 8 or later, seemingly for Windows Setup
- * only and <b>not including ImageX and Dism</b>. WIMs created with this flag
- * use version number 3584 in their header instead of 68864. If this flag is
- * passed to wimlib_overwrite() and the WIM did not previously contain packed
- * streams, the WIM's version number will be changed to 3584 and the new streams
- * will be written packed. */
+ * However, WIMs created with this flag are only compatible with wimlib v1.6.0
+ * or later and WIMGAPI Windows 8 or later, seemingly for Windows Setup only and
+ * <b>not including ImageX and Dism</b>. WIMs created with this flag must use
+ * version number 3584 in their header instead of 68864.
+ *
+ * If this flag is passed to wimlib_overwrite() and the WIM did not previously
+ * contain packed streams, the WIM's version number will be changed to 3584 and
+ * the new streams will be written packed. Use ::WIMLIB_WRITE_FLAG_REBUILD to
+ * force the WIM to be fully rebuilt. */
#define WIMLIB_WRITE_FLAG_PACK_STREAMS 0x00001000
-/** Compress all streams independently. This produces a WIM optimized for
- * random access and compatibility, as noted in the documentation for
- * ::WIMLIB_WRITE_RESOURCE_FLAG_PACK_STREAMS. For wimlib_write(), this is the
- * default behavior. For wimlib_overwrite(), this is the default if the WIM file
- * did not already contain packed streams. Also, for wimlib_overwrite(), if the
- * WIM already contained packed streams, specifying this flag but not
- * ::WIMLIB_WRITE_FLAG_REBUILD will cause new streams to be written unpacked,
- * but the WIM itself will not be rebuilt and may still contain packed streams.
- */
-#define WIMLIB_WRITE_FLAG_NO_PACK_STREAMS 0x00002000
-
/** @} */
/** @ingroup G_general
* @{ */
IMAGEX_NORPFIX_OPTION,
IMAGEX_NOCHECK_OPTION,
IMAGEX_NO_ACLS_OPTION,
- IMAGEX_NO_PACK_STREAMS_OPTION,
IMAGEX_NOT_PIPABLE_OPTION,
IMAGEX_PACK_STREAMS_OPTION,
IMAGEX_PATH_OPTION,
{T("recompress-slow"), no_argument, NULL, IMAGEX_COMPRESS_SLOW_OPTION},
{T("chunk-size"), required_argument, NULL, IMAGEX_CHUNK_SIZE_OPTION},
{T("pack-streams"),no_argument, NULL, IMAGEX_PACK_STREAMS_OPTION},
- {T("no-pack-streams"), no_argument, NULL, IMAGEX_NO_PACK_STREAMS_OPTION},
{T("threads"), required_argument, NULL, IMAGEX_THREADS_OPTION},
{T("pipable"), no_argument, NULL, IMAGEX_PIPABLE_OPTION},
{T("not-pipable"), no_argument, NULL, IMAGEX_NOT_PIPABLE_OPTION},
write_flags |= WIMLIB_WRITE_FLAG_PACK_STREAMS;
write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS;
break;
- case IMAGEX_NO_PACK_STREAMS_OPTION:
- write_flags |= WIMLIB_WRITE_FLAG_NO_PACK_STREAMS;
- break;
case IMAGEX_THREADS_OPTION:
num_threads = parse_num_threads(optarg);
if (num_threads == UINT_MAX)
wim->lookup_table);
}
+static int
+wim_default_pack_compression_type(void)
+{
+ return WIMLIB_COMPRESSION_TYPE_LZMS;
+}
+
+static u32
+wim_default_pack_chunk_size(int ctype) {
+ switch (ctype) {
+ case WIMLIB_COMPRESSION_TYPE_LZMS:
+ /* Note: WIMGAPI uses 1 << 26, but lower sizes are compatible.
+ * */
+ return 1U << 25; /* 33554432 */
+ default:
+ return 1U << 15; /* 32768 */
+ }
+}
static WIMStruct *
new_wim_struct(void)
if (wim) {
wim->in_fd.fd = -1;
wim->out_fd.fd = -1;
+ wim->out_pack_compression_type = wim_default_pack_compression_type();
+ wim->out_pack_chunk_size = wim_default_pack_chunk_size(
+ wim->out_pack_compression_type);
INIT_LIST_HEAD(&wim->subwims);
}
return wim;
}
}
-static u32
-wim_default_pack_chunk_size(int ctype) {
- switch (ctype) {
- case WIMLIB_COMPRESSION_TYPE_LZMS:
- /* Note: WIMGAPI uses 1 << 26, but lower sizes are compatible.
- * */
- return 1U << 25; /* 33554432 */
- default:
- return 1U << 15; /* 32768 */
- }
-}
-
/*
* Calls a function on images in the WIM. If @image is WIMLIB_ALL_IMAGES, @visitor
* is called on the WIM once for each image, with each image selected as the
wim->refcnts_ok = 1;
wim->compression_type = ctype;
wim->out_compression_type = ctype;
- wim->out_pack_compression_type = ctype;
wim->chunk_size = wim->hdr.chunk_size;
wim->out_chunk_size = wim->hdr.chunk_size;
- wim->out_pack_chunk_size = wim_default_pack_chunk_size(ctype);
*wim_ret = wim;
return 0;
out_free:
wim->compression_type = WIMLIB_COMPRESSION_TYPE_NONE;
}
wim->out_compression_type = wim->compression_type;
- wim->out_pack_compression_type = wim->compression_type;
/* Check and cache the chunk size. */
wim->chunk_size = wim->hdr.chunk_size;
wim->out_chunk_size = wim->chunk_size;
- wim->out_pack_chunk_size = wim_default_pack_chunk_size(wim->out_pack_compression_type);
if (!wim_chunk_size_valid(wim->chunk_size, wim->compression_type)) {
ERROR("Invalid chunk size (%"PRIu32" bytes) "
"for compression type %"TS"!",
if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS)
DEBUG("\tPACK_STREAMS");
- if (write_flags & WIMLIB_WRITE_FLAG_NO_PACK_STREAMS)
- DEBUG("\tNO_PACK_STREAMS");
-
if (write_flags & WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR)
DEBUG("\tFILE_DESCRIPTOR");
WIMLIB_WRITE_FLAG_NOT_PIPABLE))
return WIMLIB_ERR_INVALID_PARAM;
- if ((write_flags & (WIMLIB_WRITE_FLAG_PACK_STREAMS |
- WIMLIB_WRITE_FLAG_NO_PACK_STREAMS))
- == (WIMLIB_WRITE_FLAG_PACK_STREAMS |
- WIMLIB_WRITE_FLAG_NO_PACK_STREAMS))
- return WIMLIB_ERR_INVALID_PARAM;
-
/* Save previous header, then start initializing the new one. */
memcpy(&hdr_save, &wim->hdr, sizeof(struct wim_header));
write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
}
- if (!(write_flags & (WIMLIB_WRITE_FLAG_PACK_STREAMS |
- WIMLIB_WRITE_FLAG_NO_PACK_STREAMS)))
- if (wim->hdr.wim_version == WIM_VERSION_PACKED_STREAMS) {
- DEBUG("WIM version 3584; default to PACK_STREAMS.");
- write_flags |= WIMLIB_WRITE_FLAG_PACK_STREAMS;
- }
-
if ((write_flags & (WIMLIB_WRITE_FLAG_PIPABLE |
WIMLIB_WRITE_FLAG_PACK_STREAMS))
== (WIMLIB_WRITE_FLAG_PIPABLE |
if (wim_has_integrity_table(wim))
write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
- /* Set default packed flag. */
- if (!(write_flags & (WIMLIB_WRITE_FLAG_PACK_STREAMS |
- WIMLIB_WRITE_FLAG_NO_PACK_STREAMS)))
- {
- #if 0
- if (wim->hdr.wim_version == WIM_VERSION_PACKED_STREAMS)
- write_flags |= WIMLIB_WRITE_FLAG_PACK_STREAMS;
- #endif
- /* wimlib allows multiple packs in a single WIM, but they don't
- * seem to be compatible with WIMGAPI. Write new streams
- * unpacked. */
- } else if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS) {
+ /* Set WIM version if adding packed streams. */
+ if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS)
wim->hdr.wim_version = WIM_VERSION_PACKED_STREAMS;
- }
/* Set additional flags for overwrite. */
write_flags |= WIMLIB_WRITE_FLAG_OVERWRITE |