+2015-01-27 Eli Zaretskii <eliz@gnu.org>
+
+ * dired.c (directory_files_internal) [WINDOWSNT]: If readdir
+ returns NULL and errno is ENOTDIR, behave as if opendir failed to
+ open the directory. (Bug#19701)
+
+ * w32.c (sys_readdir): If FindFirstFile fails because the
+ directory doesn't exist, set errno to ENOTDIR.
+
2015-01-24 Jan Djärv <jan.h.d@swipnet.se>
* nsterm.m (drawRect:): Add block/unblock_input (Bug#19660).
QUIT;
continue;
}
+#ifdef WINDOWSNT
+ /* The MS-Windows implementation of 'opendir' doesn't
+ actually open a directory until the first call to
+ 'readdir'. If 'readdir' fails to open the directory, it
+ sets errno to ENOTDIR; we convert it here to ENOENT so
+ that the error message is similar to what happens on
+ Posix hosts in such cases. */
+ if (errno == ENOTDIR)
+ {
+ errno = ENOENT;
+ report_file_error ("Opening directory", directory);
+ }
+#endif
break;
}
}
if (dir_find_handle == INVALID_HANDLE_VALUE)
- return NULL;
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_ACCESS_DENIED:
+ case ERROR_INVALID_DRIVE:
+ case ERROR_BAD_NETPATH:
+ /* This special value will be noticed by
+ directory_files_internal, which see. */
+ errno = ENOTDIR;
+ break;
+ default:
+ break;
+ }
+ return NULL;
+ }
}
else if (w32_unicode_filenames)
{