# Zlib file decompression EOL issue

**URL:** <https://www.ruby-forum.com/t/zlib-file-decompression-eol-issue/134517>\
**Category:** Ruby\
**Created:** [April 11, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/zlib-file-decompression-eol-issue/134517 "2008-04-11T17:06:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![peho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8edcca/32.png) [@peho](https://www.ruby-forum.com/u/peho)\
**Post date:** [April 11, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/zlib-file-decompression-eol-issue/134517/1 "2008-04-11T17:06:28Z")

</div>

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/](http://www.misuse.org/science/2007/09/07/ruby-zlib-buffer-error-on-windows/)  
and modified to fit my needs.

File::open(compressedFilePath.sub(‘.gz’, ‘’), ‘wb’) do |unzipped\_file|  
unzipped\_file.binmode  
gz = File::open(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.
