]> wimlib.net Git - wimlib/blobdiff - programs/imagex.c
Initial support for resuming extraction from split pipable WIMs
[wimlib] / programs / imagex.c
index c97f2d73acdbbd98652176a5dae60777fd9de022..977f21be48c2cb714e8d3191f0b9a0400c0e6823 100644 (file)
@@ -146,6 +146,7 @@ enum {
        IMAGEX_RECOMPRESS_OPTION,
        IMAGEX_RECURSIVE_OPTION,
        IMAGEX_REF_OPTION,
+       IMAGEX_RESUME_OPTION,
        IMAGEX_RPFIX_OPTION,
        IMAGEX_SOFT_OPTION,
        IMAGEX_SOURCE_LIST_OPTION,
@@ -173,6 +174,7 @@ static const struct option apply_options[] = {
        {T("rpfix"),       no_argument,       NULL, IMAGEX_RPFIX_OPTION},
        {T("norpfix"),     no_argument,       NULL, IMAGEX_NORPFIX_OPTION},
        {T("include-invalid-names"), no_argument,       NULL, IMAGEX_INCLUDE_INVALID_NAMES_OPTION},
+       {T("resume"),      no_argument,       NULL, IMAGEX_RESUME_OPTION},
        {NULL, 0, NULL, 0},
 };
 
@@ -985,6 +987,7 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                unit_shift = get_unit(info->write_streams.total_bytes, &unit_name);
                percent_done = TO_PERCENT(info->write_streams.completed_bytes,
                                          info->write_streams.total_bytes);
+
                if (info->write_streams.completed_streams == 0) {
                        const tchar *data_type;
 
@@ -993,13 +996,28 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                                data_type, info->write_streams.num_threads,
                                (info->write_streams.num_threads == 1) ? T("") : T("s"));
                }
-               imagex_printf(T("\r%"PRIu64" %"TS" of %"PRIu64" %"TS" (uncompressed) "
-                       "written (%u%% done)"),
-                       info->write_streams.completed_bytes >> unit_shift,
-                       unit_name,
-                       info->write_streams.total_bytes >> unit_shift,
-                       unit_name,
-                       percent_done);
+               if (info->write_streams.total_parts <= 1) {
+                       imagex_printf(T("\r%"PRIu64" %"TS" of %"PRIu64" %"TS" (uncompressed) "
+                               "written (%u%% done)"),
+                               info->write_streams.completed_bytes >> unit_shift,
+                               unit_name,
+                               info->write_streams.total_bytes >> unit_shift,
+                               unit_name,
+                               percent_done);
+               } else {
+                       imagex_printf(T("\rWriting resources from part %u of %u: "
+                                 "%"PRIu64 " %"TS" of %"PRIu64" %"TS" (%u%%) written"),
+                               (info->write_streams.completed_parts ==
+                                       info->write_streams.total_parts) ?
+                                               info->write_streams.completed_parts :
+                                               info->write_streams.completed_parts + 1,
+                               info->write_streams.total_parts,
+                               info->write_streams.completed_bytes >> unit_shift,
+                               unit_name,
+                               info->write_streams.total_bytes >> unit_shift,
+                               unit_name,
+                               percent_done);
+               }
                if (info->write_streams.completed_bytes >= info->write_streams.total_bytes)
                        imagex_printf(T("\n"));
                break;
@@ -1019,8 +1037,6 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                else
                        imagex_printf(T("Scanning \"%"TS"\"\n"), info->scan.cur_path);
                break;
-       /*case WIMLIB_PROGRESS_MSG_SCAN_END:*/
-               /*break;*/
        case WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY:
                unit_shift = get_unit(info->integrity.total_bytes, &unit_name);
                percent_done = TO_PERCENT(info->integrity.completed_bytes,
@@ -1070,10 +1086,6 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                        info->extract.wimfile_name,
                        info->extract.target);
                break;
-       /*case WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN:*/
-               /*imagex_printf(T("Applying directory structure to %"TS"\n"),*/
-                       /*info->extract.target);*/
-               /*break;*/
        case WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS:
                percent_done = TO_PERCENT(info->extract.completed_bytes,
                                          info->extract.total_bytes);
@@ -1098,21 +1110,6 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                                info->extract.target);
                }
                break;
-       case WIMLIB_PROGRESS_MSG_JOIN_STREAMS:
-               percent_done = TO_PERCENT(info->join.completed_bytes,
-                                         info->join.total_bytes);
-               unit_shift = get_unit(info->join.total_bytes, &unit_name);
-               imagex_printf(T("Writing resources from part %u of %u: "
-                         "%"PRIu64 " %"TS" of %"PRIu64" %"TS" (%u%%) written\n"),
-                       (info->join.completed_parts == info->join.total_parts) ?
-                       info->join.completed_parts : info->join.completed_parts + 1,
-                       info->join.total_parts,
-                       info->join.completed_bytes >> unit_shift,
-                       unit_name,
-                       info->join.total_bytes >> unit_shift,
-                       unit_name,
-                       percent_done);
-               break;
        case WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART:
                percent_done = TO_PERCENT(info->split.completed_bytes,
                                          info->split.total_bytes);
@@ -1501,6 +1498,9 @@ imagex_apply(int argc, tchar **argv, int cmd)
                        extract_flags |= WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES;
                        extract_flags |= WIMLIB_EXTRACT_FLAG_ALL_CASE_CONFLICTS;
                        break;
+               case IMAGEX_RESUME_OPTION:
+                       extract_flags |= WIMLIB_EXTRACT_FLAG_RESUME;
+                       break;
                default:
                        goto out_usage;
                }
@@ -3454,7 +3454,7 @@ T(
 "                    (DIRECTORY | NTFS_VOLUME) [--check] [--hardlink]\n"
 "                    [--symlink] [--verbose] [--ref=\"GLOB\"] [--unix-data]\n"
 "                    [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n"
-"                    [--include-invalid-names]\n"
+"                    [--include-invalid-names] [--resume]\n"
 ),
 [CMD_CAPTURE] =
 T(
@@ -3562,9 +3562,9 @@ static const tchar *get_cmd_string(int cmd, bool nospace)
 static void
 version(void)
 {
-       static const tchar *format =
+       static const tchar *s =
        T(
-"%"TS" (" PACKAGE ") " PACKAGE_VERSION "\n"
+IMAGEX_PROGNAME " (" PACKAGE ") " PACKAGE_VERSION "\n"
 "Copyright (C) 2012, 2013 Eric Biggers\n"
 "License GPLv3+; GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
 "This is free software: you are free to change and redistribute it.\n"
@@ -3572,7 +3572,7 @@ version(void)
 "\n"
 "Report bugs to "PACKAGE_BUGREPORT".\n"
        );
-       tprintf(format, invocation_name);
+       tfputs(s, stdout);
 }