Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6521
| From | Thomas Wolf <thomasw@viacanale.de> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Zlib::GzipReader doesn't work as expected |
| Date | 2012-04-26 11:54 +0200 |
| Organization | 1&1 Internet AG |
| Message-ID | <jnb61g$7ka$1@online.de> (permalink) |
| References | <jn8e9q$sg3$1@online.de> <9vr04hFh0cU1@mid.individual.net> |
Am 25.04.2012 21:03, schrieb Robert Klemme:
>> How do I force Zlib::GzipReader do read the whole file?
>
> That's a fairly common limitation of GZip libs (Java's standard lib also
> has this limitation, or at least hat last time I checked).
>
> You might get away with wrapping the GzipReader around an open IO object
> and wrapping another GzipReader when the first finishes.
Thank you.
I found the following thread:
http://www.velocityreviews.com/forums/t866074-zlib-gzipreader-and-multiple-compressed-blobs-in-a-single-stream.html
and that code works with ruby 1.9.3p0:
require 'stringio'
require 'zlib'
def inflate(filename)
File.open(filename) do |file|
zio = file
loop do
io = Zlib::GzipReader.new zio
puts io.read
unused = io.unused
io.finish
break if unused.nil?
zio.pos -= unused.length
end
end
end
inflate "foo.gz"
Regards,
Thomas
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Zlib::GzipReader doesn't work as expected Thomas Wolf <thomasw@viacanale.de> - 2012-04-25 10:57 +0200
Re: Zlib::GzipReader doesn't work as expected Robert Klemme <shortcutter@googlemail.com> - 2012-04-25 21:03 +0200
Re: Zlib::GzipReader doesn't work as expected Simon Krahnke <overlord@gmx.li> - 2012-04-25 21:55 +0200
Re: Zlib::GzipReader doesn't work as expected Thomas Wolf <thomasw@viacanale.de> - 2012-04-26 11:54 +0200
Re: Zlib::GzipReader doesn't work as expected Simon Krahnke <overlord@gmx.li> - 2012-04-26 22:02 +0200
Re: Zlib::GzipReader doesn't work as expected Simon Krahnke <overlord@gmx.li> - 2012-04-25 21:53 +0200
csiph-web