X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fjoin.c;h=b6bf6ebd78d22d598d3e6e536cab2dbe706f7386;hb=5de5f74ca8a3bd8d013c97418320f54cd52f8e1a;hp=b5c7c37bb576c202ae108227f80441640fa4599a;hpb=7ce0d372fae285051cbc9740c9fa316d22465d9d;p=wimlib diff --git a/src/join.c b/src/join.c index b5c7c37b..b6bf6ebd 100644 --- a/src/join.c +++ b/src/join.c @@ -118,24 +118,18 @@ join_wims(WIMStruct **swms, unsigned num_swms, /* Write the non-metadata resources from each SWM part */ for (i = 0; i < num_swms; i++) { - swms[i]->fp = tfopen(swms[i]->filename, T("rb")); - if (!swms[i]->fp) { - ERROR_WITH_ERRNO("Failed to reopen `%"TS"'", - swms[i]->filename); - return WIMLIB_ERR_OPEN; - } - swms[i]->out_fp = joined_wim->out_fp; + ret = reopen_wim(swms[i]); + if (ret) + return ret; + swms[i]->out_fd = joined_wim->out_fd; swms[i]->hdr.part_number = 1; ret = for_lookup_table_entry_pos_sorted(swms[i]->lookup_table, copy_resource, swms[i]); - swms[i]->out_fp = NULL; - - if (i != 0) { - fclose(swms[i]->fp); - swms[i]->fp = NULL; - } + swms[i]->out_fd = -1; + if (i != 0) + close_wim(swms[i]); if (ret) return ret; @@ -209,8 +203,7 @@ wimlib_join(const tchar * const *swm_names, /* Don't open all the parts at the same time, in case there are * a lot of them */ - fclose(swms[i]->fp); - swms[i]->fp = NULL; + close_wim(swms[i]); } qsort(swms, num_swms, sizeof(swms[0]), cmp_swms_by_part_number);