| 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.01'; | |||||||||||||||||||||||||||
| 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 | application/x-zip | ||||||||||||||||||||||||||||
| 12 | )]); | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use IO::Uncompress::Unzip; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub expand { | ||||||||||||||||||||||||||||
| 17 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
expand: called CC=10 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 3 | my $contents = shift; | |||||||||||||||||||||||||||
| 19 | 3 | my $callback = shift; | |||||||||||||||||||||||||||
| 20 | 3 | my $c = 0; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | my $uzip = IO::Uncompress::Unzip->new( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 23 | ref $contents eq 'SCALAR' ? $contents : \$contents | ||||||||||||||||||||||||||||
| 24 | , Append => 1) | ||||||||||||||||||||||||||||
| 25 | or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n"; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 3 | my $status; | |||||||||||||||||||||||||||
| 28 | 3 | ▶ | for( $status = 1; 0 < $status; $status = $uzip->nextStream ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 9 | ▶ | die "Error processing as zip: $!" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | if( $status < 0 ); | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 9 | my $bytes; | |||||||||||||||||||||||||||
| 34 | my $buff; | ||||||||||||||||||||||||||||
| 35 | 9 | ▶ | 1 while( 0 < ($bytes = $uzip->read($buff)) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 9 | ▶ | last if( $bytes < 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 9 | my $name = $uzip->getHeaderInfo->{Name}; | |||||||||||||||||||||||||||
| 40 | 9 | ▶ | 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[/$]
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 6 | ▶ | $callback->( \$buff, { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | filename => $name, | ||||||||||||||||||||||||||||
| 44 | } ) if( ref $callback eq 'CODE' ); | ||||||||||||||||||||||||||||
| 45 | 6 | ++$c; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 3 | return $c; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 4 | 1; | |||||||||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||||||||||