- uint i;
- int ret;
- FILE *out_fp = joined_wim->out_fp;
- u64 total_bytes = wim_info_get_total_bytes(swms[0]->wim_info);
-
- swms[0]->write_metadata = false;
- for (i = 0; i < num_swms; i++) {
- if (write_flags & WIMLIB_WRITE_FLAG_SHOW_PROGRESS) {
- off_t cur_offset = ftello(out_fp);
- printf("Writing resources from part %u of %u "
- "(%"PRIu64" of %"PRIu64" bytes, %.0f%% done)\n",
- i + 1, num_swms,
- cur_offset, total_bytes,
- (double)cur_offset / total_bytes * 100.0);
- }
- swms[i]->fp = fopen(swms[i]->filename, "rb");
- if (!swms[i]->fp) {
- ERROR("Failed to reopen `%s': %m\n", swms[i]->filename);
- return WIMLIB_ERR_OPEN;
- }
- swms[i]->out_fp = out_fp;
- swms[i]->hdr.part_number = 1;
- ret = for_lookup_table_entry(swms[i]->lookup_table,
- copy_resource, swms[i]);
- if (ret != 0)
- return ret;
- if (i != 0) {
- fclose(swms[i]->fp);
- swms[i]->fp = NULL;
- }
- }
- swms[0]->write_metadata = true;
- if (write_flags & WIMLIB_WRITE_FLAG_SHOW_PROGRESS)
- printf("Writing %d metadata resources\n",
- swms[0]->hdr.image_count);
-
- for (i = 0; i < swms[0]->hdr.image_count; i++) {
- ret = copy_resource(swms[0]->image_metadata[i].lookup_table_entry,
- swms[0]);
- if (ret != 0)
- return ret;
+ unsigned total_parts = wim->hdr.total_parts;
+ int ctype;
+ u32 chunk_size;
+ const u8 *guid;
+
+ if (total_parts != num_additional_swms + 1) {
+ ERROR("`%"TS"' says there are %u parts in the spanned set, "
+ "but %"TS"%u part%"TS" provided",
+ wim->filename, total_parts,
+ (num_additional_swms + 1 < total_parts) ? T("only ") : T(""),
+ num_additional_swms + 1,
+ (num_additional_swms) ? T("s were") : T(" was"));
+ return WIMLIB_ERR_SPLIT_INVALID;