diff options
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c index 0926848..ab5f2e7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -222,7 +222,7 @@ load_project_config_file (GError **error) // which is completely undocumented g_key_file_load_from_dirs (key_file, PROJECT_NAME G_DIR_SEPARATOR_S PROJECT_NAME ".conf", - paths, NULL, 0, &e); + paths, NULL, G_KEY_FILE_KEEP_COMMENTS, &e); g_free (paths); if (!e) return key_file; @@ -236,6 +236,25 @@ load_project_config_file (GError **error) return NULL; } +gboolean +save_project_config_file (GKeyFile *key_file, GError **error) +{ + gchar *dirname = + g_build_filename (g_get_user_config_dir (), PROJECT_NAME, NULL); + (void) g_mkdir_with_parents (dirname, 0755); + gchar *path = g_build_filename (dirname, PROJECT_NAME ".conf", NULL); + g_free (dirname); + + gsize length = 0; + gchar *data = g_key_file_to_data (key_file, &length, error); + if (!data) + return FALSE; + + gboolean result = g_file_set_contents (path, data, length, error); + g_free (data); + return result; +} + // --- Loading ----------------------------------------------------------------- void |