Skip to content

Commit

Permalink
Revert "Fix File.readlink when chdir and avoid NPE"
Browse files Browse the repository at this point in the history
This reverts commit 7bb636e.
  • Loading branch information
headius committed May 19, 2012
1 parent d64fed2 commit 804f8b8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/org/jruby/RubyFile.java
Expand Up @@ -922,26 +922,24 @@ public static IRubyObject symlink(ThreadContext context, IRubyObject recv, IRuby
@JRubyMethod(required = 1, meta = true)
public static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path) {
Ruby runtime = context.getRuntime();
JRubyFile link = file(path);

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

String realPath = runtime.getPosix().readlink(path.convertToString().getUnicodeValue());

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

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

if (realPath == null) {
//FIXME: When we get JNA3 we need to properly write this to errno.
throw runtime.newErrnoFromLastPOSIXErrno();
}

return runtime.newString(realPath);
} catch (IOException e) {
if (!RubyFileTest.exist_p(recv, path).isTrue()) {
throw runtime.newErrnoENOENTError(link.toString());
}

throw runtime.newIOError(e.getMessage());
}
}
Expand Down

0 comments on commit 804f8b8

Please sign in to comment.