env.c: Try create base directory on every call to env_get_dir()
Not a huge performance loss anyway. And the directory may be deleted between calls so. However the directory can still be missing as soon as the mkdir() call has ended. Doing it this way just means that if the directory is removed during execution of the program, it will be created again and not make the rest of the programs lifetime live without it.
This commit is contained in:
parent
b967d1b147
commit
deef8a6c1a
1 changed files with 5 additions and 5 deletions
4
env.c
4
env.c
|
|
@ -44,12 +44,12 @@ static void get_base() {
|
|||
|
||||
const char* env_get_dir() {
|
||||
|
||||
if (!base) {
|
||||
if (!base)
|
||||
get_base();
|
||||
|
||||
if (mkdir(base, 0700) < 0 && errno != EEXIST) {
|
||||
fatal("Unable to create '%s': %s\n",
|
||||
base, strerror(errno));
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue