" (DIRECTORY | NTFS_VOLUME) [--check] [--hardlink]\n"
" [--symlink] [--verbose] [--ref=\"GLOB\"] [--unix-data]\n"
" [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n"
" (DIRECTORY | NTFS_VOLUME) [--check] [--hardlink]\n"
" [--symlink] [--verbose] [--ref=\"GLOB\"] [--unix-data]\n"
" [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\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"
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"
-IMAGEX_PROGNAME" update WIMFILE IMAGE [--check] [--rebuild]\n"
-" [--threads=NUM_THREADS] [DEFAULT_ADD_OPTIONS]\n"
-" [DEFAULT_DELETE_OPTIONS] [< CMDFILE]\n"
-" ... where each CMD is:\n"
-" add [--unix-data] [--no-acls] [--strict-acls] [--dereference]\n"
-" [--verbose] FILE_OR_DIRECTORY DEST_WIM_PATH\n"
-" delete [--force] [--recursive] WIM_PATH\n"
-" rename SRC_PATH_IN_WIM DEST_PATH_IN_WIM\n"
+IMAGEX_PROGNAME" update WIMFILE [IMAGE_NUM | IMAGE_NAME] [--check] [--rebuild]\n"
+" [--threads=NUM_THREADS] [DEFAULT_ADD_OPTIONS]\n"
+" [DEFAULT_DELETE_OPTIONS] [--command=STRING] [< CMDFILE]\n"
+
+static void
+recommend_man_page(const tchar *cmd_name)
+{
+ const tchar *format_str;
+#ifdef __WIN32__
+ format_str = T("See "IMAGEX_PROGNAME"%"TS"%"TS".pdf in the "
+ "doc directory for more details.\n");
+#else
+ format_str = T("Try `man "IMAGEX_PROGNAME"%"TS"%"TS"' "
+ "for more details.\n");
+#endif
+ tprintf(format_str, *cmd_name ? T("-") : T(""), cmd_name);
+}
+
{T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION},
{T("rpfix"), no_argument, NULL, IMAGEX_RPFIX_OPTION},
{T("norpfix"), no_argument, NULL, IMAGEX_NORPFIX_OPTION},
{T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION},
{T("rpfix"), no_argument, NULL, IMAGEX_RPFIX_OPTION},
{T("norpfix"), no_argument, NULL, IMAGEX_NORPFIX_OPTION},
{T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION},
{T("dest-dir"), required_argument, NULL, IMAGEX_DEST_DIR_OPTION},
{T("to-stdout"), no_argument, NULL, IMAGEX_TO_STDOUT_OPTION},
{T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION},
{T("dest-dir"), required_argument, NULL, IMAGEX_DEST_DIR_OPTION},
{T("to-stdout"), no_argument, NULL, IMAGEX_TO_STDOUT_OPTION},
{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("commit"), no_argument, NULL, IMAGEX_COMMIT_OPTION},
{T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION},
{T("rebuild"), no_argument, NULL, IMAGEX_REBUILD_OPTION},
+ /* Careful: some of the options here set the defaults for update
+ * commands, but the flags given to an actual update command (and not to
+ * `imagex update' itself are also handled in
+ * update_command_add_option(). */
{T("threads"), required_argument, NULL, IMAGEX_THREADS_OPTION},
{T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION},
{T("rebuild"), no_argument, NULL, IMAGEX_REBUILD_OPTION},
{T("threads"), required_argument, NULL, IMAGEX_THREADS_OPTION},
{T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION},
{T("rebuild"), no_argument, NULL, IMAGEX_REBUILD_OPTION},
{T("force"), no_argument, NULL, IMAGEX_FORCE_OPTION},
{T("recursive"), no_argument, NULL, IMAGEX_RECURSIVE_OPTION},
{T("force"), no_argument, NULL, IMAGEX_FORCE_OPTION},
{T("recursive"), no_argument, NULL, IMAGEX_RECURSIVE_OPTION},
{T("config"), required_argument, NULL, IMAGEX_CONFIG_OPTION},
{T("config"), required_argument, NULL, IMAGEX_CONFIG_OPTION},
{T("dereference"), no_argument, NULL, IMAGEX_DEREFERENCE_OPTION},
{T("unix-data"), no_argument, NULL, IMAGEX_UNIX_DATA_OPTION},
{T("noacls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION},
{T("no-acls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION},
{T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION},
{T("dereference"), no_argument, NULL, IMAGEX_DEREFERENCE_OPTION},
{T("unix-data"), no_argument, NULL, IMAGEX_UNIX_DATA_OPTION},
{T("noacls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION},
{T("no-acls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION},
{T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION},
- PARSE_FILENAME_SUCCESS = 0,
- PARSE_FILENAME_FAILURE = 1,
- PARSE_FILENAME_NONE = 2,
+ PARSE_STRING_SUCCESS = 0,
+ PARSE_STRING_FAILURE = 1,
+ PARSE_STRING_NONE = 2,
- * Parses a filename in the source list file format. (See the man page for
- * 'wimlib-imagex capture' for details on this format and the meaning.)
- * Accepted formats for filenames are an unquoted string (whitespace-delimited),
- * or a double or single-quoted string.
+ * Parses a string token from an array of characters.
+ *
+ * Tokens are either whitespace-delimited, or double or single-quoted.
- * to point past the filename iff the return value is
- * PARSE_FILENAME_SUCCESS. If *len_p > 0, (*line_p)[*len_p - 1] must
+ * to point past the string token iff the return value is
+ * PARSE_STRING_SUCCESS. If *len_p > 0, (*line_p)[*len_p - 1] must
* be '\0'.
*
* @len_p: @len_p initially stores the length of the line of data, which may
* be 0, and it will be updated to the number of bytes remaining in
* be '\0'.
*
* @len_p: @len_p initially stores the length of the line of data, which may
* be 0, and it will be updated to the number of bytes remaining in
- * @fn_ret: Iff the return value is PARSE_FILENAME_SUCCESS, a pointer to the
- * parsed filename will be returned here.
+ * @fn_ret: Iff the return value is PARSE_STRING_SUCCESS, a pointer to the
+ * parsed string token will be returned here.
- * Returns: PARSE_FILENAME_SUCCESS if a filename was successfully parsed; or
- * PARSE_FILENAME_FAILURE if the data was invalid due to a missing
- * closing quote; or PARSE_FILENAME_NONE if the line ended before the
- * beginning of a filename was found.
+ * Returns: PARSE_STRING_SUCCESS if a string token was successfully parsed; or
+ * PARSE_STRING_FAILURE if the data was invalid due to a missing
+ * closing quote; or PARSE_STRING_NONE if the line ended before the
+ * beginning of a string token was found.
line++;
len--;
fn = line;
line = tmemchr(line, quote_char, len);
if (!line) {
imagex_error(T("Missing closing quote: %"TS), fn - 1);
line++;
len--;
fn = line;
line = tmemchr(line, quote_char, len);
if (!line) {
imagex_error(T("Missing closing quote: %"TS), fn - 1);
- ret = parse_filename(&line, &len, &source->fs_source_path);
- if (ret != PARSE_FILENAME_SUCCESS)
+ ret = parse_string(&line, &len, &source->fs_source_path);
+ if (ret != PARSE_STRING_SUCCESS)
- ret = parse_filename(&line, &len, &source->wim_target_path);
- if (ret == PARSE_FILENAME_NONE)
+ ret = parse_string(&line, &len, &source->wim_target_path);
+ if (ret == PARSE_STRING_NONE)
"(such as [ExclusionList]"), line);
return false;
case CAPTURE_CONFIG_EXCLUSION_SECTION:
"(such as [ExclusionList]"), line);
return false;
case CAPTURE_CONFIG_EXCLUSION_SECTION:
return false;
return pattern_list_add_pattern(&config->exclusion_pats,
filename);
case CAPTURE_CONFIG_EXCLUSION_EXCEPTION_SECTION:
return false;
return pattern_list_add_pattern(&config->exclusion_pats,
filename);
case CAPTURE_CONFIG_EXCLUSION_EXCEPTION_SECTION:
-translate_text_to_tstr(char *text, size_t num_bytes,
- size_t *num_tchars_ret)
+translate_text_to_tstr(char *text, size_t num_bytes, size_t *num_tchars_ret)
+#define GIBIBYTE_MIN_NBYTES 10000000000ULL
+#define MEBIBYTE_MIN_NBYTES 10000000ULL
+#define KIBIBYTE_MIN_NBYTES 10000ULL
+
+static unsigned
+get_unit(uint64_t total_bytes, const tchar **name_ret)
+{
+ if (total_bytes >= GIBIBYTE_MIN_NBYTES) {
+ *name_ret = T("GiB");
+ return 30;
+ } else if (total_bytes >= MEBIBYTE_MIN_NBYTES) {
+ *name_ret = T("MiB");
+ return 20;
+ } else if (total_bytes >= KIBIBYTE_MIN_NBYTES) {
+ *name_ret = T("KiB");
+ return 10;
+ } else {
+ *name_ret = T("bytes");
+ return 0;
+ }
+}
+
/* Progress callback function passed to various wimlib functions. */
static int
imagex_progress_func(enum wimlib_progress_msg msg,
const union wimlib_progress_info *info)
{
unsigned percent_done;
/* Progress callback function passed to various wimlib functions. */
static int
imagex_progress_func(enum wimlib_progress_msg msg,
const union wimlib_progress_info *info)
{
unsigned percent_done;
percent_done = TO_PERCENT(info->write_streams.completed_bytes,
info->write_streams.total_bytes);
if (info->write_streams.completed_streams == 0) {
percent_done = TO_PERCENT(info->write_streams.completed_bytes,
info->write_streams.total_bytes);
if (info->write_streams.completed_streams == 0) {
data_type, info->write_streams.num_threads,
(info->write_streams.num_threads == 1) ? T("") : T("s"));
}
data_type, info->write_streams.num_threads,
(info->write_streams.num_threads == 1) ? T("") : T("s"));
}
- info->write_streams.completed_bytes >> 20,
- info->write_streams.total_bytes >> 20,
+ info->write_streams.completed_bytes >> unit_shift,
+ unit_name,
+ info->write_streams.total_bytes >> unit_shift,
+ unit_name,
percent_done = TO_PERCENT(info->integrity.completed_bytes,
info->integrity.total_bytes);
percent_done = TO_PERCENT(info->integrity.completed_bytes,
info->integrity.total_bytes);
- tprintf(T("\rVerifying integrity of \"%"TS"\": %"PRIu64" MiB "
- "of %"PRIu64" MiB (%u%%) done"),
+ tprintf(T("\rVerifying integrity of \"%"TS"\": %"PRIu64" %"TS" "
+ "of %"PRIu64" %"TS" (%u%%) done"),
- info->integrity.completed_bytes >> 20,
- info->integrity.total_bytes >> 20,
+ info->integrity.completed_bytes >> unit_shift,
+ unit_name,
+ info->integrity.total_bytes >> unit_shift,
+ unit_name,
percent_done);
if (info->integrity.completed_bytes == info->integrity.total_bytes)
tputchar(T('\n'));
break;
case WIMLIB_PROGRESS_MSG_CALC_INTEGRITY:
percent_done);
if (info->integrity.completed_bytes == info->integrity.total_bytes)
tputchar(T('\n'));
break;
case WIMLIB_PROGRESS_MSG_CALC_INTEGRITY:
percent_done = TO_PERCENT(info->integrity.completed_bytes,
info->integrity.total_bytes);
percent_done = TO_PERCENT(info->integrity.completed_bytes,
info->integrity.total_bytes);
- tprintf(T("\rCalculating integrity table for WIM: %"PRIu64" MiB "
- "of %"PRIu64" MiB (%u%%) done"),
- info->integrity.completed_bytes >> 20,
- info->integrity.total_bytes >> 20,
+ tprintf(T("\rCalculating integrity table for WIM: %"PRIu64" %"TS" "
+ "of %"PRIu64" %"TS" (%u%%) done"),
+ info->integrity.completed_bytes >> unit_shift,
+ unit_name,
+ info->integrity.total_bytes >> unit_shift,
+ unit_name,
case WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS:
percent_done = TO_PERCENT(info->extract.completed_bytes,
info->extract.total_bytes);
case WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS:
percent_done = TO_PERCENT(info->extract.completed_bytes,
info->extract.total_bytes);
- "%"PRIu64" MiB of %"PRIu64" MiB (%u%%) done"),
- info->extract.completed_bytes >> 20,
- info->extract.total_bytes >> 20,
+ "%"PRIu64" %"TS" of %"PRIu64" %"TS" (%u%%) done"),
+ info->extract.completed_bytes >> unit_shift,
+ unit_name,
+ info->extract.total_bytes >> unit_shift,
+ unit_name,
case WIMLIB_PROGRESS_MSG_JOIN_STREAMS:
percent_done = TO_PERCENT(info->join.completed_bytes,
info->join.total_bytes);
case WIMLIB_PROGRESS_MSG_JOIN_STREAMS:
percent_done = TO_PERCENT(info->join.completed_bytes,
info->join.total_bytes);
(info->join.completed_parts == info->join.total_parts) ?
info->join.completed_parts : info->join.completed_parts + 1,
info->join.total_parts,
(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 >> 20,
- info->join.total_bytes >> 20,
+ 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);
percent_done);
break;
case WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART:
percent_done = TO_PERCENT(info->split.completed_bytes,
info->split.total_bytes);
- tprintf(T("Writing \"%"TS"\": %"PRIu64" MiB of "
- "%"PRIu64" MiB (%u%%) written\n"),
+ unit_shift = get_unit(info->split.total_bytes, &unit_name);
+ tprintf(T("Writing \"%"TS"\": %"PRIu64" %"TS" of "
+ "%"PRIu64" %"TS" (%u%%) written\n"),
- info->split.completed_bytes >> 20,
- info->split.total_bytes >> 20,
+ info->split.completed_bytes >> unit_shift,
+ unit_name,
+ info->split.total_bytes >> unit_shift,
+ unit_name,
+/*
+ * Parse an option passed to an update command.
+ *
+ * @op: One of WIMLIB_UPDATE_OP_* that indicates the command being
+ * parsed.
+ *
+ * @option: Text string for the option (beginning with --)
+ *
+ * @cmd: `struct wimlib_update_command' that is being constructed for
+ * this command.
+ *
+ * Returns true if the option was recognized; false if not.
+ */
static bool
update_command_add_option(int op, const tchar *option,
struct wimlib_update_command *cmd)
static bool
update_command_add_option(int op, const tchar *option,
struct wimlib_update_command *cmd)
- if (!tstrcmp(option, T("--unix-data")))
+ if (!tstrcmp(option, T("--verbose")))
+ cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_VERBOSE;
+ else if (!tstrcmp(option, T("--unix-data")))
cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA;
else if (!tstrcmp(option, T("--no-acls")) || !tstrcmp(option, T("--noacls")))
cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_NO_ACLS;
cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA;
else if (!tstrcmp(option, T("--no-acls")) || !tstrcmp(option, T("--noacls")))
cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_NO_ACLS;
static const unsigned update_command_num_nonoptions[] = {
[WIMLIB_UPDATE_OP_ADD] = 2,
[WIMLIB_UPDATE_OP_DELETE] = 1,
[WIMLIB_UPDATE_OP_RENAME] = 2,
};
static const unsigned update_command_num_nonoptions[] = {
[WIMLIB_UPDATE_OP_ADD] = 2,
[WIMLIB_UPDATE_OP_DELETE] = 1,
[WIMLIB_UPDATE_OP_RENAME] = 2,
};
update_command_add_nonoption(int op, const tchar *nonoption,
struct wimlib_update_command *cmd,
unsigned num_nonoptions)
update_command_add_nonoption(int op, const tchar *nonoption,
struct wimlib_update_command *cmd,
unsigned num_nonoptions)
+/*
+ * Parse a command passed on stdin to `imagex update'.
+ *
+ * @line: Text of the command.
+ * @len: Length of the line, including a null terminator
+ * at line[len - 1].
+ *
+ * @command: A `struct wimlib_update_command' to fill in from the parsed
+ * line.
+ *
+ * @line_number: Line number of the command, for diagnostics.
+ *
+ * Returns true on success; returns false on parse error.
+ */
static bool
parse_update_command(tchar *line, size_t len,
struct wimlib_update_command *command,
static bool
parse_update_command(tchar *line, size_t len,
struct wimlib_update_command *command,
- ret = parse_filename(&line, &len, &command_name);
- if (ret != PARSE_FILENAME_SUCCESS)
+ /* Get the command name ("add", "delete", "rename") */
+ ret = parse_string(&line, &len, &command_name);
+ if (ret != PARSE_STRING_SUCCESS)
- ret = parse_filename(&line, &len, &next_string);
- if (ret == PARSE_FILENAME_NONE)
+ ret = parse_string(&line, &len, &next_string);
+ if (ret == PARSE_STRING_NONE) /* End of line */
if (!update_command_add_option(op, next_string, command))
{
imagex_error(T("Unrecognized option \"%"TS"\" to "
if (!update_command_add_option(op, next_string, command))
{
imagex_error(T("Unrecognized option \"%"TS"\" to "
- "update command on line %zu"),
- next_string, line_number);
+ "update command \"%"TS"\" on line %zu"),
+ next_string, command_name, line_number);
if (num_nonoptions == update_command_num_nonoptions[op])
{
imagex_error(T("Unexpected argument \"%"TS"\" in "
if (num_nonoptions == update_command_num_nonoptions[op])
{
imagex_error(T("Unexpected argument \"%"TS"\" in "
- if (!update_command_add_nonoption(op, next_string,
- command, num_nonoptions))
- return false;
+ update_command_add_nonoption(op, next_string,
+ command, num_nonoptions);
num_images = wimlib_get_num_images(w);
if (argc == 2 && num_images != 1) {
imagex_error(T("\"%"TS"\" contains %d images; Please select one "
num_images = wimlib_get_num_images(w);
if (argc == 2 && num_images != 1) {
imagex_error(T("\"%"TS"\" contains %d images; Please select one "
} else {
/* Set default name to SOURCE argument, omitting any directory
* prefixes and trailing slashes. This requires making a copy
} else {
/* Set default name to SOURCE argument, omitting any directory
* prefixes and trailing slashes. This requires making a copy
+
+ if (cmd == APPEND && name_defaulted) {
+ /* If the user did not specify an image name, and the basename
+ * of the source already exists as an image name in the WIM
+ * file, append a suffix to make it unique. */
+ unsigned long conflict_idx;
+ tchar *name_end = tstrchr(name, T('\0'));
+ for (conflict_idx = 1;
+ wimlib_image_name_in_use(w, name);
+ conflict_idx++)
+ {
+ tsprintf(name_end, T(" (%lu)"), conflict_idx);
+ }
+ }
* choose that one; otherwise, print an error. */
num_images = wimlib_get_num_images(w);
if (num_images != 1) {
* choose that one; otherwise, print an error. */
num_images = wimlib_get_num_images(w);
if (num_images != 1) {
-prepare_extract_commands(tchar **argv, int argc, int extract_flags,
- tchar *dest_dir, size_t *num_cmds_ret)
+prepare_extract_commands(tchar **paths, unsigned num_paths,
+ int extract_flags, tchar *dest_dir,
+ size_t *num_cmds_ret)
cmds = calloc(num_cmds, sizeof(cmds[0]));
if (!cmds) {
imagex_error(T("Out of memory!"));
cmds = calloc(num_cmds, sizeof(cmds[0]));
if (!cmds) {
imagex_error(T("Out of memory!"));
cmds[i].fs_dest_path = malloc((len + 1) * sizeof(tchar));
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,
cmds[i].fs_dest_path = malloc((len + 1) * sizeof(tchar));
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,
- ret = wimlib_extract_files(wim, image, 0, cmds, num_cmds,
+ ret = wimlib_extract_files(wim, image, cmds, num_cmds, 0,
"select one."), wimfile, num_images);
usage((mount_flags & WIMLIB_MOUNT_FLAG_READWRITE)
? MOUNTRW : MOUNT);
"select one."), wimfile, num_images);
usage((mount_flags & WIMLIB_MOUNT_FLAG_READWRITE)
? MOUNTRW : MOUNT);
ret = wimlib_open_wim(wimfile, open_flags, &w,
imagex_progress_func);
ret = wimlib_open_wim(wimfile, open_flags, &w,
imagex_progress_func);
case IMAGEX_THREADS_OPTION:
num_threads = parse_num_threads(optarg);
if (num_threads == UINT_MAX) {
case IMAGEX_THREADS_OPTION:
num_threads = parse_num_threads(optarg);
if (num_threads == UINT_MAX) {
+ case IMAGEX_COMMAND_OPTION:
+ if (command_str) {
+ imagex_error(T("--command may only be specified "
+ "one time. Please provide\n"
+ " the update commands "
+ "on standard input instead."));
+ ret = -1;
+ goto out;
+ }
+ command_str = tstrdup(optarg);
+ if (!command_str) {
+ imagex_error(T("Out of memory!"));
+ ret = -1;
+ goto out;
+ }
+ break;
+ /* Default delete options */
case IMAGEX_FORCE_OPTION:
default_delete_flags |= WIMLIB_DELETE_FLAG_FORCE;
break;
case IMAGEX_RECURSIVE_OPTION:
default_delete_flags |= WIMLIB_DELETE_FLAG_RECURSIVE;
break;
case IMAGEX_FORCE_OPTION:
default_delete_flags |= WIMLIB_DELETE_FLAG_FORCE;
break;
case IMAGEX_RECURSIVE_OPTION:
default_delete_flags |= WIMLIB_DELETE_FLAG_RECURSIVE;
break;
ret = wimlib_open_wim(wimfile, open_flags, &wim, imagex_progress_func);
if (ret)
goto out;
ret = wimlib_open_wim(wimfile, open_flags, &wim, imagex_progress_func);
if (ret)
goto out;
+ num_images = wimlib_get_num_images(wim);
+ if (argc == 1 && num_images != 1) {
+ imagex_error(T("\"%"TS"\" contains %d images; Please select one."),
+ wimfile, num_images);
+ usage(UPDATE);
+ ret = -1;
+ goto out_wimlib_free;
+ }
+
+ /* Parse capture configuration file if specified */
- cmd_file_contents = stdin_get_text_contents(&cmd_file_nchars);
- if (!cmd_file_contents) {
- ret = -1;
- goto out_free_config;
- }
+ /* Read update commands from standard input, or the command string if
+ * specified. */
+ if (command_str) {
+ cmds = parse_update_command_file(&command_str, tstrlen(command_str),
+ &num_cmds);
+ } else {
+ if (isatty(STDIN_FILENO)) {
+ tputs(T("Reading update commands from standard input..."));
+ recommend_man_page(T("update"));
+ }
+ cmd_file_contents = stdin_get_text_contents(&cmd_file_nchars);
+ if (!cmd_file_contents) {
+ ret = -1;
+ goto out_free_config;
+ }
- cmds = parse_update_command_file(&cmd_file_contents, cmd_file_nchars,
- &num_cmds);
+ /* Parse the update commands */
+ cmds = parse_update_command_file(&cmd_file_contents, cmd_file_nchars,
+ &num_cmds);
+ }
ret = wimlib_update_image(wim, image, cmds, num_cmds, update_flags,
imagex_progress_func);
if (ret)
ret = wimlib_update_image(wim, image, cmds, num_cmds, update_flags,
imagex_progress_func);
if (ret)
ret = wimlib_overwrite(wim, write_flags, num_threads,
imagex_progress_func);
ret = wimlib_overwrite(wim, write_flags, num_threads,
imagex_progress_func);
tprintf(T("Usage:\n%"TS), usage_strings[cmd_type]);
for_imagex_command(cmd) {
if (cmd->cmd == cmd_type) {
tprintf(T("Usage:\n%"TS), usage_strings[cmd_type]);
for_imagex_command(cmd) {
if (cmd->cmd == cmd_type) {
- tprintf(T("\nTry `man "IMAGEX_PROGNAME"-%"TS"' "
- "for more details.\n"), cmd->name);
+ tputc(T('\n'), stdout);
+ recommend_man_page(cmd->name);
{
tfputs(T("Usage:\n"), stdout);
for (int i = 0; i < ARRAY_LEN(usage_strings); i++)
{
tfputs(T("Usage:\n"), stdout);
for (int i = 0; i < ARRAY_LEN(usage_strings); i++)