diff --git a/src/ChangeLog b/src/ChangeLog index 1c444eb3..1f094d01 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2005-05-05 Hrvoje Niksic + + * utils.c (touch): Set access time to current time. + 2005-05-05 Hrvoje Niksic * url.c (url_unescape): Don't unescape %00, it effectively diff --git a/src/utils.c b/src/utils.c index 4315c36d..e09a2355 100644 --- a/src/utils.c +++ b/src/utils.c @@ -357,19 +357,23 @@ fork_to_background (void) } #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)); }