]> sjero.net Git - wget/commitdiff
Use futimens instead of utimes.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Tue, 19 Apr 2011 10:33:46 +0000 (12:33 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Tue, 19 Apr 2011 10:33:46 +0000 (12:33 +0200)
bootstrap.conf
src/ChangeLog
src/Makefile.am
src/utils.c
tests/ChangeLog
tests/Makefile.am

index 76de9805492bbc0dad688854c3c70e73627b5ad7..0b16175fe2817bdb1b14e2d7d7c3fa61a75c1bae 100644 (file)
@@ -30,9 +30,11 @@ alloca
 announce-gen
 bind
 c-ctype
+clock-time
 close
 connect
 fcntl
+futimens
 getaddrinfo
 getopt-gnu
 getpass-gnu
index 19d5f4bfa7839a8c952dad6a38a3033254a90428..1bbc6acc0f4691d6f7cbdcb16933e7b7a0c8b6ae 100644 (file)
@@ -1,5 +1,9 @@
 2011-04-19  Giuseppe Scrivano  <gscrivano@gnu.org>
 
+       * Makefile.am (LIBS): Add $(LIB_CLOCK_GETTIME)
+       * utils.c: Include <sys/stat.h>.  Do not include <sys/time.h>.
+       (touch): Use `futimens' instead of `utimes'.
+
        * mswindows.h: Do not include <direct.h>.  Remove macro definition for
        mkdir.
 
index 6a3e9947c849befd8b8102e0fd74dc1b01534ab3..a7bcbf8734371b66b8011f1df08d59a0e412c164 100644 (file)
@@ -37,7 +37,7 @@ endif
 
 # The following line is losing on some versions of make!
 DEFS     = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\"
-LIBS     = @LIBICONV@ @LIBINTL@ @LIBS@
+LIBS     = @LIBICONV@ @LIBINTL@ @LIBS@ $(LIB_CLOCK_GETTIME)
 
 bin_PROGRAMS = wget
 wget_SOURCES = cmpt.c connect.c convert.c cookies.c ftp.c                \
index 634e41ffec0b3b296be0c039957cebd79c84cc03..352cdb7b5afc14f02b5f40c7dc85f95d502af5b0 100644 (file)
@@ -51,8 +51,7 @@ as that of the covered work.  */
 #include <stdarg.h>
 #include <locale.h>
 
-#include <sys/time.h>
-
+#include <sys/stat.h>
 
 /* For TIOCGWINSZ and friends: */
 #ifdef HAVE_SYS_IOCTL_H
@@ -488,15 +487,25 @@ fork_to_background (void)
 void
 touch (const char *file, time_t tm)
 {
-  struct timeval timevals[2];
+  struct timespec timespecs[2];
+  int fd;
+
+  fd = open (file, O_WRONLY);
+  if (fd < 0)
+    {
+      logprintf (LOG_NOTQUIET, "open(%s): %s\n", file, strerror (errno));
+      return;
+    }
+
+  timespecs[0].tv_sec = time (NULL);
+  timespecs[0].tv_nsec = 0L;
+  timespecs[1].tv_sec = tm;
+  timespecs[1].tv_nsec = 0L;
 
-  timevals[0].tv_sec = time (NULL);
-  timevals[0].tv_usec = 0L;
-  timevals[1].tv_sec = tm;
-  timevals[1].tv_usec = 0L;
+  if (futimens (fd, timespecs) == -1)
+    logprintf (LOG_NOTQUIET, "futimens(%s): %s\n", file, strerror (errno));
 
-  if (utimes (file, timevals) == -1)
-    logprintf (LOG_NOTQUIET, "utimes(%s): %s\n", file, strerror (errno));
+  close (fd);
 }
 
 /* Checks if FILE is a symbolic link, and removes it if it is.  Does
index 9c8531642187a8dc54d982c214a6559788859b8e..1995c8265612a47b10774e597187922c5b33a201 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-19  Giuseppe Scrivano  <gscrivano@gnu.org>
+
+       * Makefile.am (LIBS): Add $(LIB_CLOCK_GETTIME).
+
 2011-04-04  Giuseppe Scrivano  <gscrivano@gnu.org>
 
        * Makefile.am (LIBS): Remove  @LIBSSL@ @W32LIBS@
index c27e3903dbdbf94ec44bc39d5fc50c28c4ac7be8..ccd274d15c1af2a164c788a49d0c019e482a73ec 100644 (file)
@@ -34,7 +34,7 @@
 PERL     = perl
 PERLRUN = $(PERL) -I$(srcdir)
 
-LIBS     = @LIBICONV@ @LIBINTL@ @LIBS@
+LIBS     = @LIBICONV@ @LIBINTL@ @LIBS@ $(LIB_CLOCK_GETTIME)
 
 .PHONY: test run-unit-tests run-px-tests