Improve make_path() error return for non-dir element.

This commit is contained in:
Wayne Davison committed 2015-08-23 21:55:16 -07:00
1 parent f8d2ecd223
commit 9d1cd2437c
1 file changed
+4 -2
+4 -2
View File
@@ -190,7 +190,7 @@ int make_path(char *fname, int flags)
if (flags & MKP_DROP_NAME) {
end = strrchr(fname, '/');
if (!end)
if (!end || end == fname)
return 0;
*end = '\0';
} else
@@ -210,8 +210,10 @@ int make_path(char *fname, int flags)
ret++;
break;
}
if (errno != ENOENT) {
if (errno != EEXIST)
STRUCT_STAT st;
if (errno != EEXIST || (do_stat(fname, &st) == 0 && !S_ISDIR(st.st_mode)))
ret = -ret - 1;
break;
}