X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fsplit.c;h=17a6ced680bf1d26825ee073f64e5d292fc1204f;hb=e0b8c0c5740abaeb24d39a58ffcc4235f26c4bbf;hp=091fa3fecf124585a4364fd051ea83ace5830724;hpb=9b9a502863318d6208da2818b1d522346e5eee9e;p=wimlib diff --git a/src/split.c b/src/split.c index 091fa3fe..17a6ced6 100644 --- a/src/split.c +++ b/src/split.c @@ -26,7 +26,7 @@ #include "wimlib_internal.h" #include "lookup_table.h" #include "xml.h" -#include "io.h" +#include "buffer_io.h" struct split_args { WIMStruct *w; @@ -34,9 +34,9 @@ struct split_args { size_t swm_base_name_len; const char *swm_suffix; struct list_head lte_list; - int cur_part_number; - int write_flags; - long size_remaining; + int cur_part_number; + int write_flags; + long size_remaining; size_t part_size; wimlib_progress_func_t progress_func; union wimlib_progress_info progress; @@ -47,7 +47,7 @@ static int finish_swm(WIMStruct *w, struct list_head *lte_list, { off_t lookup_table_offset = ftello(w->out_fp); int ret; - struct lookup_table_entry *lte; + struct wim_lookup_table_entry *lte; list_for_each_entry(lte, lte_list, staging_list) { ret = write_lookup_table_entry(lte, w->out_fp); @@ -70,7 +70,7 @@ static int finish_swm(WIMStruct *w, struct list_head *lte_list, progress_func); } -static int copy_resource_to_swm(struct lookup_table_entry *lte, void *__args) +static int copy_resource_to_swm(struct wim_lookup_table_entry *lte, void *__args) { struct split_args *args = (struct split_args*)__args; WIMStruct *w = args->w; @@ -121,8 +121,8 @@ static int copy_resource_to_swm(struct lookup_table_entry *lte, void *__args) return copy_resource(lte, w); } -/* Splits the WIM file @wimfile into multiple parts prefixed by @swm_name with - * size at most @part_size. */ +/* Splits the WIM file @w into multiple parts prefixed by @swm_name with size at + * most @part_size bytes. */ WIMLIBAPI int wimlib_split(WIMStruct *w, const char *swm_name, size_t part_size, int write_flags, wimlib_progress_func_t progress_func) @@ -134,7 +134,7 @@ WIMLIBAPI int wimlib_split(WIMStruct *w, const char *swm_name, size_t swm_name_len; size_t swm_base_name_len; - if (!w || !swm_name || part_size == 0) + if (!swm_name || part_size == 0) return WIMLIB_ERR_INVALID_PARAM; if (w->hdr.total_parts != 1) @@ -186,7 +186,7 @@ WIMLIBAPI int wimlib_split(WIMStruct *w, const char *swm_name, w->write_metadata = true; for (int i = 0; i < w->hdr.image_count; i++) { - struct lookup_table_entry *metadata_lte; + struct wim_lookup_table_entry *metadata_lte; metadata_lte = w->image_metadata[i].metadata_lte; ret = copy_resource(metadata_lte, w); if (ret != 0) @@ -212,8 +212,8 @@ WIMLIBAPI int wimlib_split(WIMStruct *w, const char *swm_name, } /* The swms are all ready now, except the total_parts and part_number - * fields in their headers are wrong (we don't know the total parts - * until they are all written). Fix them. */ + * fields in their headers are wrong (since we don't know the total + * parts until they are all written). Fix them. */ int total_parts = args.cur_part_number; for (int i = 1; i <= total_parts; i++) { const char *part_name; @@ -236,8 +236,9 @@ WIMLIBAPI int wimlib_split(WIMStruct *w, const char *swm_name, put_u16(&buf[2], total_parts); if (fseek(fp, 40, SEEK_SET) != 0 || - fwrite(buf, 1, sizeof(buf), fp) != sizeof(buf) - || fclose(fp) != 0) { + fwrite(buf, 1, sizeof(buf), fp) != sizeof(buf) || + fclose(fp) != 0) + { ERROR_WITH_ERRNO("Error overwriting header of `%s'", part_name); ret = WIMLIB_ERR_WRITE; @@ -245,6 +246,7 @@ WIMLIBAPI int wimlib_split(WIMStruct *w, const char *swm_name, } } out: + close_wim_writable(w); memcpy(&w->hdr, &hdr_save, sizeof(struct wim_header)); return ret; }