aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2007-06-09 10:16:52 +0000
committerVladimir Prus <vprus@gcc.gnu.org>2007-06-09 10:16:52 +0000
commit84152c25a53201930fd73cb13a905d8335367971 (patch)
treec8c465740f40eb2c178e1a3ebfe854771da47698 /libcpp
parentad365750b15b8fad2ae6785d7afa9034f3a05dd6 (diff)
cppfiles.c (open_file): Account for the fact that on windows, opening a directory gives EACCES.
* cppfiles.c (open_file): Account for the fact that on windows, opening a directory gives EACCES. From-SVN: r125590
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/files.c13
2 files changed, 19 insertions, 0 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 712bc32784b..205c1dd9db1 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2007-06-09 Vladimir Prus <vladimir@codesourcery.com>
+
+ * cppfiles.c (open_file): Account for the
+ fact that on windows, opening a directory gives
+ EACCES.
+
2007-06-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
PR preprocessor/23479
diff --git a/libcpp/files.c b/libcpp/files.c
index 3751184d02f..b20c38e8d87 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;