diff options
author | default <nobody@localhost> | 2023-04-13 09:46:05 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-04-13 09:46:05 +0200 |
commit | e47cb4f9e19656a56a2bd8a7106b9970f7434b1f (patch) | |
tree | d29dc79c10597b8a22e645341a2c136e522f8275 /data.c | |
parent | 963f2cf79a48ae311c6133ca96ddbcb9a985a07d (diff) |
f_ctime() returns the oldest of ctime and mtime.
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -249,14 +249,19 @@ double mtime_nl(const char *fn, int *n_link) } +#define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2)) + 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; + if (fn && stat(fn, &st) != -1) { + /* return the lowest of ctime and mtime; + there are operations that change the ctime, like link() */ + r = (double) MIN(st.st_ctim.tv_sec, st.st_mtim.tv_sec); + } return r; } |