]> wimlib.net Git - wimlib/blobdiff - src/error.c
Add support for unsafe in-place compaction of WIM files
[wimlib] / src / error.c
index 8448536d42e6f5e6641c2d615ebfb03daac65e6c..40d00a58838701c64b573d05e93da9c95fd439ec 100644 (file)
 #include "wimlib.h"
 #include "wimlib/error.h"
 #include "wimlib/util.h"
-#ifdef __WIN32__
-#  include "wimlib/win32.h"
-#endif
+#include "wimlib/win32.h"
 
 #ifdef ENABLE_ERROR_MESSAGES
 bool wimlib_print_errors = false;
 FILE *wimlib_error_file = NULL; /* Set in wimlib_global_init() */
 static bool wimlib_owns_error_file = false;
-#endif
 
-#if defined(ENABLE_ERROR_MESSAGES) || defined(ENABLE_DEBUG)
 static void
-wimlib_vmsg(const tchar *tag, const tchar *format,
-           va_list va, bool perror)
+wimlib_vmsg(const tchar *tag, const tchar *format, va_list va, bool perror)
 {
-#if !defined(ENABLE_DEBUG)
-       if (wimlib_print_errors)
-#endif
-       {
-               int errno_save = errno;
-               fflush(stdout);
-               tfputs(tag, wimlib_error_file);
-               tvfprintf(wimlib_error_file, format, va);
-               if (perror && errno_save != 0) {
-                       tchar buf[64];
-                       int res;
-                       res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
-                       if (res) {
-                               tsprintf(buf,
-                                        T("unknown error (errno=%d)"),
-                                        errno_save);
-                       }
-               #ifdef WIN32
-                       if (errno_save == EBUSY)
-                               tstrcpy(buf, T("Resource busy"));
-               #endif
-                       tfprintf(wimlib_error_file, T(": %"TS), buf);
+       if (!wimlib_print_errors)
+               return;
+       int errno_save = errno;
+       fflush(stdout);
+       tfputs(tag, wimlib_error_file);
+       tvfprintf(wimlib_error_file, format, va);
+       if (perror && errno_save != 0) {
+               tchar buf[64];
+               int res;
+               res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
+               if (res) {
+                       tsprintf(buf,
+                                T("unknown error (errno=%d)"),
+                                errno_save);
                }
-               tputc(T('\n'), wimlib_error_file);
-               fflush(wimlib_error_file);
-               errno = errno_save;
+       #ifdef WIN32
+               if (errno_save == EBUSY)
+                       tstrcpy(buf, T("Resource busy"));
+       #endif
+               tfprintf(wimlib_error_file, T(": %"TS), buf);
        }
+       tputc(T('\n'), wimlib_error_file);
+       fflush(wimlib_error_file);
+       errno = errno_save;
 }
-#endif
 
-#ifdef ENABLE_ERROR_MESSAGES
 void
 wimlib_error(const tchar *format, ...)
 {
@@ -128,22 +118,7 @@ wimlib_warning_with_errno(const tchar *format, ...)
        wimlib_vmsg(T("\r[WARNING] "), format, va, true);
        va_end(va);
 }
-
-#endif
-
-#if defined(ENABLE_DEBUG) || defined(ENABLE_MORE_DEBUG)
-void wimlib_debug(const tchar *filename, int line, const char *func,
-                 const tchar *format, ...)
-{
-       va_list va;
-       tchar buf[tstrlen(filename) + strlen(func) + 30];
-
-       tsprintf(buf, T("[%"TS" %d] %s(): "), filename, line, func);
-       va_start(va, format);
-       wimlib_vmsg(buf, format, va, false);
-       va_end(va);
-}
-#endif
+#endif /* ENABLE_ERROR_MESSAGES */
 
 void
 print_byte_field(const u8 *field, size_t len, FILE *out)
@@ -224,7 +199,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]
@@ -252,7 +227,7 @@ static const tchar * const error_strings[] = {
        [WIMLIB_ERR_INVALID_REPARSE_DATA]
                = T("The reparse data of a reparse point was invalid"),
        [WIMLIB_ERR_INVALID_RESOURCE_HASH]
-               = T("The SHA1 message digest of a WIM resource did not match the expected value"),
+               = T("The SHA-1 message digest of a WIM resource did not match the expected value"),
        [WIMLIB_ERR_INVALID_UTF8_STRING]
                = T("A string provided as input by the user was not a valid UTF-8 string"),
        [WIMLIB_ERR_INVALID_UTF16_STRING]
@@ -261,9 +236,6 @@ static const tchar * const error_strings[] = {
                = T("One of the specified paths to delete was a directory"),
        [WIMLIB_ERR_IS_SPLIT_WIM]
                = T("The WIM is part of a split WIM, which is not supported for this operation"),
-       [WIMLIB_ERR_LIBXML_UTF16_HANDLER_NOT_AVAILABLE]
-               = T("libxml2 was unable to find a character encoding conversion handler "
-                 "for UTF-16LE"),
        [WIMLIB_ERR_LINK]
                = T("Failed to create a hard or symbolic link when extracting "
                        "a file from the WIM"),
@@ -358,6 +330,13 @@ 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"),
+       [WIMLIB_ERR_WIM_IS_INCOMPLETE]
+               = T("The WIM file is incomplete"),
+       [WIMLIB_ERR_COMPACTION_NOT_POSSIBLE]
+               = T("The WIM file cannot be compacted because of its format, "
+                   "its layout, or the write parameters specified by the user"),
 };
 
 WIMLIBAPI const tchar *