From 5e22a8743e438c9c14fb276885cd8a1ade5d40f2 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Mon, 5 Apr 2010 22:24:35 +0200 Subject: win32: make_directory: drive letter support (buggy) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy --- libbb/make_directory.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 4486eb1ed..1eb8a8a49 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c @@ -31,7 +31,7 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) mode_t cur_mask; mode_t org_mask; const char *fail_msg; - char *s; + char *s, *s2; char c; struct stat st; @@ -45,14 +45,21 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) c = '\0'; if (flags & FILEUTILS_RECUR) { /* Get the parent */ + /* skip drive letter and initial slashes */ + if (ENABLE_PLATFORM_MINGW32 && s == path && *s && s[1] == ':') { + s += 2; + while (*s == '/') + s++; + } /* Bypass leading non-'/'s and then subsequent '/'s */ while (*s) { if (*s == '/') { + s2 = s; + c = *s2; /* Save the current char */ + *s2 = 0; /* and replace it with nul. */ do { ++s; } while (*s == '/'); - c = *s; /* Save the current char */ - *s = '\0'; /* and replace it with nul */ break; } ++s; @@ -113,7 +120,7 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) } /* Remove any inserted nul from the path (recursive mode) */ - *s = c; + *s2 = c; } /* while (1) */ bb_perror_msg("can't %s directory '%s'", fail_msg, path); -- cgit v1.2.3-55-g6feb