#include "wimlib_internal.h"
#include "lookup_table.h"
#include "xml.h"
-#include "io.h"
+#include "buffer_io.h"
struct split_args {
WIMStruct *w;
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;
{
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);
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;
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)
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)
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)
}
/* 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;
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;
}
}
out:
+ close_wim_writable(w);
memcpy(&w->hdr, &hdr_save, sizeof(struct wim_header));
return ret;
}