我曾尝试从zip容器中提取文件,但我的脚本不会返回以下错误
错误详情:
格式错误:错误签名:文件中偏移568276处的0x00000000 AUS-000X-201512 28234755_Data.zip at C:/Perl64/lib/Archive/Zip.pm line 477.Archive :: Zip :: _ readSignature(' IO :: File = GLOB(0x2a5e2a8)',' AUS-000X-20151228234755_Data.zip') C:/Perl64/lib/Archive/Zip/Archive.pm第603行 存档::邮编::存档:: readFromFileHandle('档案::拉链::存档= HASH(0x32c1e8)&#39 ;, ' IO :: File = GLOB(0x2a5e2a8)',' AUS-000X-20151228234755_Data.zip')被调用 在C:/Perl64/lib/Archive/Zip/Archive.pm第548行 存档::邮编::存档::读取('档案::邮编::存档= HASH(0x32c1e8)&#39 ;, ' AUS-000X-20151228234755_Data.zip')在zip_extraction.pl线调用 14阅读AUS-000X-20151228234755_Data.zip失败
use strict;
use Archive::Zip qw(:ERROR_CODES);
opendir( DIR, "C:\\Users\\vinayas1\\Desktop\\Automation" ) || die "Can't
+ open local directory : $!";
my @zips = grep { -f "./$_" } readdir(DIR);
close(DIR);
foreach my $zipfiles ( grep( /\.zip$/, @zips ) ) {
print "$zipfiles\n";
if ( $zipfiles =~ /\w+\.zip$/ ) {
my $zip = Archive::Zip->new();
my $zipName = "$zipfiles";
my $status = $zip->read($zipName);
die "Read of $zipName failed\n" if $status != AZ_OK;
print "$zipfiles\n";
$zip->extractTree();
#unlink($zipfiles);
}
}
答案 0 :(得分:1)
格式错误:错误签名:偏移568276处的0x00000000
这可能意味着该文件已损坏。 ZIP签名以0x4b50小端结束,但在您的情况下,它读取0x0000,表示该文件不符合ZIP规范。