aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@nuclecu.unam.mx>1998-11-12 08:32:45 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-11-12 08:32:45 +0800
commit1fa38d37db36871b9c9b252c66bbba66087c6a99 (patch)
treef47a35212453ded5c981062475ad036829298160 /calendar
parentc5cb76042a816d51c017d6b709d1c2485a47ff6b (diff)
downloadgsoc2013-evolution-1fa38d37db36871b9c9b252c66bbba66087c6a99.tar
gsoc2013-evolution-1fa38d37db36871b9c9b252c66bbba66087c6a99.tar.gz
gsoc2013-evolution-1fa38d37db36871b9c9b252c66bbba66087c6a99.tar.bz2
gsoc2013-evolution-1fa38d37db36871b9c9b252c66bbba66087c6a99.tar.lz
gsoc2013-evolution-1fa38d37db36871b9c9b252c66bbba66087c6a99.tar.xz
gsoc2013-evolution-1fa38d37db36871b9c9b252c66bbba66087c6a99.tar.zst
gsoc2013-evolution-1fa38d37db36871b9c9b252c66bbba66087c6a99.zip
Backup the old file before saving the caledar.
1998-11-11 Miguel de Icaza <miguel@nuclecu.unam.mx> * calendar.c (calendar_save): Backup the old file before saving the caledar. svn path=/trunk/; revision=467
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog5
-rw-r--r--calendar/calendar.c12
-rw-r--r--calendar/gui/calendar.c12
3 files changed, 27 insertions, 2 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 1fac39dcf4..8d57719093 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,8 @@
+1998-11-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
+
+ * calendar.c (calendar_save): Backup the old file before saving
+ the caledar.
+
1998-11-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* calobj.c: Add ctype.h
diff --git a/calendar/calendar.c b/calendar/calendar.c
index 963f91be06..374fb6874a 100644
--- a/calendar/calendar.c
+++ b/calendar/calendar.c
@@ -13,7 +13,7 @@
*/
#include <config.h>
-
+#include <unistd.h>
#include "alarm.h"
#include "calendar.h"
#include "timeutil.h"
@@ -338,7 +338,17 @@ calendar_save (Calendar *cal, char *fname)
addVObjectProp (vcal, obj);
}
+ if (g_file_exists (fname)){
+ char *backup_name = g_copy_strings (fname, "~", NULL);
+
+ if (g_file_exists (backup_name)){
+ unlink (backup_name);
+ }
+ rename (fname, backup_name);
+ g_free (backup_name);
+ }
writeVObjectToFile (fname, vcal);
+
cleanVObject (vcal);
cleanStrTbl ();
}
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 963f91be06..374fb6874a 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -13,7 +13,7 @@
*/
#include <config.h>
-
+#include <unistd.h>
#include "alarm.h"
#include "calendar.h"
#include "timeutil.h"
@@ -338,7 +338,17 @@ calendar_save (Calendar *cal, char *fname)
addVObjectProp (vcal, obj);
}
+ if (g_file_exists (fname)){
+ char *backup_name = g_copy_strings (fname, "~", NULL);
+
+ if (g_file_exists (backup_name)){
+ unlink (backup_name);
+ }
+ rename (fname, backup_name);
+ g_free (backup_name);
+ }
writeVObjectToFile (fname, vcal);
+
cleanVObject (vcal);
cleanStrTbl ();
}