comparison src/rcfile.c @ 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 ff8b802eac58
children a336b5545af6
comparison
equal deleted inserted replaced
740:9b0ac8d58c89 741:0e8b802e54d5
290 *----------------------------------------------------------------------------- 290 *-----------------------------------------------------------------------------
291 * save configuration (public) 291 * save configuration (public)
292 *----------------------------------------------------------------------------- 292 *-----------------------------------------------------------------------------
293 */ 293 */
294 294
295 void save_options(void) 295 static gboolean save_options_to(const gchar *utf8_path)
296 { 296 {
297 SecureSaveInfo *ssi; 297 SecureSaveInfo *ssi;
298 gchar *rc_path;
299 gchar *rc_pathl; 298 gchar *rc_pathl;
300 gint i; 299 gint i;
301 300
302 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL); 301 rc_pathl = path_from_utf8(utf8_path);
303
304 rc_pathl = path_from_utf8(rc_path);
305 ssi = secure_open(rc_pathl); 302 ssi = secure_open(rc_pathl);
306 g_free(rc_pathl); 303 g_free(rc_pathl);
307 if (!ssi) 304 if (!ssi)
308 { 305 {
309 log_printf(_("error saving config file: %s\n"), rc_path); 306 log_printf(_("error saving config file: %s\n"), utf8_path);
310 g_free(rc_path); 307 return FALSE;
311 return;
312 } 308 }
313 309
314 #define WRITE_BOOL(_name_) write_bool_option(ssi, #_name_, options->_name_) 310 #define WRITE_BOOL(_name_) write_bool_option(ssi, #_name_, options->_name_)
315 #define WRITE_INT(_name_) write_int_option(ssi, #_name_, options->_name_) 311 #define WRITE_INT(_name_) write_int_option(ssi, #_name_, options->_name_)
316 #define WRITE_UINT(_name_) write_uint_option(ssi, #_name_, options->_name_) 312 #define WRITE_UINT(_name_) write_uint_option(ssi, #_name_, options->_name_)
587 secure_fprintf(ssi, "# end of config file #\n"); 583 secure_fprintf(ssi, "# end of config file #\n");
588 secure_fprintf(ssi, "######################################################################\n"); 584 secure_fprintf(ssi, "######################################################################\n");
589 585
590 586
591 if (secure_close(ssi)) 587 if (secure_close(ssi))
592 log_printf(_("error saving config file: %s\nerror: %s\n"), rc_path, 588 {
593 secsave_strerror(secsave_errno)); 589 log_printf(_("error saving config file: %s\nerror: %s\n"), utf8_path,
594 590 secsave_strerror(secsave_errno));
591 return FALSE;
592 }
593
594 return TRUE;
595 }
596
597 void save_options(void)
598 {
599 gchar *rc_path;
600
601 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
602 save_options_to(rc_path);
595 g_free(rc_path); 603 g_free(rc_path);
596 } 604 }
605
606
597 607
598 /* 608 /*
599 *----------------------------------------------------------------------------- 609 *-----------------------------------------------------------------------------
600 * load configuration (public) 610 * load configuration (public)
601 *----------------------------------------------------------------------------- 611 *-----------------------------------------------------------------------------