#! /usr/bin/perl use strict; use warnings; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $zip = Archive::Zip->new(); open (FILE_LIST, '/home/user/d/file_list.txt') or die "File list open + fail: $!"; while (<FILE_LIST>) { chomp; my $member = $zip->addFile($_); print "Add error" unless ($member); } close FILE_LIST; unless ($zip->writeToFileNamed('/home/user/d/backup.zip') == AZ_OK) { die "write error";}
from multiple directories yielded success for me, with input file:
/home/user/a/a.txt /home/user/b/b.txt /home/user/c/c.txt
and where success was measured by the results of the script:
#! /usr/bin/perl use strict; use warnings; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $zip = Archive::Zip->new('backup.zip'); print $zip->memberNames();
where the only scrubbing I performed was changing user name. The only other suggestion I can make is that a review of the add_file method in Archive::Zip includes the admonition:
NOTE that you shouldn't (generally) use absolute path names in zip member names, as this will cause problems with some zip tools as well as introduce a security hole and make the zip harder to use.
In reply to Re^3: Problem with creating a zip: void file
by kennethk
in thread Problem with creating a zip: void file
by afrika
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |