Daniel Brumbaugh Keeney
3/11/2008 12:01:00 AM
On Mon, Mar 10, 2008 at 12:43 PM, celldee <celldee@gmail.com> wrote:
> Hi Daniel,
>
> I saw that, but I don't want to expand the .tar.gz any more than I
> have to. The code that I put up earlier is getting what I want out of
> the .tar file using Minitar::Reader which I quite like, I'm just
> looking to eliminate the gunzip step. Minitar.unpack expands
> the .tar.gz and writes the files to disk, which means that I'll have
> to mess around in the filesystem more than I need to.
>
> Thanks for your reply,
>
> Chris
My apologies for failing to understand the issue. GZip and Minitar
both provide incremental readers, although I have not used them. I
believe the correct combination for what you're asking is this:
tgz = Zlib::GzipReader.new(File.open('test.tgz', 'rb'))
# Warning: tgz and the file will be closed.
reader = Minitar::Reader.new(tgz)
reader.each_entry do |file|
#do something with each file, and break if you like
end
reader.close # does this do anything?
tgz.close
Daniel Brumbaugh Keeney