From 621b3351798f5c78c5907bcfbc10217a63c4ae3f Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Tue, 19 Apr 2011 11:24:33 +0200 Subject: Return -1 in io_file_is_empty() if file cannot be accessed. Ensure files don't appear as empty if fopen() fails (e.g. on temporary EACCES failures). Signed-off-by: Lukas Fleischer --- src/day.c | 2 +- src/io.c | 2 +- src/todo.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/day.c b/src/day.c index 1bcbaef..0ad9438 100644 --- a/src/day.c +++ b/src/day.c @@ -1048,7 +1048,7 @@ day_edit_note (char *editor) (void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, p->note); wins_launch_external (fullname, editor); - if (io_file_is_empty (fullname)) + if (io_file_is_empty (fullname) > 0) erase_note (&p->note, ERASE_FORCE); date = calendar_get_slctd_day_sec (); diff --git a/src/io.c b/src/io.c index bad6cf4..63e9d22 100644 --- a/src/io.c +++ b/src/io.c @@ -3085,5 +3085,5 @@ io_file_is_empty (char *file) } } - return 1; + return -1; } diff --git a/src/todo.c b/src/todo.c index 47c5ea2..9ea066d 100644 --- a/src/todo.c +++ b/src/todo.c @@ -468,7 +468,7 @@ todo_edit_note (char *editor) (void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note); wins_launch_external (fullname, editor); - if (io_file_is_empty (fullname)) + if (io_file_is_empty (fullname) > 0) erase_note (&i->note, ERASE_FORCE); } -- cgit v1.2.3-54-g00ecf