From deef8a6c1ab07a140ced5a760ceaebcc8876a75f Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 22 Jul 2012 19:31:19 +0200 Subject: [PATCH] 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. --- env.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/env.c b/env.c index 1755970..f5841d2 100644 --- a/env.c +++ b/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)); - } + + if (mkdir(base, 0700) < 0 && errno != EEXIST) { + fatal("Unable to create '%s': %s\n", + base, strerror(errno)); } return base; }