]> wimlib.net Git - wimlib/commitdiff
Remove WIMLIB_WRITE_FLAG_NO_PACK_STREAMS
authorEric Biggers <ebiggers3@gmail.com>
Fri, 27 Dec 2013 00:00:09 +0000 (18:00 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 27 Dec 2013 00:00:09 +0000 (18:00 -0600)
include/wimlib.h
programs/imagex.c
src/wim.c
src/write.c

index 00caf4e30cab804d68e14266787a1fd597ac0669..93f7f359416c5672f7aa5c562367c872446c929e 100644 (file)
@@ -1543,29 +1543,21 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour
 
 #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
  * @{ */
index fd634419eb96981aba7f74b4a2ab955142c591a2..9d68acc9fe9512fe84407c74819b887f8e591477 100644 (file)
@@ -142,7 +142,6 @@ enum {
        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,
@@ -293,7 +292,6 @@ static const struct option optimize_options[] = {
        {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},
@@ -3367,9 +3365,6 @@ imagex_optimize(int argc, tchar **argv, int cmd)
                        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)
index 7a94bd8a9dbf094fcf2cccf374cd77813c2b8d53..bad95d1933c5c77b27e211d613665a23c064aee1 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -64,6 +64,23 @@ image_print_metadata(WIMStruct *wim)
                                  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)
@@ -72,6 +89,9 @@ 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;
@@ -154,18 +174,6 @@ wim_default_chunk_size(int ctype)
        }
 }
 
-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
@@ -231,10 +239,8 @@ wimlib_create_new_wim(int ctype, WIMStruct **wim_ret)
        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:
@@ -667,12 +673,10 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd,
                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"!",
index 3895088ee2c408e5d990a073512100f3bb0bc309..3702585bf3e9b6992a009470aa44d1dbbcadc09c 100644 (file)
@@ -2542,9 +2542,6 @@ write_wim_part(WIMStruct *wim,
        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");
 
@@ -2593,12 +2590,6 @@ write_wim_part(WIMStruct *wim,
                                    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));
 
@@ -2617,13 +2608,6 @@ write_wim_part(WIMStruct *wim,
                        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 |
@@ -2931,20 +2915,9 @@ overwrite_wim_inplace(WIMStruct *wim, int write_flags,
                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 |