【问题标题】:Unable to Extract the Zip file using Perl无法使用 Perl 提取 Zip 文件
【发布时间】:2015-12-29 09:37:11
【问题描述】:

我尝试从 zip 容器中提取文件,但我的脚本没有返回以下错误

错误详情:

格式错误:错误签名:文件中偏移量 568276 处的 0x00000000 AUS-000X-201512 28234755_Data.zip 在 C:/Perl64/lib/Archive/Zip.pm 行 477.Archive::Zip::_readSignature('IO::File=GLOB(0x2a5e2a8)', 'AUS-000X-20151228234755_Data.zip') 调用于 C:/Perl64/lib/Archive/Zip/Archive.pm 第 603 行 Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x32c1e8)', 'IO::File=GLOB(0x2a5e2a8)', 'AUS-000X-20151228234755_Data.zip') 调用 在 C:/Perl64/lib/Archive/Zip/Archive.pm 第 548 行 Archive::Zip::Archive::read('Archive::Zip::Archive=HASH(0x32c1e8)', '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);
    }

}

【问题讨论】:

  • 您是否尝试过“手动”解压缩同一个文件?你得到同样的错误吗?在这种情况下,文件已损坏。

标签: perl


【解决方案1】:

格式错误:错误签名:偏移量 568276 处的 0x00000000

这可能意味着文件已损坏。 ZIP 签名以 0x4b50 little endian 结尾,但在您的情况下,它读取 0x0000,这表明该文件不符合 ZIP 规范。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多