aussiegeek/rubyzip — pull request #25 by 2potatocakes (2012-02-06 05:36:26+00:00)
Title: Added better support for windows mingw users

Hi Alan/Alex,

Had been running into a couple of problems since bumping a windows project I work on up to ruby1.8.7mingw recently. There were about 14 broken tests when I first got the tests running. Have fixed the majority of them I think, there's still 3 left, but the 3 remaining I believe are for legitimate reasons..

1) Error:
test_rename(ZipFileTest):
Zlib::DataError: invalid stored block lengths
../lib/zip/inflater.rb:42:in `inflate'
../lib/zip/inflater.rb:42:in `internal_produce_input'
../lib/zip/inflater.rb:14:in `sysread'
../lib/zip/zip_input_stream.rb:106:in `sysread'
../lib/zip/ioextras.rb:59:in `read'
../lib/zip/zip_file.rb:150:in `read'
../lib/zip/zip_entry.rb:502:in `get_input_stream'
../lib/zip/zip_file.rb:125:in `get_input_stream'
../lib/zip/zip_file.rb:150:in `read'
C:/code/GitHub/rubyzip/test/ziptest.rb:1239:in `test_rename'

2) Error:
test_replace(ZipFileTest):
Zlib::DataError: invalid stored block lengths
../lib/zip/inflater.rb:42:in `inflate'
../lib/zip/inflater.rb:42:in `internal_produce_input'
../lib/zip/inflater.rb:14:in `sysread'
../lib/zip/zip_input_stream.rb:106:in `sysread'
../lib/zip/ioextras.rb:59:in `read'
C:/code/GitHub/rubyzip/test/ziptest.rb:1312:in `test_replace'
../lib/zip/zip_entry.rb:502:in `get_input_stream'
../lib/zip/zip_file.rb:125:in `get_input_stream'
C:/code/GitHub/rubyzip/test/ziptest.rb:1312:in `test_replace'

3) Failure:
test_put_next_entry(ZipOutputStreamTest) [C:/code/GitHub/rubyzip/test/ziptest.rb:686]:
is not true.

95 tests, 933 assertions, 1 failures, 2 errors

I've narrowed down the problem a bit.. If I just take a fresh copy of 5entry.zip I can unzip its contents to a local windows directory fine and all the files within it are fine also. If I then take that exact same zip file and run the following:

require 'zip/zip'
zf = Zip::ZipFile.new("5entry.zip")
zf.rename("data/generated/longAscii.txt", "data/generated/longAscii2.txt")
zf.close

The file is now corrupt and will not extract properly anymore. I've spent a few hours trying to figure out why but I'm a bit stumped? Have you guys got any ideas? If I try and re-open it with your gem at this point, it chokes on the zlib inflater method with the same error as in the tests above if that helps.

Apologies about the syntax changes in the pull request also. I can remove them if you'd prefer? Let me know if you'd like me to change anything and I will.

Kind Regards,
Lucas