[Gnucash-changes] r12906 - gnucash/trunk - Provide better arguments for specifying what to do when a key_file

David Hampton hampton at cvs.gnucash.org
Thu Jan 19 20:38:15 EST 2006


Author: hampton
Date: 2006-01-19 20:38:15 -0500 (Thu, 19 Jan 2006)
New Revision: 12906
Trac: http://svn.gnucash.org/trac/changeset/12906

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/app-utils/file-utils.c
   gnucash/trunk/src/app-utils/gnc-exp-parser.c
   gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c
   gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.h
Log:
Provide better arguments for specifying what to do when a key_file
doesn't exist.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-01-20 01:02:57 UTC (rev 12905)
+++ gnucash/trunk/ChangeLog	2006-01-20 01:38:15 UTC (rev 12906)
@@ -1,5 +1,10 @@
 2006-01-19  David Hampton  <hampton at employees.org>
 
+	* src/core-utils/gnc-gkeyfile-utils.[ch]:
+	* src/app-utils/file-utils.c:
+	* src/app-utils/gnc-exp-parser.c: Provide better arguments for
+	specifying what to do when a key_file doesn't exist.
+
 	* src/gnome-utils/gnc-main-window.c: Check for bogus window
 	structures (i.e. empty) when reading/writing the state file.
 

Modified: gnucash/trunk/src/app-utils/file-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/file-utils.c	2006-01-20 01:02:57 UTC (rev 12905)
+++ gnucash/trunk/src/app-utils/file-utils.c	2006-01-20 01:38:15 UTC (rev 12906)
@@ -198,7 +198,7 @@
     else
       filename = g_strdup_printf("%s_%d", original, i);
     DEBUG("Trying %s", filename);
-    key_file = gnc_key_file_load_from_file(filename, FALSE);
+    key_file = gnc_key_file_load_from_file(filename, FALSE, FALSE);
     DEBUG("Result %p", key_file);
 
     if (!key_file) {

Modified: gnucash/trunk/src/app-utils/gnc-exp-parser.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-exp-parser.c	2006-01-20 01:02:57 UTC (rev 12905)
+++ gnucash/trunk/src/app-utils/gnc-exp-parser.c	2006-01-20 01:38:15 UTC (rev 12906)
@@ -83,7 +83,7 @@
 
   if ( addPredefined ) {
     filename = gnc_exp_parser_filname();
-    key_file = gnc_key_file_load_from_file(filename, FALSE);
+    key_file = gnc_key_file_load_from_file(filename, TRUE, FALSE);
     if (key_file) {
       keys = g_key_file_get_keys(key_file, GROUP_NAME, NULL, NULL);
       for (key = keys; key && *key; key++) {

Modified: gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c	2006-01-20 01:02:57 UTC (rev 12905)
+++ gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c	2006-01-20 01:38:15 UTC (rev 12906)
@@ -46,7 +46,9 @@
 #include "gnc-gkeyfile-utils.h"
 
 GKeyFile *
-gnc_key_file_load_from_file (const gchar *filename, gboolean ignore_error)
+gnc_key_file_load_from_file (const gchar *filename,
+			     gboolean ignore_error,
+			     gboolean return_empty_struct)
 {
   GKeyFile *key_file;
   GError *error = NULL;
@@ -64,12 +66,13 @@
     return key_file;
 
   /* An error occurred */
-  if (!ignore_error) {
+  if (!return_empty_struct) {
     g_key_file_free(key_file);
     key_file = NULL;
   }
 
-  g_warning("Unable to read file %s: %s\n", filename, error->message);
+  if (!ignore_error)
+    g_warning("Unable to read file %s: %s\n", filename, error->message);
   g_error_free(error);
   return key_file;
 }

Modified: gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.h	2006-01-20 01:02:57 UTC (rev 12905)
+++ gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.h	2006-01-20 01:38:15 UTC (rev 12906)
@@ -48,15 +48,17 @@
  *  qualified path.
  *
  *  @param ignore_error If true this function will ignore any problems
- *  reading the an existing file from disk and will return a GKeyFile
- *  structure.  Set to TRUE if performing a read/modify/write on a
- *  file that may or may not already exist.
+ *  reading the an existing file from disk.
  *
- *  @return A pointer to a GKeyFile data structure, or NULL if a
- *  (non-ignored) error occurred.
+ *  @param return_empty_struct If TRUE this function will always
+ *  return a GKeyFile structure.  Set to TRUE if performing a
+ *  read/modify/write on a file that may or may not already exist.
+ *
+ *  @return A pointer to a GKeyFile data structure, or NULL.
  */
 GKeyFile *gnc_key_file_load_from_file (const gchar *file,
-				       gboolean ignore_error);
+				       gboolean ignore_error,
+				       gboolean return_empty_struct);
 
 
 /** Write a key/value file from memory to disk.  If there is no data



More information about the gnucash-changes mailing list