| 1 | package MIME::Expander::Plugin::ApplicationZip; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use parent qw(MIME::Expander::Plugin); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | __PACKAGE__->mk_classdata('ACCEPT_TYPES' => [qw( | |||||||||||||||||||||||||||
| 10 | application/zip | ||||||||||||||||||||||||||||
| 11 | )]); | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use IO::Uncompress::Unzip; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | sub expand { | ||||||||||||||||||||||||||
|
Subroutine
expand: called CC=9 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 17 | 4 | my $part = shift; | |||||||||||||||||||||||||||
| 18 | 4 | my $callback = shift; | |||||||||||||||||||||||||||
| 19 | 4 | my $c = 0; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | my $contents = $part->body; | |||||||||||||||||||||||||||
| 22 | 4 | ▶ | my $uzip = IO::Uncompress::Unzip->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | \$contents, Append => 1 | ||||||||||||||||||||||||||||
| 24 | ) or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n"; | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | my $status; | |||||||||||||||||||||||||||
| 27 | 4 | ▶ | for( $status = 1; 0 < $status; $status = $uzip->nextStream ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 11 | ▶ | die "Error processing as zip: $!" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | if( $status < 0 ); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 11 | my $bytes; | |||||||||||||||||||||||||||
| 33 | my $buff; | ||||||||||||||||||||||||||||
| 34 | 11 | ▶ | 1 while( 0 < ($bytes = $uzip->read($buff)) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 11 | ▶ | last if( $bytes < 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 11 | my $name = $uzip->getHeaderInfo->{Name}; | |||||||||||||||||||||||||||
| 39 | 11 | ▶ | next if( $name and $name =~ m,/$, ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name and $name =~ m[/$]
MC/DC50%1/2
$name and $name =~ m[/$]
$name
$name =~ m[/$]
Truth table66%2/3
A and B
A= $nameB= $name =~ m[/$]
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 8 | ▶ | $callback->( \$buff, { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | filename => $name, | ||||||||||||||||||||||||||||
| 43 | } ) if( ref $callback eq 'CODE' ); | ||||||||||||||||||||||||||||
| 44 | 8 | ++$c; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 4 | return $c; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 4 | 1; | |||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||