From 71aa9b002bacf3b32342cf5a319a4cd1a372feba Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 22 Apr 2009 22:26:12 +1000 Subject: libbb/bb_make_directory() remove trailing slashes before passing to mkdir() because Windows does not like it --- libbb/make_directory.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libbb') diff --git a/libbb/make_directory.c b/libbb/make_directory.c index d540ad133..b8da09901 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c @@ -30,7 +30,7 @@ int bb_make_directory (char *path, long mode, int flags) { mode_t mask; const char *fail_msg; - char *s = path; + char *s = path,*s2; char c; struct stat st; @@ -51,11 +51,12 @@ int bb_make_directory (char *path, long mode, int flags) /* 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; @@ -94,7 +95,7 @@ int bb_make_directory (char *path, long mode, int flags) } /* Remove any inserted nul from the path (recursive mode). */ - *s = c; + *s2 = c; } while (1); -- cgit v1.2.3-55-g6feb