Skip to content

Commit

Permalink
Merge pull request #1170 from kidandcat/patch-1
Browse files Browse the repository at this point in the history
Windows support for contrib/untar
  • Loading branch information
mmatuska committed Feb 6, 2022
2 parents 7d3c18a + 9d1c5db commit c9788f9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions contrib/untar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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. */
Expand All @@ -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)
Expand Down

0 comments on commit c9788f9

Please sign in to comment.