travis@aop:~/rubyzip/test$ irb
irb(main):001:0> $:.push("…")
=> ["/usr/local/lib/ruby/site_ruby/1.8",
"/usr/local/lib/ruby/site_ruby/1.8/i386-freebsd4",
"/usr/local/lib/ruby/site_ruby",
"/usr/local/lib/ruby/1.8",
"/usr/local/lib/ruby/1.8/i386-freebsd4", “.”, “…”]
irb(main):002:0> require ‘zip/zip’
…/zip/zip.rb:11: warning: already initialized constant Tempfile
=> true
irb(main):003:0> Zip::ZipFile.new(“rubycode.zip”)
Errno::EFBIG: File too large - rubycode.zip
from …/zip/zip.rb:818:in read' from ../zip/zip.rb:818:inget_e_o_c_d’
from …/zip/zip.rb:783:in read_e_o_c_d' from ../zip/zip.rb:808:inread_from_stream’
from …/zip/zip.rb:869:in initialize' from ../zip/zip.rb:869:inopen’
from …/zip/zip.rb:869:in initialize' from (irb):3:innew’
from (irb):3
travis@aop:~/rubyzip/test$ file rubycode.zip
rubycode.zip: Zip archive data, at least v2.0 to extract
I have never experienced the Errno::EFBIG exception myself. If anyone
else on this list has tried rubyzip and seen this problem I’d be
interested in hearing about it.
Travis, could you try something like this:
require ‘zip/zip’
is = File.open(“rubycode.zip”, “rb”)
is.seek(5, IO::SEEK_SET)
is.read
Does that cause the problem? If it does, try without requiring
‘zip/zip’.
Rubyzip doesn’t do anything too weird with the files, all it does is
opening the archive file in “rb”-mode and seek-around and read a bit,
which is what the code fragment above is intended to mimic.
I have run the test suite succesfully myself on Windows XP/ruby-1.8.0
(pragprog build) and on RedHat 9.0 Linux/ruby-1.8.1 before making the
release.
Does that cause the problem? If it does, try without requiring
‘zip/zip’.
Looks like it works fine.
Rubyzip doesn’t do anything too weird with the files, all it does is
opening the archive file in “rb”-mode and seek-around and read a bit,
which is what the code fragment above is intended to mimic.
I’ll see if I can figure it out later when I have more time.
File.open(name, “rb”) do |f|
f.seek(-MAX_END_OF_CENTRAL_DIRECTORY_STRUCTURE_SIZE, IO::SEEK_END)
f.read
end
travis@aop:~$ ruby crash.rb
crash.rb:6:in read': File too large - foo.txt (Errno::EFBIG) from crash.rb:6 from crash.rb:4:inopen’
from crash.rb:4
travis@aop:~$ ruby crash.rb
crash.rb:6:in read': File too large - foo.txt (Errno::EFBIG) from crash.rb:6 from crash.rb:4:in open’
from crash.rb:4
Aah, on my systems (ruby 1.8.1 (2003-12-25) [i686-linux] and ruby 1.8.0
(2003-08-04) [i386-mswin32]) your example raises Errno::EINVAL which rubyzip
expects and handles.
I wonder if it is matz’ intention that the ruby interpreter should mend such
inconsistencies between different operating systems. Otherwise I will add
another rescue-clause that handles Errno::EFBIG.
At Fri, 2 Apr 2004 03:34:23 +0900,
Thomas Sondergaard wrote in [ruby-talk:96327]:
I wonder if it is matz’ intention that the ruby interpreter should mend such
inconsistencies between different operating systems. Otherwise I will add
another rescue-clause that handles Errno::EFBIG.