X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/fb8edc0bbd76abae0237a7a34291870b0dc9f2f7..ff5dec5cd103f6a9b030d295b014f0ff81025def:/src/w32.c diff --git a/src/w32.c b/src/w32.c index 2a7be366ae..2ff344abd6 100644 --- a/src/w32.c +++ b/src/w32.c @@ -1,6 +1,6 @@ /* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API. Copyright (C) 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009 Free Software Foundation, Inc. + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -34,6 +34,7 @@ along with GNU Emacs. If not, see . */ #include #include /* for _mbspbrk */ #include +#include /* must include CRT headers *before* config.h */ @@ -2555,12 +2556,23 @@ logon_network_drive (const char *path) char share[MAX_PATH]; int i, n_slashes; char drive[4]; + UINT drvtype; - sprintf (drive, "%c:\\", path[0]); + if (IS_DIRECTORY_SEP (path[0]) && IS_DIRECTORY_SEP (path[1])) + drvtype = DRIVE_REMOTE; + else if (path[0] == '\0' || path[1] != ':') + drvtype = GetDriveType (NULL); + else + { + drive[0] = path[0]; + drive[1] = ':'; + drive[2] = '\\'; + drive[3] = '\0'; + drvtype = GetDriveType (drive); + } /* Only logon to networked drives. */ - if ((!IS_DIRECTORY_SEP (path[0]) || !IS_DIRECTORY_SEP (path[1])) - && GetDriveType (drive) != DRIVE_REMOTE) + if (drvtype != DRIVE_REMOTE) return; n_slashes = 2; @@ -3234,6 +3246,28 @@ get_file_owner_and_group ( } } +/* Return non-zero if NAME is a potentially slow filesystem. */ +int +is_slow_fs (const char *name) +{ + char drive_root[4]; + UINT devtype; + + if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1])) + devtype = DRIVE_REMOTE; /* assume UNC name is remote */ + else if (!(strlen (name) >= 2 && IS_DEVICE_SEP (name[1]))) + devtype = GetDriveType (NULL); /* use root of current drive */ + else + { + /* GetDriveType needs the root directory of the drive. */ + strncpy (drive_root, name, 2); + drive_root[2] = '\\'; + drive_root[3] = '\0'; + devtype = GetDriveType (drive_root); + } + return !(devtype == DRIVE_FIXED || devtype == DRIVE_RAMDISK); +} + /* MSVC stat function can't cope with UNC names and has other bugs, so replace it with our own. This also allows us to calculate consistent inode values without hacks in the main Emacs code. */ @@ -3347,21 +3381,8 @@ stat (const char * path, struct stat * buf) } } - if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1])) - devtype = DRIVE_REMOTE; /* assume UNC name is remote */ - else if (!(strlen (name) >= 2 && IS_DEVICE_SEP (name[1]))) - devtype = GetDriveType (NULL); /* use root of current drive */ - else - { - /* GetDriveType needs the root directory of NAME's drive. */ - 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) - && devtype != DRIVE_FIXED && devtype != DRIVE_RAMDISK)) + || (EQ (Vw32_get_true_file_attributes, Qlocal) && is_slow_fs (name))) /* No access rights required to get info. */ && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL))