Sorry ... I'm catching up on some outstanding emails:
On Jun 20, 2007, at 8:34 AM, Daniel Berger wrote:
Can you provide a link to Jamis' post? I must have missed it.
It was included as an attachment in the original message. Perhaps
the mailing list ate the attachment, so I will include it here directly:
--><--snip--><--
From: Jamis Buck
Here's my work-around for the Zlib issue. Just replace the
zipped_stream method in package.rb with the following:
def zipped_stream(entry)
entry.read(10) # skip the gzip header
zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
is = StringIO.new(zis.inflate(entry.read))
ensure
zis.finish if zis
end
A slightly more robust gzip reader looks something like this (sorry
about the magic numbers, it was just a proof of concept. if you want
to use this more robust approach, let me know and I can do it up
right with symbolic constants):
require 'zlib'
File.open("out.gz", "rb") do |f|
head = f.read(10)
abort "bad magic" if head[0] != 0x1f || head[1] != 0x8b
abort "bad compression method #{head[2]}" if head[2] != 8
abort "multipart gzip is unsupported" if head[3] & 0x2 != 0
abort "encrypted gzip is unsupported" if head[3] & 0x20 != 0
abort "unknown flags #{head[3]}" if head[3] & 0xc0 != 0
if head[3] & 0x4 != 0
len = f.read(2).unpack("n").first
f.read(len + 2)
end
if head[3] & 0x8 != 0
loop { break if f.read(1) == 0 }
end
if head[3] & 0x10 != 0
loop { break if f.read(1) == 0 }
end
zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
result = zis.inflate(f.read)
puts "got #{result.length} bytes"
end
- Jamis
--><--snip--><--
--
-- Jim Weirich
-- [EMAIL PROTECTED]
_______________________________________________
Rubygems-developers mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers