case WIMLIB_PROGRESS_MSG_SCAN_BEGIN:
printf("Scanning `%s'...\n", info->scan.source);
break;
+ case WIMLIB_PROGRESS_MSG_SCAN_DENTRY:
+ if (info->scan.excluded)
+ printf("Excluding `%s' from capture\n", info->scan.cur_path);
+ else
+ printf("Scanning `%s'\n", info->scan.cur_path);
+ break;
/*case WIMLIB_PROGRESS_MSG_SCAN_END:*/
/*break;*/
case WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY:
if (info->extract.completed_bytes == info->extract.total_bytes)
putchar('\n');
break;
+ case WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY:
+ puts(info->extract.cur_path);
+ break;
case WIMLIB_PROGRESS_MSG_JOIN_STREAMS:
percent_done = TO_PERCENT(info->join.completed_bytes,
info->join.total_bytes);
if (inode_unnamed_lte_resolved(inode))
return 0;
- if (extract_flags & WIMLIB_EXTRACT_FLAG_VERBOSE)
- puts(dentry->full_path_utf8);
+ if ((extract_flags & WIMLIB_EXTRACT_FLAG_VERBOSE) &&
+ args->progress_func)
+ {
+ args->progress.extract.cur_path = dentry->full_path_utf8;
+ args->progress_func(WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY,
+ &args->progress);
+ }
len = strlen(args->target);
char output_path[len + dentry->full_path_utf8_len + 1];
args.num_lutimes_warnings = 0;
args.target = target;
args.stream_list = &stream_list;
+ args.progress_func = progress_func;
if (progress_func) {
args.progress.extract.image = image;
struct lookup_table *lookup_table,
struct wim_security_data *sd,
const struct capture_config *config,
- int add_flags,
+ int add_image_flags,
+ wimlib_progress_func_t progress_func,
void *extra_arg)
{
struct stat root_stbuf;
struct inode *inode;
if (exclude_path(root_disk_path, config, true)) {
- if (add_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) {
+ if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) {
ERROR("Cannot exclude the root directory from capture");
return WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
}
- if (add_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
- printf("Excluding file `%s' from capture\n",
- root_disk_path);
+ if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
+ && progress_func)
+ {
+ union wimlib_progress_info info;
+ info.scan.cur_path = root_disk_path;
+ info.scan.excluded = true;
+ progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
+ }
*root_ret = NULL;
return 0;
}
+ if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
+ && progress_func)
+ {
+ union wimlib_progress_info info;
+ info.scan.cur_path = root_disk_path;
+ info.scan.excluded = false;
+ progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
+ }
- if (add_flags & WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE)
+ if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE)
stat_fn = stat;
else
stat_fn = lstat;
- if (add_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
- printf("Scanning `%s'\n", root_disk_path);
-
ret = (*stat_fn)(root_disk_path, &root_stbuf);
if (ret != 0) {
ERROR_WITH_ERRNO("Failed to stat `%s'", root_disk_path);
return WIMLIB_ERR_STAT;
}
- if ((add_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) &&
+ if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) &&
!S_ISDIR(root_stbuf.st_mode)) {
ERROR("`%s' is not a directory", root_disk_path);
return WIMLIB_ERR_NOTDIR;
return WIMLIB_ERR_SPECIAL_FILE;
}
- if (add_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT)
+ if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT)
filename = "";
else
filename = path_basename(root_disk_path);
inode->ino = (u64)root_stbuf.st_ino |
((u64)root_stbuf.st_dev << ((sizeof(ino_t) * 8) & 63));
- add_flags &= ~WIMLIB_ADD_IMAGE_FLAG_ROOT;
+ add_image_flags &= ~WIMLIB_ADD_IMAGE_FLAG_ROOT;
inode->resolved = true;
if (S_ISREG(root_stbuf.st_mode)) { /* Archiving a regular file */
continue;
strcpy(name + len + 1, p->d_name);
ret = build_dentry_tree(&child, name, lookup_table,
- NULL, config,
- add_flags, NULL);
+ NULL, config, add_image_flags,
+ progress_func, NULL);
if (ret != 0)
break;
if (child)
struct lookup_table *,
struct wim_security_data *,
const struct capture_config *,
- int, void *);
+ int, wimlib_progress_func_t, void *);
void *extra_arg;
struct dentry *root_dentry = NULL;
DEBUG("Building dentry tree.");
ret = (*capture_tree)(&root_dentry, source, w->lookup_table, sd,
&config, add_image_flags | WIMLIB_ADD_IMAGE_FLAG_ROOT,
- extra_arg);
+ progress_func, extra_arg);
destroy_capture_config(&config);
if (ret != 0) {
if (inode_unnamed_lte_resolved(dentry->d_inode))
return 0;
+
DEBUG("Applying dentry `%s' to NTFS", dentry->full_path_utf8);
- if (extract_flags & WIMLIB_EXTRACT_FLAG_VERBOSE)
- puts(dentry->full_path_utf8);
+ if ((extract_flags & WIMLIB_EXTRACT_FLAG_VERBOSE) &&
+ args->progress_func)
+ {
+ args->progress.extract.cur_path = dentry->full_path_utf8;
+ args->progress_func(WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY,
+ &args->progress);
+ }
if (dentry_is_root(dentry))
return wim_apply_root_dentry_ntfs(dentry, vol, w);
struct sd_set *sd_set;
const struct capture_config *config;
ntfs_volume **ntfs_vol_p;
- int flags;
+ int add_image_flags;
+ wimlib_progress_func_t progress_func;
};
static int
struct sd_set *sd_set,
const struct capture_config *config,
ntfs_volume **ntfs_vol_p,
- int flags);
+ int add_image_flags,
+ wimlib_progress_func_t progress_func);
static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
const int name_len, const int name_type,
ni, ctx->path, path_len, name_type,
ctx->lookup_table, ctx->sd_set,
ctx->config, ctx->ntfs_vol_p,
- ctx->flags);
+ ctx->add_image_flags,
+ ctx->progress_func);
if (child)
dentry_add_child(ctx->parent, child);
struct sd_set *sd_set,
const struct capture_config *config,
ntfs_volume **ntfs_vol_p,
- int flags)
+ int add_image_flags,
+ wimlib_progress_func_t progress_func)
{
u32 attributes;
int mrec_flags;
char dos_name_utf8[64];
struct dentry *root;
+ if (exclude_path(path, config, false)) {
+ if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
+ && progress_func)
+ {
+ union wimlib_progress_info info;
+ info.scan.cur_path = path;
+ info.scan.excluded = true;
+ progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
+ }
+ *root_p = NULL;
+ return 0;
+ }
+
mrec_flags = ni->mrec->flags;
struct SECURITY_CONTEXT ctx;
memset(&ctx, 0, sizeof(ctx));
return WIMLIB_ERR_NTFS_3G;
}
- if (exclude_path(path, config, false)) {
- if (flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE) {
- const char *file_type;
- if (attributes & MFT_RECORD_IS_DIRECTORY)
- file_type = "directory";
- else
- file_type = "file";
- printf("Excluding %s `%s' from capture\n",
- file_type, path);
- }
- *root_p = NULL;
- return 0;
+ if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
+ && progress_func)
+ {
+ union wimlib_progress_info info;
+ info.scan.cur_path = path;
+ info.scan.excluded = false;
+ progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
}
- if (flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE)
- printf("Scanning `%s'\n", path);
-
root = new_dentry_with_timeless_inode(path_basename(path));
if (!root)
return WIMLIB_ERR_NOMEM;
.sd_set = sd_set,
.config = config,
.ntfs_vol_p = ntfs_vol_p,
- .flags = flags,
+ .add_image_flags = add_image_flags,
+ .progress_func = progress_func,
};
ret = ntfs_readdir(ni, &pos, &ctx, wim_ntfs_capture_filldir);
if (ret != 0) {
struct lookup_table *lookup_table,
struct wim_security_data *sd,
const struct capture_config *config,
- int flags,
+ int add_image_flags,
+ wimlib_progress_func_t progress_func,
void *extra_arg)
{
ntfs_volume *vol;
ret = build_dentry_tree_ntfs_recursive(root_p, NULL, root_ni, path, 1,
FILE_NAME_POSIX, lookup_table,
&sd_set, config, ntfs_vol_p,
- flags);
+ add_image_flags,
+ progress_func);
out_cleanup:
FREE(path);
ntfs_inode_close(root_ni);
* info will point to ::wimlib_progress_info.extract. */
WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
+ /** A file or directory is being extracted. @a info will point to
+ * ::wimlib_progress_info.extract, and the @a cur_path member will be
+ * valid. */
+ WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY,
+
/** All the WIM files and directories have been extracted, and
* timestamps are about to be applied. @a info will point to
* ::wimlib_progress_info.extract. */
* ::wimlib_progress_info.scan. */
WIMLIB_PROGRESS_MSG_SCAN_BEGIN,
+ /** A directory or file is being scanned. @a info will point to
+ * ::wimlib_progress_info.scan, and its @a cur_path member will be
+ * valid. This message is only sent if ::WIMLIB_ADD_IMAGE_FLAG_VERBOSE
+ * is passed to wimlib_add_image(). */
+ WIMLIB_PROGRESS_MSG_SCAN_DENTRY,
+
/** The directory or NTFS volume has been successfully scanned, and a
* tree of WIM dentries has been built in-memory. @a info will point to
* ::wimlib_progress_info.scan. */
struct wimlib_progress_info_scan {
/** Directory or NTFS volume that is being scanned. */
const char *source;
+
+ /** Path to the file or directory that is about to be scanned,
+ * relative to the root of the image capture or the NTFS volume.
+ * */
+ const char *cur_path;
+
+ /** True iff @a cur_path is being excluded from the image
+ * capture due to the capture configuration file. */
+ bool excluded;
} scan;
/** Valid on messages ::WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN,
* extracted. */
const char *target;
+ /** Current dentry being extracted. (Valid only if message is
+ * ::WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY.) */
+ const char *cur_path;
+
/** Number of bytes of uncompressed data that will be extracted.
* Takes into account hard links (they are not counted for each
* link.)
* with ::WIMLIB_ADD_IMAGE_FLAG_NTFS. */
#define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE 0x00000002
-/** Print the name of each file or directory as it is scanned to be included in
- * the WIM image. */
+/** Call the progress function with the message
+ * ::WIMLIB_PROGRESS_MSG_SCAN_DENTRY when each directory or file is starting to
+ * be scanned. */
#define WIMLIB_ADD_IMAGE_FLAG_VERBOSE 0x00000004
/** Mark the image being added as the bootable image of the WIM. */
* together. Cannot be used with ::WIMLIB_EXTRACT_FLAG_NTFS. */
#define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000004
-/** Print the name of each file or directory as it is extracted from the WIM
- * image. */
+/** Call the progress function with the argument
+ * ::WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY each time a file or directory is
+ * extracted. Note: these calls will be interspersed with calls for the message
+ * ::WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS. */
#define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
/** Read the WIM file sequentially while extracting the image. */
struct _ntfs_volume *vol;
#endif
struct list_head empty_files;
+ wimlib_progress_func_t progress_func;
};
extern int wim_apply_dentry_ntfs(struct dentry *dentry, void *arg);
extern int wim_apply_dentry_timestamps(struct dentry *dentry, void *arg);
/* ntfs-capture.c */
-int build_dentry_tree_ntfs(struct dentry **root_p,
- const char *device,
- struct lookup_table *lookup_table,
- struct wim_security_data *sd,
- const struct capture_config *config,
- int flags,
- void *extra_arg);
+extern int build_dentry_tree_ntfs(struct dentry **root_p,
+ const char *device,
+ struct lookup_table *lookup_table,
+ struct wim_security_data *sd,
+ const struct capture_config *config,
+ int add_image_flags,
+ wimlib_progress_func_t progress_func,
+ void *extra_arg);
/* resource.c */
extern const u8 *get_resource_entry(const u8 *p, struct resource_entry *entry);