File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,46 +38,42 @@ bool mkdirRecursive(const char* path, bool includeDotPath)
3838{
3939 char temp[1024 ];
4040 char folder[265 ];
41+ char *end, *curend;
4142
4243 strcpy (temp, path);
4344 FixPathSlashes (temp);
44-
45- char * end = (char *)strchr (temp, CORRECT_PATH_SEPARATOR);
4645
47- // just do a fucking mkdir already
48- // FIXME: pls pls do a better code for it
49- if (end == NULL )
50- {
51- _mkdir (temp);
52- return true ;
53- }
54-
55- while (end != NULL )
46+ end = temp;
47+
48+ do
5649 {
5750 int result;
5851
52+ // skip any separators in the beginning
53+ while (*end == CORRECT_PATH_SEPARATOR)
54+ end++;
55+
56+ // get next string part
57+ curend = (char *)strchr (end, CORRECT_PATH_SEPARATOR);
58+
59+ if (curend)
60+ end = curend;
61+ else
62+ end = temp + strlen (temp);
63+
5964 strncpy (folder, temp, end - temp);
6065 folder[end - temp] = 0 ;
6166
62- // stop on file extension?
63- if (strchr (folder, ' .' ) != NULL && !includeDotPath)
67+ // stop on file extension if needed
68+ if (strchr (folder, ' .' ) && !includeDotPath)
6469 break ;
65-
66- result = _mkdir (folder);
70+
71+ result = _mkdir (folder);
6772
6873 if (result > 0 && result != EEXIST)
6974 return false ;
70-
71- if (*end == 0 )
72- break ;
73-
74- char * next = strchr (++end, CORRECT_PATH_SEPARATOR);
7575
76- if (next)
77- end = next;
78- else
79- end += strlen (end);
80- }
76+ } while (curend);
8177
8278 return true ;
8379}
You can’t perform that action at this time.
0 commit comments