aboutsummaryrefslogtreecommitdiff
path: root/libcpp/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/files.c')
-rw-r--r--libcpp/files.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libcpp/files.c b/libcpp/files.c
index 3751184..b20c38e 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -228,6 +228,19 @@ open_file (_cpp_file *file)
close (file->fd);
file->fd = -1;
}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ else if (errno == EACCES)
+ {
+ /* On most UNIX systems, open succeeds on a directory. Above,
+ we check if we have opened a directory and if so, set errno
+ to ENOENT. However, on Windows, opening a directory
+ fails with EACCESS. We want to return ENOENT in that
+ case too. */
+ if (stat (file->path, &file->st) == 0
+ && S_ISDIR (file->st.st_mode))
+ errno = ENOENT;
+ }
+#endif
else if (errno == ENOTDIR)
errno = ENOENT;