]> sourceware.org Git - newlib-cygwin.git/commitdiff
* fhandler.cc (fhandler_disk_file::fstat): Add setting access time
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 14 Nov 2001 21:47:41 +0000 (21:47 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 14 Nov 2001 21:47:41 +0000 (21:47 +0000)
and creation time to last modification time for files on filesystems
not supporting multiple timestamps.
(fhandler_disk_file::fstat_helper): Set access time and creation
time in incoming Windows structure instead of in stat buf to avoid
incorrectly overwriting Epoch timestamp.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.cc

index 7a6b73ff4f58d6b37f971156ade432607c308db2..61a68933b4a006a5423872923d87021adb85cc2a 100644 (file)
@@ -1,3 +1,12 @@
+2001-11-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler.cc (fhandler_disk_file::fstat): Add setting access time
+       and creation time to last modification time for files on filesystems 
+       not supporting multiple timestamps.
+       (fhandler_disk_file::fstat_helper): Set access time and creation
+       time in incoming Windows structure instead of in stat buf to avoid
+       incorrectly overwriting Epoch timestamp.
+
 2001-11-14  Corinna Vinschen  <corinna@vinschen.de>
 
        * winsup.h: Remove alloca definition since it's now defined through
index 9a177bd6ebd466e192d4a5a0f46134fca06085bb..7ccf0dde39c4809f676f5c40c22a0c44b5aa54e1 100644 (file)
@@ -1001,6 +1001,14 @@ fhandler_disk_file::fstat (struct stat *buf, path_conv *pc)
       if ((handle = FindFirstFile (pc->get_win32 (), &wfd))
          != INVALID_HANDLE_VALUE)
        {
+         /* This is for FAT filesystems, which don't support atime/ctime */
+         if (wfd.ftLastAccessTime.dwLowDateTime == 0
+             && wfd.ftLastAccessTime.dwHighDateTime == 0)
+           wfd.ftLastAccessTime = wfd.ftLastWriteTime;
+         if (wfd.ftCreationTime.dwLowDateTime == 0
+             && wfd.ftCreationTime.dwHighDateTime == 0)
+           wfd.ftCreationTime = wfd.ftLastWriteTime;
+
          buf->st_atime   = to_time_t (&wfd.ftLastAccessTime);
          buf->st_mtime   = to_time_t (&wfd.ftLastWriteTime);
          buf->st_ctime   = to_time_t (&wfd.ftCreationTime);
@@ -1062,6 +1070,14 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
       return -1;
     }
 
+  /* This is for FAT filesystems, which don't support atime/ctime */
+  if (local.ftLastAccessTime.dwLowDateTime == 0
+      && local.ftLastAccessTime.dwHighDateTime == 0)
+    local.ftLastAccessTime = local.ftLastWriteTime;
+  if (local.ftCreationTime.dwLowDateTime == 0
+      && local.ftCreationTime.dwHighDateTime == 0)
+    local.ftCreationTime = local.ftLastWriteTime;
+
   buf->st_atime   = to_time_t (&local.ftLastAccessTime);
   buf->st_mtime   = to_time_t (&local.ftLastWriteTime);
   buf->st_ctime   = to_time_t (&local.ftCreationTime);
@@ -1069,12 +1085,6 @@ fhandler_disk_file::fstat_helper (struct stat *buf)
   buf->st_dev     = local.dwVolumeSerialNumber;
   buf->st_size    = local.nFileSizeLow;
 
-  /* This is for FAT filesystems, which don't support atime/ctime */
-  if (buf->st_atime == 0)
-    buf->st_atime = buf->st_mtime;
-  if (buf->st_ctime == 0)
-    buf->st_ctime = buf->st_mtime;
-
   /* Allocate some place to determine the root directory. Need to allocate
      enough so that rootdir can add a trailing slash if path starts with \\. */
   char root[strlen (get_win32_name ()) + 3];
This page took 0.036541 seconds and 5 git commands to generate.