[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

zip a directory, unzip a zip file

Its Me

3/29/2005 6:56:00 AM

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


6 Answers

Stefan Lang

3/29/2005 8:54:00 AM

0

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


Thomas Sondergaard

3/29/2005 11:41:00 AM

0

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.sourc...). It's available as a
gem too:

gem install rubyzip

Cheers,

Thomas

Its Me

3/29/2005 4:47:00 PM

0

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.sourc...). It's available as a
> gem too:


Austin Ziegler

3/29/2005 6:53:00 PM

0

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.

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

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


Thomas Sondergaard

3/30/2005 7:33:00 AM

0



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

Its Me

3/30/2005 6:15:00 PM

0

Perfect! Thanks, austin & thomas.


"Austin Ziegler" <halostatue@gmail.com> wrote in message
news:9e7db911050329105255e330e@mail.gmail.com...
> 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.
>
> It uses the .tar format, but Archive::Tar::Minitar does.
>
> -austin