Set access time to current time when "touching" a file
Hrvoje Niksic <[email protected]> Thu, 05 May 2005 16:46:03 +0200
| Newsgroups | gmane.comp.web.wget.patches |
|---|---|
| Message-ID | <[email protected]> |
A Debian wishlist item asks for access time to be set to current time rather than to remote's mtime. This wishlist item could even be viewed as a (very minor) bug: why would we *ever* want access time to be set to the remote mtime? This patch should have minimum impact on Wget's behavior and I think it should be safe for 1.10. Mauro, if you disagree, please let me know and I'll back it out. 2005-05-05 Hrvoje Niksic <[email protected]> * utils.c (touch): Set access time to current time. Index: src/utils.c =================================================================== RCS file: /pack/anoncvs/wget/src/utils.c,v retrieving revision 1.96 diff -u -r1.96 utils.c --- src/utils.c 2005/04/28 13:18:30 1.96 +++ src/utils.c 2005/05/05 14:45:24 @@ -357,19 +357,23 @@ } #endif /* not WINDOWS */ -/* "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, ×) == -1) logprintf (LOG_NOTQUIET, "utime(%s): %s\n", file, strerror (errno)); }