changeset 97488:caf9103a3856

(stat): Only root directory passed to GetDriveType.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 15 Aug 2008 13:52:30 +0000
parents 999b2122b66c
children 72743054422c
files src/w32.c
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32.c	Fri Aug 15 12:49:09 2008 +0000
+++ b/src/w32.c	Fri Aug 15 13:52:30 2008 +0000
@@ -2879,6 +2879,8 @@
 stat (const char * path, struct stat * buf)
 {
   char *name, *r;
+  char drive_root[4];
+  UINT devtype;
   WIN32_FIND_DATA wfd;
   HANDLE fh;
   unsigned __int64 fake_inode;
@@ -2983,9 +2985,19 @@
 	}
     }
 
+  /* GetDriveType needs the root directory of NAME's drive.  */
+  if (!(strlen (name) >= 2 && IS_DEVICE_SEP (name[1])))
+    devtype = GetDriveType (NULL); /* use root of current diectory */
+  else
+    {
+      strncpy (drive_root, name, 3);
+      drive_root[3] = '\0';
+      devtype = GetDriveType (drive_root);
+    }
+
   if (!(NILP (Vw32_get_true_file_attributes)
-	|| (EQ (Vw32_get_true_file_attributes, Qlocal) &&
-	    GetDriveType (name) != DRIVE_FIXED))
+	|| (EQ (Vw32_get_true_file_attributes, Qlocal)
+	    && devtype != DRIVE_FIXED && devtype != DRIVE_RAMDISK))
       /* No access rights required to get info.  */
       && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING,
 			   FILE_FLAG_BACKUP_SEMANTICS, NULL))