【发布时间】:2016-08-25 16:49:25
【问题描述】:
我正在使用 Archive::Zip 创建存档文件,我想知道是否可以将文件添加到已经存在的存档中?看起来每次我调用 ->writeToFileNamed 文件都会被截断......
【问题讨论】:
-
看看这个link,它可能有你需要的东西。
-
也可以使用
$zip->addMember( $member )
我正在使用 Archive::Zip 创建存档文件,我想知道是否可以将文件添加到已经存在的存档中?看起来每次我调用 ->writeToFileNamed 文件都会被截断......
【问题讨论】:
$zip->addMember( $member )
use strict;
use warnings;
use Archive::Zip;
my $zip = Archive::Zip->new();
#create your archive
my $member = #"file you want to add to archive";
$zip->addMember( $member );
如果您没有在脚本中创建 zip,那么只需“读取”它并添加您的文件...
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES );
my $zip = Archive::Zip->new();
$zip->read('c:\users\user\desktop\test.zip') == AZ_OK or die "read error\n";
$zip->addFile('test.pl');
$zip->overwrite() == AZ_OK or die "write error\n";
【讨论】: