Howdy bros. I'm trying to set up some code using Archive::Zip to zip up a directory. I'm a little confused from the docs about how the compression level works. The directory in question has some zip files already in it, and I don't want to take the time to compress those since it won't do any good, but everything else I want to compress. So I've got this so far:
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use File::Find qw(find);
my $startdir = 'foo';
our $zip = Archive::Zip->new();
my $dir_member = $zip->addDirectory( '04campaigndashboard/' );
$dir_member->desiredCompressionLevel( 9 );
find(\&wanted,$startdir);
sub wanted {
($fn = $File::Find::name) =~ s/$startdir//;
if ($fn =~ /.zip/) {
????
}
else {
my $file_member = $zip->addFile( $fn );
}
return;
}
What I'm confused about is what goes in the zip case. The docs say you can change the compression for any element with the desiredCompressionLevel method, but you have to know the member name first. But isn't the file member compressed when you add it? If so this would not help me avoid the cycles to compress it only to uncompress it with the desiredCompressionLevel method, in fact it would make things worse.
Or is the compression done when the archive is written to disk?
UPDATE: I was just doing some testing and found tat the addFile method seems to not work when the argument is a zip file--it returns undef. So maybe you can't nest zip files with this mod at all>
TIA....Steve
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.