Mon, 12 Aug 2013 15:58:30 +0200
creates a .dav dir if it doesn't exist
dav/config.c | file | annotate | diff | comparison | revisions | |
dav/main.c | file | annotate | diff | comparison | revisions |
--- a/dav/config.c Mon Aug 12 15:34:40 2013 +0200 +++ b/dav/config.c Mon Aug 12 15:58:30 2013 +0200 @@ -29,7 +29,10 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> +#include <sys/stat.h> #include <ucx/map.h> +#include <errno.h> #include <libxml/tree.h> #include "config.h" @@ -40,9 +43,24 @@ static UcxMap *repos; static UcxMap *keys; +int check_config_dir() { + char *file = util_concat_path(getenv("HOME"), ".dav"); + int ret = 0; + if(mkdir(file, S_IRWXU)) { + if(errno != EEXIST) { + ret = 1; + } + } + free(file); + return ret; +} + void load_config() { repos = ucx_map_new(16); keys = ucx_map_new(16); + if(check_config_dir()) { + return; + } char *file = util_concat_path(getenv("HOME"), ".dav/config.xml"); xmlDoc *doc = xmlReadFile(file, NULL, 0);