return 0;
}
-/* Returns the compression type given in the flags of a WIM header. */
-static int
-wim_hdr_flags_compression_type(int wim_hdr_flags)
-{
- if (wim_hdr_flags & WIM_HDR_FLAG_COMPRESSION) {
- if (wim_hdr_flags & WIM_HDR_FLAG_COMPRESS_LZX)
- return WIMLIB_COMPRESSION_TYPE_LZX;
- else if (wim_hdr_flags & WIM_HDR_FLAG_COMPRESS_XPRESS)
- return WIMLIB_COMPRESSION_TYPE_XPRESS;
- else
- return WIMLIB_COMPRESSION_TYPE_INVALID;
- } else {
- return WIMLIB_COMPRESSION_TYPE_NONE;
- }
-}
-
/*
* Creates a WIMStruct for a new WIM file.
*/
}
w->lookup_table = table;
w->refcnts_ok = 1;
+ w->compression_type = ctype;
*w_ret = w;
return 0;
out_free:
WIMLIBAPI int
wimlib_get_compression_type(const WIMStruct *w)
{
- return wim_hdr_flags_compression_type(w->hdr.flags);
+ return w->compression_type;
}
WIMLIBAPI const tchar *
tputchar(T('\n'));
tprintf(T("Image Count: %d\n"), hdr->image_count);
tprintf(T("Compression: %"TS"\n"),
- wimlib_get_compression_type_string(wimlib_get_compression_type(w)));
+ wimlib_get_compression_type_string(w->compression_type));
tprintf(T("Part Number: %d/%d\n"), hdr->part_number, hdr->total_parts);
tprintf(T("Boot Index: %d\n"), hdr->boot_idx);
tprintf(T("Size: %"PRIu64" bytes\n"),
if (ret)
return ret;
+ if (w->hdr.flags & WIM_HDR_FLAG_WRITE_IN_PROGRESS) {
+ WARNING("The WIM_HDR_FLAG_WRITE_IN_PROGRESS is set in the header of \"%"TS"\".\n"
+ " It may be being changed by another process, or a process\n"
+ " may have crashed while writing the WIM.", in_wim_path);
+ }
+
if (open_flags & WIMLIB_OPEN_FLAG_WRITE_ACCESS) {
ret = can_modify_wim(w);
if (ret)
if (w->hdr.total_parts != 1 && !(open_flags & WIMLIB_OPEN_FLAG_SPLIT_OK)) {
ERROR("\"%"TS"\": This WIM is part %u of a %u-part WIM",
- w->filename, w->hdr.part_number, w->hdr.total_parts);
+ in_wim_path, w->hdr.part_number, w->hdr.total_parts);
return WIMLIB_ERR_SPLIT_UNSUPPORTED;
}
w->hdr.boot_idx = 0;
}
- 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);
}
if (open_flags & WIMLIB_OPEN_FLAG_CHECK_INTEGRITY) {