+/* API function documented in wimlib.h */
+WIMLIBAPI int
+wimlib_set_output_compression_type(WIMStruct *wim, int ctype)
+{
+ switch (ctype) {
+ case WIMLIB_COMPRESSION_TYPE_INVALID:
+ break;
+ case WIMLIB_COMPRESSION_TYPE_NONE:
+ case WIMLIB_COMPRESSION_TYPE_LZX:
+ case WIMLIB_COMPRESSION_TYPE_XPRESS:
+ case WIMLIB_COMPRESSION_TYPE_LZMS:
+ wim->out_compression_type = ctype;
+
+ /* Reset the chunk size if it's no longer valid. */
+ if (!wim_chunk_size_valid(wim->out_chunk_size,
+ wim->out_compression_type))
+ wim->out_chunk_size = wim_default_chunk_size(wim->out_compression_type);
+ return 0;
+ }
+ return WIMLIB_ERR_INVALID_PARAM;
+}
+
+/* API function documented in wimlib.h */
+WIMLIBAPI int
+wimlib_set_output_chunk_size(WIMStruct *wim, uint32_t chunk_size)
+{
+ if (!wim_chunk_size_valid(chunk_size, wim->out_compression_type)) {
+ ERROR("Invalid chunk size (%"PRIu32" bytes) "
+ "for compression type %"TS"!",
+ chunk_size,
+ wimlib_get_compression_type_string(wim->out_compression_type));
+ switch (wim->out_compression_type) {
+ case WIMLIB_COMPRESSION_TYPE_XPRESS:
+ ERROR("Valid chunk sizes for XPRESS are "
+ "32768, 65536, 131072, ..., 67108864.");
+ break;
+ case WIMLIB_COMPRESSION_TYPE_LZX:
+ ERROR("Valid chunk sizes for LZX are "
+ "32768, 65536, 131072, ..., 2097152.");
+ break;
+ case WIMLIB_COMPRESSION_TYPE_LZMS:
+ ERROR("Valid chunk sizes for LZMS are 131072.");
+ break;
+ }
+ return WIMLIB_ERR_INVALID_CHUNK_SIZE;
+ }
+ if (chunk_size != 32768) {
+ WARNING ("Changing the compression chunk size to any value other than\n"
+ " the default of 32768 bytes eliminates compatibility with\n"
+ " Microsoft's software!");
+ }
+ wim->out_chunk_size = chunk_size;
+ return 0;
+}
+