store all templates in a subdirectory

This commit is contained in:
Martin Willi
2009-04-07 13:06:33 +00:00
parent 5ec7ff5675
commit 58da11911b
+6 -1
View File
@@ -30,6 +30,7 @@
#define PERME (S_IRWXU | S_IRWXG) #define PERME (S_IRWXU | S_IRWXG)
#define GUEST_DIR "guests" #define GUEST_DIR "guests"
#define TEMPLATE_DIR "templates"
typedef struct private_dumm_t private_dumm_t; typedef struct private_dumm_t private_dumm_t;
@@ -165,7 +166,11 @@ static bool load_template(private_dumm_t *this, char *dir)
return FALSE; return FALSE;
} }
this->template = strdup(dir); if (asprintf(&this->template, "%s/%s", TEMPLATE_DIR, dir) < 0)
{
this->template = NULL;
return FALSE;
}
if (access(this->template, F_OK) != 0) if (access(this->template, F_OK) != 0)
{ /* does not exist, create template */ { /* does not exist, create template */
if (!mkdir_p(this->template, PERME)) if (!mkdir_p(this->template, PERME))