Permalink
Browse files

Revert "Fix File.readlink when chdir and avoid NPE"

This reverts commit 7bb636e.
  • Loading branch information...
1 parent d64fed2 commit 804f8b825f62126ccb0bfa91292461e091400c46 @headius headius committed May 19, 2012
Showing with 6 additions and 8 deletions.
  1. +6 −8 src/org/jruby/RubyFile.java
@@ -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());
}
}

0 comments on commit 804f8b8

Please sign in to comment.