version 1.1.1.1, 2010/02/23 22:54:52
|
version 1.1.1.1.8.2, 2010/09/10 12:38:26
|
Line 9
|
Line 9
|
#include "global.h" |
#include "global.h" |
|
|
|
|
|
int io_Debug; |
|
|
|
|
#pragma GCC visibility push(hidden) |
#pragma GCC visibility push(hidden) |
|
|
int io_Errno; |
int io_Errno; |
Line 302 char *ioRegexReplace(const char *csRegex, const char *
|
Line 305 char *ioRegexReplace(const char *csRegex, const char *
|
|
|
return str; |
return str; |
} |
} |
|
|
|
|
|
/* |
|
* ioMkDir() Function for racursive directory creation and validation |
|
* @csDir = Full directory path |
|
* @mode = Mode for directory creation if missing dir |
|
* return: -1 error, 0 directory path exist, >0 created missing dirs |
|
*/ |
|
int |
|
ioMkDir(const char *csDir, int mode) |
|
{ |
|
char *str, *s, *pbrk, szOld[MAXPATHLEN] = { 0 }; |
|
register int cx = -1; |
|
|
|
if (!csDir) |
|
return cx; |
|
|
|
str = strdup(csDir); |
|
if (!str) { |
|
LOGERR; |
|
return cx; |
|
} |
|
|
|
getcwd(szOld, MAXPATHLEN); |
|
if (*str == '/') |
|
chdir("/"); |
|
|
|
for (cx = 0, s = strtok_r(str, "/", &pbrk); s; s = strtok_r(NULL, "/", &pbrk)) { |
|
if (mkdir(s, mode) == -1) { |
|
if (errno != EEXIST) { |
|
LOGERR; |
|
cx = -1; |
|
goto end; |
|
} |
|
} else |
|
cx++; |
|
|
|
if (chdir(s) == -1) { |
|
LOGERR; |
|
cx = -1; |
|
goto end; |
|
} |
|
} |
|
end: |
|
chdir(szOld); |
|
free(str); |
|
return cx; |
|
} |
|
|