Skip to content
Permalink
Browse files
Fix #2291. Dir[] fails if path does not exist instead of returning nil
  • Loading branch information
enebo committed Dec 18, 2014
1 parent 467ccfb commit 91444d1c8c761a307ca9859de8b6af4ec1b48f5d
Showing with 9 additions and 0 deletions.
  1. +9 −0 core/src/main/java/org/jruby/util/Dir.java
@@ -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()) {

0 comments on commit 91444d1

Please sign in to comment.