]> sjero.net Git - wget/commitdiff
Use utimes instead of utime.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Mon, 18 Apr 2011 12:37:42 +0000 (14:37 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Mon, 18 Apr 2011 12:37:42 +0000 (14:37 +0200)
src/ChangeLog
src/utils.c

index 07c99b975341497e29e57b6026ac2d5de465e718..53db6608791c11e3f74f02a34e4499de892da6ca 100644 (file)
@@ -1,5 +1,8 @@
 2011-04-18  Giuseppe Scrivano  <gscrivano@gnu.org>
 
 2011-04-18  Giuseppe Scrivano  <gscrivano@gnu.org>
 
+       * utils.c: Include <sys/time.h>.  Do not include <sys/utime.h>.
+       (touch): Use `utimes' instead of `utime'.
+
        * openssl.c (openssl_read): Fix build error.
 
 2011-04-17  Giuseppe Scrivano  <gscrivano@gnu.org>
        * openssl.c (openssl_read): Fix build error.
 
 2011-04-17  Giuseppe Scrivano  <gscrivano@gnu.org>
index 86f4e12292c1bf47a0d485e6224638b16d3d8ebe..634e41ffec0b3b296be0c039957cebd79c84cc03 100644 (file)
@@ -35,9 +35,6 @@ as that of the covered work.  */
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
 #include <unistd.h>
 #ifdef HAVE_MMAP
 # include <sys/mman.h>
 #include <unistd.h>
 #ifdef HAVE_MMAP
 # include <sys/mman.h>
@@ -48,15 +45,15 @@ as that of the covered work.  */
 #ifdef HAVE_UTIME_H
 # include <utime.h>
 #endif
 #ifdef HAVE_UTIME_H
 # include <utime.h>
 #endif
-#ifdef HAVE_SYS_UTIME_H
-# include <sys/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>
 
+#include <sys/time.h>
+
+
 /* For TIOCGWINSZ and friends: */
 #ifdef HAVE_SYS_IOCTL_H
 # include <sys/ioctl.h>
 /* For TIOCGWINSZ and friends: */
 #ifdef HAVE_SYS_IOCTL_H
 # include <sys/ioctl.h>
@@ -491,18 +488,15 @@ fork_to_background (void)
 void
 touch (const char *file, time_t tm)
 {
 void
 touch (const char *file, time_t tm)
 {
-#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));
+  struct timeval timevals[2];
+
+  timevals[0].tv_sec = time (NULL);
+  timevals[0].tv_usec = 0L;
+  timevals[1].tv_sec = tm;
+  timevals[1].tv_usec = 0L;
+
+  if (utimes (file, timevals) == -1)
+    logprintf (LOG_NOTQUIET, "utimes(%s): %s\n", file, strerror (errno));
 }
 
 /* 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