bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Download files and preserve their data and time


From: Giuseppe Scrivano
Subject: Re: [Bug-wget] Download files and preserve their data and time
Date: Thu, 25 Aug 2011 11:51:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Ray Satiro <address@hidden> writes:

> Calling utime() works. You could also use SetFileTime(). 2489 changed utime 
> to utimes but the CRT doesn't have utimes. 

thanks to have checked it.

I am going to apply the patch below.

Cheers,
Giuseppe



=== modified file 'configure.ac'
--- configure.ac        2011-08-11 10:20:25 +0000
+++ configure.ac        2011-08-25 09:01:31 +0000
@@ -197,7 +197,7 @@
 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])

=== modified file 'src/utils.c'
--- src/utils.c 2011-08-11 12:23:39 +0000
+++ src/utils.c 2011-08-25 09:22:03 +0000
@@ -42,15 +42,23 @@
 #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 @@
 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 @@
     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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]