wimoptimize: Add --no-pack-streams option
[wimlib] / programs / imagex.c
index c3187f7..a9e6fa6 100644 (file)
@@ -142,7 +142,9 @@ 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,
        IMAGEX_PIPABLE_OPTION,
        IMAGEX_REBUILD_OPTION,
@@ -192,6 +194,7 @@ static const struct option capture_or_append_options[] = {
        {T("compress"),    required_argument, NULL, IMAGEX_COMPRESS_OPTION},
        {T("compress-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("config"),      required_argument, NULL, IMAGEX_CONFIG_OPTION},
        {T("dereference"), no_argument,       NULL, IMAGEX_DEREFERENCE_OPTION},
        {T("flags"),       required_argument, NULL, IMAGEX_FLAGS_OPTION},
@@ -289,6 +292,8 @@ static const struct option optimize_options[] = {
        {T("compress-slow"), no_argument,     NULL, IMAGEX_COMPRESS_SLOW_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},
@@ -414,6 +419,8 @@ get_compression_type(const tchar *optarg)
                return WIMLIB_COMPRESSION_TYPE_LZX;
        else if (!tstrcasecmp(optarg, T("fast")) || !tstrcasecmp(optarg, T("xpress")))
                return WIMLIB_COMPRESSION_TYPE_XPRESS;
+       else if (!tstrcasecmp(optarg, T("recovery")) || !tstrcasecmp(optarg, T("lzms")))
+               return WIMLIB_COMPRESSION_TYPE_LZMS;
        else if (!tstrcasecmp(optarg, T("none")))
                return WIMLIB_COMPRESSION_TYPE_NONE;
        else {
@@ -1024,22 +1031,6 @@ stdin_get_text_contents(size_t *num_tchars_ret)
 #define TO_PERCENT(numerator, denominator) \
        (((denominator) == 0) ? 0 : ((numerator) * 100 / (denominator)))
 
-/* Given an enumerated value for WIM compression type, return a descriptive
- * string. */
-static const tchar *
-get_data_type(int ctype)
-{
-       switch (ctype) {
-       case WIMLIB_COMPRESSION_TYPE_NONE:
-               return T("uncompressed");
-       case WIMLIB_COMPRESSION_TYPE_LZX:
-               return T("LZX-compressed");
-       case WIMLIB_COMPRESSION_TYPE_XPRESS:
-               return T("XPRESS-compressed");
-       }
-       return NULL;
-}
-
 #define GIBIBYTE_MIN_NBYTES 10000000000ULL
 #define MEBIBYTE_MIN_NBYTES 10000000ULL
 #define KIBIBYTE_MIN_NBYTES 10000ULL
@@ -1079,11 +1070,9 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                                          info->write_streams.total_bytes);
 
                if (info->write_streams.completed_streams == 0) {
-                       const tchar *data_type;
-
-                       data_type = get_data_type(info->write_streams.compression_type);
-                       imagex_printf(T("Writing %"TS" data using %u thread%"TS"\n"),
-                               data_type, info->write_streams.num_threads,
+                       imagex_printf(T("Writing %"TS"-compressed data using %u thread%"TS"\n"),
+                               wimlib_get_compression_type_string(info->write_streams.compression_type),
+                               info->write_streams.num_threads,
                                (info->write_streams.num_threads == 1) ? T("") : T("s"));
                }
                if (info->write_streams.total_parts <= 1) {
@@ -1753,6 +1742,9 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
                        if (chunk_size == UINT32_MAX)
                                goto out_err;
                        break;
+               case IMAGEX_PACK_STREAMS_OPTION:
+                       write_flags |= WIMLIB_WRITE_FLAG_PACK_STREAMS;
+                       break;
                case IMAGEX_FLAGS_OPTION:
                        flags_element = optarg;
                        break;
@@ -2773,6 +2765,7 @@ print_wim_information(const tchar *wimfile, const struct wimlib_wim_info *info)
        tprintf(T("GUID:           0x"));
        print_byte_field(info->guid, sizeof(info->guid));
        tputchar(T('\n'));
+       tprintf(T("Version:        %u\n"), info->wim_version);
        tprintf(T("Image Count:    %d\n"), info->image_count);
        tprintf(T("Compression:    %"TS"\n"),
                wimlib_get_compression_type_string(info->compression_type));
@@ -2796,10 +2789,7 @@ print_resource(const struct wimlib_resource_entry *resource,
 {
        tprintf(T("Uncompressed size     = %"PRIu64" bytes\n"),
                resource->uncompressed_size);
-       if (resource->is_partial) {
-               tprintf(T("Raw uncompressed size = %"PRIu64" bytes\n"),
-                       resource->raw_resource_uncompressed_size);
-
+       if (resource->packed) {
                tprintf(T("Raw compressed size   = %"PRIu64" bytes\n"),
                        resource->raw_resource_compressed_size);
 
@@ -2816,7 +2806,6 @@ print_resource(const struct wimlib_resource_entry *resource,
                        resource->offset);
        }
 
-
        tprintf(T("Part Number           = %u\n"), resource->part_number);
        tprintf(T("Reference Count       = %u\n"), resource->reference_count);
 
@@ -2833,6 +2822,8 @@ print_resource(const struct wimlib_resource_entry *resource,
                tprintf(T("WIM_RESHDR_FLAG_FREE  "));
        if (resource->is_spanned)
                tprintf(T("WIM_RESHDR_FLAG_SPANNED  "));
+       if (resource->packed)
+               tprintf(T("WIM_RESHDR_FLAG_PACKED_STREAMS  "));
        tputchar(T('\n'));
        tputchar(T('\n'));
        return 0;
@@ -3331,6 +3322,13 @@ imagex_optimize(int argc, tchar **argv, int cmd)
                        if (chunk_size == UINT32_MAX)
                                goto out_err;
                        break;
+               case IMAGEX_PACK_STREAMS_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)