1
0
mirror of https://github.com/mirror/wget.git synced 2025-03-31 14:40:18 +08:00

Use gnulib's utime()

* bootstrap.conf: Add modules utime and utime-h
* src/utils.c (touch): Remove own code for gnulib's utime()
This commit is contained in:
Tim Rühsen 2018-02-08 21:31:37 +01:00
parent c722973212
commit 9887b870d1
2 changed files with 4 additions and 29 deletions

View File

@ -113,6 +113,8 @@ update-copyright
libunistring-optional
unistr/u8-strlen
unicase/u8-tolower
utime
utime-h
utimens
vasprintf
vsnprintf

View File

@ -529,40 +529,13 @@ fork_to_background (void)
void
touch (const char *file, time_t tm)
{
#if HAVE_UTIME
# ifdef HAVE_STRUCT_UTIMBUF
struct utimbuf times;
# else
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));
#else
struct timespec timespecs[2];
int fd;
fd = open (file, O_WRONLY);
if (fd < 0)
{
logprintf (LOG_NOTQUIET, "open(%s): %s\n", file, strerror (errno));
return;
}
timespecs[0].tv_sec = time (NULL);
timespecs[0].tv_nsec = 0L;
timespecs[1].tv_sec = tm;
timespecs[1].tv_nsec = 0L;
if (futimens (fd, timespecs) == -1)
logprintf (LOG_NOTQUIET, "futimens(%s): %s\n", file, strerror (errno));
close (fd);
#endif
}
/* Checks if FILE is a symbolic link, and removes it if it is. Does