X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=programs%2Fimagex.c;h=854be037e42ac281dd25eba5685f017bee191d69;hp=85026c82adddd52d722588afe72008891ff6e45e;hb=e9fa56fa6e181ae15282a2fcf0dbfa0b7c59cd81;hpb=c24a5c14de3e01948996198fa886517983b39613 diff --git a/programs/imagex.c b/programs/imagex.c index 85026c82..854be037 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -22,7 +22,10 @@ * along with this program. If not, see . */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" /* Need for PACKAGE_VERSION, etc. */ +#endif + #include "wimlib.h" #include "wimlib_tchar.h" @@ -40,7 +43,7 @@ #include #ifdef HAVE_ALLOCA_H -#include +# include #endif #ifdef __WIN32__ @@ -80,7 +83,7 @@ enum imagex_op_type { }; static void usage(int cmd_type); -static void usage_all(); +static void usage_all(void); static bool imagex_be_quiet = false; @@ -165,7 +168,7 @@ IMAGEX_PROGNAME" split WIMFILE SPLIT_WIMFILE PART_SIZE_MB [--check]\n" ), [UNMOUNT] = T( -IMAGEX_PROGNAME" unmount DIRECTORY [--commit] [--check] [--rebuild]\n" +IMAGEX_PROGNAME" unmount DIRECTORY [--commit] [--check] [--rebuild] [--lazy]\n" ), [UPDATE] = T( @@ -179,14 +182,15 @@ IMAGEX_PROGNAME" update WIMFILE [IMAGE_NUM | IMAGE_NAME] [--check] [--rebuild]\n static void recommend_man_page(const tchar *cmd_name) { + const tchar *format_str; #ifdef __WIN32__ - tprintf(T("See "IMAGEX_PROGNAME"-%"TS".pdf in the " - "doc directory for more details.\n"), - cmd_name); + format_str = T("See "IMAGEX_PROGNAME"%"TS"%"TS".pdf in the " + "doc directory for more details.\n"); #else - tprintf(T("Try `man "IMAGEX_PROGNAME"-%"TS"' " - "for more details.\n"), cmd_name); + format_str = T("Try `man "IMAGEX_PROGNAME"%"TS"%"TS"' " + "for more details.\n"); #endif + tprintf(format_str, *cmd_name ? T("-") : T(""), cmd_name); } enum { @@ -204,6 +208,7 @@ enum { IMAGEX_FORCE_OPTION, IMAGEX_HARDLINK_OPTION, IMAGEX_HEADER_OPTION, + IMAGEX_LAZY_OPTION, IMAGEX_LOOKUP_TABLE_OPTION, IMAGEX_METADATA_OPTION, IMAGEX_NORPFIX_OPTION, @@ -331,6 +336,7 @@ static const struct option unmount_options[] = { {T("commit"), no_argument, NULL, IMAGEX_COMMIT_OPTION}, {T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION}, {T("rebuild"), no_argument, NULL, IMAGEX_REBUILD_OPTION}, + {T("lazy"), no_argument, NULL, IMAGEX_LAZY_OPTION}, {NULL, 0, NULL, 0}, }; @@ -2780,9 +2786,13 @@ imagex_optimize(int argc, tchar **argv) wimfile = argv[0]; + ret = file_writable(wimfile); + if (ret) + return ret; + ret = wimlib_open_wim(wimfile, open_flags, &w, imagex_progress_func); - if (ret != 0) + if (ret) return ret; old_size = file_get_size(argv[0]); @@ -2880,6 +2890,9 @@ imagex_unmount(int argc, tchar **argv) case IMAGEX_REBUILD_OPTION: unmount_flags |= WIMLIB_UNMOUNT_FLAG_REBUILD; break; + case IMAGEX_LAZY_OPTION: + unmount_flags |= WIMLIB_UNMOUNT_FLAG_LAZY; + break; default: usage(UNMOUNT); return -1; @@ -2983,6 +2996,11 @@ imagex_update(int argc, tchar **argv) if (argc < 1 || argc > 2) goto out_usage; wimfile = argv[0]; + + ret = file_writable(wimfile); + if (ret) + goto out; + ret = wimlib_open_wim(wimfile, open_flags, &wim, imagex_progress_func); if (ret) goto out; @@ -3109,7 +3127,7 @@ static const struct imagex_command imagex_commands[] = { }; static void -version() +version(void) { static const tchar *s = T( @@ -3172,7 +3190,7 @@ usage(int cmd_type) } static void -usage_all() +usage_all(void) { tfputs(T("Usage:\n"), stdout); for (int i = 0; i < ARRAY_LEN(usage_strings); i++) @@ -3184,9 +3202,9 @@ usage_all() "\n" " The compression TYPE may be \"maximum\", \"fast\", or \"none\".\n" "\n" -" Try `man "IMAGEX_PROGNAME"' for more information.\n" ); tfputs(extra, stdout); + recommend_man_page(T("")); } /* Entry point for wimlib's ImageX implementation. On UNIX the command