summaryrefslogtreecommitdiffstats
path: root/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index 7619696..04ad99f 100644
--- a/src/io.c
+++ b/src/io.c
@@ -3040,3 +3040,28 @@ io_get_pid (char *file)
return pid;
}
+
+/*
+ * Check whether a file is empty.
+ */
+int
+io_file_is_empty (char *file)
+{
+ FILE *fp;
+
+ if (file && (fp = fopen (file, "r")))
+ {
+ if (fgetc (fp) == '\n' || feof (fp))
+ {
+ fclose (fp);
+ return 1;
+ }
+ else
+ {
+ fclose (fp);
+ return 0;
+ }
+ }
+
+ return 1;
+}