summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMartin Matuška <martin@matuska.org>2022-02-07 00:59:09 +0100
committerGitHub <noreply@github.com>2022-02-07 00:59:09 +0100
commitc9788f9b70ba930797bd114b2149d8c633d2d6cb (patch)
tree628b60dd4c52b2b32d43f52b50ab62e81f208ebb /contrib
parent7d3c18ab8a39942cc3b83ab0f0748c1353c2e972 (diff)
parent9d1c5db643515c9fd375d46ec9fc98f7a6734a1b (diff)
downloadlibarchive-c9788f9b70ba930797bd114b2149d8c633d2d6cb.tar.gz
Merge pull request #1170 from kidandcat/patch-1
Windows support for contrib/untar
Diffstat (limited to 'contrib')
-rw-r--r--contrib/untar.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/contrib/untar.c b/contrib/untar.c
index 3d954f63..4d10c264 100644
--- a/contrib/untar.c
+++ b/contrib/untar.c
@@ -36,6 +36,10 @@
/* This is for mkdir(); this may need to be changed for some platforms. */
#include <sys/stat.h> /* For mkdir() */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#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) && !defined(__CYGWIN__)
+ 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) && !defined(__CYGWIN__)
+ r = _mkdir(pathname);
+ #else
+ r = mkdir(pathname, mode);
+ #endif
}
}
if (r != 0)