Fix "no member named 'st_atim' in 'struct stat'" on macOS
Advanced PNG optimization program
Status: Beta
Brought to you by:
cosmin
On macOS (10.12.5), compiling the default branch (19:a9d8ace0ee2f) results in:
src/optk/io.c:768:25: error: no member named 'st_atim' in 'struct stat' times[0] = sbuf.st_atim; ~~~~ ^ src/optk/io.c:769:25: error: no member named 'st_mtim' in 'struct stat' times[1] = sbuf.st_mtim; ~~~~ ^ 2 errors generated.
This is because AT_FDCWD is defined on macOS, but there are no st_atim and st_mtim in struct stat, only st_atime, st_mtime, st_atimespec, and st_mtimespec. (I'm attaching the stat.2 man page).
The attached patch simply tests APPLE before using st_atim and st_mtim.
I think a better fix is to do something like this:
The reason is on MacOSX 10.13 High Sierra,
utimensat()
exists and itstimes
param expects nanosecond precision time fromtimespec
'stv_nsec
. The supplied patch assumes none of the MacOS versions haveutimensat()
, this is no longer true.