aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-util.c
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@novell.com>2007-12-05 23:11:26 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2007-12-05 23:11:26 +0800
commit08380ae64ec3d29f1335ce1d1a4a7b601be7903d (patch)
tree0ca7262699f9cbc0b70e559611b1ff6c54eec305 /e-util/e-util.c
parenteeeb246bdd1de04ab60e46c95449137db5ef0d5f (diff)
downloadgsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar.gz
gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.tar.zst
gsoc2013-evolution-08380ae64ec3d29f1335ce1d1a4a7b601be7903d.zip
** Add basic support for crash recovery
2007-12-05 Srinivasa Ragavan <sragavan@novell.com> ** Add basic support for crash recovery * apps_evolution_shell.schemas.in: Keys to recover and recovery dialog. * e-shell.c: (e_shell_quit): Delete the lock while quitting. * main.c: (show_recovery_warning), (idle_cb): Create lock and also show the warning dialog. svn path=/trunk/; revision=34652
Diffstat (limited to 'e-util/e-util.c')
-rw-r--r--e-util/e-util.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 625c617a8b..b1634bcfff 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1017,3 +1017,52 @@ e_file_get_save_path (void)
return (uri);
}
+/* Evolution Locks for crash recovery */
+
+#define LOCK_FILE ".running"
+
+static const gchar *
+get_lock_filename (void)
+{
+ static gchar *filename = NULL;
+
+ if (G_UNLIKELY (filename == NULL))
+ filename = g_build_filename (g_get_home_dir (), ".evolution", LOCK_FILE, NULL);
+
+ return filename;
+}
+
+gboolean
+e_file_lock_create ()
+{
+ const char *fname = get_lock_filename ();
+ gboolean status = FALSE;
+
+ int fd = g_creat (fname, S_IRUSR|S_IWUSR);
+ if (fd == -1){
+ g_warning ("Lock file '%s' creation failed, error %d\n", fname, errno);
+ } else {
+ status = TRUE;
+ close (fd);
+ }
+
+ return status;
+}
+
+void
+e_file_lock_destroy ()
+{
+ const char *fname = get_lock_filename ();
+
+ if (g_unlink (fname) == -1){
+ g_warning ("Lock destroy: failed to unlink file '%s'!",fname);
+ }
+}
+
+gboolean
+e_file_lock_exists ()
+{
+ const char *fname = get_lock_filename ();
+
+ return g_file_test (fname, G_FILE_TEST_EXISTS);
+}