mirror of
git://git.suckless.org/sbase
synced 2024-12-23 07:25:07 +00:00
mkdir -p: Fail if argument exists, but is not a directory
If it is a directory, we can just return straightaway.
This commit is contained in:
parent
e795946971
commit
6ac5f01cc9
@ -10,6 +10,15 @@ int
|
||||
mkdirp(const char *path)
|
||||
{
|
||||
char tmp[PATH_MAX], *p;
|
||||
struct stat st;
|
||||
|
||||
if (stat(path, &st) == 0) {
|
||||
if (S_ISDIR(st.st_mode))
|
||||
return 0;
|
||||
errno = ENOTDIR;
|
||||
weprintf("%s:", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
estrlcpy(tmp, path, sizeof(tmp));
|
||||
for (p = tmp + (tmp[0] == '/'); *p; p++) {
|
||||
|
Loading…
Reference in New Issue
Block a user