Archive-SevenZip
view release on metacpan or search on metacpan
lib/Archive/SevenZip/Entry.pm view on Meta::CPAN
package Archive::SevenZip::Entry;
use strict;
use warnings;
use Archive::Zip::Member;
use Time::Piece; # for strptime
use File::Basename ();
use Path::Class ();
our $VERSION= '0.20';
=head1 NAME
Archive::SevenZip::Entry - a member of an archive
=head1 SYNOPSIS
use POSIX 'strftime';
for my $entry ( $ar->list ) {
print $entry->fileName,"\n";
print strftime('%Y-%m-%d %H:%M', gmtime($entry->lastModTime)),"\n";
my $content = $entry->slurp();
print $content;
};
=cut
sub new {
my( $class, %options) = @_;
bless \%options => $class
}
=head1 METHODS
=over 4
=item C<< ->archive >>
my $ar = $entry->archive();
Returns the containing archive as an L<Archive::SevenZip> object.
=cut
sub archive {
$_[0]->{_Container}
}
=item C<< ->fileName >>
my $fn = $entry->fileName();
Returns the stored path
=cut
sub fileName {
my( $self ) = @_;
my $res = $self->{Path};
# Normalize to unixy path names
$res =~ s!\\!/!g;
# If we're a directory, append the slash:
if( exists $self->{Folder} and $self->{Folder} eq '+') {
$res .= '/';
};
$res
}
=item C<< ->basename >>
my $fn = $entry->basename();
Returns the stored filename without a directory
=cut
# Class::Path API
sub basename {
Path::Class::file( $_[0]->{Path} )->basename
}
=item C<< ->components >>
my @parts = $entry->components();
Returns the stored filename as an array of directory names and the file name
( run in 0.341 second using v1.01-cache-2.11-cpan-a5abf4f5562 )