Add new helper function for attaching newly scanned dentry tree
authorEric Biggers <ebiggers3@gmail.com>
Sun, 7 Jun 2015 19:07:30 +0000 (14:07 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 7 Jun 2015 20:45:13 +0000 (15:45 -0500)
include/wimlib/capture.h
src/capture_common.c
src/ntfs-3g_capture.c
src/unix_capture.c
src/win32_capture.c

index a731bdb08e6f2da99a2c4e771294b0ef57e959cd..88ca5e8d54544c1838182a6993657e732280f6a0 100644 (file)
@@ -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 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 */
 #endif /* _WIMLIB_CAPTURE_H */
index ee051aea8c52c87a3333644482de3163b24b22a0..353ff2b67f64fabb134eae8150175a6f54ec27e8 100644 (file)
@@ -340,3 +340,18 @@ should_ignore_filename(const tchar *name, const int name_nchars)
 
        return false;
 }
 
        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);
+       }
+}
index de472327cec5df0d0f335a11afd87fea31d12d22..439d17a61aa98c7931b9b59646427f62aa72ac6d 100644 (file)
@@ -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);
        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:
 out_free_mbs_name:
        FREE(mbs_name);
 out:
index 9b3ea4fedfef72593b3ff72fbfe80502c005f091..b56c55db1a676ab8997428bebf9b1919cf5d5ee1 100644 (file)
@@ -196,8 +196,7 @@ unix_scan_directory(struct wim_dentry *dir_dentry,
                full_path[full_path_len] = '\0';
                if (ret)
                        break;
                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;
        }
        closedir(dir);
        return ret;
index 854428e4dfd20266780858558bed72b608c9f465..450dfb5898cf0dbf34e765ff0733b3ec39ade226 100644 (file)
@@ -449,8 +449,7 @@ winnt_recurse_directory(HANDLE h,
 
                                if (ret)
                                        goto out_free_buf;
 
                                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;
                        }
                        if (info->NextEntryOffset == 0)
                                break;