Thomas Sondergaard
3/30/2005 7:33:00 AM
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