Archive-Zip

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


1.15_01 Wed Mar  9 22:26:52 CST 2005
    - added fix for RT #11818 extractMember method corrupts archive
    - added t/pod.t to test for pod correctness

1.10 Thu Mar 25 06:24:17 PST 2004
    - Fixed documentation of setErrorHandler()
    - Fixed link to Japanese translation of docs
    - Added Compress::Zlib Bufsize patch from Yeasah Pell that was supposed to
      have been added in 1.02
    - Fixed problems with backup filenames for zips with no extension
    - Fixed problems with undef volume names in _asLocalName()

1.09 Wed Nov 26 17:43:49 PST 2003
    - Fixed handling of inserted garbage (as from viruses)
    - Always check for local header signatures before using them
    - Added updateMember() and updateTree() functions
    - Added examples/mailZip.pl
    - Added examples/updateTree.pl
    - Fixed some potential but unreported bugs with function parameters like '0'
    - Removed stray warn() call

lib/Archive/Zip/Archive.pm  view on Meta::CPAN

# as safely as possible.
# Returns AZ_OK if successful.
sub overwriteAs {
    my $self = shift;
    my $zipName = (ref($_[0]) eq 'HASH') ? $_[0]->{filename} : shift;
    return _error("no filename in overwriteAs()") unless defined($zipName);

    my ($fh, $tempName) = Archive::Zip::tempFile();
    return _error("Can't open temp file", $!) unless $fh;

    (my $backupName = $zipName) =~ s{(\.[^.]*)?$}{.zbk};

    my $status = $self->writeToFileHandle($fh);
    $fh->close();
    $fh = undef;

    if ($status != AZ_OK) {
        unlink($tempName);
        _printError("Can't write to $tempName");
        return $status;
    }

    my $err;

    # rename the zip
    if (-f $zipName && !rename($zipName, $backupName)) {
        $err = $!;
        unlink($tempName);
        return _error("Can't rename $zipName as $backupName", $err);
    }

    # move the temp to the original name (possibly copying)
    unless (File::Copy::move($tempName, $zipName)
        || File::Copy::copy($tempName, $zipName)) {
        $err = $!;
        rename($backupName, $zipName);
        unlink($tempName);
        return _error("Can't move $tempName to $zipName", $err);
    }

    # unlink the backup
    if (-f $backupName && !unlink($backupName)) {
        $err = $!;
        return _error("Can't unlink $backupName", $err);
    }

    return AZ_OK;
}

# Used only during writing
sub _writeCentralDirectoryOffset {
    shift->{'writeCentralDirectoryOffset'};
}



( run in 1.244 second using v1.01-cache-2.11-cpan-49f99fa48dc )