tags:

views:

88

answers:

2

I have a .zip archive containing several directories. Using the rubyzip gem I would like to reach into the .zip archive, copy a specified directory (and its contents) and move the directory into a second .zip archive.

Ideally I would not have to extract the contents of the first .zip archive, then re-zip them into a second archive. I'm hoping there is a way to use methods provided in the rubyzip gem.

A: 

This is a bit of a brute force method (and may or may not work for your application), but you could copy the entire first zip file and then use rubyzip methods to delete everything but the target directory from the copied file.

Theoretically what you are asking should be possible if you are using deflate compression (which stores every file as an individually compressed item).

Mike Buckbee
I actually tried the brute force method you mentioned, but the contents of the .zip are so large and I have to make several copies -- it ends up being too slow.
rswolff
Adding some more information to your question would be helpful: what OS are you on? Size of zips? Reasons for storing files in a zip.
Mike Buckbee
+1  A: 

After checking with one of the maintainers of the rubyzip gem, I have learned that this is not possible.

rswolff