Zlib file decompression EOL issue

  • Thread starter Pierre-olivier Rioux
  • Start date
P

Pierre-olivier Rioux

Hi, first thx for helping !

I'm trying to decompress some .gz files with zlip. Here's the code that
i use, taken from here
http://www.misuse.org/science/2007/09/07/ruby-zlib-buffer-error-on-windows/
and modified to fit my needs.

File::eek:pen(compressedFilePath.sub('.gz', ''), 'wb') do |unzipped_file|
unzipped_file.binmode
gz = File::eek:pen(compressedFilePath, 'rb')
gz.binmode
begin
zis = Zlib::GzipReader.new(gz)
puts zis.os_code()
dis = zis.read
io = StringIO.new(dis)
ensure
zis.finish if zis
end
unzipped_file.write(io.read)
unzipped_file.flush
unzipped_file.fsync
gz.close
end


The problem is, when i try to decompress FAT encoded files, only the
first line is read and managed. The GzipReader ignore the rest of the
file beyond the first line:
file object-TS1T-AA-CS-C-0123-2005.08.31.05.01-2005.08.31.05.34.csv.gz
object-TS1T-AA-CS-C-0123-2005.08.31.05.01-2005.08.31.05.34.csv.gz: gzip
compressed data, from FAT filesystem (MS-DOS, OS/2, NT)

No problem when it's Unix encoded:
file error-TS1T-AA-CS-C-0123-2005.08.31.05.01-2005.08.31.05.34.csv.gz
error-TS1T-AA-CS-C-0123-2005.08.31.05.01-2005.08.31.05.34.csv.gz: gzip
compressed data, was "error-TS1T-AA-CS-C-0123-2005.08", from Unix, last
modified: Thu Apr 10 14:02:51 2008


I suspect EOL issue, but i can't find a workaround. Any suggestions are
welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top