Archive-Merged
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Archive/Merged.pm view on Meta::CPAN
package Archive::Merged;
use strict;
use Carp qw(croak);
our $VERSION = '0.03';
=head1 NAME
Archive::Merged - virtually merge two archives
=head1 SYNOPSIS
my $merged = Archive::Merged->new(
Archive::Tar->new( 'default_theme.tar' ),
Archive::SevenZip->archiveTarApi( archivename => 'theme.zip' ),
Archive::Dir->new( 'customized/' ),
);
=head1 METHODS
=head2 C<< Archive::Merged->new >>
my $merged = Archive::Merged->new(
Archive::Tar->new( 'default_theme.tar' ),
Archive::Dir->new( 'customized/' ),
);
Creates a new archive as the merged view of one or more archives
or directories.
=cut
sub new {
my ($class, @archives) = @_;
my $self = {
archives => \@archives,
};
bless $self => $class;
$self
};
=head2 C<< ->directory >>
=cut
sub directory {
undef
};
=head2 C<< ->archives >>
my @archives = $merged->archives;
Accessor for the archives that represent this archive.
=cut
sub archives {
@{ $_[0]->{archives} }
}
=head2 C<< ->contains_file >>
if( $merged->contains_file( $file ) ) {
print "Yay!"
} else {
print "File '$file' not found";
};
Returns the underlying archive that contains the file. Returns
undef if the file is not found.
=cut
sub contains_file {
my( $self, $file ) = @_;
for my $ar ($self->archives) {
if( $ar->contains_file( $file ) ) {
return $ar
};
};
};
=head2 C<< ->get_content( $file, %options ) >>
my $content = $merged->get_content( $file, binmode => ':raw' )
Returns the content of the file, potentially with the encoding.
=cut
sub get_content {
my( $self, $file, %options ) = @_;
my $ar = $self->contains_file( $file );
$ar->get_content( $file, %options )
};
=head2 C<< ->list_files( ) >>
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.491 second using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )