1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Prefers utime over futimens when available.

This commit is contained in:
Giuseppe Scrivano 2011-08-25 11:41:51 +02:00
parent 2158e58bc1
commit 5e3c9b55f2
4 changed files with 38 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2011-08-25 Giuseppe Scrivano <gscrivano@gnu.org>
* configure.ac: Check for `utime'.
2011-08-11 Giuseppe Scrivano <gscrivano@gnu.org>
* bootstrap.conf (gnulib_modules): Add `sigprocmask'.

View File

@ -197,7 +197,7 @@ AC_FUNC_MMAP
AC_FUNC_FSEEKO
AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48)
AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
AC_CHECK_FUNCS(sleep symlink)
AC_CHECK_FUNCS(sleep symlink utime)
if test x"$ENABLE_OPIE" = xyes; then
AC_LIBOBJ([ftp-opie])

View File

@ -1,3 +1,10 @@
2011-08-25 Giuseppe Scrivano <gscrivano@gnu.org>
* utils.c [HAVE_UTIME && HAVE_UTIME_H]: Include <utime.h>.
[HAVE_UTIME && HAVE_SYS_UTIME_H]: Include <sys/utime.h>.
(touch) [HAVE_UTIME: Prefers utime over futimens when it is available.
It was reported that Cygwin has a not working futimens.
2011-08-19 Giuseppe Scrivano <gscrivano@gnu.org>
* init.c (home_dir) [MSDOS]: Move local variable `len' here.

View File

@ -42,15 +42,23 @@ as that of the covered work. */
#ifdef HAVE_PROCESS_H
# include <process.h> /* getpid() */
#endif
#ifdef HAVE_UTIME_H
# include <utime.h>
#endif
#include <errno.h>
#include <fcntl.h>
#include <assert.h>
#include <stdarg.h>
#include <locale.h>
#if HAVE_UTIME
# include <sys/types.h>
# ifdef HAVE_UTIME_H
# include <utime.h>
# endif
# ifdef HAVE_SYS_UTIME_H
# include <sys/utime.h>
# endif
#endif
#include <sys/stat.h>
/* For TIOCGWINSZ and friends: */
@ -487,6 +495,20 @@ 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;
@ -506,6 +528,7 @@ touch (const char *file, time_t tm)
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