aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/w32.c b/src/w32.c
index aedf64942e0..2faa742f9d7 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3433,17 +3433,30 @@ sys_readdir (DIR *dirp)
3433 3433
3434 if (dir_find_handle == INVALID_HANDLE_VALUE) 3434 if (dir_find_handle == INVALID_HANDLE_VALUE)
3435 { 3435 {
3436 /* Any changes in the value of errno here should be in sync
3437 with what directory_files_internal does when it calls
3438 readdir. */
3436 switch (GetLastError ()) 3439 switch (GetLastError ())
3437 { 3440 {
3438 case ERROR_PATH_NOT_FOUND: 3441 /* Windows uses this value when FindFirstFile finds no
3442 files that match the wildcard. This is not supposed
3443 to happen, since our wildcard is "*", but just in
3444 case, if there's some weird empty directory with not
3445 even "." and ".." entries... */
3446 case ERROR_FILE_NOT_FOUND:
3447 errno = 0;
3448 /* FALLTHRU */
3449 default:
3450 break;
3439 case ERROR_ACCESS_DENIED: 3451 case ERROR_ACCESS_DENIED:
3452 case ERROR_NETWORK_ACCESS_DENIED:
3453 errno = EACCES;
3454 break;
3455 case ERROR_PATH_NOT_FOUND:
3440 case ERROR_INVALID_DRIVE: 3456 case ERROR_INVALID_DRIVE:
3441 case ERROR_BAD_NETPATH: 3457 case ERROR_BAD_NETPATH:
3442 /* This special value will be noticed by 3458 case ERROR_BAD_NET_NAME:
3443 directory_files_internal, which see. */ 3459 errno = ENOENT;
3444 errno = ENOTDIR;
3445 break;
3446 default:
3447 break; 3460 break;
3448 } 3461 }
3449 return NULL; 3462 return NULL;
@@ -3452,12 +3465,18 @@ sys_readdir (DIR *dirp)
3452 else if (w32_unicode_filenames) 3465 else if (w32_unicode_filenames)
3453 { 3466 {
3454 if (!FindNextFileW (dir_find_handle, &dir_find_data_w)) 3467 if (!FindNextFileW (dir_find_handle, &dir_find_data_w))
3455 return NULL; 3468 {
3469 errno = 0;
3470 return NULL;
3471 }
3456 } 3472 }
3457 else 3473 else
3458 { 3474 {
3459 if (!FindNextFileA (dir_find_handle, &dir_find_data_a)) 3475 if (!FindNextFileA (dir_find_handle, &dir_find_data_a))
3460 return NULL; 3476 {
3477 errno = 0;
3478 return NULL;
3479 }
3461 } 3480 }
3462 3481
3463 /* Emacs never uses this value, so don't bother making it match 3482 /* Emacs never uses this value, so don't bother making it match
@@ -3559,7 +3578,11 @@ open_unc_volume (const char *path)
3559 if (result == NO_ERROR) 3578 if (result == NO_ERROR)
3560 return henum; 3579 return henum;
3561 else 3580 else
3562 return INVALID_HANDLE_VALUE; 3581 {
3582 /* Make sure directory_files_internal reports a sensible error. */
3583 errno = ENOENT;
3584 return INVALID_HANDLE_VALUE;
3585 }
3563} 3586}
3564 3587
3565static void * 3588static void *