Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support for contrib/untar #1170

Merged
merged 3 commits into from
Feb 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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