Make mkdir -p "a/./b" work (with ".")

This commit is contained in:
Ben Gras 2005-10-10 09:02:47 +00:00
parent bd5afd235a
commit 1f497fe707

View File

@ -195,9 +195,11 @@ char *fordir;
char parent[PATH_MAX + 1], *end;
strcpy(parent, fordir);
if (!(end = strrchr(parent, '/'))) return(0);
*end = '\0';
if (!parent[0]) return(0);
do {
if (!(end = strrchr(parent, '/'))) return(0);
*end = '\0';
if (!parent[0] || !strcmp(parent, ".")) return(0);
} while((last = strrchr(parent, '/')) && !strcmp(last+1, "."));
if (!stat(parent, &st)) {
if (S_ISDIR(st.st_mode)) return(0);