# include <sys/uio.h> /* for `struct iovec' */
#endif
-static int
-alloc_lzx_context(int write_resource_flags, struct wimlib_lzx_context **ctx_pp)
-{
- struct wimlib_lzx_params params;
- params.size_of_this = sizeof(params);
- if (write_resource_flags & WIMLIB_WRITE_RESOURCE_FLAG_COMPRESS_SLOW)
- params.algorithm = WIMLIB_LZX_ALGORITHM_SLOW;
- else
- params.algorithm = WIMLIB_LZX_ALGORITHM_FAST;
- params.use_defaults = 1;
- return wimlib_lzx_alloc_context(¶ms, ctx_pp);
-}
-
static unsigned
compress_chunk(const void * uncompressed_data,
unsigned uncompressed_len,
* @resource_flags:
* * WIMLIB_WRITE_RESOURCE_FLAG_RECOMPRESS to force data to be recompressed even
* if it could otherwise be copied directly from the input;
- * * WIMLIB_WRITE_RESOURCE_FLAG_COMPRESS_SLOW to compress the data as much
- * as possible;
* * WIMLIB_WRITE_RESOURCE_FLAG_PIPABLE if writing a resource for a pipable WIM
* (and the output file descriptor may be a pipe).
*
+ * @comp_ctx:
+ * Location of LZX compression context pointer, which will be allocated or
+ * updated if needed. (Initialize to NULL.)
+ *
* Additional notes: The SHA1 message digest of the uncompressed data is
* calculated (except when doing a raw copy --- see below). If the @unhashed
* flag is set on the lookup table entry, this message digest is simply copied
if (!(resource_flags & WIMLIB_READ_RESOURCE_FLAG_RAW)) {
write_ctx.out_ctype = out_ctype;
if (out_ctype == WIMLIB_COMPRESSION_TYPE_LZX) {
- ret = alloc_lzx_context(resource_flags, comp_ctx);
+ ret = wimlib_lzx_alloc_context(NULL, comp_ctx);
if (ret)
goto out;
}
if (write_flags & WIMLIB_WRITE_FLAG_RECOMPRESS)
resource_flags |= WIMLIB_WRITE_RESOURCE_FLAG_RECOMPRESS;
- if (write_flags & WIMLIB_WRITE_FLAG_COMPRESS_SLOW)
- resource_flags |= WIMLIB_WRITE_RESOURCE_FLAG_COMPRESS_SLOW;
if (write_flags & WIMLIB_WRITE_FLAG_PIPABLE)
resource_flags |= WIMLIB_WRITE_RESOURCE_FLAG_PIPABLE;
return resource_flags;
params[i].compressed_res_queue = &compressed_res_queue;
params[i].out_ctype = out_ctype;
if (out_ctype == WIMLIB_COMPRESSION_TYPE_LZX) {
- ret = alloc_lzx_context(write_resource_flags,
- ¶ms[i].comp_ctx);
+ ret = wimlib_lzx_alloc_context(NULL, ¶ms[i].comp_ctx);
if (ret)
goto out_free_params;
}
{
int ret = 0;
- if (!(write_flags & WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR))
+ if (!(write_flags & WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR)) {
+ DEBUG("Closing WIM file.");
if (filedes_valid(&wim->out_fd))
if (filedes_close(&wim->out_fd))
ret = WIMLIB_ERR_WRITE;
+ }
filedes_invalidate(&wim->out_fd);
return ret;
}
off_t new_lookup_table_end;
u64 xml_totalbytes;
+ DEBUG("image=%d, write_flags=%08x", image, write_flags);
+
write_resource_flags = write_flags_to_resource_flags(write_flags);
/* In the WIM header, there is room for the resource entry for a
hdr_offset = 0;
if (write_flags & WIMLIB_WRITE_FLAG_HEADER_AT_END)
hdr_offset = wim->out_fd.offset;
+ DEBUG("Writing new header @ %"PRIu64".", hdr_offset);
ret = write_wim_header_at_offset(&wim->hdr, &wim->out_fd, hdr_offset);
if (ret)
return ret;
* operation has been written to disk, but the new file data has not.
*/
if (write_flags & WIMLIB_WRITE_FLAG_FSYNC) {
+ DEBUG("Syncing WIM file.");
if (fsync(wim->out_fd.fd)) {
ERROR_WITH_ERRNO("Error syncing data to WIM file");
return WIMLIB_ERR_WRITE;
out_restore_hdr:
memcpy(&wim->hdr, &hdr_save, sizeof(struct wim_header));
(void)close_wim_writable(wim, write_flags);
+ DEBUG("ret=%d", ret);
return ret;
}