line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Merged; |
2
|
2
|
|
|
2
|
|
70286
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
71
|
|
3
|
2
|
|
|
2
|
|
11
|
use Carp qw(croak); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
877
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Archive::Merged - virtually merge two archives |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $merged = Archive::Merged->new( |
13
|
|
|
|
|
|
|
Archive::Tar->new( 'default_theme.tar' ), |
14
|
|
|
|
|
|
|
Archive::SevenZip->archiveTarApi( archivename => 'theme.zip' ), |
15
|
|
|
|
|
|
|
Archive::Dir->new( 'customized/' ), |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 C<< Archive::Merged->new >> |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $merged = Archive::Merged->new( |
23
|
|
|
|
|
|
|
Archive::Tar->new( 'default_theme.tar' ), |
24
|
|
|
|
|
|
|
Archive::Dir->new( 'customized/' ), |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Creates a new archive as the merged view of one or more archives |
28
|
|
|
|
|
|
|
or directories. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
1
|
|
|
1
|
1
|
6
|
my ($class, @archives) = @_; |
34
|
1
|
|
|
|
|
4
|
my $self = { |
35
|
|
|
|
|
|
|
archives => \@archives, |
36
|
|
|
|
|
|
|
}; |
37
|
1
|
|
|
|
|
3
|
bless $self => $class; |
38
|
1
|
|
|
|
|
3
|
$self |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 C<< ->directory >> |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub directory { |
46
|
|
|
|
|
|
|
undef |
47
|
0
|
|
|
0
|
1
|
0
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 C<< ->archives >> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my @archives = $merged->archives; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Accessor for the archives that represent this archive. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub archives { |
58
|
1
|
|
|
1
|
1
|
2
|
@{ $_[0]->{archives} } |
|
1
|
|
|
|
|
7
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 C<< ->contains_file >> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if( $merged->contains_file( $file ) ) { |
64
|
|
|
|
|
|
|
print "Yay!" |
65
|
|
|
|
|
|
|
} else { |
66
|
|
|
|
|
|
|
print "File '$file' not found"; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns the underlying archive that contains the file. Returns |
70
|
|
|
|
|
|
|
undef if the file is not found. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub contains_file { |
75
|
1
|
|
|
1
|
1
|
7
|
my( $self, $file ) = @_; |
76
|
1
|
|
|
|
|
5
|
for my $ar ($self->archives) { |
77
|
1
|
50
|
|
|
|
5
|
if( $ar->contains_file( $file ) ) { |
78
|
1
|
|
|
|
|
229
|
return $ar |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C<< ->get_content( $file, %options ) >> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $content = $merged->get_content( $file, binmode => ':raw' ) |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns the content of the file, potentially with the encoding. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub get_content { |
92
|
0
|
|
|
0
|
1
|
|
my( $self, $file, %options ) = @_; |
93
|
0
|
|
|
|
|
|
my $ar = $self->contains_file( $file ); |
94
|
0
|
|
|
|
|
|
$ar->get_content( $file, %options ) |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C<< ->list_files( ) >> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my @contents = $merged->list_files; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Lists the contained files of the archive. Files that are shadowed |
102
|
|
|
|
|
|
|
are only listed once. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub list_files { |
107
|
0
|
|
|
0
|
1
|
|
my ($self,$properties) = @_; |
108
|
0
|
0
|
|
|
|
|
croak "Listing properties is not (yet) implemented" |
109
|
|
|
|
|
|
|
if $properties; |
110
|
0
|
|
|
|
|
|
my %seen; |
111
|
|
|
|
|
|
|
my @files; |
112
|
0
|
|
|
|
|
|
for my $ar ($self->archives) { |
113
|
0
|
|
|
|
|
|
for my $file ($ar->list_files) { |
114
|
0
|
0
|
|
|
|
|
if( ! $seen{ $file }++) { |
115
|
0
|
|
|
|
|
|
push @files, $file; |
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
}; |
119
|
|
|
|
|
|
|
@files |
120
|
0
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 C<< ->extract_file( ) >> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$merged->extract_file( $name => $target ); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Extracts the file to the target name. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub extract_file { |
131
|
0
|
|
|
0
|
1
|
|
my ($self,$file,$target) = @_; |
132
|
0
|
|
|
|
|
|
my $ar = $self->contains_file( $file ); |
133
|
0
|
|
|
|
|
|
$ar->extract_file( $file, $target ); |
134
|
|
|
|
|
|
|
}; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 REPOSITORY |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The public repository of this module is |
141
|
|
|
|
|
|
|
L. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SUPPORT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
The public support forum of this module is |
146
|
|
|
|
|
|
|
L. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 BUG TRACKER |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Please report bugs in this module via the RT CPAN bug queue at |
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
or via mail to L. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Max Maischein C |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Copyright 2015-2023 by Max Maischein C. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 LICENSE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SEE ALSO |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
L |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |