aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 ();
}