From: Daniel Brumbaugh Keeney Date: 2008-03-11T09:01:27+09:00 Subject: Re: Getting files out of a .tar.gz archive On Mon, Mar 10, 2008 at 12:43 PM, celldee 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