]> wimlib.net Git - wimlib/blobdiff - programs/imagex.c
Windows native build
[wimlib] / programs / imagex.c
index f635e08613ec9e2447db625f41372784e301ab08..1972505824766aaad8be23eb9b91d5175ff0dcbf 100644 (file)
@@ -29,7 +29,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <getopt.h>
-#include <glob.h>
+
 #include <inttypes.h>
 #include <libgen.h>
 #include <limits.h>
 #include <alloca.h>
 #endif
 
+#ifdef __WIN32__
+#  include "imagex-win32.h"
+#else
+#  include <glob.h>
+#endif
+
 #define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
 
 #define for_opt(c, opts) while ((c = getopt_long_only(argc, (char**)argv, "", \
@@ -733,6 +739,7 @@ static int open_swms_from_glob(const char *swm_glob,
        glob_t globbuf;
        int ret;
 
+       /* Warning: glob() is replaced in Windows native builds */
        ret = glob(swm_glob, GLOB_ERR | GLOB_NOSORT, NULL, &globbuf);
        if (ret != 0) {
                if (ret == GLOB_NOMATCH) {
@@ -1322,9 +1329,10 @@ static int imagex_export(int argc, char **argv)
 
                wim_is_new = false;
                /* Destination file exists. */
-               if (!S_ISREG(stbuf.st_mode) && !S_ISLNK(stbuf.st_mode)) {
+
+               if (!S_ISREG(stbuf.st_mode)) {
                        imagex_error("`%s' is not a regular file",
-                                       dest_wimfile);
+                                    dest_wimfile);
                        ret = -1;
                        goto out;
                }
@@ -2124,14 +2132,14 @@ int main(int argc, char **argv)
        for_imagex_command(cmd) {
                if (strcmp(cmd->name, *argv) == 0) {
                        ret = cmd->func(argc, argv);
-                       goto out;
+                       goto out_check_write_error;
                }
        }
 
        imagex_error("Unrecognized command: `%s'", argv[0]);
        usage_all();
        return 1;
-out:
+out_check_write_error:
        /* For 'imagex info' and 'imagex dir', data printed to standard output
         * is part of the program's actual behavior and not just for
         * informational purposes, so we should set a failure exit status if
@@ -2143,7 +2151,7 @@ out:
                                ret = -1;
                }
        }
-
+out:
        /* Exit status (ret):  -1 indicates an error found by 'imagex' outside
         * of the wimlib library code.  0 indicates success.  > 0 indicates a
         * wimlib error code from which an error message can be printed. */