- if (wimlib_get_compression_type(w) == WIMLIB_COMPRESSION_TYPE_INVALID) {
- ERROR("Invalid compression type (WIM header flags = 0x%x)",
- w->hdr.flags);
- return WIMLIB_ERR_INVALID_COMPRESSION_TYPE;
+ /* Check and cache the compression type */
+ if (w->hdr.flags & WIM_HDR_FLAG_COMPRESSION) {
+ if (w->hdr.flags & WIM_HDR_FLAG_COMPRESS_LZX) {
+ if (w->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) {
+ ERROR("Multiple compression flags are set in \"%"TS"\"",
+ in_wim_path);
+ return WIMLIB_ERR_INVALID_COMPRESSION_TYPE;
+ }
+ w->compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
+ } else if (w->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) {
+ w->compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
+ } else {
+ ERROR("The compression flag is set on \"%"TS"\", but "
+ "neither the XPRESS nor LZX flag is set",
+ in_wim_path);
+ return WIMLIB_ERR_INVALID_COMPRESSION_TYPE;
+ }
+ } else {
+ BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_NONE != 0);