+2011-08-25 Giuseppe Scrivano <gscrivano@gnu.org>
+
+ * configure.ac: Check for `utime'.
+
2011-08-11 Giuseppe Scrivano <gscrivano@gnu.org>
* bootstrap.conf (gnulib_modules): Add `sigprocmask'.
AC_FUNC_FSEEKO
AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48)
AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
-AC_CHECK_FUNCS(sleep symlink)
+AC_CHECK_FUNCS(sleep symlink utime)
if test x"$ENABLE_OPIE" = xyes; then
AC_LIBOBJ([ftp-opie])
+2011-08-25 Giuseppe Scrivano <gscrivano@gnu.org>
+
+ * utils.c [HAVE_UTIME && HAVE_UTIME_H]: Include <utime.h>.
+ [HAVE_UTIME && HAVE_SYS_UTIME_H]: Include <sys/utime.h>.
+ (touch) [HAVE_UTIME: Prefers utime over futimens when it is available.
+ It was reported that Cygwin has a not working futimens.
+
2011-08-19 Giuseppe Scrivano <gscrivano@gnu.org>
* init.c (home_dir) [MSDOS]: Move local variable `len' here.
#ifdef HAVE_PROCESS_H
# include <process.h> /* getpid() */
#endif
-#ifdef HAVE_UTIME_H
-# include <utime.h>
-#endif
#include <errno.h>
#include <fcntl.h>
#include <assert.h>
#include <stdarg.h>
#include <locale.h>
+#if HAVE_UTIME
+# include <sys/types.h>
+# ifdef HAVE_UTIME_H
+# include <utime.h>
+# endif
+
+# ifdef HAVE_SYS_UTIME_H
+# include <sys/utime.h>
+# endif
+#endif
+
#include <sys/stat.h>
/* For TIOCGWINSZ and friends: */
void
touch (const char *file, time_t tm)
{
+#if HAVE_UTIME
+# ifdef HAVE_STRUCT_UTIMBUF
+ struct utimbuf times;
+# else
+ struct {
+ time_t actime;
+ time_t modtime;
+ } times;
+# endif
+ times.modtime = tm;
+ times.actime = time (NULL);
+ if (utime (file, ×) == -1)
+ logprintf (LOG_NOTQUIET, "utime(%s): %s\n", file, strerror (errno));
+#else
struct timespec timespecs[2];
int fd;
logprintf (LOG_NOTQUIET, "futimens(%s): %s\n", file, strerror (errno));
close (fd);
+#endif
}
/* Checks if FILE is a symbolic link, and removes it if it is. Does