]> wimlib.net Git - wimlib/blobdiff - src/join.c
Fix sequential extraction, and include progress info
[wimlib] / src / join.c
index 8bdd24be83605b1ad9a7c71bfd6200f24e8424cb..222c9a9a8e81411405d08f25be93c847018dc45c 100644 (file)
@@ -252,7 +252,9 @@ static int join_wims(WIMStruct **swms, uint num_swms, WIMStruct *joined_wim,
         * table has no header, we can just concatenate the lookup tables of all
         * the SWM parts. */
        for (i = 0; i < num_swms; i++) {
-               ret = write_lookup_table(swms[i]->lookup_table, out_fp);
+               ret = for_lookup_table_entry(swms[i]->lookup_table,
+                                            write_lookup_table_entry,
+                                            out_fp);
                if (ret != 0)
                        return ret;
        }
@@ -265,6 +267,10 @@ static int join_wims(WIMStruct **swms, uint num_swms, WIMStruct *joined_wim,
        swms[0]->hdr.lookup_table_res_entry.offset = lookup_table_offset;
        swms[0]->hdr.lookup_table_res_entry.size =
                                        xml_data_offset - lookup_table_offset;
+       swms[0]->hdr.lookup_table_res_entry.original_size =
+                                       xml_data_offset - lookup_table_offset;
+       swms[0]->hdr.lookup_table_res_entry.flags =
+                                       WIM_RESHDR_FLAG_METADATA;
 
 
        /* finish_write is called on the first swm, not the joined_wim, because
@@ -272,29 +278,25 @@ static int join_wims(WIMStruct **swms, uint num_swms, WIMStruct *joined_wim,
         * attached to it.  */
        swms[0]->hdr.flags &= ~WIM_HDR_FLAG_SPANNED;
        swms[0]->hdr.total_parts = 1;
-       return finish_write(swms[0], WIM_ALL_IMAGES, write_flags, 0);
+       return finish_write(swms[0], WIM_ALL_IMAGES,
+                           write_flags | WIMLIB_WRITE_FLAG_NO_LOOKUP_TABLE);
 }
 
 
 WIMLIBAPI int wimlib_join(const char **swm_names, unsigned num_swms,
                          const char *output_path, int flags)
 {
-       int i;
        int ret;
-       int part_idx;
        int write_flags = 0;
        WIMStruct *joined_wim = NULL;
        WIMStruct *swms[num_swms];
 
-       int ctype;
-       u8 *guid;
-
        if (num_swms < 1)
                return WIMLIB_ERR_INVALID_PARAM;
 
        ZERO_ARRAY(swms);
 
-       for (i = 0; i < num_swms; i++) {
+       for (unsigned i = 0; i < num_swms; i++) {
                ret = wimlib_open_wim(swm_names[i],
                                      flags | WIMLIB_OPEN_FLAG_SPLIT_OK, &swms[i]);
                if (ret != 0)
@@ -328,14 +330,13 @@ WIMLIBAPI int wimlib_join(const char **swm_names, unsigned num_swms,
                goto out;
        ret = join_wims(swms, num_swms, joined_wim, write_flags);
 out:
-       for (i = 0; i < num_swms; i++) {
-               /* out_fp is the same in all the swms and joined_wim; only close
-                * it one time, when freeing joined_wim. */
-               if (swms[i]) {
-                       swms[i]->out_fp = NULL;
-                       wimlib_free(swms[i]);
-               }
+       /* out_fp is the same in all the swms and joined_wim.  And it was
+        * already closed in the call to finish_write(). */
+       for (unsigned i = 0; i < num_swms; i++) {
+               swms[i]->out_fp = NULL;
+               wimlib_free(swms[i]);
        }
+       joined_wim->out_fp = NULL;
        wimlib_free(joined_wim);
        return ret;
 }