Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #472 from atambo/file_size

File.size should handle IO's
  • Loading branch information...
commit a64079496d59c0599879f88a67e774aad0b70172 2 parents ff74833 + 90981d9
@headius headius authored
View
2  spec/tags/1.8/ruby/core/file/size_tags.txt
@@ -1,4 +1,2 @@
fails(JRUBY-4667):File.size? accepts a String-like (to_str) parameter
fails(JRUBY-4667):File.size accepts a String-like (to_str) parameter
-fails:File.size? calls #to_io to convert the argument to an IO
-fails:File.size calls #to_io to convert the argument to an IO
View
2  spec/tags/1.9/ruby/core/file/size_tags.txt
@@ -2,5 +2,3 @@ windows(JRUBY-4820):File#size returns the file's size as a Fixnum
windows(JRUBY-4820):File#size returns the file's size in bytes
windows(JRUBY-4820):File#size returns the file's current size even if modified
windows(JRUBY-4820):File#size for an empty file returns 0
-fails:File.size? calls #to_io to convert the argument to an IO
-fails:File.size calls #to_io to convert the argument to an IO
View
12 src/org/jruby/RubyFileTest.java
@@ -280,7 +280,11 @@ public static IRubyObject size(IRubyObject recv, IRubyObject filename) {
public static IRubyObject size(ThreadContext context, IRubyObject recv, IRubyObject filename) {
Ruby runtime = recv.getRuntime();
if (!(filename instanceof RubyFile)) {
- filename = get_path(context, filename);
+ if (filename.respondsTo("to_io")) {
+ filename = (RubyIO) TypeConverter.convertToType(filename, runtime.getIO(), "to_io");
+ } else {
+ filename = get_path(context, filename);
+ }
}
ZipEntry entry = file_in_archive(filename);
@@ -305,7 +309,11 @@ public static IRubyObject size_p(IRubyObject recv, IRubyObject filename) {
public static IRubyObject size_p(ThreadContext context, IRubyObject recv, IRubyObject filename) {
Ruby runtime = context.runtime;
if (!(filename instanceof RubyFile)) {
- filename = get_path(context, filename);
+ if (filename.respondsTo("to_io")) {
+ filename = (RubyIO) TypeConverter.convertToType(filename, runtime.getIO(), "to_io");
+ } else {
+ filename = get_path(context, filename);
+ }
}
ZipEntry entry = file_in_archive(filename);
Please sign in to comment.
Something went wrong with that request. Please try again.