[gnome-db] gda_file_save()



Hi,

Currently gda_file_save() doesn't truncate files when saving data to
existing files.

I noticed the behaviour with these operations:

 - open gnome_database_properties;
 - save a DSN in a file using XML format;
 - save the same DSN in the same file using an other format (CSV for
example);
 - open the file with an editor, there is still XML information at the
end of the file.

Cheers,

--
Laurent
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.606
diff -u -r1.606 ChangeLog
--- ChangeLog	22 Dec 2003 13:07:02 -0000	1.606
+++ ChangeLog	27 Dec 2003 16:39:26 -0000
@@ -1,3 +1,7 @@
+2003-12-27  Laurent Sansonetti <lrz gnome org>
+
+	* libgda/gda-util.c (gda_file_save): added O_TRUNC flag.
+
 2003-12-22  Rodrigo Moya <rodrigo gnome-db org>
 
 	* libgda/gda-command.c (gda_command_copy): dont use C99.
Index: libgda/gda-util.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-util.c,v
retrieving revision 1.16
diff -u -r1.16 gda-util.c
--- libgda/gda-util.c	16 Nov 2003 01:28:36 -0000	1.16
+++ libgda/gda-util.c	27 Dec 2003 16:39:26 -0000
@@ -207,7 +207,7 @@
 	
 	g_return_val_if_fail (filename != NULL, FALSE);
 
-	fd = open (filename, O_RDWR | O_CREAT, 0644);
+	fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
 	if (fd == -1) {
 		gda_log_error (_("Could not create file %s"), filename);
 		return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]