1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

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.
This commit is contained in:
Eli Zaretskii 2019-09-16 22:19:16 +03:00
parent 169d04b8ac
commit facd6d5aff

View file

@ -4151,13 +4151,36 @@ w32_accessible_directory_p (const char *dirname, ptrdiff_t dirlen)
/* In case DIRNAME cannot be expressed in characters from the
current ANSI codepage. */
if (_mbspbrk (pat_a, "?"))
dh = INVALID_HANDLE_VALUE;
else
dh = FindFirstFileA (pat_a, &dfd_a);
{
errno = ENOENT;
return 0;
}
dh = FindFirstFileA (pat_a, &dfd_a);
}
if (dh == INVALID_HANDLE_VALUE)
{
DWORD w32err = GetLastError ();
switch (w32err)
{
case ERROR_INVALID_NAME:
case ERROR_BAD_PATHNAME:
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
case ERROR_NO_MORE_FILES:
case ERROR_BAD_NETPATH:
errno = ENOENT;
break;
case ERROR_NOT_READY:
errno = ENODEV;
break;
default:
errno = EACCES;
break;
}
return 0;
}
FindClose (dh);
return 1;
}