]> git.eshelyaron.com Git - emacs.git/commitdiff
(stat): Only root directory passed to GetDriveType.
authorEli Zaretskii <eliz@gnu.org>
Fri, 15 Aug 2008 13:54:14 +0000 (13:54 +0000)
committerEli Zaretskii <eliz@gnu.org>
Fri, 15 Aug 2008 13:54:14 +0000 (13:54 +0000)
src/ChangeLog
src/w32.c

index 1576266855e815d2aa0126907143934e2f295df9..2af33df079b0d7bcf663fac33c2e16544dfdb5a9 100644 (file)
@@ -3,6 +3,9 @@
        * w32.c (_MEMORY_STATUS_EX, MEMORY_STATUS_EX, LPMEMORY_STATUS_EX):
        Rename from _MEMORYSTATUSEX, MEMORYSTATUSEX, LPMEMORYSTATUSEX.
        All users changed.
+       (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'.
 
 2008-08-14  Lawrence Mitchell  <wence@gmx.li>
 
index cf4bd7bec714a192ce8b1b4e3756d643a3105a55..ddb48981c5849cd8c1e058387d27e35193fe7519 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -2879,6 +2879,8 @@ int
 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 @@ stat (const char * path, struct stat * buf)
        }
     }
 
+  /* 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))