]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
RT #1667. File modification dates were wrong due to the isc_time_set routine not...
authorDanny Mayer <source@isc.org>
Thu, 30 Aug 2001 04:31:31 +0000 (04:31 +0000)
committerDanny Mayer <source@isc.org>
Thu, 30 Aug 2001 04:31:31 +0000 (04:31 +0000)
lib/isc/win32/file.c
lib/isc/win32/time.c

index 790c3439f857e99f6ca39def1933f417401df94d..3802e62b05f95a4a868e97417cc9823e0566b518 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: file.c,v 1.20 2001/07/17 20:29:26 gson Exp $ */
+/* $Id: file.c,v 1.21 2001/08/30 04:31:30 mayer Exp $ */
 
 #include <config.h>
 
@@ -220,33 +220,34 @@ isc_file_getmodtime(const char *file, isc_time_t *time) {
 
 isc_result_t
 isc_file_settime(const char *file, isc_time_t *time) {
-       struct utimbuf timem;
+       int fh;
 
        REQUIRE(file != NULL && time != NULL);
 
-       /*
-        * tv_sec is at least a 32 bit quantity on all platforms we're
-        * dealing with, but it is signed on most (all?) of them,
-        * so we need to make sure the high bit isn't set.  This unfortunately
-        * loses when either:
-        *   * tv_sec becomes a signed 64 bit integer but long is 32 bits
-        *      and isc_time_seconds > LONG_MAX, or
-        *   * isc_time_seconds is changed to be > 32 bits but long is 32 bits
-        *      and isc_time_seconds has at least 33 significant bits.
-        */
-       timem.actime = timem.modtime = (long)isc_time_seconds(time);
-
-       /*
-        * Here is the real check for the high bit being set.
-        */
-       if ((timem.actime &
-            (1UL << (sizeof(timem.actime) * CHAR_BIT - 1))) != 0)
-               return (ISC_R_RANGE);
+//     updtime.absolute.dwLowDateTime = time->absolute.dwLowDateTime;
+//     updtime.absolute.dwHighDateTime = time->absolute.dwHighDateTime;
 
-       if (utime(file, &timem) < 0)
+       if ((fh = open(file, _O_RDWR | _O_BINARY)) < 0)
                return (isc__errno2result(errno));
 
-       return (ISC_R_SUCCESS);
+        /* set the date via the filedate system call and return. failing
+         * this call implies the new file times are not supported by the
+         * underlying file system.
+         */
+
+       if (!SetFileTime((HANDLE) _get_osfhandle(fh),
+                                NULL,
+                                &time->absolute,
+                                &time->absolute
+                               ))
+        {
+               close(fh);
+                errno = EINVAL;
+                return (isc__errno2result(errno));
+        }
+
+       close(fh);
+        return (ISC_R_SUCCESS);
 
 }
 
index 8203106fbb134c376ab1afbc819194ca9582c069..2c1e0a45f8cfee91b7a02171743504d840ea7d8b 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: time.c,v 1.24 2001/08/29 05:13:42 mayer Exp $ */
+/* $Id: time.c,v 1.25 2001/08/30 04:31:31 mayer Exp $ */
 
 /*
  * Windows has a different epoch than Unix. Therefore this code sets the epoch
@@ -108,8 +108,10 @@ isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
        i.QuadPart = (LONGLONG)seconds * INTERVALS_PER_S
                + nanoseconds / NS_INTERVAL;
 
-       t->absolute.dwLowDateTime = i.LowPart;
-       t->absolute.dwHighDateTime = i.HighPart;
+       t->absolute.dwLowDateTime = i.LowPart
+                                 + epoch.absolute.dwLowDateTime;
+       t->absolute.dwHighDateTime = i.HighPart
+                                  + epoch.absolute.dwHighDateTime;
 
 }