Skip to content

Commit

Permalink
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit cccc1d7

Please sign in to comment.