typedef char wimlib_tchar;
#endif
+#ifdef __WIN32__
+/** Path separator for WIM paths passed back to progress callbacks. */
+# define WIMLIB_WIM_PATH_SEPARATOR '\\'
+# define WIMLIB_WIM_PATH_SEPARATOR_STRING L"\\"
+#else
+/** Path separator for WIM paths passed back to progress callbacks. */
+# define WIMLIB_WIM_PATH_SEPARATOR '/'
+# define WIMLIB_WIM_PATH_SEPARATOR_STRING "/"
+#endif
/**
* Specifies the compression type of a WIM file.
*/
* @a info will point to ::wimlib_progress_info.rename. */
WIMLIB_PROGRESS_MSG_RENAME,
+ /**
+ * A WIM update command is just about to be executed; @a info will point
+ * to ::wimlib_progress_info.update.
+ */
+ WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
+
+ /**
+ * A WIM update command is just about to be executed; @a info will point
+ * to ::wimlib_progress_info.update.
+ */
+ WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
+
/** The contents of the WIM are being checked against the integrity
* table. Only happens when wimlib_open_wim() is called with the
* ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY flag. @a info will point to
const wimlib_tchar *to;
} rename;
+ /** Valid on messages ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
+ * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND. */
+ struct wimlib_progress_info_update {
+ /** Pointer to the update command that will be executed or has
+ * just been executed. */
+ const struct wimlib_update_command *command;
+
+ /** Number of update commands that have been completed so far.
+ */
+ size_t completed_commands;
+
+ /** Number of update commands that are being executed as part of
+ * this call to wimlib_update_image(). */
+ size_t total_commands;
+ } update;
+
/** Valid on messages ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY and
* ::WIMLIB_PROGRESS_MSG_CALC_INTEGRITY. */
struct wimlib_progress_info_integrity {
/** Do a "lazy" unmount (detach filesystem immediately, even if busy) */
#define WIMLIB_UNMOUNT_FLAG_LAZY 0x00000010
+/******************************
+ * WIMLIB_UPDATE_FLAG_*
+ ******************************/
+
+/** Send ::WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND and
+ * ::WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND messages. */
+#define WIMLIB_UPDATE_FLAG_SEND_PROGRESS 0x00000001
+
/******************************
* WIMLIB_WRITE_FLAG_*
******************************/
* @param num_cmds
* Number of commands in @a cmds.
* @param update_flags
- * Reserved; must be 0.
+ * ::WIMLIB_UPDATE_FLAG_SEND_PROGRESS or 0.
* @param progress_func
* If non-NULL, a function that will be called periodically with the
* progress of the current operation.
# define is_any_path_separator(c) ((c) == '/' || (c) == '\\')
#endif
-#define WIM_PATH_SEPARATOR OS_PREFERRED_PATH_SEPARATOR
-
+#define WIM_PATH_SEPARATOR WIMLIB_WIM_PATH_SEPARATOR
#endif /* _WIMLIB_UTIL_H */
# include "imagex-win32.h"
# define tbasename win32_wbasename
# define tglob win32_wglob
+# define OS_PREFERRED_PATH_SEPARATOR L'\\'
+# define OS_PREFERRED_PATH_SEPARATOR_STRING L"\\"
#else /* __WIN32__ */
# include <glob.h>
# include <getopt.h>
# include <langinfo.h>
# define tbasename basename
# define tglob glob
+# define OS_PREFERRED_PATH_SEPARATOR '/'
+# define OS_PREFERRED_PATH_SEPARATOR_STRING "/"
#endif /* !__WIN32 */
case WIMLIB_PROGRESS_MSG_SCAN_BEGIN:
tprintf(T("Scanning \"%"TS"\""), info->scan.source);
if (*info->scan.wim_target_path) {
- tprintf(T(" (loading as WIM path: \"/%"TS"\")...\n"),
+ tprintf(T(" (loading as WIM path: "
+ "\""WIMLIB_WIM_PATH_SEPARATOR_STRING"%"TS"\")...\n"),
info->scan.wim_target_path);
} else {
tprintf(T(" (loading as root of WIM image)...\n"));
info->extract.target);
break;
case WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN:
- tprintf(T("Extracting \"%"TS"\" from image %d (\"%"TS"\") "
+ tprintf(T("Extracting "
+ "\""WIMLIB_WIM_PATH_SEPARATOR_STRING"%"TS"\" from image %d (\"%"TS"\") "
"in \"%"TS"\" to \"%"TS"\"\n"),
info->extract.extract_root_wim_source_path,
info->extract.image,
info->split.cur_part_number);
}
break;
+ case WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND:
+ switch (info->update.command->op) {
+ case WIMLIB_UPDATE_OP_DELETE:
+ tprintf(T("Deleted WIM path "
+ "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
+ info->update.command->delete.wim_path);
+ break;
+ case WIMLIB_UPDATE_OP_RENAME:
+ tprintf(T("Renamed WIM path "
+ "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\" => "
+ "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
+ info->update.command->rename.wim_source_path,
+ info->update.command->rename.wim_target_path);
+ break;
+ case WIMLIB_UPDATE_OP_ADD:
+ default:
+ break;
+ }
+ break;
default:
break;
}
free_extract_commands(cmds, num_cmds, dest_dir);
return NULL;
}
- tsprintf(cmds[i].fs_dest_path, T("%"TS"/%"TS), dest_dir,
- tbasename(paths[i]));
+ tsprintf(cmds[i].fs_dest_path, T("%"TS""OS_PREFERRED_PATH_SEPARATOR_STRING"%"TS),
+ dest_dir, tbasename(paths[i]));
}
}
*num_cmds_ret = num_cmds;
int ret;
int open_flags = 0;
int write_flags = 0;
- int update_flags = 0;
+ int update_flags = WIMLIB_UPDATE_FLAG_SEND_PROGRESS;
int default_add_flags = WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE;
int default_delete_flags = 0;
unsigned num_threads = 0;
# include "config.h"
#endif
+#include "wimlib.h"
#include "wimlib/paths.h"
#include "wimlib/util.h"
execute_update_commands(WIMStruct *wim,
const struct wimlib_update_command *cmds,
size_t num_cmds,
+ int update_flags,
wimlib_progress_func_t progress_func)
{
int ret = 0;
+ union wimlib_progress_info info;
+ info.update.completed_commands = 0;
+ info.update.total_commands = num_cmds;
for (size_t i = 0; i < num_cmds; i++) {
DEBUG("Executing update command %zu of %zu (op=%"TS")",
i + 1, num_cmds, update_op_to_str(cmds[i].op));
+ if (update_flags & WIMLIB_UPDATE_FLAG_SEND_PROGRESS &&
+ progress_func)
+ {
+ info.update.command = &cmds[i];
+ (*progress_func)(WIMLIB_PROGRESS_MSG_UPDATE_BEGIN_COMMAND,
+ &info);
+ }
switch (cmds[i].op) {
case WIMLIB_UPDATE_OP_ADD:
ret = execute_add_command(wim, &cmds[i], progress_func);
}
if (ret)
break;
+ info.update.completed_commands++;
+ if (update_flags & WIMLIB_UPDATE_FLAG_SEND_PROGRESS &&
+ progress_func)
+ {
+ (*progress_func)(WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND,
+ &info);
+ }
}
return ret;
}
/* Actually execute the update commands. */
DEBUG("Executing %zu update commands", num_cmds);
- ret = execute_update_commands(wim, cmds_copy, num_cmds, progress_func);
+ ret = execute_update_commands(wim, cmds_copy, num_cmds, update_flags,
+ progress_func);
if (ret)
goto out_free_cmds_copy;