]> wimlib.net Git - wimlib/blobdiff - programs/imagex.c
wimcapture, wimexport: With --pack-streams, default to LZMS compression
[wimlib] / programs / imagex.c
index 2a474d7e172f6594eda8b25063490a0c500e2841..fc2dd45ce48e3dcb9c644f200dc40587ce353c5f 100644 (file)
 
 #ifdef __WIN32__
 #  include "imagex-win32.h"
-#  define OS_PREFERRED_PATH_SEPARATOR L'\\'
-#  define OS_PREFERRED_PATH_SEPARATOR_STRING L"\\"
 #  define print_security_descriptor     win32_print_security_descriptor
 #else /* __WIN32__ */
 #  include <getopt.h>
 #  include <langinfo.h>
-#  define OS_PREFERRED_PATH_SEPARATOR '/'
-#  define OS_PREFERRED_PATH_SEPARATOR_STRING "/"
 #  define print_security_descriptor    default_print_security_descriptor
 static inline void set_fd_to_binary_mode(int fd)
 {
@@ -483,7 +479,9 @@ verify_image_exists_and_is_single(int image, const tchar *image_name,
 static int
 get_compression_type(const tchar *optarg)
 {
-       if (!tstrcasecmp(optarg, T("maximum")) || !tstrcasecmp(optarg, T("lzx")))
+       if (!tstrcasecmp(optarg, T("maximum")) ||
+           !tstrcasecmp(optarg, T("lzx")) ||
+           !tstrcasecmp(optarg, T("max")))
                return WIMLIB_COMPRESSION_TYPE_LZX;
        else if (!tstrcasecmp(optarg, T("fast")) || !tstrcasecmp(optarg, T("xpress")))
                return WIMLIB_COMPRESSION_TYPE_XPRESS;
@@ -1055,39 +1053,23 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                percent_done = TO_PERCENT(info->write_streams.completed_bytes,
                                          info->write_streams.total_bytes);
 
-               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);
-               }
+               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.completed_bytes >= info->write_streams.total_bytes)
                        imagex_printf(T("\n"));
                break;
        case WIMLIB_PROGRESS_MSG_SCAN_BEGIN:
                imagex_printf(T("Scanning \"%"TS"\""), info->scan.source);
-               if (*info->scan.wim_target_path) {
-                       imagex_printf(T(" (loading as WIM path: "
-                                 "\""WIMLIB_WIM_PATH_SEPARATOR_STRING"%"TS"\")...\n"),
-                              info->scan.wim_target_path);
-               } else {
+               if (WIMLIB_IS_WIM_ROOT_PATH(info->scan.wim_target_path)) {
                        imagex_printf(T("\n"));
+               } else {
+                       imagex_printf(T(" (loading as WIM path: \"%"TS"\")...\n"),
+                                     info->scan.wim_target_path);
                }
                memset(&last_scan_progress, 0, sizeof(last_scan_progress));
                break;
@@ -1156,17 +1138,6 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                         T("NTFS volume") : T("directory")),
                        info->extract.target);
                break;
-       case WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN:
-               if (info->extract.extract_root_wim_source_path[0]) {
-                       imagex_printf(T("Extracting \"%"TS"\" from image %d "
-                                       "(\"%"TS"\") in \"%"TS"\" to \"%"TS"\"\n"),
-                                     info->extract.extract_root_wim_source_path,
-                                     info->extract.image,
-                                     info->extract.image_name,
-                                     info->extract.wimfile_name,
-                                     info->extract.target);
-               }
-               break;
        case WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS:
                percent_done = TO_PERCENT(info->extract.completed_bytes,
                                          info->extract.total_bytes);
@@ -1189,8 +1160,7 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                }
                break;
        case WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS:
-               if (info->extract.extract_root_wim_source_path[0] == T('\0'))
-                       imagex_printf(T("Setting timestamps on all extracted files...\n"));
+               imagex_printf(T("Setting timestamps on all extracted files...\n"));
                break;
        case WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END:
                if (info->extract.extract_flags & WIMLIB_EXTRACT_FLAG_NTFS) {
@@ -1223,14 +1193,11 @@ imagex_progress_func(enum wimlib_progress_msg msg,
        case WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND:
                switch (info->update.command->op) {
                case WIMLIB_UPDATE_OP_DELETE:
-                       imagex_printf(T("Deleted WIM path "
-                                 "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
+                       imagex_printf(T("Deleted WIM path \"%"TS"\"\n"),
                                info->update.command->delete_.wim_path);
                        break;
                case WIMLIB_UPDATE_OP_RENAME:
-                       imagex_printf(T("Renamed WIM path "
-                                 "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\" => "
-                                 "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
+                       imagex_printf(T("Renamed WIM path \"%"TS"\" => \"%"TS"\"\n"),
                                info->update.command->rename.wim_source_path,
                                info->update.command->rename.wim_target_path);
                        break;
@@ -1243,6 +1210,10 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                imagex_printf(T("Updating \"%"TS"\" in WIM image\n"),
                              info->replace.path_in_wim);
                break;
+       case WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE:
+               imagex_printf(T("\nExtracting \"%"TS"\" as normal file (not WIMBoot pointer)\n"),
+                             info->wimboot_exclude.path_in_wim);
+               break;
        default:
                break;
        }
@@ -1851,9 +1822,19 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
 
 
        if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {
+               /* No compression type specified.  Use the default.  */
+
                if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_WIMBOOT) {
+                       /* With --wimboot, default to XPRESS compression.  */
                        compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
+               } else if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS) {
+                       /* With --pack-streams or --solid, default to LZMS
+                        * compression.  (However, this will not affect packed
+                        * resources!)  */
+                       compression_type = WIMLIB_COMPRESSION_TYPE_LZMS;
                } else {
+                       /* Otherwise, default to LZX compression in fast mode.
+                        */
                        compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
                        if (!compress_slow && pack_ctype != WIMLIB_COMPRESSION_TYPE_LZX) {
                                struct wimlib_lzx_compressor_params params = {
@@ -1967,7 +1948,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
                /* Set up capture source in non-source-list mode.  */
                capture_sources = alloca(sizeof(struct wimlib_capture_source));
                capture_sources[0].fs_source_path = source;
-               capture_sources[0].wim_target_path = NULL;
+               capture_sources[0].wim_target_path = WIMLIB_WIM_ROOT_PATH;
                capture_sources[0].reserved = 0;
                num_sources = 1;
                capture_sources_malloced = false;
@@ -2494,7 +2475,7 @@ imagex_dir(int argc, tchar **argv, int cmd)
        WIMStruct *wim = NULL;
        int image;
        int ret;
-       const tchar *path = T("");
+       const tchar *path = WIMLIB_WIM_ROOT_PATH;
        int c;
        struct print_dentry_options options = {
                .detailed = false,
@@ -2745,9 +2726,13 @@ imagex_export(int argc, tchar **argv, int cmd)
 
                if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {
                        /* The user did not specify a compression type; default
-                        * to that of the source WIM.  */
+                        * to that of the source WIM, unless --pack-streams or
+                        * --solid was specified.   */
 
-                       compression_type = src_info.compression_type;
+                       if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS)
+                               compression_type = WIMLIB_COMPRESSION_TYPE_LZMS;
+                       else
+                               compression_type = src_info.compression_type;
                }
                ret = wimlib_create_new_wim(compression_type, &dest_wim);
                if (ret)
@@ -2851,7 +2836,7 @@ imagex_extract(int argc, tchar **argv, int cmd)
 
        STRING_SET(refglobs);
 
-       tchar *root_path = T("");
+       tchar *root_path = WIMLIB_WIM_ROOT_PATH;
 
        for_opt(c, extract_options) {
                switch (c) {
@@ -3885,16 +3870,14 @@ imagex_update(int argc, tchar **argv, int cmd)
                /* --wimboot-config=FILE is short for an
                 * "add FILE /Windows/System32/WimBootCompress.ini" command.
                 */
-               struct wimlib_update_command cmd = {
-                       .op = WIMLIB_UPDATE_OP_ADD,
-                       .add = {
-                               .fs_source_path = wimboot_config,
-                               .wim_target_path =
-                                       T("/Windows/System32/WimBootCompress.ini"),
-                               .config_file = NULL,
-                               .add_flags = 0,
-                       },
-               };
+               struct wimlib_update_command cmd;
+
+               cmd.op = WIMLIB_UPDATE_OP_ADD;
+               cmd.add.fs_source_path = wimboot_config;
+               cmd.add.wim_target_path = T("/Windows/System32/WimBootCompress.ini");
+               cmd.add.config_file = NULL;
+               cmd.add.add_flags = 0;
+
                ret = wimlib_update_image(wim, image, &cmd, 1,
                                          update_flags, imagex_progress_func);
                if (ret)