X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fsplit.c;h=296b03fafc6bbc585295cdad3f36e657aad026e3;hp=8b67079e0f507316eba1b91f40ab0aefac143a1a;hb=630e15501a368eccaf6d0999f330c82a8fd4aa5f;hpb=3b5ae49e2ed3c288a00f8ad4dc45c443939204f2 diff --git a/src/split.c b/src/split.c index 8b67079e..296b03fa 100644 --- a/src/split.c +++ b/src/split.c @@ -23,12 +23,22 @@ * along with wimlib; if not, see http://www.gnu.org/licenses/. */ -#include "wimlib_internal.h" -#include "lookup_table.h" -#include "xml.h" -#include "buffer_io.h" -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "wimlib.h" +#include "wimlib/endianness.h" +#include "wimlib/error.h" +#include "wimlib/file_io.h" +#include "wimlib/lookup_table.h" +#include "wimlib/metadata.h" +#include "wimlib/types.h" +#include "wimlib/write.h" +#include "wimlib/list.h" + +#include /* for open() */ +#include /* for close() */ struct split_args { WIMStruct *w; @@ -60,9 +70,9 @@ finish_swm(WIMStruct *w, struct list_head *lte_list, } static int -copy_resource_to_swm(struct wim_lookup_table_entry *lte, void *__args) +copy_resource_to_swm(struct wim_lookup_table_entry *lte, void *_args) { - struct split_args *args = (struct split_args*)__args; + struct split_args *args = (struct split_args*)_args; WIMStruct *w = args->w; int ret; @@ -133,10 +143,6 @@ wimlib_split(WIMStruct *w, const tchar *swm_name, write_flags &= WIMLIB_WRITE_MASK_PUBLIC; - ret = wim_checksum_unhashed_streams(w); - if (ret) - return ret; - swm_name_len = tstrlen(swm_name); tchar swm_base_name[swm_name_len + 20]; @@ -214,8 +220,7 @@ wimlib_split(WIMStruct *w, const tchar *swm_name, for (int i = 1; i <= total_parts; i++) { const tchar *part_name; int part_fd; - u8 part_data_buf[4]; - size_t bytes_written; + int ret2; if (i == 1) { part_name = swm_name; @@ -226,21 +231,19 @@ wimlib_split(WIMStruct *w, const tchar *swm_name, } part_fd = topen(part_name, O_WRONLY | O_BINARY); - if (part_fd == INVALID_FILEDES) { + if (part_fd == -1) { ERROR_WITH_ERRNO("Failed to open `%"TS"'", part_name); ret = WIMLIB_ERR_OPEN; goto out; } - put_u16(&part_data_buf[0], i); - put_u16(&part_data_buf[2], total_parts); - bytes_written = full_pwrite(part_fd, part_data_buf, - sizeof(part_data_buf), 40); - ret = close(part_fd); - if (bytes_written != sizeof(part_data_buf) || ret != 0) { + ret = write_header_part_data(i, total_parts, part_fd); + ret2 = close(part_fd); + if (ret == 0 && ret2 != 0) + ret = WIMLIB_ERR_WRITE; + if (ret) { ERROR_WITH_ERRNO("Error updating header of `%"TS"'", part_name); - ret = WIMLIB_ERR_WRITE; goto out; } }