Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #6522

Re: Zlib::GzipReader doesn't work as expected

From Simon Krahnke <overlord@gmx.li>
Newsgroups comp.lang.ruby
Subject Re: Zlib::GzipReader doesn't work as expected
Date 2012-04-26 22:02 +0200
Organization there's no z in organisation
Message-ID <87aa1y6z40.fsf@xts.gnuu.de> (permalink)
References <jn8e9q$sg3$1@online.de> <9vr04hFh0cU1@mid.individual.net> <jnb61g$7ka$1@online.de>

Show all headers | View raw


* Thomas Wolf <thomasw@viacanale.de> (11:54) schrieb:

> require 'stringio'

This is unneeded.

>require 'zlib'
>
>def inflate(filename)
>  File.open(filename) do |file|
>    zio = file

You could just use | zio | instead of |file| and get rid of the
assignment.

>    loop do
>      io = Zlib::GzipReader.new zio
>      puts io.read

puts here will put another "\n" at the end of the output, use print
instead.

>      unused = io.unused
>      io.finish
>      break if unused.nil?
>      zio.pos -= unused.length
>    end
>  end
>end
>
>inflate "foo.gz"

Note that as said in the thread this works only for files and other
seekable sources.

So "(seq 1 5 | gzip; seq 6 10 | gzip) | yourscript.rb" won't work.

mfg,                    simon .... hth

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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