Fix: macOS uses st_ctimespec instead of st_ctim

This commit is contained in:
Nikita Ivanov 2023-03-16 22:11:59 +01:00
parent fbf7f938fb
commit 2936aba143
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

View File

@ -144,10 +144,18 @@ static RESULT is_newer(int *resp, char *f1, char *f2)
ERRCHK_RET_ERN(lstat(f1, &stat1) == -1);
ERRCHK_RET_ERN(lstat(f2, &stat2) == -1);
int sec_d = stat1.st_ctim.tv_sec - stat2.st_ctim.tv_sec;
#if __APPLE__
struct timespec *t1 = &stat1.st_ctimespec;
struct timespec *t2 = &stat2.st_ctimespec;
#else
struct timespec *t1 = &stat1.st_ctim;
struct timespec *t2 = &stat2.st_ctim;
#endif
time_t sec_d = t1->tv_sec - t2->tv_sec;
if (sec_d < 0)
goto older;
else if (sec_d == 0 && stat1.st_ctim.tv_nsec <= stat2.st_ctim.tv_nsec)
else if (sec_d == 0 && t1->tv_nsec <= t2->tv_nsec)
goto older;
*resp = 1;