changeset 80782:a20e957dc172

(stat): Only root directory passed to GetDriveType. Allow RAM disk as well as local fixed disk when w32-get-true-file-attributes is set to `local'.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 30 Aug 2008 10:54:06 +0000
parents 5e49fbefd047
children bfd66bd99699
files src/w32.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32.c	Sat Aug 30 08:38:14 2008 +0000
+++ b/src/w32.c	Sat Aug 30 10:54:06 2008 +0000
@@ -2390,6 +2390,8 @@
 stat (const char * path, struct stat * buf)
 {
   char *name, *r;
+  char drive_root[4];
+  UINT devtype;
   WIN32_FIND_DATA wfd;
   HANDLE fh;
   DWORD fake_inode;
@@ -2491,9 +2493,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))
+	    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))