Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1.1
-
Fix Version/s: JRuby 1.2
-
Component/s: Core Classes/Modules
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
FileTest methods in MRI work on filename strings or File objects, but in JRuby they only work with strings.
dudley@hiro jruby-trunk :> irb
>> FileTest.size(File.new('x','w+'))
=> 0
dudley@hiro jruby-trunk :> jirb
>> FileTest.size(File.new('x','w+'))
TypeError: can't convert File into String
Here's a patch that works for the specific case where you're passing in a File object (or anything that responds_to "path"). MRI calls to_io and then fstat on the IO object's file descriptor, so this isn't 100% compatible, but it is slightly closer than just accepting strings.