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:
#!/usr/bin/perl use strict; use warnings; use IO::Compress::Zip qw(:all); my $outfile = "test.zip"; my @dirs = ("tc.html", "tc.html.gz"); zip \@dirs => "$outfile", BinModeIn => 0 or die "$!"; print "Done\n";
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.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |