Mercurial > emacs
comparison src/w32.c @ 103859:fe78cff95301
(logon_network_drive): Don't assume PATH is an absolute file name.
(is_slow_fs): New function.
(stat): Use it to determine whether to issue more system calls to get
accurate file attributes, when w32-get-true-file-attributes is `local'.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 11 Jul 2009 15:44:36 +0000 |
parents | 5b3dd5ad8689 |
children | b2b6dc6a2417 |
comparison
equal
deleted
inserted
replaced
103858:e94bd524533d | 103859:fe78cff95301 |
---|---|
2553 { | 2553 { |
2554 NETRESOURCE resource; | 2554 NETRESOURCE resource; |
2555 char share[MAX_PATH]; | 2555 char share[MAX_PATH]; |
2556 int i, n_slashes; | 2556 int i, n_slashes; |
2557 char drive[4]; | 2557 char drive[4]; |
2558 | 2558 UINT drvtype; |
2559 sprintf (drive, "%c:\\", path[0]); | 2559 |
2560 if (IS_DIRECTORY_SEP (path[0]) && IS_DIRECTORY_SEP (path[1])) | |
2561 drvtype = DRIVE_REMOTE; | |
2562 else if (path[0] == '\0' || path[1] != ':') | |
2563 drvtype = GetDriveType (NULL); | |
2564 else | |
2565 { | |
2566 drive[0] = path[0]; | |
2567 drive[1] = ':'; | |
2568 drive[2] = '\\'; | |
2569 drive[3] = '\0'; | |
2570 drvtype = GetDriveType (drive); | |
2571 } | |
2560 | 2572 |
2561 /* Only logon to networked drives. */ | 2573 /* Only logon to networked drives. */ |
2562 if ((!IS_DIRECTORY_SEP (path[0]) || !IS_DIRECTORY_SEP (path[1])) | 2574 if (drvtype != DRIVE_REMOTE) |
2563 && GetDriveType (drive) != DRIVE_REMOTE) | |
2564 return; | 2575 return; |
2565 | 2576 |
2566 n_slashes = 2; | 2577 n_slashes = 2; |
2567 strncpy (share, path, MAX_PATH); | 2578 strncpy (share, path, MAX_PATH); |
2568 /* Truncate to just server and share name. */ | 2579 /* Truncate to just server and share name. */ |
3232 st->st_gid = dflt_passwd.pw_gid; | 3243 st->st_gid = dflt_passwd.pw_gid; |
3233 strcpy (st->st_gname, dflt_group.gr_name); | 3244 strcpy (st->st_gname, dflt_group.gr_name); |
3234 } | 3245 } |
3235 } | 3246 } |
3236 | 3247 |
3248 /* Return non-zero if NAME is a potentially slow filesystem. */ | |
3249 int | |
3250 is_slow_fs (const char *name) | |
3251 { | |
3252 char drive_root[4]; | |
3253 UINT devtype; | |
3254 | |
3255 if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1])) | |
3256 devtype = DRIVE_REMOTE; /* assume UNC name is remote */ | |
3257 else if (!(strlen (name) >= 2 && IS_DEVICE_SEP (name[1]))) | |
3258 devtype = GetDriveType (NULL); /* use root of current drive */ | |
3259 else | |
3260 { | |
3261 /* GetDriveType needs the root directory of the drive. */ | |
3262 strncpy (drive_root, name, 2); | |
3263 drive_root[2] = '\\'; | |
3264 drive_root[3] = '\0'; | |
3265 devtype = GetDriveType (drive_root); | |
3266 } | |
3267 return !(devtype == DRIVE_FIXED || devtype == DRIVE_RAMDISK); | |
3268 } | |
3269 | |
3237 /* MSVC stat function can't cope with UNC names and has other bugs, so | 3270 /* MSVC stat function can't cope with UNC names and has other bugs, so |
3238 replace it with our own. This also allows us to calculate consistent | 3271 replace it with our own. This also allows us to calculate consistent |
3239 inode values without hacks in the main Emacs code. */ | 3272 inode values without hacks in the main Emacs code. */ |
3240 int | 3273 int |
3241 stat (const char * path, struct stat * buf) | 3274 stat (const char * path, struct stat * buf) |
3345 } | 3378 } |
3346 FindClose (fh); | 3379 FindClose (fh); |
3347 } | 3380 } |
3348 } | 3381 } |
3349 | 3382 |
3350 if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1])) | |
3351 devtype = DRIVE_REMOTE; /* assume UNC name is remote */ | |
3352 else if (!(strlen (name) >= 2 && IS_DEVICE_SEP (name[1]))) | |
3353 devtype = GetDriveType (NULL); /* use root of current drive */ | |
3354 else | |
3355 { | |
3356 /* GetDriveType needs the root directory of NAME's drive. */ | |
3357 strncpy (drive_root, name, 3); | |
3358 drive_root[3] = '\0'; | |
3359 devtype = GetDriveType (drive_root); | |
3360 } | |
3361 | |
3362 if (!(NILP (Vw32_get_true_file_attributes) | 3383 if (!(NILP (Vw32_get_true_file_attributes) |
3363 || (EQ (Vw32_get_true_file_attributes, Qlocal) | 3384 || (EQ (Vw32_get_true_file_attributes, Qlocal) && !is_slow_fs (name))) |
3364 && devtype != DRIVE_FIXED && devtype != DRIVE_RAMDISK)) | |
3365 /* No access rights required to get info. */ | 3385 /* No access rights required to get info. */ |
3366 && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING, | 3386 && (fh = CreateFile (name, 0, 0, NULL, OPEN_EXISTING, |
3367 FILE_FLAG_BACKUP_SEMANTICS, NULL)) | 3387 FILE_FLAG_BACKUP_SEMANTICS, NULL)) |
3368 != INVALID_HANDLE_VALUE) | 3388 != INVALID_HANDLE_VALUE) |
3369 { | 3389 { |