}
@JRubyMethod(name = "symlink?", required = 1, module = true)
public static RubyBoolean symlink_p(IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
JRubyFile file = file(filename);
try {
// Note: We can't use file.exists() to check whether the symlink
// exists or not, because that method returns false for existing
// but broken symlink. So, we try without the existence check,
// but in the try-catch block.
// MRI behavior: symlink? on broken symlink should return true.
return runtime.newBoolean(runtime.getPosix().lstat(file.getAbsolutePath()).isSymlink());
} catch (RaiseException re) {
return runtime.getFalse();
}
}