Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

zip a directory, unzip a zip file

378 views
Skip to first unread message

itsme213

unread,
Mar 29, 2005, 1:55:41 AM3/29/05
to
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

unread,
Mar 29, 2005, 3:54:11 AM3/29/05
to

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

Stefan


Thomas Sondergaard

unread,
Mar 29, 2005, 6:41:08 AM3/29/05
to

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

gem install rubyzip

Cheers,

Thomas

itsme213

unread,
Mar 29, 2005, 11:47:25 AM3/29/05
to
Does rubyzip directly support zipping up a directory into a file, and vice
versa?

Thanks.

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

Austin Ziegler

unread,
Mar 29, 2005, 1:52:46 PM3/29/05
to
On Wed, 30 Mar 2005 01:49:47 +0900, itsme213 <itsm...@hotmail.com> wrote:
> Does rubyzip directly support zipping up a directory into a file, and vice
> versa?
>
> Thanks.

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

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


Thomas Sondergaard

unread,
Mar 30, 2005, 2:33:20 AM3/30/05
to

itsme213 wrote:
> Does rubyzip directly support zipping up a directory into a file, and vice
> versa?

Nope, but maybe I should add such methods :-)

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

itsme213

unread,
Mar 30, 2005, 1:15:18 PM3/30/05
to
Perfect! Thanks, austin & thomas.


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

0 new messages