]> sjero.net Git - wget/commitdiff
[svn] Set access time to current time when "touching" the file.
authorhniksic <devnull@localhost>
Thu, 5 May 2005 14:47:48 +0000 (07:47 -0700)
committerhniksic <devnull@localhost>
Thu, 5 May 2005 14:47:48 +0000 (07:47 -0700)
src/ChangeLog
src/utils.c

index 1c444eb34af47ea725f9e29ac6de9e88441f53ec..1f094d012f98acfbcc13dd61ffc466b11f8a56f9 100644 (file)
@@ -1,3 +1,7 @@
+2005-05-05  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * utils.c (touch): Set access time to current time.
+
 2005-05-05  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * url.c (url_unescape): Don't unescape %00, it effectively
index 4315c36de784b7b69237a4d40c7a48448cc3cbd5..e09a2355c7e1950274fa9ae4f76c3de200c01eaf 100644 (file)
@@ -357,19 +357,23 @@ fork_to_background (void)
 }
 #endif /* not WINDOWS */
 \f
-/* "Touch" FILE, i.e. make its atime and mtime equal to the time
-   specified with TM.  */
+/* "Touch" FILE, i.e. make its mtime ("modified time") equal the time
+   specified with TM.  The atime ("access time") is set to the current
+   time.  */
+
 void
 touch (const char *file, time_t tm)
 {
 #ifdef HAVE_STRUCT_UTIMBUF
   struct utimbuf times;
-  times.actime = times.modtime = tm;
 #else
-  time_t times[2];
-  times[0] = times[1] = tm;
+  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));
 }