aboutsummaryrefslogtreecommitdiff
path: root/libbb/make_directory.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-09-07 11:52:17 +0100
committerRon Yorston <rmy@pobox.com>2012-09-07 11:52:17 +0100
commitfbcb8015dac9b0077c403f4e7e045c2e77b652b5 (patch)
tree8faade0a1f359f8a988b6379569ec28e5473e9c9 /libbb/make_directory.c
parentfecf687cc358883de2da21de33346f0df204c80b (diff)
downloadbusybox-w32-fbcb8015dac9b0077c403f4e7e045c2e77b652b5.tar.gz
busybox-w32-fbcb8015dac9b0077c403f4e7e045c2e77b652b5.tar.bz2
busybox-w32-fbcb8015dac9b0077c403f4e7e045c2e77b652b5.zip
Simplify recursive directory creation
Diffstat (limited to 'libbb/make_directory.c')
-rw-r--r--libbb/make_directory.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 6f59fda29..39599b657 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)
31 mode_t cur_mask; 31 mode_t cur_mask;
32 mode_t org_mask; 32 mode_t org_mask;
33 const char *fail_msg; 33 const char *fail_msg;
34 char *s, *s2; 34 char *s;
35 char c; 35 char c;
36 struct stat st; 36 struct stat st;
37 37
@@ -45,21 +45,18 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
45 c = '\0'; 45 c = '\0';
46 46
47 if (flags & FILEUTILS_RECUR) { /* Get the parent */ 47 if (flags & FILEUTILS_RECUR) { /* Get the parent */
48 /* skip drive letter and initial slashes */ 48 /* skip drive letter */
49 if (ENABLE_PLATFORM_MINGW32 && s == path && *s && s[1] == ':') { 49 if (ENABLE_PLATFORM_MINGW32 && s == path && *s && s[1] == ':') {
50 s += 2; 50 s += 2;
51 while (*s == '/')
52 s++;
53 } 51 }
54 /* Bypass leading non-'/'s and then subsequent '/'s */ 52 /* Bypass leading non-'/'s and then subsequent '/'s */
55 while (*s) { 53 while (*s) {
56 if (*s == '/') { 54 if (*s == '/') {
57 s2 = s;
58 c = *s2; /* Save the current char */
59 *s2 = 0; /* and replace it with nul. */
60 do { 55 do {
61 ++s; 56 ++s;
62 } while (*s == '/'); 57 } while (*s == '/');
58 c = *s; /* Save the current char */
59 *s = '\0'; /* and replace it with nul */
63 break; 60 break;
64 } 61 }
65 ++s; 62 ++s;
@@ -124,7 +121,7 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
124 } 121 }
125 122
126 /* Remove any inserted nul from the path (recursive mode) */ 123 /* Remove any inserted nul from the path (recursive mode) */
127 *s2 = c; 124 *s = c;
128 } /* while (1) */ 125 } /* while (1) */
129 126
130 flags = -1; 127 flags = -1;