[grisbi-cvs] grisbi/src gsb_file_load.c,1.177,1.178

Pierre Biava pbiava at users.sourceforge.net
Sat May 23 23:29:03 CEST 2009


Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7444

Modified Files:
	gsb_file_load.c 
Log Message:
rewrite the function gsb_file_load_copy_old_file ()

Index: gsb_file_load.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_load.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -d -r1.177 -r1.178
--- gsb_file_load.c	23 May 2009 19:25:10 -0000	1.177
+++ gsb_file_load.c	23 May 2009 21:29:00 -0000	1.178
@@ -87,7 +87,7 @@
 static gboolean gsb_file_load_check_new_structure ( gchar *file_content );
 static void gsb_file_load_color_part ( const gchar **attribute_names,
                         const gchar **attribute_values );
-static gboolean gsb_file_load_copy_old_file_and_glib ( gchar *filename, gchar *file_content);
+static void gsb_file_load_copy_old_file ( gchar *filename, gchar *file_content);
 static void gsb_file_load_currency ( const gchar **attribute_names,
                         const gchar **attribute_values );
 static void gsb_file_load_currency_link ( const gchar **attribute_names,
@@ -345,13 +345,8 @@
         else
         {
             /* copy of an old file grisbi */
-//~ #if GLIB_CHECK_VERSION(2,18,0)
-        //~ if ( ! gsb_file_load_copy_old_file ( filename ) )
-            //~ return FALSE;
-//~ # else
-            if ( ! gsb_file_load_copy_old_file_and_glib ( filename, file_content ) )
-            return FALSE;
-//~ #endif
+            gsb_file_load_copy_old_file ( filename, file_content );
+
             /* fill the GMarkupParser for the last xml structure */
             markup_parser -> start_element = (void *) gsb_file_load_start_element_before_0_6;
             markup_parser -> end_element = (void *) gsb_file_load_end_element_before_0_6;
@@ -7908,13 +7903,11 @@
  *
  * \return TRUE : ok, FALSE : problem
  * */
-/*gboolean gsb_file_load_copy_old_file ( gchar *filename )
+
+void gsb_file_load_copy_old_file ( gchar *filename, gchar *file_content)
 {
     if ( g_str_has_suffix (filename, ".gsb" ) )
     {
-        gchar *new_filename;
-        GFile * file_ori;
-        GFile * file_copy;
         GError * error = NULL;
 
         copy_old_filename = g_path_get_basename ( filename );
@@ -7923,31 +7916,22 @@
         copy_old_filename = g_build_filename ( G_DIR_SEPARATOR_S, 
                         my_get_XDG_grisbi_data_dir (),
                         copy_old_filename, NULL );
+
+#if GLIB_CHECK_VERSION (2,18,0)
+        GFile * file_ori;
+        GFile * file_copy;
+
         file_ori = g_file_new_for_path ( filename );
         file_copy = g_file_new_for_path ( copy_old_filename );
         if ( !g_file_copy ( file_ori, file_copy, G_FILE_COPY_OVERWRITE, 
                         NULL, NULL, NULL, &error ) )
             dialogue_error (error -> message );
-    }
-    return TRUE;
-} */
-
-gboolean gsb_file_load_copy_old_file_and_glib ( gchar *filename, gchar *file_content)
-{
-    if ( g_str_has_suffix (filename, ".gsb" ) )
-    {
-        GError * error = NULL;
-
-        copy_old_filename = g_path_get_basename ( filename );
-        copy_old_filename = gsb_string_remplace_string ( copy_old_filename, ".gsb",
-                        "-old-version.gsb" );
-        copy_old_filename = g_build_filename ( G_DIR_SEPARATOR_S, 
-                        my_get_XDG_grisbi_data_dir (),
-                        copy_old_filename, NULL );
+#else
         if ( ! g_file_set_contents ( copy_old_filename, file_content,-1, &error ) )
             dialogue_error (error -> message );
+#endif
+        g_free ( copy_old_filename );
     }
-    return TRUE;
 }
 /* Local Variables: */
 /* c-basic-offset: 4 */



More information about the cvs mailing list