commit e47cb4f
default
·
2023-04-13 07:46:05 +0000 UTC
parent 963f2cf
f_ctime() returns the oldest of ctime and mtime.
1 files changed,
+7,
-2
M
data.c
M
data.c
+7,
-2
1@@ -249,14 +249,19 @@ double mtime_nl(const char *fn, int *n_link)
2 }
3
4
5+#define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))
6+
7 double f_ctime(const char *fn)
8 /* returns the ctime of a file or directory, or 0.0 */
9 {
10 struct stat st;
11 double r = 0.0;
12
13- if (fn && stat(fn, &st) != -1)
14- r = (double) st.st_ctim.tv_sec;
15+ if (fn && stat(fn, &st) != -1) {
16+ /* return the lowest of ctime and mtime;
17+ there are operations that change the ctime, like link() */
18+ r = (double) MIN(st.st_ctim.tv_sec, st.st_mtim.tv_sec);
19+ }
20
21 return r;
22 }