changeset 741:0e8b802e54d5

Move code from save_options() to new save_options_to() which takes the destination path as parameter.
author zas_
date Thu, 22 May 2008 23:17:26 +0000
parents 9b0ac8d58c89
children a336b5545af6
files src/rcfile.c
diffstat 1 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/rcfile.c	Thu May 22 23:09:53 2008 +0000
+++ b/src/rcfile.c	Thu May 22 23:17:26 2008 +0000
@@ -292,23 +292,19 @@
  *-----------------------------------------------------------------------------
  */
 
-void save_options(void)
+static gboolean save_options_to(const gchar *utf8_path)
 {
 	SecureSaveInfo *ssi;
-	gchar *rc_path;
 	gchar *rc_pathl;
 	gint i;
 
-	rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
-
-	rc_pathl = path_from_utf8(rc_path);
+	rc_pathl = path_from_utf8(utf8_path);
 	ssi = secure_open(rc_pathl);
 	g_free(rc_pathl);
 	if (!ssi)
 		{
-		log_printf(_("error saving config file: %s\n"), rc_path);
-		g_free(rc_path);
-		return;
+		log_printf(_("error saving config file: %s\n"), utf8_path);
+		return FALSE;
 		}
 
 #define WRITE_BOOL(_name_) write_bool_option(ssi, #_name_, options->_name_)
@@ -589,12 +585,26 @@
 
 
 	if (secure_close(ssi))
-		log_printf(_("error saving config file: %s\nerror: %s\n"), rc_path,
-			    secsave_strerror(secsave_errno));
+		{
+		log_printf(_("error saving config file: %s\nerror: %s\n"), utf8_path,
+			   secsave_strerror(secsave_errno));
+		return FALSE;
+		}
 
+	return TRUE;
+}
+
+void save_options(void)
+{
+	gchar *rc_path;
+
+	rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
+	save_options_to(rc_path);
 	g_free(rc_path);
 }
 
+
+
 /*
  *-----------------------------------------------------------------------------
  * load configuration (public)