From 1fa38d37db36871b9c9b252c66bbba66087c6a99 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 12 Nov 1998 00:32:45 +0000 Subject: Backup the old file before saving the caledar. 1998-11-11 Miguel de Icaza * calendar.c (calendar_save): Backup the old file before saving the caledar. svn path=/trunk/; revision=467 --- calendar/ChangeLog | 5 +++++ calendar/calendar.c | 12 +++++++++++- calendar/gui/calendar.c | 12 +++++++++++- 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 + + * calendar.c (calendar_save): Backup the old file before saving + the caledar. + 1998-11-06 Miguel de Icaza * 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 - +#include #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 - +#include #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 (); } -- cgit v1.2.3