summaryrefslogtreecommitdiff
path: root/walls_conf.c
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2009-12-24 05:07:09 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2009-12-24 05:07:09 +0100
commit78e1dc3199ff8408ea7e297ff5f985ee29938ea8 (patch)
treec82618798d53b5da734a9b1abb43319c73b0e826 /walls_conf.c
parent211177a9747939002f8e7da1d569a5551c4e0600 (diff)
Check for and create the config directory if necessary.
Diffstat (limited to 'walls_conf.c')
-rw-r--r--walls_conf.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/walls_conf.c b/walls_conf.c
index 7ef3a8d..9eb4fdc 100644
--- a/walls_conf.c
+++ b/walls_conf.c
@@ -1,9 +1,13 @@
+#include <unistd.h>
+
+#include <glib/gstdio.h>
#include "walls_conf.h"
GKeyFile *keyfile = NULL;
void conf_open() {
gchar *filename;
+ gchar *confdir;
GError *error = NULL;
keyfile = g_key_file_new();
@@ -13,9 +17,14 @@ void conf_open() {
}
filename = g_strdup_printf("%s/walls/config", g_get_user_config_dir());
+ confdir = g_path_get_dirname(filename);
+ if(g_access(confdir, F_OK) == -1) {
+ g_mkdir_with_parents(confdir, 0700);
+ }
+ g_free(confdir);
if(!g_key_file_load_from_file(keyfile, filename, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) {
- g_warning("%s", error->message);
+ g_warning("Can't read config: %s", error->message);
g_error_free(error);
}
@@ -29,7 +38,7 @@ gint conf_get_int(const gchar *group_name, const gchar *key, gint _default) {
ret = g_key_file_get_integer(keyfile, group_name, key, &error);
if(ret == 0) {
- g_warning("%s", error->message);
+ g_warning("Can't get key from config: %s", error->message);
g_error_free(error);
return _default;
}