Mercurial > hg > octave-lyh > gnulib-hg
changeset 6283:b377d8796118
* lib/utimens.c (futimens): Use futimesat if available.
Prefer it to futimes since it doesn't have the futimes bug.
* m4/utimens.m4 (gl_UTIMENS): Check for futimesat.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 23 Sep 2005 19:18:06 +0000 |
parents | ad1b37bff099 |
children | 9500c37faeb5 |
files | lib/utimens.c m4/utimens.m4 |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/utimens.c +++ b/lib/utimens.c @@ -25,6 +25,7 @@ #include "utimens.h" #include <errno.h> +#include <fcntl.h> #if HAVE_UTIME_H # include <utime.h> @@ -61,7 +62,7 @@ /* There's currently no interface to set file timestamps with nanosecond resolution, so do the best we can, discarding any fractional part of the timestamp. */ -#if HAVE_WORKING_UTIMES +#if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES struct timeval timeval[2]; struct timeval const *t; if (timespec) @@ -74,7 +75,11 @@ } else t = NULL; -# if HAVE_FUTIMES + +# if HAVE_FUTIMESAT + return fd < 0 ? futimesat (AT_FDCWD, file, t) : futimesat (fd, NULL, t); +# else +# if HAVE_FUTIMES if (0 <= fd) { if (futimes (fd, t) == 0) @@ -92,8 +97,9 @@ return -1; } } +# endif + return utimes (file, t); # endif - return utimes (file, t); #else