diff options
| author | Eli Zaretskii | 2019-09-16 22:19:16 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-09-16 22:19:16 +0300 |
| commit | facd6d5affaa897e7efe4018ede054489268b065 (patch) | |
| tree | 9b88aa54fff0f733e0d58840f38dac30adc99d25 /src | |
| parent | 169d04b8ac416c71a8b89a9c4a975d0f014265e0 (diff) | |
| download | emacs-facd6d5affaa897e7efe4018ede054489268b065.tar.gz emacs-facd6d5affaa897e7efe4018ede054489268b065.zip | |
Improve error reporting in file_accessible_directory_p
* src/w32.c (w32_accessible_directory_p): Set errno, so that
file_accessible_directory_p does on MS-Windows, to live up to
its callers' expectations.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 29 |
1 files changed, 26 insertions, 3 deletions
| @@ -4151,13 +4151,36 @@ w32_accessible_directory_p (const char *dirname, ptrdiff_t dirlen) | |||
| 4151 | /* In case DIRNAME cannot be expressed in characters from the | 4151 | /* In case DIRNAME cannot be expressed in characters from the |
| 4152 | current ANSI codepage. */ | 4152 | current ANSI codepage. */ |
| 4153 | if (_mbspbrk (pat_a, "?")) | 4153 | if (_mbspbrk (pat_a, "?")) |
| 4154 | dh = INVALID_HANDLE_VALUE; | 4154 | { |
| 4155 | else | 4155 | errno = ENOENT; |
| 4156 | dh = FindFirstFileA (pat_a, &dfd_a); | 4156 | return 0; |
| 4157 | } | ||
| 4158 | dh = FindFirstFileA (pat_a, &dfd_a); | ||
| 4157 | } | 4159 | } |
| 4158 | 4160 | ||
| 4159 | if (dh == INVALID_HANDLE_VALUE) | 4161 | if (dh == INVALID_HANDLE_VALUE) |
| 4162 | { | ||
| 4163 | DWORD w32err = GetLastError (); | ||
| 4164 | |||
| 4165 | switch (w32err) | ||
| 4166 | { | ||
| 4167 | case ERROR_INVALID_NAME: | ||
| 4168 | case ERROR_BAD_PATHNAME: | ||
| 4169 | case ERROR_FILE_NOT_FOUND: | ||
| 4170 | case ERROR_PATH_NOT_FOUND: | ||
| 4171 | case ERROR_NO_MORE_FILES: | ||
| 4172 | case ERROR_BAD_NETPATH: | ||
| 4173 | errno = ENOENT; | ||
| 4174 | break; | ||
| 4175 | case ERROR_NOT_READY: | ||
| 4176 | errno = ENODEV; | ||
| 4177 | break; | ||
| 4178 | default: | ||
| 4179 | errno = EACCES; | ||
| 4180 | break; | ||
| 4181 | } | ||
| 4160 | return 0; | 4182 | return 0; |
| 4183 | } | ||
| 4161 | FindClose (dh); | 4184 | FindClose (dh); |
| 4162 | return 1; | 4185 | return 1; |
| 4163 | } | 4186 | } |