mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-26 01:03:37 +00:00
f_ctime() returns the oldest of ctime and mtime.
This commit is contained in:
parent
963f2cf79a
commit
e47cb4f9e1
1 changed files with 7 additions and 2 deletions
9
data.c
9
data.c
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue