Skip to content

Commit

Permalink
WTF is all this logic for? Make readlink pass some more rubyspecs
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Nov 3, 2014
1 parent 2c58354 commit cccc1d7
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions core/src/main/java/org/jruby/RubyFile.java
Expand Up @@ -993,22 +993,10 @@ public static IRubyObject symlink(ThreadContext context, IRubyObject recv, IRuby
public static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path) {
Ruby runtime = context.runtime;
JRubyFile link = file(path);

try {
String realPath = runtime.getPosix().readlink(link.toString());

if (!RubyFileTest.exist_p(recv, path).isTrue()) {
throw runtime.newErrnoENOENTError(path.toString());
}

if (!RubyFileTest.symlink_p(recv, path).isTrue()) {
// Can not check earlier, File.exist? might return false yet the symlink be there
if (!RubyFileTest.exist_p(recv, path).isTrue()) {
throw runtime.newErrnoENOENTError(path.toString());
}
throw runtime.newErrnoEINVALError(path.toString());
}


if (realPath == null) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
Expand Down

0 comments on commit cccc1d7

Please sign in to comment.