Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6518
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Robert Klemme <shortcutter@googlemail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Zlib::GzipReader doesn't work as expected |
| Date | Wed, 25 Apr 2012 21:03:44 +0200 |
| Lines | 60 |
| Message-ID | <9vr04hFh0cU1@mid.individual.net> (permalink) |
| References | <jn8e9q$sg3$1@online.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net U+8DoTwdBzLrfN8wOdVObAuUZukQ7B2oNyxweki4huKa9UE08= |
| Cancel-Lock | sha1:6xxQ0Deyt9arCCt//zZZmEhgJ0w= |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 |
| In-Reply-To | <jn8e9q$sg3$1@online.de> |
| Xref | csiph.com comp.lang.ruby:6518 |
Show key headers only | View raw
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