Skip to content

Commit

Permalink
Fix #2291. Dir[] fails if path does not exist instead of returning nil
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Dec 18, 2014
1 parent 467ccfb commit 91444d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/util/Dir.java
Expand Up @@ -580,6 +580,15 @@ private static boolean isSpecialFile(String name) {

private static int addToResultIfExists(POSIX posix, String cwd, byte[] bytes, int begin, int end, int flags, GlobFunc func, GlobArgs arg) {
String fileName = newStringFromUTF8(bytes, begin, end - begin);

// FIXME: Ultimately JRubyFile.createResource should do this but all 1.7.x is only selectively honoring raw
// paths and using system drive make it absolute. MRI does this on many methods we don't.
if (Platform.IS_WINDOWS && cwd == null && !fileName.isEmpty() && fileName.charAt(0) == '/') {
cwd = System.getenv("SYSTEMDRIVE");
if (cwd == null) cwd = "C:";
cwd = cwd + "/";
}

FileResource file = JRubyFile.createResource(posix, cwd, fileName);

if (file.exists()) {
Expand Down

0 comments on commit 91444d1

Please sign in to comment.