Making mkdir -p handle empty paths. Thanks, Willem van de Krol!

This commit is contained in:
David Galos 2013-07-11 21:43:38 -04:00
parent 7adf4f380a
commit 48e6870bb7

View File

@ -46,7 +46,7 @@ mkdirp(char *path)
char *p = path; char *p = path;
do { do {
if((p = strchr(&p[1], '/'))) if(*p && (p = strchr(&p[1], '/')))
*p = '\0'; *p = '\0';
if(mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO) == -1 && errno != EEXIST) if(mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO) == -1 && errno != EEXIST)
eprintf("mkdir %s:", path); eprintf("mkdir %s:", path);