From: Eric Biggers Date: Sun, 7 Jun 2015 19:07:30 +0000 (-0500) Subject: Add new helper function for attaching newly scanned dentry tree X-Git-Tag: v1.8.2~62 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=fd451e930fe11d94dc51700f67db84e1055fe917 Add new helper function for attaching newly scanned dentry tree --- diff --git a/include/wimlib/capture.h b/include/wimlib/capture.h index a731bdb0..88ca5e8d 100644 --- a/include/wimlib/capture.h +++ b/include/wimlib/capture.h @@ -120,4 +120,8 @@ report_capture_error(struct capture_params *params, int error_code, extern bool should_ignore_filename(const tchar *name, int name_nchars); +extern void +attach_scanned_tree(struct wim_dentry *parent, struct wim_dentry *child, + struct blob_table *blob_table); + #endif /* _WIMLIB_CAPTURE_H */ diff --git a/src/capture_common.c b/src/capture_common.c index ee051aea..353ff2b6 100644 --- a/src/capture_common.c +++ b/src/capture_common.c @@ -340,3 +340,18 @@ should_ignore_filename(const tchar *name, const int name_nchars) return false; } + +/* Attach a newly scanned directory tree to its parent directory, with duplicate + * handling. */ +void +attach_scanned_tree(struct wim_dentry *parent, struct wim_dentry *child, + struct blob_table *blob_table) +{ + struct wim_dentry *duplicate; + + if (child && (duplicate = dentry_add_child(parent, child))) { + WARNING("Duplicate file path: \"%"TS"\". Only capturing " + "the first version.", dentry_full_path(duplicate)); + free_dentry_tree(child, blob_table); + } +} diff --git a/src/ntfs-3g_capture.c b/src/ntfs-3g_capture.c index de472327..439d17a6 100644 --- a/src/ntfs-3g_capture.c +++ b/src/ntfs-3g_capture.c @@ -607,8 +607,7 @@ filldir(void *_ctx, const ntfschar *name, const int name_nchars, ret = ntfs_3g_build_dentry_tree_recursive(&child, mref, ctx->path, path_len, name_type, ctx->volume, ctx->params); - if (child) - dentry_add_child(ctx->parent, child); + attach_scanned_tree(ctx->parent, child, ctx->params->blob_table); out_free_mbs_name: FREE(mbs_name); out: diff --git a/src/unix_capture.c b/src/unix_capture.c index 9b3ea4fe..b56c55db 100644 --- a/src/unix_capture.c +++ b/src/unix_capture.c @@ -196,8 +196,7 @@ unix_scan_directory(struct wim_dentry *dir_dentry, full_path[full_path_len] = '\0'; if (ret) break; - if (child) - dentry_add_child(dir_dentry, child); + attach_scanned_tree(dir_dentry, child, params->blob_table); } closedir(dir); return ret; diff --git a/src/win32_capture.c b/src/win32_capture.c index 854428e4..450dfb58 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -449,8 +449,7 @@ winnt_recurse_directory(HANDLE h, if (ret) goto out_free_buf; - if (child) - dentry_add_child(parent, child); + attach_scanned_tree(parent, child, params->blob_table); } if (info->NextEntryOffset == 0) break;