summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-13 09:46:05 +0200
committerGravatar default2023-04-13 09:46:05 +0200
commite47cb4f9e19656a56a2bd8a7106b9970f7434b1f (patch)
treed29dc79c10597b8a22e645341a2c136e522f8275
parentUpdated RELEASE_NOTES. (diff)
downloadpenes-snac2-e47cb4f9e19656a56a2bd8a7106b9970f7434b1f.tar.gz
penes-snac2-e47cb4f9e19656a56a2bd8a7106b9970f7434b1f.tar.xz
penes-snac2-e47cb4f9e19656a56a2bd8a7106b9970f7434b1f.zip
f_ctime() returns the oldest of ctime and mtime.
-rw-r--r--data.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/data.c b/data.c
index bfbf26a..b375cb2 100644
--- a/data.c
+++ b/data.c
@@ -249,14 +249,19 @@ double mtime_nl(const char *fn, int *n_link)
249} 249}
250 250
251 251
252#define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))
253
252double f_ctime(const char *fn) 254double f_ctime(const char *fn)
253/* returns the ctime of a file or directory, or 0.0 */ 255/* returns the ctime of a file or directory, or 0.0 */
254{ 256{
255 struct stat st; 257 struct stat st;
256 double r = 0.0; 258 double r = 0.0;
257 259
258 if (fn && stat(fn, &st) != -1) 260 if (fn && stat(fn, &st) != -1) {
259 r = (double) st.st_ctim.tv_sec; 261 /* return the lowest of ctime and mtime;
262 there are operations that change the ctime, like link() */
263 r = (double) MIN(st.st_ctim.tv_sec, st.st_mtim.tv_sec);
264 }
260 265
261 return r; 266 return r;
262} 267}