Skip to content

Commit

Permalink
Mark File.readlink as not impl on Windows. Sorta fixes #3287.
Browse files Browse the repository at this point in the history
MRI does not appear to implement any Windows version of
File.readlink, and instead just marks it as not impleemnted when
it is not available at compile time. We will do the same, but I do
wonder if both of us could provide equivalent functionality using
Win32 soft/hard link API calls.
headius committed Sep 3, 2015
1 parent 9e2d6dc commit 2797b9b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -176,6 +176,12 @@ public static RubyClass createFileClass(Ruby runtime) {
// File::Constants module is included in IO.
runtime.getIO().includeModule(constants);

if (Platform.IS_WINDOWS) {
// readlink is not available on Windows. See below and jruby/jruby#3287.
// TODO: MRI does not implement readlink on Windows, but perhaps we could?
fileClass.searchMethod("readlink").setNotImplemented(true);
}

return fileClass;
}

@@ -1044,6 +1050,13 @@ 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.runtime;

if (Platform.IS_WINDOWS) {
// readlink is not available on Windows. See above and jruby/jruby#3287.
// TODO: MRI does not implement readlink on Windows, but perhaps we could?
throw runtime.newNotImplementedError("readlink");
}

JRubyFile link = file(path);

try {

0 comments on commit 2797b9b

Please sign in to comment.