]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Windows support
authorJairo <kidandcat@gmail.com>
Mon, 15 Apr 2019 07:42:24 +0000 (09:42 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Apr 2019 07:42:24 +0000 (09:42 +0200)
contrib/untar.c

index 3d954f638be02ff244659cd919373e2fe62a4fe2..34b06c7fec54751450b5ac5206dcb5ae1a66a1a9 100644 (file)
 /* This is for mkdir(); this may need to be changed for some platforms. */
 #include <sys/stat.h>  /* For mkdir() */
 
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
 /* Parse an octal number, ignoring leading and trailing nonsense. */
 static int
 parseoct(const char *p, size_t n)
@@ -78,7 +82,11 @@ create_dir(char *pathname, int mode)
                pathname[strlen(pathname) - 1] = '\0';
 
        /* Try creating the directory. */
-       r = mkdir(pathname, mode);
+  #if defined(_WIN32)
+  r = _mkdir(pathname);
+  #else 
+  r = mkdir(pathname, mode); 
+  #endif
 
        if (r != 0) {
                /* On failure, try creating parent directory. */
@@ -87,7 +95,11 @@ create_dir(char *pathname, int mode)
                        *p = '\0';
                        create_dir(pathname, 0755);
                        *p = '/';
-                       r = mkdir(pathname, mode);
+                       #if defined(_WIN32)
+      r = _mkdir(pathname);
+      #else 
+      r = mkdir(pathname, mode); 
+      #endif
                }
        }
        if (r != 0)