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:
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting IO::Compress::Zip to include directory entries (on Windows)
by dasgar (Priest) on Feb 02, 2016 at 23:13 UTC | |
by hilitai (Monk) on Feb 03, 2016 at 00:35 UTC | |
by poj (Abbot) on Feb 03, 2016 at 07:48 UTC | |
by pmqs (Friar) on Feb 03, 2016 at 13:10 UTC | |
by dasgar (Priest) on Feb 03, 2016 at 05:41 UTC | |
|
Re: Getting IO::Compress::Zip to include directory entries (on Windows)
by Mr. Muskrat (Canon) on Feb 03, 2016 at 00:45 UTC | |
by hilitai (Monk) on Feb 05, 2016 at 20:42 UTC | |
|
Re: Getting IO::Compress::Zip to include directory entries (on Windows)
by Anonymous Monk on Feb 03, 2016 at 17:56 UTC |