mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Doesn't use access to check if a directory exists.
This commit is contained in:
parent
2378de67dd
commit
d6c3b1b326
1 changed files with 9 additions and 4 deletions
13
util.c
13
util.c
|
|
@ -678,9 +678,14 @@ int mkancestor(const char* file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (access(dir, F_OK) == 0) {
|
||||
/* the directory/file exists */
|
||||
return 0;
|
||||
/* try creating it */
|
||||
if (mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) {
|
||||
/* if it already exists, we are done */
|
||||
if (errno == EEXIST) {
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, "Error creating directory '%s'. %s.\n", dir, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* recursively create them all */
|
||||
|
|
@ -693,7 +698,7 @@ int mkancestor(const char* file)
|
|||
fprintf(stderr, "Error creating directory '%s'. %s.\n", dir, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue