diff options
| author | Eli Zaretskii | 2015-01-27 21:02:13 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-01-27 21:02:13 +0200 |
| commit | 9664defd262252faf037c5fe1ea095f1cc4b308b (patch) | |
| tree | 141dc6740e1de7e715ae5037fe4297a55c921dac /src | |
| parent | fd4e65e4ae76eb59a990fc72bce791a50e494338 (diff) | |
| download | emacs-9664defd262252faf037c5fe1ea095f1cc4b308b.tar.gz emacs-9664defd262252faf037c5fe1ea095f1cc4b308b.zip | |
Signal a file-error from directory-files on MS-Windows (Bug#19701)
src/dired.c (directory_files_internal) [WINDOWSNT]: If readdir
returns NULL and errno is ENOTDIR, behave as if opendir failed to
open the directory.
src/w32.c (sys_readdir): If FindFirstFile fails because the
directory doesn't exist, set errno to ENOTDIR.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/dired.c | 13 | ||||
| -rw-r--r-- | src/w32.c | 17 |
3 files changed, 38 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9cf5eb591bb..a33e834e0ec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2015-01-27 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * dired.c (directory_files_internal) [WINDOWSNT]: If readdir | ||
| 4 | returns NULL and errno is ENOTDIR, behave as if opendir failed to | ||
| 5 | open the directory. (Bug#19701) | ||
| 6 | |||
| 7 | * w32.c (sys_readdir): If FindFirstFile fails because the | ||
| 8 | directory doesn't exist, set errno to ENOTDIR. | ||
| 9 | |||
| 1 | 2015-01-24 Jan Djärv <jan.h.d@swipnet.se> | 10 | 2015-01-24 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 11 | ||
| 3 | * nsterm.m (drawRect:): Add block/unblock_input (Bug#19660). | 12 | * nsterm.m (drawRect:): Add block/unblock_input (Bug#19660). |
diff --git a/src/dired.c b/src/dired.c index 5d7977bf024..f6c47a71400 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -247,6 +247,19 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, | |||
| 247 | QUIT; | 247 | QUIT; |
| 248 | continue; | 248 | continue; |
| 249 | } | 249 | } |
| 250 | #ifdef WINDOWSNT | ||
| 251 | /* The MS-Windows implementation of 'opendir' doesn't | ||
| 252 | actually open a directory until the first call to | ||
| 253 | 'readdir'. If 'readdir' fails to open the directory, it | ||
| 254 | sets errno to ENOTDIR; we convert it here to ENOENT so | ||
| 255 | that the error message is similar to what happens on | ||
| 256 | Posix hosts in such cases. */ | ||
| 257 | if (errno == ENOTDIR) | ||
| 258 | { | ||
| 259 | errno = ENOENT; | ||
| 260 | report_file_error ("Opening directory", directory); | ||
| 261 | } | ||
| 262 | #endif | ||
| 250 | break; | 263 | break; |
| 251 | } | 264 | } |
| 252 | 265 | ||
| @@ -3432,7 +3432,22 @@ sys_readdir (DIR *dirp) | |||
| 3432 | } | 3432 | } |
| 3433 | 3433 | ||
| 3434 | if (dir_find_handle == INVALID_HANDLE_VALUE) | 3434 | if (dir_find_handle == INVALID_HANDLE_VALUE) |
| 3435 | return NULL; | 3435 | { |
| 3436 | switch (GetLastError ()) | ||
| 3437 | { | ||
| 3438 | case ERROR_PATH_NOT_FOUND: | ||
| 3439 | case ERROR_ACCESS_DENIED: | ||
| 3440 | case ERROR_INVALID_DRIVE: | ||
| 3441 | case ERROR_BAD_NETPATH: | ||
| 3442 | /* This special value will be noticed by | ||
| 3443 | directory_files_internal, which see. */ | ||
| 3444 | errno = ENOTDIR; | ||
| 3445 | break; | ||
| 3446 | default: | ||
| 3447 | break; | ||
| 3448 | } | ||
| 3449 | return NULL; | ||
| 3450 | } | ||
| 3436 | } | 3451 | } |
| 3437 | else if (w32_unicode_filenames) | 3452 | else if (w32_unicode_filenames) |
| 3438 | { | 3453 | { |