X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwrite.c;h=668c7abd03c0c21353aa2ec65cd4c6adb1a4e40d;hb=c7757ea1100cc329ea78ae16abad9f5338151b2b;hp=ef1e02dba39effd838e25408d0d1e2e6b60b6fa3;hpb=eff67c0d712100642ae6dce8262366eb0c3b911b;p=wimlib diff --git a/src/write.c b/src/write.c index ef1e02db..668c7abd 100644 --- a/src/write.c +++ b/src/write.c @@ -50,9 +50,10 @@ #ifdef HAVE_ALLOCA_H #include +#else +#include #endif - /* Reopens the FILE* for a WIM read-write. */ static int reopen_rw(WIMStruct *w) { @@ -1071,6 +1072,8 @@ static int main_writer_thread_proc(struct list_head *stream_list, #else ret = prepare_resource_for_read(next_lte); #endif + if (ret != 0) + goto out; DEBUG("Initializing buffers for uncompressed " "and compressed data (%zu bytes needed)", @@ -1093,6 +1096,9 @@ static int main_writer_thread_proc(struct list_head *stream_list, } } + // This loop is executed until all resources have been written, except + // possibly a few that have been added to the @my_resources list for + // writing later. while (1) { // Send chunks to the compressor threads until either (a) there // are no more messages available since they were all sent off, @@ -1258,9 +1264,6 @@ static int main_writer_thread_proc(struct list_head *stream_list, DEBUG2("Complete msg (begin_chunk=%"PRIu64")", msg->begin_chunk); if (msg->begin_chunk == 0) { DEBUG2("Begin chunk tab"); - - - if (write_flags & WIMLIB_WRITE_FLAG_SHOW_PROGRESS) { show_stream_write_progress(&cur_size, &next_size, @@ -1382,12 +1385,6 @@ out: #endif if (ret == 0) { list_for_each_entry(lte, &my_resources, staging_list) { - ret = write_wim_resource(lte, out_fp, - out_ctype, - <e->output_resource_entry, - 0); - if (ret != 0) - break; if (write_flags & WIMLIB_WRITE_FLAG_SHOW_PROGRESS) { show_stream_write_progress(&cur_size, &next_size, @@ -1396,6 +1393,12 @@ out: &cur_percent, lte); } + ret = write_wim_resource(lte, out_fp, + out_ctype, + <e->output_resource_entry, + 0); + if (ret != 0) + break; } if (write_flags & WIMLIB_WRITE_FLAG_SHOW_PROGRESS) finish_stream_write_progress(total_size); @@ -1427,6 +1430,19 @@ out: return ret; } + +static const char *get_data_type(int ctype) +{ + switch (ctype) { + case WIM_COMPRESSION_TYPE_NONE: + return "uncompressed"; + case WIM_COMPRESSION_TYPE_LZX: + return "LZX-compressed"; + case WIM_COMPRESSION_TYPE_XPRESS: + return "XPRESS-compressed"; + } +} + static int write_stream_list_parallel(struct list_head *stream_list, FILE *out_fp, int out_ctype, int write_flags, u64 total_size, @@ -1484,8 +1500,8 @@ static int write_stream_list_parallel(struct list_head *stream_list, } if (write_flags & WIMLIB_WRITE_FLAG_SHOW_PROGRESS) { - printf("Writing compressed data using %u threads...\n", - num_threads); + printf("Writing %s compressed data using %u threads...\n", + get_data_type(out_ctype), num_threads); } ret = main_writer_thread_proc(stream_list, @@ -1561,7 +1577,8 @@ static int write_stream_list(struct list_head *stream_list, FILE *out_fp, const char *reason = ""; if (!compression_needed) reason = " (no compression needed)"; - printf("Writing data using 1 thread%s\n", reason); + printf("Writing %s data using 1 thread%s\n", + get_data_type(out_ctype), reason); } return write_stream_list_serial(stream_list, out_fp,