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 a731bdb..88ca5e8 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 void
+attach_scanned_tree(struct wim_dentry *parent, struct wim_dentry *child,
+                   struct blob_table *blob_table);
+
 #endif /* _WIMLIB_CAPTURE_H */
index ee051ae..353ff2b 100644 (file)
@@ -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);
+       }
+}
index de47232..439d17a 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);
-       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:
index 9b3ea4f..b56c55d 100644 (file)
@@ -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;
index 854428e..450dfb5 100644 (file)
@@ -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;