]> wimlib.net Git - wimlib/blobdiff - src/capture_common.c
Improved error reporting if loading capture configuration file fails
[wimlib] / src / capture_common.c
index cbc1aa49a85230f9accaccbd40014f50da7819c2..e544b7c126794f0e5013b684d9c3d83f455058de 100644 (file)
 
 #include <string.h>
 
+#include "wimlib/blob_table.h"
 #include "wimlib/capture.h"
 #include "wimlib/dentry.h"
 #include "wimlib/error.h"
-#include "wimlib/lookup_table.h"
 #include "wimlib/paths.h"
 #include "wimlib/progress.h"
 #include "wimlib/textfile.h"
@@ -71,12 +71,12 @@ do_capture_progress(struct capture_params *params, int status,
 
                /* Successful scan, and visiting inode for the first time  */
 
-               /* Tally size of all data streams.  */
-               const struct wim_lookup_table_entry *lte;
-               for (unsigned i = 0; i <= inode->i_num_ads; i++) {
-                       lte = inode_stream_lte_resolved(inode, i);
-                       if (lte)
-                               params->progress.scan.num_bytes_scanned += lte->size;
+               /* Tally size of all streams.  */
+               for (unsigned i = 0; i < inode->i_num_streams; i++) {
+                       const struct blob_descriptor *blob =
+                               stream_blob_resolved(&inode->i_streams[i]);
+                       if (blob)
+                               params->progress.scan.num_bytes_scanned += blob->size;
                }
 
                /* Tally the file itself.  */
@@ -203,8 +203,25 @@ read_capture_config(const tchar *config_file, const void *buf,
        ret = do_load_text_file(config_file, buf, bufsize, &mem,
                                sections, ARRAY_LEN(sections),
                                LOAD_TEXT_FILE_REMOVE_QUOTES, mangle_pat);
-       if (ret)
+       if (ret) {
+               ERROR("Failed to load capture configuration file \"%"TS"\"",
+                     config_file);
+               switch (ret) {
+               case WIMLIB_ERR_INVALID_UTF8_STRING:
+               case WIMLIB_ERR_INVALID_UTF16_STRING:
+                       ERROR("Note: the capture configuration file must be "
+                             "valid UTF-8 or UTF-16LE");
+                       ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
+                       break;
+               case WIMLIB_ERR_OPEN:
+               case WIMLIB_ERR_STAT:
+               case WIMLIB_ERR_NOMEM:
+               case WIMLIB_ERR_READ:
+                       ret = WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG;
+                       break;
+               }
                return ret;
+       }
 
        FREE(prepopulate_pats.strings);
        FREE(compression_exclusion_pats.strings);