* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h" /* Need for PACKAGE_VERSION, etc. */
+#endif
+
#include "wimlib.h"
#include "wimlib_tchar.h"
#include <locale.h>
#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
+# include <alloca.h>
#endif
#ifdef __WIN32__
};
static void usage(int cmd_type);
-static void usage_all();
+static void usage_all(void);
static bool imagex_be_quiet = false;
),
[UNMOUNT] =
T(
-IMAGEX_PROGNAME" unmount DIRECTORY [--commit] [--check] [--rebuild]\n"
+IMAGEX_PROGNAME" unmount DIRECTORY [--commit] [--check] [--rebuild] [--lazy]\n"
),
[UPDATE] =
T(
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 {
IMAGEX_FORCE_OPTION,
IMAGEX_HARDLINK_OPTION,
IMAGEX_HEADER_OPTION,
+ IMAGEX_LAZY_OPTION,
IMAGEX_LOOKUP_TABLE_OPTION,
IMAGEX_METADATA_OPTION,
IMAGEX_NORPFIX_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("lazy"), no_argument, NULL, IMAGEX_LAZY_OPTION},
{NULL, 0, NULL, 0},
};
num_images = wimlib_get_num_images(w);
if (argc == 2 && num_images != 1) {
imagex_error(T("\"%"TS"\" contains %d images; Please select one "
- "(or all)"), wimfile, num_images);
+ "(or all)."), wimfile, num_images);
usage(APPLY);
ret = -1;
goto out;
* choose that one; otherwise, print an error. */
num_images = wimlib_get_num_images(w);
if (num_images != 1) {
- imagex_error(T("The file \"%"TS"\" contains %d images; Please "
+ imagex_error(T("\"%"TS"\" contains %d images; Please "
"select one."), wimfile, num_images);
usage(DIR);
ret = -1;
image = 1;
num_images = wimlib_get_num_images(w);
if (num_images != 1) {
- imagex_error(T("The file \"%"TS"\" contains %d images; Please "
+ imagex_error(T("\"%"TS"\" contains %d images; Please "
"select one."), wimfile, num_images);
usage((mount_flags & WIMLIB_MOUNT_FLAG_READWRITE)
? MOUNTRW : MOUNT);
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]);
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;
size_t cmd_file_nchars;
struct wimlib_update_command *cmds;
size_t num_cmds;
+ int num_images;
const tchar *config_file = NULL;
tchar *config_str;
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;
if (ret)
goto out_wimlib_free;
+ 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 */
if (config_file) {
size_t config_len;
}
}
+#ifdef __WIN32__
+ win32_acquire_capture_privileges();
+#endif
+
/* Execute the update commands */
ret = wimlib_update_image(wim, image, cmds, num_cmds, update_flags,
imagex_progress_func);
if (ret)
- goto out_free_cmds;
+ goto out_release_privs;
/* Overwrite the updated WIM */
ret = wimlib_overwrite(wim, write_flags, num_threads,
imagex_progress_func);
+out_release_privs:
+#ifdef __WIN32__
+ win32_release_capture_privileges();
+#endif
out_free_cmds:
free(cmds);
out_free_cmd_file_contents:
};
static void
-version()
+version(void)
{
static const tchar *s =
T(
}
static void
-usage_all()
+usage_all(void)
{
tfputs(T("Usage:\n"), stdout);
for (int i = 0; i < ARRAY_LEN(usage_strings); i++)
"\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