]> sjero.net Git - wget/commitdiff
Prefers utime over futimens when available.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 25 Aug 2011 09:41:51 +0000 (11:41 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 25 Aug 2011 09:41:51 +0000 (11:41 +0200)
ChangeLog
configure.ac
src/ChangeLog
src/utils.c

index 6372d51e313c46795bc3bf77a3d4f5ff3296ee66..b461e9398b5da7fc4c63e0b4c8a6ee1c97b9e7ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+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'.
 2011-08-11  Giuseppe Scrivano  <gscrivano@gnu.org>
 
        * bootstrap.conf (gnulib_modules): Add `sigprocmask'.
index b9ccbfef3c53b70ba28b4679b8011103d2f83d97..c26c93ecc1e40d4840a2e0d88bff9035a5eec42a 100644 (file)
@@ -197,7 +197,7 @@ AC_FUNC_MMAP
 AC_FUNC_FSEEKO
 AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48)
 AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
 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])
 
 if test x"$ENABLE_OPIE" = xyes; then
   AC_LIBOBJ([ftp-opie])
index 8e9572f235b47ae1ddcacbba3e760a6a78089ebd..fe03b7bf26ef77bf13c96f6cf7a7656d56517aa6 100644 (file)
@@ -1,3 +1,10 @@
+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.
 2011-08-19  Giuseppe Scrivano  <gscrivano@gnu.org>
 
        * init.c (home_dir) [MSDOS]: Move local variable `len' here.
index 7d4834fba4e42bc93549d6fe2aec8e04f6a13ca1..4950ab2ea392f1223bb98a809d7472e0eb91e89a 100644 (file)
@@ -42,15 +42,23 @@ as that of the covered work.  */
 #ifdef HAVE_PROCESS_H
 # include <process.h>  /* getpid() */
 #endif
 #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>
 
 #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: */
 #include <sys/stat.h>
 
 /* For TIOCGWINSZ and friends: */
@@ -487,6 +495,20 @@ fork_to_background (void)
 void
 touch (const char *file, time_t tm)
 {
 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, &times) == -1)
+    logprintf (LOG_NOTQUIET, "utime(%s): %s\n", file, strerror (errno));
+#else
   struct timespec timespecs[2];
   int fd;
 
   struct timespec timespecs[2];
   int fd;
 
@@ -506,6 +528,7 @@ touch (const char *file, time_t tm)
     logprintf (LOG_NOTQUIET, "futimens(%s): %s\n", file, strerror (errno));
 
   close (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
 }
 
 /* Checks if FILE is a symbolic link, and removes it if it is.  Does