]> wimlib.net Git - wimlib/commitdiff
Add WIMLIB_ERR_WIM_IS_INCOMPLETE
authorEric Biggers <ebiggers3@gmail.com>
Sat, 3 Oct 2015 19:56:32 +0000 (14:56 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 3 Oct 2015 20:12:06 +0000 (15:12 -0500)
Usually WIMLIB_ERR_XML was returned in this situation, but a separate
error code is more appropriate.

include/wimlib.h
src/error.c
src/wim.c

index a2d6299e4cb4133aed1667a6f60b342859d88e81..e9fb0b761ba55c3105be3caae29c3b3e03d323e0 100644 (file)
@@ -2479,6 +2479,7 @@ enum wimlib_error_code {
        WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT           = 81,
        WIMLIB_ERR_FVE_LOCKED_VOLUME                  = 82,
        WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG      = 83,
+       WIMLIB_ERR_WIM_IS_INCOMPLETE                  = 84,
 };
 
 
@@ -3553,6 +3554,9 @@ wimlib_mount_image(WIMStruct *wim,
  * @retval ::WIMLIB_ERR_WIM_IS_ENCRYPTED
  *     The WIM cannot be opened because it contains encrypted segments.  (It
  *     may be a Windows 8 "ESD" file.)
+ * @retval ::WIMLIB_ERR_WIM_IS_INCOMPLETE
+ *     The WIM file is not complete (e.g. the program which wrote it was
+ *     terminated before it finished)
  * @retval ::WIMLIB_ERR_WIM_IS_READONLY
  *     ::WIMLIB_OPEN_FLAG_WRITE_ACCESS was specified but the WIM file was
  *     considered read-only because of any of the reasons mentioned in the
index a4672a5644e68eb2f1adc435d87f1940a5bbb35f..ac12cec440422bfab91cca9712d0bc508d2bab1c 100644 (file)
@@ -332,6 +332,8 @@ static const tchar * const error_strings[] = {
                = T("The volume must be unlocked before it can be used"),
        [WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG]
                = T("The capture configuration file could not be read"),
+       [WIMLIB_ERR_WIM_IS_INCOMPLETE]
+               = T("The WIM file is incomplete"),
 };
 
 WIMLIBAPI const tchar *
index 9b5e4b24856d8b70deec0bfc50059158ec0c6e0f..1b66aaf7271ef2fb1bfb2988a1ad4af0f498cf7a 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -733,6 +733,9 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, int open_flags)
                if (!wim->blob_table)
                        return WIMLIB_ERR_NOMEM;
        } else {
+               if (wim->hdr.blob_table_reshdr.uncompressed_size == 0 &&
+                   wim->hdr.xml_data_reshdr.uncompressed_size == 0)
+                       return WIMLIB_ERR_WIM_IS_INCOMPLETE;
 
                ret = read_wim_xml_data(wim);
                if (ret)