static void usage(int cmd_type);
static void usage_all();
+static bool imagex_be_quiet = false;
+
static const tchar *usage_strings[] = {
[APPEND] =
),
[EXTRACT] =
T(
-IMAGEX_PROGNAME" extract SRC_WIMFILE (SRC_IMAGE_NUM | SRC_IMAGE_NAME) [PATH...]\n"
-" [--check] [--ref=\"GLOB\"] [--verbose] [--unix-data] [--no-acls]\n"
-" [--strict-acls] [--to-stdout] [--dest-dir=DIR]\n"
+IMAGEX_PROGNAME" extract WIMFILE (IMAGE_NUM | IMAGE_NAME) [PATH...]\n"
+" [--check] [--ref=\"GLOB\"] [--verbose] [--unix-data]\n"
+" [--no-acls] [--strict-acls] [--to-stdout] [--dest-dir=DIR]\n"
),
[INFO] =
T(
const union wimlib_progress_info *info)
{
unsigned percent_done;
+ if (imagex_be_quiet)
+ return 0;
switch (msg) {
case WIMLIB_PROGRESS_MSG_WRITE_STREAMS:
percent_done = TO_PERCENT(info->write_streams.completed_bytes,
{
const tchar *p;
for (p = path; *p; p++)
- if (*p != T('\\') && *p != T('\\'))
+ if (*p != T('\\') && *p != T('/'))
return false;
return true;
}
static void
free_extract_commands(struct wimlib_extract_command *cmds, size_t num_cmds,
- tchar *dest_dir)
+ const tchar *dest_dir)
{
for (size_t i = 0; i < num_cmds; i++)
if (cmds[i].fs_dest_path != dest_dir)
- free(cmds[i].fs_dest_path);
+ free(cmds[i].fs_dest_path);
free(cmds);
}
size_t num_cmds;
tchar *emptystr = T("");
- num_cmds = argc;
if (argc == 0) {
- num_cmds = 1;
+ argc = 1;
argv = &emptystr;
}
+ num_cmds = argc;
cmds = calloc(num_cmds, sizeof(cmds[0]));
if (!cmds) {
- imagex_error("Out of memory!");
+ imagex_error(T("Out of memory!"));
return NULL;
}
} else {
size_t len = tstrlen(dest_dir) + 1 + tstrlen(argv[i]);
cmds[i].fs_dest_path = malloc((len + 1) * sizeof(tchar));
- if (!cmds[i].fs_dest_path)
- goto oom;
- tsprintf(cmds[i].fs_dest_path, "%"TS"/%"TS, dest_dir, tbasename(argv[i]));
+ if (!cmds[i].fs_dest_path) {
+ free_extract_commands(cmds, num_cmds, dest_dir);
+ return NULL;
+ }
+ tsprintf(cmds[i].fs_dest_path, T("%"TS"/%"TS), dest_dir,
+ tbasename(argv[i]));
}
}
-
*num_cmds_ret = num_cmds;
return cmds;
-oom:
- free_extract_commands(cmds, num_cmds, dest_dir);
- return NULL;
}
+/* Extract files or directories from a WIM image */
static int
imagex_extract(int argc, tchar **argv)
{
const tchar *wimfile;
const tchar *image_num_or_name;
tchar *dest_dir = T(".");
- int extract_flags = WIMLIB_EXTRACT_FLAG_SEQUENTIAL;
+ int extract_flags = WIMLIB_EXTRACT_FLAG_SEQUENTIAL | WIMLIB_EXTRACT_FLAG_NORPFIX;
const tchar *swm_glob = NULL;
WIMStruct **additional_swms = NULL;
break;
case IMAGEX_TO_STDOUT_OPTION:
extract_flags |= WIMLIB_EXTRACT_FLAG_TO_STDOUT;
+ imagex_be_quiet = true;
break;
default:
usage(EXTRACT);
ret = wimlib_extract_files(wim, image, 0, cmds, num_cmds,
additional_swms, num_additional_swms,
imagex_progress_func);
- if (ret == 0)
- tprintf(T("Done extracting files.\n"));
+ if (ret == 0) {
+ if (!imagex_be_quiet)
+ tprintf(T("Done extracting files.\n"));
+ } else if (ret == WIMLIB_ERR_PATH_DOES_NOT_EXIST) {
+ tfprintf(stderr, T("Note: You can use `"IMAGEX_PROGNAME" dir' to see what "
+ "files and directories\n"
+ " are in the WIM image.\n"));
+ }
#ifdef __WIN32__
win32_release_restore_privileges();
#endif