Skip to content
Permalink
Browse files
WTF is all this logic for? Make readlink pass some more rubyspecs
  • Loading branch information
enebo committed Nov 3, 2014
1 parent 2c58354 commit cccc1d7beabd8622738d0a5470c1418d84b2f708
Showing 1 changed file with 2 additions and 14 deletions.
@@ -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.