line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIME::Expander::Plugin::ApplicationZip; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
104585
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
141
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
121
|
|
5
|
4
|
|
|
4
|
|
13
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
190
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
16
|
use parent qw(MIME::Expander::Plugin); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('ACCEPT_TYPES' => [qw( |
10
|
|
|
|
|
|
|
application/zip |
11
|
|
|
|
|
|
|
)]); |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
2767
|
use IO::Uncompress::Unzip; |
|
4
|
|
|
|
|
135068
|
|
|
4
|
|
|
|
|
1073
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub expand { |
16
|
4
|
|
|
4
|
0
|
5438
|
my $self = shift; |
17
|
4
|
|
|
|
|
8
|
my $part = shift; |
18
|
4
|
|
|
|
|
6
|
my $callback = shift; |
19
|
4
|
|
|
|
|
9
|
my $c = 0; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
14
|
my $contents = $part->body; |
22
|
4
|
50
|
|
|
|
311
|
my $uzip = IO::Uncompress::Unzip->new( |
23
|
|
|
|
|
|
|
\$contents, Append => 1 |
24
|
|
|
|
|
|
|
) or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n"; |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
4013
|
my $status; |
27
|
4
|
|
|
|
|
16
|
for( $status = 1; 0 < $status; $status = $uzip->nextStream ){ |
28
|
|
|
|
|
|
|
|
29
|
11
|
50
|
|
|
|
3278
|
die "Error processing as zip: $!" |
30
|
|
|
|
|
|
|
if( $status < 0 ); |
31
|
|
|
|
|
|
|
|
32
|
11
|
|
|
|
|
17
|
my $bytes; |
33
|
|
|
|
|
|
|
my $buff; |
34
|
11
|
|
|
|
|
30
|
1 while( 0 < ($bytes = $uzip->read($buff)) ); |
35
|
|
|
|
|
|
|
|
36
|
11
|
50
|
|
|
|
3994
|
last if( $bytes < 0 ); |
37
|
|
|
|
|
|
|
|
38
|
11
|
|
|
|
|
35
|
my $name = $uzip->getHeaderInfo->{Name}; |
39
|
11
|
100
|
66
|
|
|
136
|
next if( $name and $name =~ m,/$, ); |
40
|
|
|
|
|
|
|
|
41
|
8
|
50
|
|
|
|
51
|
$callback->( \$buff, { |
42
|
|
|
|
|
|
|
filename => $name, |
43
|
|
|
|
|
|
|
} ) if( ref $callback eq 'CODE' ); |
44
|
8
|
|
|
|
|
4754
|
++$c; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
588
|
return $c; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |