diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-09-13 15:20:05 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-09-14 07:48:43 +0200 |
commit | ffa0709a889a3d59553538ee00ce81a0e524a96e (patch) | |
tree | 4e0c85325e9fb6a317faabef9d12a48ed2042b62 /src/tool_dirhie.c | |
parent | 4a35bbbe8ee57e6549e89e655819fae75410236e (diff) | |
download | curl-ffa0709a889a3d59553538ee00ce81a0e524a96e.tar.gz |
curl: make --create-dirs on windows grok both forward and backward slashes
Reported-by: Ryan Scott
Fixes #1007
Diffstat (limited to 'src/tool_dirhie.c')
-rw-r--r-- | src/tool_dirhie.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c index db810d647..23bb2cb42 100644 --- a/src/tool_dirhie.c +++ b/src/tool_dirhie.c @@ -91,6 +91,14 @@ static void show_dir_errno(FILE *errors, const char *name) * should create all the dir* automagically */ +#ifdef WIN32 +/* systems that may use either or when specifying a path */ +#define PATH_DELIMITERS "\\/" +#else +#define PATH_DELIMITERS DIR_CHAR +#endif + + CURLcode create_dir_hierarchy(const char *outfile, FILE *errors) { char *tempdir; @@ -114,10 +122,10 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors) /* Allow strtok() here since this isn't used threaded */ /* !checksrc! disable BANNEDFUNC 2 */ - tempdir = strtok(outdup, DIR_CHAR); + tempdir = strtok(outdup, PATH_DELIMITERS); while(tempdir != NULL) { - tempdir2 = strtok(NULL, DIR_CHAR); + tempdir2 = strtok(NULL, PATH_DELIMITERS); /* since strtok returns a token for the last word even if not ending with DIR_CHAR, we need to prune it */ if(tempdir2 != NULL) { @@ -125,7 +133,8 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors) if(dlen) snprintf(&dirbuildup[dlen], outlen - dlen, "%s%s", DIR_CHAR, tempdir); else { - if(0 != strncmp(outdup, DIR_CHAR, 1)) + if(outdup == tempdir) + /* the output string doesn't start with a separator */ strcpy(dirbuildup, tempdir); else snprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir); |