summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2008-12-28 19:41:24 +0100
committerBenjamin Otte <otte@gnome.org>2008-12-28 19:41:24 +0100
commitb509c65c4828bb1795b0090bebd8f96ac868a479 (patch)
tree93adfd1fd10a7278129d6d80af0d50842c463b35
parent91e38e66bd1f046f00014ee4c5cc1836e60783ef (diff)
create the config directory if it doesn't exist yet
-rw-r--r--src/swfmoz_config.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/swfmoz_config.c b/src/swfmoz_config.c
index 10685e3..c197604 100644
--- a/src/swfmoz_config.c
+++ b/src/swfmoz_config.c
@@ -21,6 +21,8 @@
#include "config.h"
#endif
+#include <glib/gstdio.h>
+
#include "swfmoz_config.h"
G_DEFINE_TYPE (SwfmozConfig, swfmoz_config, G_TYPE_OBJECT)
@@ -40,13 +42,18 @@ swfmoz_config_save_file (SwfmozConfig *config)
SWFMOZ_CONFIG_FILE, NULL);
data = g_key_file_to_data (config->keyfile, &data_size, &error);
- if (error) {
+ if (error)
goto fail;
- }
- g_file_set_contents (keyfile_name, data, data_size, &error);
- if (error) {
- goto fail;
+ if (!g_file_set_contents (keyfile_name, data, data_size, &error)) {
+ /* try creating the config directory if it doesn't exist yet */
+ if (g_mkdir_with_parents (g_get_user_config_dir (), 0700) == 0) {
+ g_error_free (error);
+ if (!g_file_set_contents (keyfile_name, data, data_size, &error))
+ goto fail;
+ } else {
+ goto fail;
+ }
}
g_free (data);