Zip a directory, unzip a zip file

I have a directory that I want to compress/uncompress using any or zip,
gzip, bz2, etc. What is the easiest way to do this?

I've looked at zlib but could not find something simple and convenient.

Thanks

Look at archive-tar-minitar. It's available on RAA and as a RubyGem.

Stefan

···

On Tuesday 29 March 2005 08:59, itsme213 wrote:

I have a directory that I want to compress/uncompress using any or zip,
gzip, bz2, etc. What is the easiest way to do this?

I've looked at zlib but could not find something simple and convenient.

Thanks

Stefan Lang wrote:

···

On Tuesday 29 March 2005 08:59, itsme213 wrote:

I have a directory that I want to compress/uncompress using any or zip,
gzip, bz2, etc. What is the easiest way to do this?

I've looked at zlib but could not find something simple and convenient.

Thanks

Look at archive-tar-minitar. It's available on RAA and as a RubyGem.

Stefan

Or try my rubyzip (http://rubyzip.sourceforge.net). It's available as a gem too:

gem install rubyzip

Cheers,

Thomas

Does rubyzip directly support zipping up a directory into a file, and vice
versa?

Thanks.

···

"Thomas Sondergaard" <ts_news1@sondergaard.cc> wrote

Or try my rubyzip (http://rubyzip.sourceforge.net). It's available as a
gem too:

It uses the .tar format, but Archive::Tar::Minitar does.

-austin

···

On Wed, 30 Mar 2005 01:49:47 +0900, itsme213 <itsme213@hotmail.com> wrote:

Does rubyzip directly support zipping up a directory into a file, and vice
versa?

Thanks.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

itsme213 wrote:

Does rubyzip directly support zipping up a directory into a file, and vice
versa?

Nope, but maybe I should add such methods :slight_smile:

Currently you'd do something like the following to zip everything in the 'test' and 'lib' dirs:

Zip::ZipFile::open("all.zip", true) {
   >zf>

   Dir['{test,lib}/**/*'].each { |f| zf.add(f, f) }

}

To unzip it to the file system again you'd do something like:

OUTDIR="out"

Zip::ZipFile::open("all.zip") {
   >zf>

   zf.each { |e|
     fpath = File.join(OUTDIR, e.name)
     FileUtils.mkdir_p(File.dirname(fpath))
     zf.extract(e, fpath)
   }
}

Cheers,

Thomas

Perfect! Thanks, austin & thomas.

"Austin Ziegler" <halostatue@gmail.com> wrote in message
news:9e7db911050329105255e330e@mail.gmail.com...

> Does rubyzip directly support zipping up a directory into a file, and

vice

···

On Wed, 30 Mar 2005 01:49:47 +0900, itsme213 <itsme213@hotmail.com> wrote:
> versa?
>
> Thanks.

It uses the .tar format, but Archive::Tar::Minitar does.

-austin