| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Archive::Peek::External; |
|
2
|
1
|
|
|
1
|
|
1148
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Archive::Peek::External::Tar; |
|
4
|
|
|
|
|
|
|
use Archive::Peek::External::Zip; |
|
5
|
|
|
|
|
|
|
use MooseX::Types::Path::Class qw( File ); |
|
6
|
|
|
|
|
|
|
our $VERSION = '0.35'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'filename' => ( |
|
9
|
|
|
|
|
|
|
is => 'ro', |
|
10
|
|
|
|
|
|
|
isa => File, |
|
11
|
|
|
|
|
|
|
required => 1, |
|
12
|
|
|
|
|
|
|
coerce => 1, |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub BUILD { |
|
16
|
|
|
|
|
|
|
my $self = shift; |
|
17
|
|
|
|
|
|
|
my $filename = $self->filename; |
|
18
|
|
|
|
|
|
|
my $basename = $filename->basename; |
|
19
|
|
|
|
|
|
|
if ( $basename =~ /\.zip$/i ) { |
|
20
|
|
|
|
|
|
|
bless $self, 'Archive::Peek::External::Zip'; |
|
21
|
|
|
|
|
|
|
} elsif ( $basename =~ /(\.tar|\.tar\.gz|\.tgz|\.bz2|\.bzip2)$/i ) { |
|
22
|
|
|
|
|
|
|
bless $self, 'Archive::Peek::External::Tar'; |
|
23
|
|
|
|
|
|
|
} else { |
|
24
|
|
|
|
|
|
|
confess("Failed to open $filename"); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Archive::Peek::External - Peek into archives without extracting them (using external tools) |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use Archive::Peek::External; |
|
39
|
|
|
|
|
|
|
my $peek = Archive::Peek::External->new( filename => 'archive.tgz' ); |
|
40
|
|
|
|
|
|
|
my @files = $peek->files(); |
|
41
|
|
|
|
|
|
|
my $contents = $peek->file('README.txt') |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This module lets you peek into archives without extracting them. |
|
46
|
|
|
|
|
|
|
It currently supports tar files and zip files using external tools |
|
47
|
|
|
|
|
|
|
such as 'tar' and 'unzip'. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 new |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
The constructor takes the filename of the archive to peek into: |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $peek = Archive::Peek::External->new( filename => 'archive.tgz' ); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 files |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns the files in the archive: |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my @files = $peek->files(); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 file |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns the contents of a file in the archive: |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $contents = $peek->file('README.txt') |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Leon Brocard <acme@astray.com> |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Copyright (C) 2011, Leon Brocard. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LICENSE |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This module is free software; you can redistribute it or |
|
80
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |