line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Peek; |
2
|
1
|
|
|
1
|
|
1717
|
use Moose; |
|
1
|
|
|
|
|
519740
|
|
|
1
|
|
|
|
|
10
|
|
3
|
1
|
|
|
1
|
|
9612
|
use Archive::Peek::Tar; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
828
|
use Archive::Peek::Zip; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
5
|
1
|
|
|
1
|
|
1004
|
use MooseX::Types::Path::Class qw( File ); |
|
1
|
|
|
|
|
137589
|
|
|
1
|
|
|
|
|
9
|
|
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
|
3
|
|
|
3
|
0
|
10565
|
my $self = shift; |
17
|
3
|
|
|
|
|
118
|
my $filename = $self->filename; |
18
|
3
|
|
|
|
|
16
|
my $basename = $filename->basename; |
19
|
3
|
100
|
|
|
|
46
|
if ( $basename =~ /\.zip$/i ) { |
|
|
50
|
|
|
|
|
|
20
|
1
|
|
|
|
|
7
|
bless $self, 'Archive::Peek::Zip'; |
21
|
|
|
|
|
|
|
} elsif ( $basename =~ /(\.tar|\.tar\.gz|\.tgz|\.bz2|\.bzip2)$/i ) { |
22
|
2
|
|
|
|
|
13
|
bless $self, 'Archive::Peek::Tar'; |
23
|
|
|
|
|
|
|
} else { |
24
|
0
|
|
|
|
|
|
confess("Failed to open $filename"); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Archive::Peek - Peek into archives without extracting them |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use Archive::Peek; |
39
|
|
|
|
|
|
|
my $peek = Archive::Peek->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. To support Bzip2- |
47
|
|
|
|
|
|
|
compressed files, you should install IO::Uncompress::Bunzip2. |
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->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) 2008, 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. |