From 8df12d500338a4d4f42143f6aaf6198582b3f124 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Fri, 31 May 2013 11:17:21 -0600 Subject: [PATCH] Use native windows APIs for File.exists() On windows, there are obscure cases where _wstat can return non-zero for a path that actually exists, but the native GetFileAttributes returns valid attributes. This is the case in particular when the user or process doesn't have permissions to access the directory (for instance, anything outside of %temp%\Low, when running as a low-integrity process). This was causing problems with .mkdirs() - which first tries to check if the parent exists, and creates it if it doesn't. In our particular case, the exists() was returning false for the parent, even though it exists, and .mkdir() works fine, mkdirs() fails for the same directory. --- classpath/java-io.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index ff6bc8fffc..d15fe1489b 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -126,8 +126,12 @@ OPEN(string_t path, int mask, int mode) inline bool exists(string_t path) { +#ifdef PLATFORM_WINDOWS + return GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES; +#else STRUCT_STAT s; return STAT(path, &s) == 0; +#endif } inline int