diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-01-29 13:54:51 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-01-29 13:54:51 -0800 |
commit | eadf313c72edcc3a11b9d03032699416efebfe1a (patch) | |
tree | 81469c8442f140d2fdc6896e17b15cf3761e1663 /src/w32.c | |
parent | 7c8b0b3644ada886dfde4032fdf38687a5968089 (diff) | |
parent | ad588afdaa166bcdacbf9f746bd4d39b2c649768 (diff) | |
download | emacs-eadf313c72edcc3a11b9d03032699416efebfe1a.tar.gz |
Merge from origin/emacs-24
ad588af Improve the fix for bug #19701
Conflicts:
src/ChangeLog
Diffstat (limited to 'src/w32.c')
-rw-r--r-- | src/w32.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/w32.c b/src/w32.c index acd06ba2601..90096689776 100644 --- a/src/w32.c +++ b/src/w32.c @@ -3434,17 +3434,30 @@ sys_readdir (DIR *dirp) if (dir_find_handle == INVALID_HANDLE_VALUE) { + /* Any changes in the value of errno here should be in sync + with what directory_files_internal does when it calls + readdir. */ switch (GetLastError ()) { - case ERROR_PATH_NOT_FOUND: + /* Windows uses this value when FindFirstFile finds no + files that match the wildcard. This is not supposed + to happen, since our wildcard is "*", but just in + case, if there's some weird empty directory with not + even "." and ".." entries... */ + case ERROR_FILE_NOT_FOUND: + errno = 0; + /* FALLTHRU */ + default: + break; case ERROR_ACCESS_DENIED: + case ERROR_NETWORK_ACCESS_DENIED: + errno = EACCES; + break; + case ERROR_PATH_NOT_FOUND: case ERROR_INVALID_DRIVE: case ERROR_BAD_NETPATH: - /* This special value will be noticed by - directory_files_internal, which see. */ - errno = ENOTDIR; - break; - default: + case ERROR_BAD_NET_NAME: + errno = ENOENT; break; } return NULL; @@ -3453,12 +3466,18 @@ sys_readdir (DIR *dirp) else if (w32_unicode_filenames) { if (!FindNextFileW (dir_find_handle, &dir_find_data_w)) - return NULL; + { + errno = 0; + return NULL; + } } else { if (!FindNextFileA (dir_find_handle, &dir_find_data_a)) - return NULL; + { + errno = 0; + return NULL; + } } /* Emacs never uses this value, so don't bother making it match @@ -3560,7 +3579,11 @@ open_unc_volume (const char *path) if (result == NO_ERROR) return henum; else - return INVALID_HANDLE_VALUE; + { + /* Make sure directory_files_internal reports a sensible error. */ + errno = ENOENT; + return INVALID_HANDLE_VALUE; + } } static void * |