line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIME::Expander::Plugin::ApplicationZip; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
38647
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
142
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
130
|
|
5
|
4
|
|
|
4
|
|
22
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
236
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.01'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
1762
|
use parent qw(MIME::Expander::Plugin); |
|
4
|
|
|
|
|
370
|
|
|
4
|
|
|
|
|
44
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('ACCEPT_TYPES' => [qw( |
10
|
|
|
|
|
|
|
application/zip |
11
|
|
|
|
|
|
|
application/x-zip |
12
|
|
|
|
|
|
|
)]); |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
5129
|
use IO::Uncompress::Unzip; |
|
4
|
|
|
|
|
238319
|
|
|
4
|
|
|
|
|
1599
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub expand { |
17
|
3
|
|
|
3
|
0
|
10
|
my $self = shift; |
18
|
3
|
|
|
|
|
24
|
my $contents = shift; |
19
|
3
|
|
|
|
|
8
|
my $callback = shift; |
20
|
3
|
|
|
|
|
8
|
my $c = 0; |
21
|
|
|
|
|
|
|
|
22
|
3
|
50
|
|
|
|
48
|
my $uzip = IO::Uncompress::Unzip->new( |
|
|
50
|
|
|
|
|
|
23
|
|
|
|
|
|
|
ref $contents eq 'SCALAR' ? $contents : \$contents |
24
|
|
|
|
|
|
|
, Append => 1) |
25
|
|
|
|
|
|
|
or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n"; |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
4102
|
my $status; |
28
|
3
|
|
|
|
|
17
|
for( $status = 1; 0 < $status; $status = $uzip->nextStream ){ |
29
|
|
|
|
|
|
|
|
30
|
9
|
50
|
|
|
|
4292
|
die "Error processing as zip: $!" |
31
|
|
|
|
|
|
|
if( $status < 0 ); |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
18
|
my $bytes; |
34
|
|
|
|
|
|
|
my $buff; |
35
|
9
|
|
|
|
|
36
|
1 while( 0 < ($bytes = $uzip->read($buff)) ); |
36
|
|
|
|
|
|
|
|
37
|
9
|
50
|
|
|
|
8189
|
last if( $bytes < 0 ); |
38
|
|
|
|
|
|
|
|
39
|
9
|
|
|
|
|
53
|
my $name = $uzip->getHeaderInfo->{Name}; |
40
|
9
|
100
|
66
|
|
|
340
|
next if( $name and $name =~ m,/$, ); |
41
|
|
|
|
|
|
|
|
42
|
6
|
50
|
|
|
|
64
|
$callback->( \$buff, { |
43
|
|
|
|
|
|
|
filename => $name, |
44
|
|
|
|
|
|
|
} ) if( ref $callback eq 'CODE' ); |
45
|
6
|
|
|
|
|
5310
|
++$c; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
2109
|
return $c; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |