[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Unexpected EOF while inflating GZIP file?

cmercier

4/12/2006 3:38:00 AM

Hi,

I'm trying to inflate a gzip file but for whatever reason, it always
gives me the error "unexpected end of file". I tried with 3 different
..gz file and I always get the same result. Can anyone help please?

Thanks!


Here's my code:

----
require 'zlib'

zip_file ='tmp_downloads/edu.zone.gz'
output_path = 'tmp_downloads/tmp/'

f = File.open(zip_file)
gz = Zlib::GzipReader.new(f)

print gz.read

gz.close

----

and the error

test.rb:9:in `read': unexpected end of file (Zlib::GzipFile::Error)
from test.rb:9

6 Answers

Robert Klemme

4/12/2006 7:11:00 AM

0

cmercier@gmail.com wrote:
> Hi,
>
> I'm trying to inflate a gzip file but for whatever reason, it always
> gives me the error "unexpected end of file". I tried with 3 different
> .gz file and I always get the same result. Can anyone help please?

Did you verify (with the command line tool) that the file is actually ok?

Kind regards

robert

rickhg12hs

4/12/2006 7:25:00 AM

0

I downloaded edu.zone.gz from http://www.internic....,
replicated your directory structure and then just ran ruby, pasted your
code, and it worked great.

Does your edu.zone.gz produce the correct md5sum?

cmercier

4/12/2006 2:12:00 PM

0

I downloaded the file from Verisign, and the md5sum is ok. I can
extract it with Winrar...

I'll try with the internic file.

cmercier

4/12/2006 2:21:00 PM

0

I'm getting the exact same error with the file from Internic.net. I'm
on a Windows box, could it be why?

Karl von Laudermann

4/12/2006 3:40:00 PM

0

cmercier@gmail.com wrote:
> Hi,
>
> I'm trying to inflate a gzip file but for whatever reason, it always
> gives me the error "unexpected end of file". I tried with 3 different
> .gz file and I always get the same result. Can anyone help please?

<snip>

> f = File.open(zip_file)

You probably need to open the file in binary mode, i.e.:

f = File.open(zip_file, "rb")

myjpa1@gmail.com

4/14/2006 1:01:00 PM

0

yes, i think that's the key problem