R
R
Roman Mirilaczvili2017-05-24 23:12:21
ruby
Roman Mirilaczvili, 2017-05-24 23:12:21

How to decompress deflated in chunks in Ruby?

According to the example in the Zlib::Inflate Ruby documentation

open "compressed.file" do |compressed_io|
  zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)

  begin
    open "uncompressed.file", "w+" do |uncompressed_io|
      uncompressed_io << zi.inflate(compressed_io.read)
    end
  ensure
    zi.close
  end
end

From the code, you can see compressed_io.readthat the entire contents of the file are read as the passed argument.
Are there any more humane ways of unpacking, ie. portions?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question