I have a binary string that holds two gzip binarys concatenated. (I am reading a binary file log file that concatenated two gzip files together)
In other words, I have the equivalient of:
require 'zlib'
require 'stringio'
File.open('t1.gz', 'w') do |f|
gz = Zlib::GzipWriter.new(f)
gz.write 'part one'
gz.close
end
File.open('t2.gz', 'w') do |f|
gz = Zlib::GzipWriter.new(f)
gz.write 'part 2'
gz.close
end
contents1 = File.open('t1.gz', "rb") {|io| io.read }
contents2 = File.open('t2.gz', "rb") {|io| io.read }
c = contents1 + contents2
gz = Zlib::GzipReader.new(StringIO.new(c))
gz.each do | l |
puts l
end
When I try to unzip the combined string, I only get the first string. How do I get both strings?