]> wimlib.net Git - wimlib/blobdiff - src/extract_image.c
imagex-export.1.in: Clarify sentence
[wimlib] / src / extract_image.c
index e3229c33009e4b2d44d70bc76112b8ab01de5973..fad438f52b27eeb62347e8dcfcb4642c1f8e8e06 100644 (file)
@@ -59,10 +59,6 @@ do_apply_op(struct wim_dentry *dentry, struct apply_args *args,
                         (full_path_nchars - args->wim_source_path_nchars) + 1];
        p = output_path;
 
-       /*print_dentry(dentry, NULL);*/
-       /*ERROR("%"TS" %"TS, args->target, dentry->_full_path);*/
-       /*ERROR("");*/
-
        tmemcpy(p, args->target, args->target_nchars);
        p += args->target_nchars;
 
@@ -191,7 +187,8 @@ dentry_find_streams_to_extract(struct wim_dentry *dentry, void *_ctx)
 
        lte = inode_unnamed_lte_resolved(inode);
        if (lte) {
-               maybe_add_stream_for_extraction(lte, stream_list);
+               if (!inode->i_visited)
+                       maybe_add_stream_for_extraction(lte, stream_list);
                list_add_tail(&dentry->tmp_list, &lte->lte_dentry_list);
                dentry_added = true;
        }
@@ -214,8 +211,10 @@ dentry_find_streams_to_extract(struct wim_dentry *dentry, void *_ctx)
                        if (inode->i_ads_entries[i].stream_name_nbytes != 0) {
                                lte = inode->i_ads_entries[i].lte;
                                if (lte) {
-                                       maybe_add_stream_for_extraction(lte,
-                                                                       stream_list);
+                                       if (!inode->i_visited) {
+                                               maybe_add_stream_for_extraction(lte,
+                                                                               stream_list);
+                                       }
                                        if (!dentry_added) {
                                                list_add_tail(&dentry->tmp_list,
                                                              &lte->lte_dentry_list);
@@ -225,6 +224,7 @@ dentry_find_streams_to_extract(struct wim_dentry *dentry, void *_ctx)
                        }
                }
        }
+       inode->i_visited = 1;
        return 0;
 }
 
@@ -263,6 +263,7 @@ static int
 dentry_reset_needs_extraction(struct wim_dentry *dentry, void *_ignore)
 {
        dentry->needs_extraction = 0;
+       dentry->d_inode->i_visited = 0;
        return 0;
 }
 
@@ -736,16 +737,15 @@ do_wimlib_extract_files(WIMStruct *wim,
 WIMLIBAPI int
 wimlib_extract_files(WIMStruct *wim,
                     int image,
-                    int default_extract_flags,
                     const struct wimlib_extract_command *cmds,
                     size_t num_cmds,
+                    int default_extract_flags,
                     WIMStruct **additional_swms,
                     unsigned num_additional_swms,
                     wimlib_progress_func_t progress_func)
 {
        int ret;
        struct wimlib_extract_command *cmds_copy;
-       struct wim_lookup_table *wim_tab_save, *joined_tab;
        int all_flags = 0;
 
        default_extract_flags &= WIMLIB_EXTRACT_MASK_PUBLIC;
@@ -757,15 +757,8 @@ wimlib_extract_files(WIMStruct *wim,
        if (num_cmds == 0)
                goto out;
 
-       if (num_additional_swms) {
-               ret = new_joined_lookup_table(wim, additional_swms,
-                                             num_additional_swms,
-                                             &joined_tab);
-               if (ret)
-                       goto out;
-               wim_tab_save = wim->lookup_table;
-               wim->lookup_table = joined_tab;
-       }
+       if (num_additional_swms)
+               merge_lookup_tables(wim, additional_swms, num_additional_swms);
 
        cmds_copy = CALLOC(num_cmds, sizeof(cmds[0]));
        if (!cmds_copy) {
@@ -809,10 +802,8 @@ out_free_cmds_copy:
        }
        FREE(cmds_copy);
 out_restore_lookup_table:
-       if (num_additional_swms) {
-               free_lookup_table(wim->lookup_table);
-               wim->lookup_table = wim_tab_save;
-       }
+       if (num_additional_swms)
+               unmerge_lookup_table(wim);
 out:
        return ret;
 }
@@ -936,7 +927,6 @@ wimlib_extract_image(WIMStruct *wim,
                     unsigned num_additional_swms,
                     wimlib_progress_func_t progress_func)
 {
-       struct wim_lookup_table *joined_tab, *wim_tab_save;
        int ret;
 
        extract_flags &= WIMLIB_EXTRACT_MASK_PUBLIC;
@@ -945,14 +935,8 @@ wimlib_extract_image(WIMStruct *wim,
        if (ret)
                return ret;
 
-       if (num_additional_swms) {
-               ret = new_joined_lookup_table(wim, additional_swms,
-                                             num_additional_swms, &joined_tab);
-               if (ret)
-                       return ret;
-               wim_tab_save = wim->lookup_table;
-               wim->lookup_table = joined_tab;
-       }
+       if (num_additional_swms)
+               merge_lookup_tables(wim, additional_swms, num_additional_swms);
 
        if (image == WIMLIB_ALL_IMAGES) {
                ret = extract_all_images(wim, target,
@@ -970,9 +954,7 @@ wimlib_extract_image(WIMStruct *wim,
                                       lte_free_extracted_file,
                                       NULL);
        }
-       if (num_additional_swms) {
-               free_lookup_table(wim->lookup_table);
-               wim->lookup_table = wim_tab_save;
-       }
+       if (num_additional_swms)
+               unmerge_lookup_table(wim);
        return ret;
 }