X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=programs%2Fimagex.c;h=c74bdb253ef183efcef45a542a9675298edd672f;hp=ffc841f680d16fd008995bcd0f8f7be90c4e44bf;hb=cf373e59a7f6ff7d1fd007c1f22defe508aa67d4;hpb=7e7aeb2b91b492886ebdc28e5bac0b25462c154b diff --git a/programs/imagex.c b/programs/imagex.c index ffc841f6..c74bdb25 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -23,8 +23,8 @@ */ #include "config.h" -#include "wimlib_tchar.h" #include "wimlib.h" +#include "wimlib_tchar.h" #include #include @@ -145,6 +145,7 @@ IMAGEX_PROGNAME" mountrw WIMFILE [IMAGE_NUM | IMAGE_NAME] DIRECTORY\n" [OPTIMIZE] = T( IMAGEX_PROGNAME" optimize WIMFILE [--check] [--recompress]\n" +" [--threads=NUM_THREADS]\n" ), [SPLIT] = T( @@ -262,6 +263,7 @@ static const struct option mount_options[] = { static const struct option optimize_options[] = { {T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION}, {T("recompress"), no_argument, NULL, IMAGEX_RECOMPRESS_OPTION}, + {T("threads"), required_argument, NULL, IMAGEX_THREADS_OPTION}, {NULL, 0, NULL, 0}, }; @@ -712,8 +714,7 @@ parse_capture_config(tchar **contents_p, size_t nchars, { ssize_t nlines; tchar *p; - struct wimlib_capture_source *sources; - size_t i, j; + size_t i; enum capture_config_section cur_section; memset(config, 0, sizeof(*config)); @@ -1499,7 +1500,6 @@ out_free_capture_sources: free(capture_sources); out_free_source_list_contents: free(source_list_contents); -out: return ret; } @@ -2256,6 +2256,7 @@ imagex_optimize(int argc, tchar **argv) const tchar *wimfile; off_t old_size; off_t new_size; + unsigned num_threads = 0; for_opt(c, optimize_options) { switch (c) { @@ -2266,6 +2267,11 @@ imagex_optimize(int argc, tchar **argv) case IMAGEX_RECOMPRESS_OPTION: write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS; break; + case IMAGEX_THREADS_OPTION: + num_threads = parse_num_threads(optarg); + if (num_threads == UINT_MAX) + return -1; + break; default: usage(OPTIMIZE); return -1; @@ -2293,7 +2299,8 @@ imagex_optimize(int argc, tchar **argv) else tprintf(T("%"PRIu64" KiB\n"), old_size >> 10); - ret = wimlib_overwrite(w, write_flags, 0, imagex_progress_func); + ret = wimlib_overwrite(w, write_flags, num_threads, + imagex_progress_func); if (ret == 0) { new_size = file_get_size(argv[0]); @@ -2519,11 +2526,16 @@ main(int argc, char **argv) { const struct imagex_command *cmd; int ret; + int init_flags = 0; #ifndef __WIN32__ - setlocale(LC_ALL, ""); - { - char *codeset = nl_langinfo(CODESET); + if (getenv("WIMLIB_IMAGEX_USE_UTF8")) { + init_flags |= WIMLIB_INIT_FLAG_ASSUME_UTF8; + } else { + char *codeset; + + setlocale(LC_ALL, ""); + codeset = nl_langinfo(CODESET); if (!strstr(codeset, "UTF-8") && !strstr(codeset, "UTF8") && !strstr(codeset, "utf-8") && @@ -2531,7 +2543,10 @@ main(int argc, char **argv) { fputs( "WARNING: Running "IMAGEX_PROGNAME" in a UTF-8 locale is recommended!\n" -" (Maybe try: `export LANG=en_US.UTF-8'?\n", stderr); +" Maybe try: `export LANG=en_US.UTF-8'?\n" +" Alternatively, set the environmental variable WIMLIB_IMAGEX_USE_UTF8\n" +" to any value to force wimlib to use UTF-8.\n", + stderr); } } @@ -2554,7 +2569,7 @@ main(int argc, char **argv) wimlib_set_print_errors(true); /* Do any initializations that the library needs */ - ret = wimlib_global_init(); + ret = wimlib_global_init(init_flags); if (ret) goto out_check_status;