summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-27 19:03:11 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-27 19:03:11 +0300
commita7f59172b83910f9e2dc17c116f70530f46cf6a1 (patch)
tree17347154f4536a490ff4848dc9f31528cfbcae96 /src
parent30e89c08e26cb0988afc33da18bcebed1d177883 (diff)
downloadmv-a7f59172b83910f9e2dc17c116f70530f46cf6a1.tar.gz
mv-a7f59172b83910f9e2dc17c116f70530f46cf6a1.tar.bz2
mv-a7f59172b83910f9e2dc17c116f70530f46cf6a1.tar.xz
mv-a7f59172b83910f9e2dc17c116f70530f46cf6a1.zip
Fix recursive directory creation for windows.
Diffstat (limited to 'src')
-rw-r--r--src/utils/mkdir.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 84c205b33..dc2ab63ef 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -43,6 +43,7 @@
int mkdir_r(const char *pathname)
{
char tmp[PATH_MAX];
+ char tmp2[PATH_MAX];
char *p;
if (strlen(pathname) >= PATH_MAX - 2)
@@ -72,9 +73,13 @@ int mkdir_r(const char *pathname)
continue;
}
+ strcpy(tmp2, tmp);
+ char *p2 = tmp2 + strlen(tmp2) - 1;
+ if (*p2 == '/' || *p2 == '\\')
+ *p2 = 0;
// check if the name already exists, but not as directory
struct stat statbuf;
- if (!stat(tmp, &statbuf))
+ if (!stat(tmp2, &statbuf))
{
if (S_ISDIR(statbuf.st_mode))
{
@@ -85,13 +90,12 @@ int mkdir_r(const char *pathname)
return -1;
}
- if (!CreateDirectory(tmp, 0))
+ if (!CreateDirectory(tmp2, 0))
{
// hack, hack. just assume that x: might be a drive
// letter, and try again
- if (!(strlen(tmp) == 2 &&
- !strcmp(tmp + 1, ":")))
- return -1;
+ if (!(strlen(tmp2) == 2 && !strcmp(tmp2 + 1, ":")))
+ return -1;
}
#ifdef M_MKDIR_TEST_