Archived
1
0
Fork 0

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:
Henrik Hautakoski 2012-07-22 19:31:19 +02:00
parent b967d1b147
commit deef8a6c1a

10
env.c
View file

@ -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));
}
if (mkdir(base, 0700) < 0 && errno != EEXIST) {
fatal("Unable to create '%s': %s\n",
base, strerror(errno));
}
return base;
}