Closed GerbilSoft closed 2 years ago
Thanks for the patch.
Seems like it would be cleaner to use utimensat() instead of futimens(), though?
As it would save the overhead having to open file...
Should be able to simply do something like the following?
if (utimensat(AT_FDCWD, outfile, time_save, 0) != 0)
warn("failed to reset output file time/date");
Yeah, that should work. I didn't see that particular part of the documentation for utimensat(), so I didn't realize dirfd wasn't required.
Will update this and push the changes.
Thanks, I merged the change to use utimensat().
Can you explain what the configure change is doing exactly?
I didn't notice any problem doing "out-of-tree" build without this change...
mkdir /tmp/build
cd /tmp/build
${HOME}/src/jpegoptim/configure
make
When I tried an out-of-tree build, I ended up getting this error:
$ ../configure
$ make
gcc -g -O2 -DHAVE_CONFIG_H -c -o jpegoptim.o ../jpegoptim.c
../jpegoptim.c:13:10: fatal error: config.h: No such file or directory
13 | #include "config.h"
| ^~~~~~~~~~
compilation terminated.
make: *** [<builtin>: jpegoptim.o] Error 1
config.h is located in the build directory, and gcc doesn't add the current directory to the include path on my system.
Also, I forgot to remove the HAVE_FILENO check, which isn't needed with utimensat().
Odd, I can't seem to replicate that behavior. Does the generated Makefile contain correct VPATH setting? (and you're using GNU Make?)
$ mkdir build
$ cd build
$ ../configure
$ make
gcc -g -O2 -DHAVE_CONFIG_H -c -o jpegoptim.o ../jpegoptim.c
gcc -g -O2 -DHAVE_CONFIG_H -c -o jpegdest.o ../jpegdest.c
gcc -g -O2 -DHAVE_CONFIG_H -c -o misc.o ../misc.c
gcc -g -O2 -DHAVE_CONFIG_H -o jpegoptim jpegoptim.o jpegdest.o misc.o -lm -ljpeg
jpegoptim's
-p
option currently only preserves timestamps at a 1-second resolution. This PR makes use ofstat.st_mtim
andfutimens()
to preserve nanosecond-resolution timestamps.