From 95213c9cdb04d1791d55c231331467edce9ab722 Mon Sep 17 00:00:00 2001 From: Vasily_Makarov Date: Wed, 19 Oct 2011 23:49:08 +0400 Subject: Correct config loading/saving --- saedit/config.c | 11 +++++++---- saedit/config.h | 7 ++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/saedit/config.c b/saedit/config.c index 98a1325..f28ab54 100644 --- a/saedit/config.c +++ b/saedit/config.c @@ -56,10 +56,13 @@ void config_keys_save(Keys *keys) { POSTFIX_FOLDER, NULL)); g_key_file_set_boolean(key_file, "General", "ShowGrid", keys->show_grid); - g_file_set_contents(KEYS_CONFIG_FILE, - g_key_file_to_data(key_file, NULL, NULL), - -1, - NULL); + + mkdir(KEYS_CONFIG_DIR, S_IRWXU); + int fd = g_creat(KEYS_CONFIG_FILE, S_IREAD | S_IWRITE); + gchar *buf = g_key_file_to_data(key_file, NULL, NULL); + write(fd, buf, strlen(buf), NULL); + close(fd); + g_key_file_free(key_file); } diff --git a/saedit/config.h b/saedit/config.h index e7c5fb5..e8e064a 100644 --- a/saedit/config.h +++ b/saedit/config.h @@ -14,6 +14,10 @@ #include #include +#include +#include +#include +#include #include "common.h" #include "xml.h" @@ -21,7 +25,8 @@ #define KEY_SHOW_GRID_DEFAULT TRUE #define KEY_CLIENTDATA_FOLDER_DEFAULT "" -#define KEYS_CONFIG_FILE g_strjoin(SEPARATOR_SLASH, g_get_user_config_dir(), "saedit/config.ini", NULL) +#define KEYS_CONFIG_DIR g_strjoin(SEPARATOR_SLASH, g_get_user_config_dir(), "saedit", NULL) +#define KEYS_CONFIG_FILE g_strjoin(SEPARATOR_SLASH, KEYS_CONFIG_DIR, "config.ini", NULL) typedef struct { gchar *sprites; -- cgit v1.2.3-70-g09d2