line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# PANT::Zip - Provide support for zip archives
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package PANT::Zip;
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2162
|
use 5.008;
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
57
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
7
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
7
|
use Carp;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
9
|
1
|
|
|
1
|
|
5
|
use Cwd;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
210
|
|
10
|
1
|
|
|
1
|
|
8
|
use XML::Writer;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
11
|
1
|
|
|
1
|
|
1214
|
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );;
|
|
1
|
|
|
|
|
142395
|
|
|
1
|
|
|
|
|
183
|
|
12
|
1
|
|
|
1
|
|
11
|
use Exporter;
|
|
1
|
|
|
|
|
25
|
|
|
1
|
|
|
|
|
709
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export
|
17
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead.
|
18
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants.
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# This allows declaration use PANT ':all';
|
21
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
22
|
|
|
|
|
|
|
# will save memory.
|
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @EXPORT = qw( );
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '0.04';
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new {
|
33
|
1
|
|
|
1
|
1
|
14
|
my($clsname, $writer, $zipname, @rest) =@_;
|
34
|
1
|
|
|
|
|
10
|
my $self = {
|
35
|
|
|
|
|
|
|
writer=>$writer,
|
36
|
|
|
|
|
|
|
name=>$zipname,
|
37
|
|
|
|
|
|
|
zip=>Archive::Zip->new(),
|
38
|
|
|
|
|
|
|
compression=>9,
|
39
|
|
|
|
|
|
|
@rest,
|
40
|
|
|
|
|
|
|
};
|
41
|
1
|
|
|
|
|
47
|
bless $self, $clsname;
|
42
|
1
|
|
|
|
|
4
|
return $self;
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub Compression {
|
46
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
47
|
0
|
|
|
|
|
0
|
my $oval = $self->{compression};
|
48
|
0
|
|
|
|
|
0
|
$self->{compression} = shift;
|
49
|
0
|
|
|
|
|
0
|
return $oval;
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub AddFile {
|
53
|
1
|
|
|
1
|
1
|
887
|
my($self, $name, $newname) = @_;
|
54
|
1
|
|
|
|
|
3
|
my $writer = $self->{writer};
|
55
|
1
|
|
|
|
|
2
|
my $zip = $self->{zip};
|
56
|
1
|
50
|
|
|
|
6
|
my $extra = $newname ? " as $newname" : "";
|
57
|
1
|
|
|
|
|
9
|
$writer->dataElement('li', "Adding file $name$extra to zip archive $self->{name}\n");
|
58
|
1
|
50
|
|
|
|
83
|
return 1 if ($self->{dryrun});
|
59
|
1
|
|
|
|
|
6
|
return $zip->addFile($name, $newname);
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub AddTree {
|
63
|
1
|
|
|
1
|
1
|
1098
|
my($self, $name, $newname, $func) = @_;
|
64
|
1
|
|
|
|
|
3
|
my $writer = $self->{writer};
|
65
|
1
|
|
|
|
|
3
|
my $zip = $self->{zip};
|
66
|
1
|
50
|
|
|
|
5
|
my $extra = $newname ? " as $newname" : "";
|
67
|
1
|
|
|
|
|
7
|
$writer->dataElement('li', "Adding tree $name$extra to zip archive $self->{name}\n");
|
68
|
1
|
50
|
|
|
|
227
|
return 1 if ($self->{dryrun});
|
69
|
1
|
|
|
|
|
6
|
return $zip->addTree($name, $newname, $func) == AZ_OK;
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub Close {
|
73
|
1
|
|
|
1
|
0
|
31380
|
my($self) = @_;
|
74
|
1
|
|
|
|
|
6
|
my $writer = $self->{writer};
|
75
|
1
|
|
|
|
|
4
|
my $zip = $self->{zip};
|
76
|
1
|
|
|
|
|
20
|
foreach my $zm ($zip->members()) {
|
77
|
10
|
|
|
|
|
104
|
$zm->desiredCompressionLevel($self->{compression});
|
78
|
|
|
|
|
|
|
}
|
79
|
1
|
|
|
|
|
41
|
$writer->dataElement('li', "Writing out zip file $self->{name}\n");
|
80
|
1
|
50
|
|
|
|
181
|
return 1 if ($self->{dryrun});
|
81
|
1
|
|
|
|
|
11
|
return $zip->writeToFileNamed($self->{name}) == AZ_OK;
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1;
|
85
|
|
|
|
|
|
|
__END__
|