Archive-SevenZip

 view release on metacpan or  search on metacpan

lib/Archive/SevenZip/Entry.pm  view on Meta::CPAN


Returns the time of last modification of the stored file as number of seconds

=cut

sub lastModTime {
    (my $dt = $_[0]->{Modified}) =~ s/\.\d+$//;
    Time::Piece->strptime($dt, '%Y-%m-%d %H:%M:%S')->epoch;
}

sub lastModFileDateTime {
    Archive::Zip::Member::_unixToDosTime($_[0]->lastModTime())
}

sub crc32 {
    hex( $_[0]->{CRC} );
}

sub crc32String {
    lc $_[0]->{CRC};
}

lib/Archive/SevenZip/Entry.pm  view on Meta::CPAN

    <$fh>
}

# Archive::Zip API
#externalFileName()

# Archive::Zip API
#fileName()

# Archive::Zip API
#lastModFileDateTime()

# Archive::Zip API
#lastModTime()

=item C<< ->extractToFileNamed $name >>

  $entry->extractToFileNamed( '/tmp/foo.txt' );

Extracts the data

t/02_main.t  view on Meta::CPAN

#--------- check time conversion

foreach my $unix_time (
    315576062,  315576064,  315580000,  315600000,
    316000000,  320000000,  400000000,  500000000,
    600000000,  700000000,  800000000,  900000000,
    1000000000, 1100000000, 1200000000, int(time() / 2) * 2,
  ) {
    my $dos_time   = Archive::Zip::Member::_unixToDosTime($unix_time);
    my $round_trip = Archive::Zip::Member::_dosToUnixTime($dos_time);
    is($unix_time, $round_trip, 'Got expected DOS DateTime value');
}

#####################################################################
# Testing Archives

my $version = Archive::SevenZip->find_7z_executable();
if( ! $version ) {
    SKIP: { skip "7z binary not found (not installed?)", 64; }
    exit;
};

t/02_main.t  view on Meta::CPAN

my $dirName    = TESTDIR();

# addDirectory	# Archive::Zip::Archive
# new	# Archive::Zip::Member
my $member = $zip->addDirectory($memberName);
ok(defined($member));
is($member->fileName(), $memberName);

# On some (Windows systems) the modification time is
# corrupted. Save this to check late.
my $dir_time = $member->lastModFileDateTime();
note "Time is $dir_time";

# members	# Archive::Zip::Archive
@members = $zip->members();
is(scalar(@members), 1, "We have one member");
is($members[0]->fileName,      $member->fileName, "... with the correct filename");

# numberOfMembers	# Archive::Zip::Archive
$numberOfMembers = $zip->numberOfMembers();
is($numberOfMembers, 1);

# writeToFileNamed	# Archive::Zip::Archive
$status = $zip->writeToFileNamed(OUTPUTZIP());
is($status, AZ_OK);

# Does the modification time get corrupted?
is(($zip->members)[0]->lastModFileDateTime(), $dir_time);

SKIP: {
    skip("No 'unzip' program to test against", 1) unless HAVEUNZIP();
    ($status, $zipout) = testZip();

    # STDERR->print("status= $status, out=$zipout\n");
    skip("test zip doesn't work", 1) if $testZipDoesntWork;
    is($status, 0);
}



( run in 0.313 second using v1.01-cache-2.11-cpan-05444aca049 )