Just another Perl shrine | |
PerlMonks |
Getting IO::Compress::Zip to include directory entries (on Windows)by hilitai (Monk) |
on Feb 02, 2016 at 22:16 UTC ( [id://1154303]=perlquestion: print w/replies, xml ) | Need Help?? |
hilitai has asked for the wisdom of the Perl Monks concerning the following question: My task is: take a zip file (really a .war file, but I assume that's neither here nor there), uncompress it into a directory structure, manipulate a few files, and rezip it into a new zip file. I think I'm about 99% there. I've got a small script that uses IO::Uncompress::Unzip and IO::Compress::Zip to extract the files and then recompress them. However, when I do the recompression, I can't get the zip method of IO::Compress::Zip to include directory entities, as the original war file did. For example, the original file contains an entry for the directory WEB-INF/. My output file contains entries for all the files within WEB-INF/, but nothing for the directory itself. Here's some sample code. Assume two files, tc.html and tc.html.gz, and a directory, WEB-INF. The following code will compress the two files into a zip:
But I can find no variant of that zip invocation that will include the directory without dying, e.g.: my @dirs = ("tc.html", "tc.html.gz", "WEB-INF");Running with this modification gets me: Died at C:\Temp\zipSnip.pl line 10.Am I missing some option? Or am I stuck? Note that I am using IO::Compress and IO::Uncompress because I am trying to use *only* core modules. I don't think Archive::Zip counts.
Back to
Seekers of Perl Wisdom
|
|