comparison src/w32.c @ 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 58df3fdb731c
children
comparison
equal deleted inserted replaced
80781:5e49fbefd047 80782:a20e957dc172
2388 inode values without hacks in the main Emacs code. */ 2388 inode values without hacks in the main Emacs code. */
2389 int 2389 int
2390 stat (const char * path, struct stat * buf) 2390 stat (const char * path, struct stat * buf)
2391 { 2391 {
2392 char *name, *r; 2392 char *name, *r;
2393 char drive_root[4];
2394 UINT devtype;
2393 WIN32_FIND_DATA wfd; 2395 WIN32_FIND_DATA wfd;
2394 HANDLE fh; 2396 HANDLE fh;
2395 DWORD fake_inode; 2397 DWORD fake_inode;
2396 int permission; 2398 int permission;
2397 int len; 2399 int len;
2489 } 2491 }
2490 FindClose (fh); 2492 FindClose (fh);
2491 } 2493 }
2492 } 2494 }
2493 2495
2496 /* GetDriveType needs the root directory of NAME's drive. */
2497 if (!(strlen (name) >= 2 && IS_DEVICE_SEP (name[1])))
2498 devtype = GetDriveType (NULL); /* use root of current diectory */
2499 else
2500 {
2501 strncpy (drive_root, name, 3);
2502 drive_root[3] = '\0';
2503 devtype = GetDriveType (drive_root);
2504 }
2505
2494 if (!(NILP (Vw32_get_true_file_attributes) 2506 if (!(NILP (Vw32_get_true_file_attributes)
2495 || (EQ (Vw32_get_true_file_attributes, Qlocal) && 2507 || (EQ (Vw32_get_true_file_attributes, Qlocal) &&
2496 GetDriveType (name) != DRIVE_FIXED)) 2508 devtype != DRIVE_FIXED && devtype != DRIVE_RAMDISK))
2497 /* No access rights required to get info. */ 2509 /* No access rights required to get info. */
2498 && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING, 2510 && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING,
2499 FILE_FLAG_BACKUP_SEMANTICS, NULL)) 2511 FILE_FLAG_BACKUP_SEMANTICS, NULL))
2500 != INVALID_HANDLE_VALUE) 2512 != INVALID_HANDLE_VALUE)
2501 { 2513 {