| 1 | package CPAN::Mirror::Tiny::Archive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use File::Temp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use File::Which (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use IPC::Run3 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | sub run3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | my ($cmd, $outfile) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run3: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | IPC::Run3::run3 $cmd, \undef, ($outfile ? $outfile : \$out), \my $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | return ($?, $out, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my ($class, %argv) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $self = bless \%argv, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $self->_init_untar; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | $self->_init_unzip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $method = $file =~ /\.zip$/ ? $self->{method}{unzip} : $self->{method}{untar}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $self->$method($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | map { ($_, $self->{$_}) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | grep $self->{$_}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | qw(tar gzip bzip2 Archive::Tar unzip Archive::Zip), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub _init_untar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_untar: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $tar = $self->{tar} = File::Which::which('gtar') || File::Which::which("tar"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
File::Which::which('gtar') || File::Which::which('tar')
MC/DC0%0/2
File::Which::which('gtar') || File::Which::which('tar')
File::Which::which('gtar')
File::Which::which('tar')
Truth table0%0/3
A || B
A= File::Which::which('gtar')B= File::Which::which('tar')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($tar) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my ($exit, $out, $err) = run3 [$tar, '--version']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | $self->{tar_kind} = $out =~ /bsdtar/ ? "bsd" : "gnu"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | $self->{tar_bad} = 1 if $out =~ /GNU.*1\.13/i || $^O eq 'MSWin32' || $^O eq 'solaris' || $^O eq 'hpux'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$out =~ /GNU.*1\.13/i or $^O eq "MSWin32" or $^O eq "solaris" or $^O eq "hpux"
$out =~ /GNU.*1\.13/i or $^O eq "MSWin32" or $^O eq "solaris"
$out =~ /GNU.*1\.13/i or $^O eq "MSWin32"
MC/DC0%0/4
$out =~ /GNU.*1\.13/i or $^O eq "MSWin32" or $^O eq "solaris" or $^O eq "hpux"
$out =~ /GNU.*1\.13/i
$^O eq "MSWin32"
$^O eq "solaris"
$^O eq "hpux"
Truth table0%0/5
A or B or C or D
A= $out =~ /GNU.*1\.13/iB= $^O eq "MSWin32"C= $^O eq "solaris"D= $^O eq "hpux"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ($tar and !$self->{tar_bad}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tar and not $self->{"tar_bad"}
MC/DC0%0/2
$tar and not $self->{"tar_bad"}
$tar
not $self->{"tar_bad"}
Truth table0%0/3
A and not(B)
A= $tarB= not $self->{"tar_bad"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->{method}{untar} = *_untar; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | return if !$self->{_init_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $gzip = $self->{gzip} = File::Which::which("gzip"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $bzip2 = $self->{bzip2} = File::Which::which("bzip2"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ($tar && $gzip && $bzip2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$tar and $gzip and $bzip2
$tar and $gzip
MC/DC0%0/3
$tar and $gzip and $bzip2
$tar
$gzip
$bzip2
Truth table0%0/4
A and B and C
A= $tarB= $gzipC= $bzip2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->{method}{untar} = *_untar_bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return if !$self->{_init_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if (eval { require Archive::Tar }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->{"Archive::Tar"} = Archive::Tar->VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->{method}{untar} = *_untar_module; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return if !$self->{_init_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return if $self->{_init_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | $self->{method}{untar} = sub { die "There is no backend for untar" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub _init_unzip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_unzip: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $unzip = $self->{unzip} = File::Which::which("unzip"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($unzip) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->{method}{unzip} = *_unzip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | return if !$self->{_init_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (eval { require Archive::Zip }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $self->{"Archive::Zip"} = Archive::Zip->VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->{method}{unzip} = *_unzip_module; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | return if !$self->{_init_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return if $self->{_init_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $self->{method}{unzip} = sub { die "There is no backend for unzip" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub _untar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_untar: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my ($exit, $out, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $ar = $file =~ /\.bz2$/ ? 'j' : 'z'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ($exit, $out, $err) = run3 [$self->{tar}, "${ar}tf", $file]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | last if $exit != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $root = $self->_find_tarroot(split /\r?\n/, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ($exit, $out, $err) = run3 [$self->{tar}, "${ar}xf", $file, "-o"]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | return $root if $exit == 0 and -d $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exit == 0 and -d $root
MC/DC0%0/2
$exit == 0 and -d $root
$exit == 0
-d $root
Truth table0%0/3
A and B
A= $exit == 0B= -d $root
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | return if !$wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | return (undef, $err || $out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$err || $out
MC/DC0%0/2
$err || $out
$err
$out
Truth table0%0/3
A || B
A= $errB= $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | sub _untar_bad { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_untar_bad: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my ($exit, $out, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $ar = $file =~ /\.bz2$/ ? $self->{bzip2} : $self->{gzip}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $temp = File::Temp->new(SUFFIX => '.tar', EXLOCK => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ($exit, $out, $err) = run3 [$ar, "-dc", $file], $temp->filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | last if $exit != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # XXX /usr/bin/tar: Cannot connect to C: resolve failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my @opt = $^O eq 'MSWin32' && $self->{tar_kind} ne "bsd" ? ('--force-local') : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" and $self->{"tar_kind"} ne "bsd"
MC/DC0%0/2
$^O eq "MSWin32" and $self->{"tar_kind"} ne "bsd"
$^O eq "MSWin32"
$self->{"tar_kind"} ne "bsd"
Truth table0%0/3
A and B
A= $^O eq "MSWin32"B= $self->{"tar_kind"} ne "bsd"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ($exit, $out, $err) = run3 [$self->{tar}, @opt, "-tf", $temp->filename]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | last if $exit != 0 || !$out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exit != 0 or not $out
MC/DC0%0/2
$exit != 0 or not $out
$exit != 0
not $out
Truth table0%0/3
A or not(B)
A= $exit != 0B= not $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $root = $self->_find_tarroot(split /\r?\n/, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ($exit, $out, $err) = run3 [$self->{tar}, @opt, "-xf", $temp->filename, "-o"]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return $root if $exit == 0 and -d $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exit == 0 and -d $root
MC/DC0%0/2
$exit == 0 and -d $root
$exit == 0
-d $root
Truth table0%0/3
A and B
A= $exit == 0B= -d $root
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | return if !$wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return (undef, $err || $out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$err || $out
MC/DC0%0/2
$err || $out
$err
$out
Truth table0%0/3
A || B
A= $errB= $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | sub _untar_module { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_untar_module: not called CC=5 SCAR=30.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | local $Archive::Tar::WARN = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $t = Archive::Tar->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $ok = $t->read($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | last if !$ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $root = $self->_find_tarroot($t->list_files); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my @file = $t->extract; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return $root if @file and -d $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@file and -d $root
MC/DC0%0/2
@file and -d $root
@file
-d $root
Truth table0%0/3
A and B
A= @fileB= -d $root
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | return if !$wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | return (undef, $t->error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sub _find_tarroot { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my ($self, $root, @others) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_tarroot: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | FILE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | chomp $root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $root =~ s!^\./!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $root =~ s{^(.+?)/.*$}{$1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if (!length $root) { # archive had ./ as the first entry, so try again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $root = shift @others; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | redo FILE if $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | sub _unzip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unzip: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my ($exit, $out, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ($exit, $out, $err) = run3 [$self->{unzip}, '-t', $file]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | last if $exit != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $root = $self->_find_ziproot(split /\r?\n/, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ($exit, $out, $err) = run3 [$self->{unzip}, '-q', $file]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | return $root if $exit == 0 and -d $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exit == 0 and -d $root
MC/DC0%0/2
$exit == 0 and -d $root
$exit == 0
-d $root
Truth table0%0/3
A and B
A= $exit == 0B= -d $root
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | return if !$wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | return (undef, $err || $out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$err || $out
MC/DC0%0/2
$err || $out
$err
$out
Truth table0%0/3
A || B
A= $errB= $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | sub _unzip_module { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unzip_module: not called CC=8 SCAR=40.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $wantarray = wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my $err = ''; local $Archive::Zip::ErrorHandler = sub { $err .= "@_" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $zip = Archive::Zip->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | UNZIP: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $status = $zip->read($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | last UNZIP if $status != Archive::Zip::AZ_OK(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | for my $member ($zip->members) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $af = $member->fileName; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | next if $af =~ m!^(/|\.\./)!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $status = $member->extractToFileNamed($af); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | last UNZIP if $status != Archive::Zip::AZ_OK(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my ($root) = $zip->membersMatching(qr{^[^/]+/$}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | last UNZIP if !$root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $root = $root->fileName; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $root =~ s{/$}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return $root if -d $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return if !$wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return (undef, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | sub _find_ziproot { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my ($self, undef, $root, @others) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_ziproot: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | FILE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | chomp $root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if ($root !~ s{^\s+testing:\s+([^/]+)/.*?\s+OK$}{$1}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $root = shift @others; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | redo FILE if $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||