Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6518
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Zlib::GzipReader doesn't work as expected |
| Date | 2012-04-25 21:03 +0200 |
| Message-ID | <9vr04hFh0cU1@mid.individual.net> (permalink) |
| References | <jn8e9q$sg3$1@online.de> |
On 04/25/2012 10:57 AM, Thomas Wolf wrote:
> Hi,
> given 2 files:
> cat 5lines.txt
> 5 lines
> 5 lines
> 5 lines
> 5 lines
> 5 lines
>
> cat more5lines.txt
> More 5 lines
> More 5 lines
> More 5 lines
> More 5 lines
> More 5 lines
>
> These files are "gzip"ed as follows:
> gzip < 5lines.txt > foo.gz
> gzip < more5lines.txt >> foo.gz
>
> zcat foo.gz:
> 5 lines
> 5 lines
> 5 lines
> 5 lines
> 5 lines
> More 5 lines
> More 5 lines
> More 5 lines
> More 5 lines
> More 5 lines
>
> This ruby code only reads the first 5 lines:
> #!/usr/bin/ruby
> require "zlib"
> filename = ARGV[0]
>
> Zlib::GzipReader.open(filename) {|gz|
> print gz.read
> }
>
> ./test.rb foo.gz
> 5 lines
> 5 lines
> 5 lines
> 5 lines
> 5 lines
>
> 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.
Kind regards
robert
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