summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-07-16 23:22:36 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-07-16 23:31:31 +0200
commit5aec5408950ed41fad203e749bda225bd3f86a8b (patch)
tree87e49708cb0ab6d8ca92484ac331cd6a42a166a6 /src/io.c
parente93030befb2aebe94faf5c5455313d312611d7b3 (diff)
downloadcalcurse-5aec5408950ed41fad203e749bda225bd3f86a8b.zip
Allow for merging data files when reloading
This allows for merging the (unsaved) items with the items from the data files when invoking the reload operation. To this end, an external merge tool (defaults to vimdiff) is used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/io.c b/src/io.c
index acf624b..f24b0f7 100644
--- a/src/io.c
+++ b/src/io.c
@@ -319,12 +319,22 @@ void io_extract_data(char *dst_data, const char *org, int len)
static pthread_mutex_t io_save_mutex = PTHREAD_MUTEX_INITIALIZER;
+void io_save_mutex_lock(void)
+{
+ pthread_mutex_lock(&io_save_mutex);
+}
+
+void io_save_mutex_unlock(void)
+{
+ pthread_mutex_unlock(&io_save_mutex);
+}
+
/*
* Save the apts data file, which contains the
* appointments first, and then the events.
* Recursive items are written first.
*/
-unsigned io_save_apts(void)
+unsigned io_save_apts(const char *aptsfile)
{
llist_item_t *i;
FILE *fp;
@@ -332,7 +342,7 @@ unsigned io_save_apts(void)
if (read_only)
return 1;
- if ((fp = fopen(path_apts, "w")) == NULL)
+ if ((fp = fopen(aptsfile, "w")) == NULL)
return 0;
recur_save_data(fp);
@@ -356,7 +366,7 @@ unsigned io_save_apts(void)
}
/* Save the todo data file. */
-unsigned io_save_todo(void)
+unsigned io_save_todo(const char *todofile)
{
llist_item_t *i;
FILE *fp;
@@ -364,7 +374,7 @@ unsigned io_save_todo(void)
if (read_only)
return 1;
- if ((fp = fopen(path_todo, "w")) == NULL)
+ if ((fp = fopen(todofile, "w")) == NULL)
return 0;
LLIST_FOREACH(&todolist, i) {
@@ -419,12 +429,12 @@ void io_save_cal(enum save_display display)
if (show_bar)
progress_bar(PROGRESS_BAR_SAVE, PROGRESS_BAR_TODO);
- if (!io_save_todo())
+ if (!io_save_todo(path_todo))
ERROR_MSG("%s", access_pb);
if (show_bar)
progress_bar(PROGRESS_BAR_SAVE, PROGRESS_BAR_APTS);
- if (!io_save_apts())
+ if (!io_save_apts(path_apts))
ERROR_MSG("%s", access_pb);
if (show_bar)