From 93008cfc3e60b09e12fc3e1220602cab3a40b652 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 12 Apr 2023 09:43:23 +0200 Subject: [PATCH] New function f_ctime(). --- data.c | 13 +++++++++++++ snac.h | 1 + 2 files changed, 14 insertions(+) diff --git a/data.c b/data.c index 50a484f..96ec7f0 100644 --- a/data.c +++ b/data.c @@ -249,6 +249,19 @@ double mtime_nl(const char *fn, int *n_link) } +double f_ctime(const char *fn) +/* returns the ctime of a file or directory, or 0.0 */ +{ + struct stat st; + double r = 0.0; + + if (fn && stat(fn, &st) != -1) + r = (double) st.st_ctim.tv_sec; + + return r; +} + + /** database 2.1+ **/ /** indexes **/ diff --git a/snac.h b/snac.h index 6cd16d4..570f5cc 100644 --- a/snac.h +++ b/snac.h @@ -60,6 +60,7 @@ void srv_archive_error(const char *prefix, const xs_str *err, double mtime_nl(const char *fn, int *n_link); #define mtime(fn) mtime_nl(fn, NULL) +double f_ctime(const char *fn); int index_add(const char *fn, const char *md5); int index_gc(const char *fn);