mirror of
https://github.com/mirror/wget.git
synced 2025-01-06 02:10:28 +08:00
[svn] Set access time to current time when "touching" the file.
This commit is contained in:
parent
486d672e99
commit
4810f65361
@ -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
|
||||
|
16
src/utils.c
16
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user