- /* Fill in out_res_entry with information about the newly written
- * resource. */
- out_res_entry->size = out_fd->offset - res_start_offset;
- out_res_entry->flags = lte->resource_entry.flags;
- if (out_ctype == WIMLIB_COMPRESSION_TYPE_NONE)
- out_res_entry->flags &= ~WIM_RESHDR_FLAG_COMPRESSED;
- else
- out_res_entry->flags |= WIM_RESHDR_FLAG_COMPRESSED;
- out_res_entry->offset = res_start_offset;
- out_res_entry->original_size = wim_resource_size(lte);
-
- /* Check for resources compressed to greater than their original size
- * and write them uncompressed instead. (But never do this if writing
- * to a pipe, and don't bother if we did a raw copy.) */
- if (out_res_entry->size > out_res_entry->original_size &&
- !(resource_flags & (WIMLIB_WRITE_RESOURCE_FLAG_PIPABLE |
- WIMLIB_READ_RESOURCE_FLAG_RAW)))
- {
- DEBUG("Compressed %"PRIu64" => %"PRIu64" bytes; "
- "writing uncompressed instead",
- out_res_entry->original_size, out_res_entry->size);
- ret = seek_and_truncate(out_fd, res_start_offset);
- if (ret)
- goto out_free_chunk_tab;
- out_ctype = WIMLIB_COMPRESSION_TYPE_NONE;
- FREE(write_ctx.chunk_tab);
- write_ctx.out_ctype = WIMLIB_COMPRESSION_TYPE_NONE;
- write_ctx.chunk_tab = NULL;
- write_ctx.doing_sha = false;
- goto try_write_again;
- }
- if (resource_flags & WIMLIB_READ_RESOURCE_FLAG_RAW) {
- DEBUG("Copied raw compressed data "
- "(%"PRIu64" => %"PRIu64" bytes @ +%"PRIu64", flags=0x%02x)",
- out_res_entry->original_size, out_res_entry->size,
- out_res_entry->offset, out_res_entry->flags);
- } else if (out_ctype != WIMLIB_COMPRESSION_TYPE_NONE) {
- DEBUG("Wrote compressed resource "
- "(%"PRIu64" => %"PRIu64" bytes @ +%"PRIu64", flags=0x%02x)",
- out_res_entry->original_size, out_res_entry->size,
- out_res_entry->offset, out_res_entry->flags);
- } else {
- DEBUG("Wrote uncompressed resource "
- "(%"PRIu64" bytes @ +%"PRIu64", flags=0x%02x)",
- out_res_entry->original_size,
- out_res_entry->offset, out_res_entry->flags);
- }
- ret = 0;
-out_free_chunk_tab:
- FREE(write_ctx.chunk_tab);
-out:
- return ret;