OPTIMIZE,
SPLIT,
UNMOUNT,
+ UPDATE,
};
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(
T(
IMAGEX_PROGNAME" unmount DIRECTORY [--commit] [--check] [--rebuild]\n"
),
+[UPDATE] =
+T(
+IMAGEX_PROGNAME" update WIMFILE IMAGE [--check] [--rebuild]\n"
+" [--threads=NUM_THREADS] [DEFAULT_ADD_OPTIONS]\n"
+" [DEFAULT_DELETE_OPTIONS] [CMD...] [< 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"
+),
};
enum {
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
return ret;
}
+static int
+imagex_update(int argc, tchar **argv)
+{
+ const tchar *wimfile;
+ const tchar *image_num_or_name;
+ int image;
+ WIMStruct *wim;
+ int ret;
+ int open_flags = 0;
+ int write_flags = 0;
+ unsigned num_threads = 0;
+
+ if (argc < 3)
+ goto out_usage;
+ wimfile = argv[1];
+ image_num_or_name = argv[2];
+
+ ret = wimlib_open_wim(wimfile, open_flags, &wim, imagex_progress_func);
+ if (ret)
+ goto out;
+
+ /*wimlib_update_image();*/
+
+ ret = wimlib_overwrite(wim, write_flags, num_threads,
+ imagex_progress_func);
+out_wimlib_free:
+ wimlib_free(wim);
+out:
+ return ret;
+out_usage:
+ usage(UPDATE);
+ ret = -1;
+ goto out;
+}
+
struct imagex_command {
const tchar *name;
int (*func)(int , tchar **);
{T("optimize"),imagex_optimize, OPTIMIZE},
{T("split"), imagex_split, SPLIT},
{T("unmount"), imagex_unmount, UNMOUNT},
+ {T("update"), imagex_update, UPDATE},
};
static void