[svn] Set access time to current time when "touching" the file.

This commit is contained in:
hniksic 2005-05-05 07:47:48 -07:00
parent 486d672e99
commit 4810f65361
2 changed files with 14 additions and 6 deletions

View 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

View File

@ -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, &times) == -1)
logprintf (LOG_NOTQUIET, "utime(%s): %s\n", file, strerror (errno));
}