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 a2d6299..e9fb0b7 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 a4672a5..ac12cec 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 9b5e4b2..1b66aaf 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)