Reputation: 31
I have tried to extract files from a zip container, but my script does not returns the below error
Error Details:
format error: bad signature: 0x00000000 at offset 568276 in file 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') called at C:/Perl64/lib/Archive/Zip/Archive.pm line 603 Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x32c1e8)', 'IO::File=GLOB(0x2a5e2a8)', 'AUS-000X-20151228234755_Data.zip') called at C:/Perl64/lib/Archive/Zip/Archive.pm line 548 Archive::Zip::Archive::read('Archive::Zip::Archive=HASH(0x32c1e8)', 'AUS-000X-20151228234755_Data.zip') called at zip_extraction.pl line 14 Read of AUS-000X-20151228234755_Data.zip failed
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);
}
}
Upvotes: 0
Views: 911
Reputation: 123270
format error: bad signature: 0x00000000 at offset 568276
This probably means that the file is corrupt. ZIP signatures end with 0x4b50 little endian but in your case it reads 0x0000 which indicates that the file does not conform to the ZIP specification.
Upvotes: 1