]> code.delx.au - gnu-emacs/blobdiff - src/dired.c
Speed up most calls to 'stat' and 'lstat' on MS-Windows.
[gnu-emacs] / src / dired.c
index bdb71c46364f1b2de05edd3e7d4998afc879628c..85af906c1daebf24c09480ac3f48721bbfd10b7b 100644 (file)
@@ -895,6 +895,7 @@ so last access time will always be midnight of that day.  */)
   Lisp_Object dirname;
   struct stat sdir;
 #endif /* BSD4_2 */
+  int lstat_result;
 
   /* An array to hold the mode string generated by filemodestring,
      including its terminating space and null byte.  */
@@ -922,7 +923,21 @@ so last access time will always be midnight of that day.  */)
   encoded = ENCODE_FILE (filename);
   UNGCPRO;
 
-  if (lstat (SSDATA (encoded), &s) < 0)
+#ifdef WINDOWSNT
+  /* We usually don't request accurate owner and group info, because
+     it can be very expensive on Windows to get that, and most callers
+     of 'lstat' don't need that.  But here we do want that information
+     to be accurate.  */
+  w32_stat_get_owner_group = 1;
+#endif
+
+  lstat_result = lstat (SSDATA (encoded), &s);
+
+#ifdef WINDOWSNT
+  w32_stat_get_owner_group = 0;
+#endif
+
+  if (lstat_result < 0)
     return Qnil;
 
   values[0] = (S_ISLNK (s.st_mode) ? Ffile_symlink_p (filename)