- if (lookup_table_offset == -1 || xml_data_offset == -1) {
- ERROR_WITH_ERRNO("Failed to get file offset");
- return WIMLIB_ERR_WRITE;
- }
- 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;
-
-
- /* finish_write is called on the first swm, not the joined_wim, because
- * the first swm is the one that has the image metadata and XML data
- * 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 | WIMLIB_WRITE_FLAG_NO_LOOKUP_TABLE);
+ joined_wim->hdr.image_count = swms[0]->hdr.image_count;
+ for (i = 0; i < num_swms; i++)
+ lookup_table_join(joined_wim->lookup_table, swms[i]->lookup_table);
+
+ free_wim_info(joined_wim->wim_info);
+ joined_wim->wim_info = swms[0]->wim_info;
+ ret = finish_write(joined_wim, WIMLIB_ALL_IMAGES, write_flags, progress_func);
+ joined_wim->wim_info = NULL;
+ return ret;