Commit facd6d5a authored by Eli Zaretskii's avatar Eli Zaretskii

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.
parent 169d04b8
Pipeline #3154 passed with stage
in 59 minutes and 25 seconds
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment