From: Eric Biggers Date: Sun, 3 May 2015 21:35:11 +0000 (-0500) Subject: Improved error reporting if loading capture configuration file fails X-Git-Tag: v1.8.1~16 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=5fce6aa92826ec69fdeeea13e28292fa1fbb43a8 Improved error reporting if loading capture configuration file fails --- diff --git a/include/wimlib.h b/include/wimlib.h index 2dcbd12d..81e8f09c 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -2451,6 +2451,7 @@ enum wimlib_error_code { WIMLIB_ERR_NOT_A_MOUNTPOINT = 80, WIMLIB_ERR_NOT_PERMITTED_TO_UNMOUNT = 81, WIMLIB_ERR_FVE_LOCKED_VOLUME = 82, + WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG = 83, }; @@ -4244,8 +4245,7 @@ wimlib_unmount_image_with_progress(const wimlib_tchar *dir, * Windows-only: One of the "add" commands attempted to add files from an * encrypted BitLocker volume that hasn't yet been unlocked. * @retval ::WIMLIB_ERR_INVALID_CAPTURE_CONFIG - * The capture configuration structure specified for an add command was - * invalid. + * The contents of a capture configuration file were invalid. * @retval ::WIMLIB_ERR_INVALID_IMAGE * @p image did not exist in @p wim. * @retval ::WIMLIB_ERR_INVALID_OVERLAY @@ -4292,6 +4292,8 @@ wimlib_unmount_image_with_progress(const wimlib_tchar *dir, * @retval ::WIMLIB_ERR_STAT * While executing an add command, failed to get attributes for a file or * directory. + * @retval ::WIMLIB_ERR_UNABLE_TO_READ_CAPTURE_CONFIG + * A capture configuration file could not be read. * @retval ::WIMLIB_ERR_UNSUPPORTED * ::WIMLIB_ADD_FLAG_NTFS was specified in the @p add_flags for an update * command, but wimlib was configured with the @c --without-ntfs-3g flag; diff --git a/src/capture_common.c b/src/capture_common.c index 0e682619..e544b7c1 100644 --- a/src/capture_common.c +++ b/src/capture_common.c @@ -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); diff --git a/src/error.c b/src/error.c index 49f83294..ed9e6b72 100644 --- a/src/error.c +++ b/src/error.c @@ -220,7 +220,7 @@ static const tchar * const error_strings[] = { [WIMLIB_ERR_INTEGRITY] = T("The WIM file is corrupted (failed integrity check)"), [WIMLIB_ERR_INVALID_CAPTURE_CONFIG] - = T("The capture configuration string was invalid"), + = T("The contents of the capture configuration file were invalid"), [WIMLIB_ERR_INVALID_CHUNK_SIZE] = T("The compression chunk size was unrecognized"), [WIMLIB_ERR_INVALID_COMPRESSION_TYPE] @@ -354,6 +354,8 @@ static const tchar * const error_strings[] = { = T("The current user does not have permission to unmount the WIM image"), [WIMLIB_ERR_FVE_LOCKED_VOLUME] = 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"), }; WIMLIBAPI const tchar *