]> wimlib.net Git - wimlib/blobdiff - src/unix_capture.c
write.c: Do not raw-copy packed resources
[wimlib] / src / unix_capture.c
index ff9a6ac00179e977ebd8cadf8dc013717c86957b..0d9b3998094c6902194cf87c6990ee8d0e7b50b1 100644 (file)
@@ -64,7 +64,7 @@ unix_capture_regular_file(const char *path,
                }
                lte->file_on_disk = file_on_disk;
                lte->resource_location = RESOURCE_IN_FILE_ON_DISK;
-               lte->resource_entry.original_size = size;
+               lte->size = size;
                lookup_table_insert_unhashed(lookup_table, lte, inode, 0);
                inode->i_lte = lte;
        }
@@ -128,6 +128,7 @@ unix_capture_directory(struct wim_dentry *dir_dentry,
                if (child)
                        dentry_add_child(dir_dentry, child);
        }
+       path[path_len] = '\0';
        closedir(dir);
        return ret;
 }
@@ -203,44 +204,41 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        struct wim_dentry *root = NULL;
        int ret;
        struct wim_inode *inode;
-
-       params->progress.scan.cur_path = path;
+       struct stat stbuf;
 
        if (exclude_path(path, path_len, params->config, true)) {
-               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED);
                ret = 0;
-               goto out;
+               goto out_progress;
        }
 
-       struct stat stbuf;
-       int (*stat_fn)(const char *restrict, struct stat *restrict);
        if ((params->add_flags & WIMLIB_ADD_FLAG_DEREFERENCE) ||
            (params->add_flags & WIMLIB_ADD_FLAG_ROOT))
-               stat_fn = stat;
+               ret = stat(path, &stbuf);
        else
-               stat_fn = lstat;
+               ret = lstat(path, &stbuf);
 
-       ret = (*stat_fn)(path, &stbuf);
        if (ret) {
-               ERROR_WITH_ERRNO("Failed to stat `%s'", path);
+               ERROR_WITH_ERRNO("Failed to stat \"%s\"", path);
                ret = WIMLIB_ERR_STAT;
                goto out;
        }
-       if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)
-           && !S_ISLNK(stbuf.st_mode)) {
+
+       if (!S_ISREG(stbuf.st_mode) &&
+           !S_ISDIR(stbuf.st_mode) &&
+           !S_ISLNK(stbuf.st_mode))
+       {
                if (params->add_flags & WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE)
                {
                        ERROR("Can't archive unsupported file \"%s\"", path);
                        ret = WIMLIB_ERR_UNSUPPORTED_FILE;
                        goto out;
                }
-               do_capture_progress(params, WIMLIB_SCAN_DENTRY_UNSUPPORTED);
+               params->progress.scan.cur_path = path;
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_UNSUPPORTED, NULL);
                ret = 0;
                goto out;
        }
 
-       do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK);
-
        ret = inode_table_new_dentry(&params->inode_table,
                                     path_basename_with_len(path, path_len),
                                     stbuf.st_ino, stbuf.st_dev, false, &root);
@@ -252,7 +250,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        if (inode->i_nlink > 1) {
                /* Already captured this inode? */
                ret = 0;
-               goto out;
+               goto out_progress;
        }
 
 #ifdef HAVE_STAT_NANOSECOND_PRECISION
@@ -286,6 +284,12 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        if (ret)
                goto out;
 
+out_progress:
+       params->progress.scan.cur_path = path;
+       if (root == NULL)
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
+       else
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
 out:
        if (ret)
                free_dentry_tree(root, params->lookup_table);
@@ -296,8 +300,8 @@ out:
 
 /*
  * unix_build_dentry_tree():
- *     Builds a tree of WIM dentries from an on-disk directory tree (UNIX
- *     version; no NTFS-specific data is captured).
+ *     Builds a tree of WIM dentries from an on-disk directory tree (UNIX
+ *     version; no NTFS-specific data is captured).
  *
  * @root_ret:   Place to return a pointer to the root of the dentry tree.  Only
  *             modified if successful.  Set to NULL if the file or directory was
@@ -348,7 +352,7 @@ unix_build_dentry_tree(struct wim_dentry **root_ret,
        if (path_len >= path_bufsz)
                return WIMLIB_ERR_INVALID_PARAM;
 
-       path_buf = MALLOC(path_bufsz);
+       path_buf = MALLOC(path_bufsz);
        if (!path_buf)
                return WIMLIB_ERR_NOMEM;
        memcpy(path_buf, root_disk_path, path_len + 1);