line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Any::Create; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
32166
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
171
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
2848
|
use Exception::Class 'Archive::Any::Create::Error'; |
|
3
|
|
|
|
|
42664
|
|
|
3
|
|
|
|
|
23
|
|
7
|
3
|
|
|
3
|
|
3631
|
use UNIVERSAL::require; |
|
3
|
|
|
|
|
5139
|
|
|
3
|
|
|
|
|
38
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our %Type2Class = ( |
10
|
|
|
|
|
|
|
'tar' => [ 'Archive::Any::Create::Tar' ], |
11
|
|
|
|
|
|
|
'tar.gz' => [ 'Archive::Any::Create::Tar', { comp => 1 } ], |
12
|
|
|
|
|
|
|
'zip' => [ 'Archive::Any::Create::Zip' ], |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $re = '(' . join('|', map quotemeta, keys %Type2Class) . ')$'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
2
|
|
|
2
|
1
|
25
|
my $class = shift; |
19
|
2
|
|
|
|
|
12
|
bless [ ], $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub container { |
23
|
2
|
|
|
2
|
1
|
13
|
my $self = shift; |
24
|
2
|
|
|
|
|
26
|
push @$self, [ 'container', @_ ]; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub add_file { |
28
|
4
|
|
|
4
|
1
|
23
|
my $self = shift; |
29
|
4
|
|
|
|
|
16
|
push @$self, [ 'add_file', @_ ]; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub write_file { |
33
|
2
|
|
|
2
|
1
|
12
|
my $self = shift; |
34
|
2
|
|
|
|
|
11
|
$self->proxy_methods($_[0])->write_file(@_); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub write_filehandle { |
38
|
2
|
|
|
2
|
1
|
264
|
my $self = shift; |
39
|
2
|
|
|
|
|
8
|
$self->proxy_methods($_[1])->write_filehandle(@_); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub proxy_methods { |
43
|
4
|
|
|
4
|
0
|
6
|
my $self = shift; |
44
|
4
|
|
|
|
|
9
|
my($file) = @_; |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
12
|
my @methods = @$self; |
47
|
|
|
|
|
|
|
|
48
|
4
|
50
|
|
|
|
168
|
$file =~ /$re/ or throw Archive::Any::Create::Error(error => "Can't detect archive type via filename $file"); |
49
|
4
|
|
|
|
|
10
|
my($subclass, $opt) = @{ $Type2Class{$1} }; |
|
4
|
|
|
|
|
22
|
|
50
|
4
|
50
|
|
|
|
51
|
$subclass->require or die $@; |
51
|
4
|
|
|
|
|
99
|
$self = bless { }, $subclass; |
52
|
4
|
|
|
|
|
17
|
$self->init($opt); |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
73
|
for my $m (@methods) { |
55
|
12
|
|
|
|
|
1521
|
my($method, @args) = @$m; |
56
|
12
|
|
|
|
|
42
|
$self->$method(@args); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
618
|
$self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |