blib/lib/CPAN/Tarzip.pm

filter: Statementstmt 21.7% 112 / 514 Branchbran 13.1% 49 / 372 Conditioncond 14.6% 12 / 82 MC/DCmcdc 1.8% 1 / 53 Subroutinesub 46.4% 13 / 28 Podpod 0.0% 0 / 12 totaltotal 17.6% 187 / 1061 CC 223 SCAR 63.6
CC
223
Cov
18%
untar
1462.6
untar
1462.6
gtest
202.1
CRAP 580.4
« blib/lib/CPAN/Shell.pm ↑ Summary blib/lib/CPAN/Distribution.pm »
1 # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
2 package CPAN::Tarzip;
3 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 ▶use vars qw($VERSION @ISA $BUGHUNTING);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use CPAN::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 26 ▶use File::Basename qw(basename);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 26 $VERSION = "5.5014";
8 # module is internal to CPAN.pm
9  
10 26 @ISA = qw(CPAN::Debug); ## no critic
11 26 ▶$BUGHUNTING ||= 0; # released code must have turned off
Condition50%1/2
$CPAN::Tarzip::BUGHUNTING ||= 0
l!l
026
MC/DC0%0/1
$CPAN::Tarzip::BUGHUNTING ||= 0
$CPAN::Tarzip::BUGHUNTING
Truth table50%1/2
A
A= $CPAN::Tarzip::BUGHUNTING
Aresult
11
00
12  
13 # it's ok if file doesn't exist, it just matters if it is .gz or .bz2
14 42 ▶sub new {
Subroutine new: called CC=7 SCAR=32.7
Pod undocumented
15 0 ▶ my($class,$file) = @_;
Subroutine new: not called CC=7 SCAR=32.7
Pod undocumented
16 0 ▶ $CPAN::Frontend->mydie("CPAN::Tarzip->new called without arg") unless defined $file;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $file 0 42 42
unless defined $file 0 0 0
17 0 my $me = { FILE => $file };
18 0 ▶ if ($file =~ /\.(bz2|gz|zip|tbz|tgz)$/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($file =~ /\.(bz2|gz|zip|tbz|tgz)$/i) { } 29 13 42
if ($file =~ /\.(bz2|gz|zip|tbz|tgz)$/i) { } 0 0 0
19 0 $me->{ISCOMPRESSED} = 1;
20 } else {
21 0 $me->{ISCOMPRESSED} = 0;
22 }
23 0 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $file =~ /\.(?:bz2|tbz)$/i }) { } 0 42 42
if (do { $file =~ /\.(?:bz2|tbz)$/i }) { } 0 0 0
24 } elsif ($file =~ /\.(?:bz2|tbz)$/i) {
25 0 ▶ unless ($me->{UNGZIPPRG} = $CPAN::Config->{bzip2}) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($me->{"UNGZIPPRG"} = $CPAN::Config->{"bzip2"}) 0 0 0
unless ($me->{"UNGZIPPRG"} = $CPAN::Config->{"bzip2"}) 0 0 0
26 0 my $bzip2 = _my_which("bzip2");
27 0 ▶ if ($bzip2) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bzip2) { } 0 0 0
if ($bzip2) { } 0 0 0
28 0 $me->{UNGZIPPRG} = $bzip2;
29 } else {
30 0 $CPAN::Frontend->mydie(qq{
31 CPAN.pm needs the external program bzip2 in order to handle '$file'.
32 Please install it now and run 'o conf init bzip2' from the
33 CPAN shell prompt to register it as external program.
34 });
35 }
36 }
37 } else {
38 0 $me->{UNGZIPPRG} = _my_which("gzip");
39 }
40 0 ▶ $me->{TARPRG} = _my_which("tar") || _my_which("gtar");
Condition16%1/6
_my_which('tar') || _my_which('gtar')
l!l&&r!l&&!r
4200
_my_which('tar') || _my_which('gtar')
l!l&&r!l&&!r
000
MC/DC0%0/2
_my_which('tar') || _my_which('gtar')
_my_which('tar') _my_which('gtar')
MC/DC0%0/2
_my_which('tar') || _my_which('gtar')
_my_which('tar') _my_which('gtar')
Truth table33%1/3
A || B
A= _my_which('tar')B= _my_which('gtar')
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= _my_which('tar')B= _my_which('gtar')
ABresult
1X1
011
000
41 0 bless $me, $class;
42 }
43  
44 58 ▶sub _zlib_ok () {
Subroutine _zlib_ok: called CC=2 SCAR=10.9
45 0 ▶ $CPAN::META->has_inst("Compress::Zlib") or return;
Subroutine _zlib_ok: not called CC=2 SCAR=10.9
Branch: 2 branches
BranchTrueFalseTotal
$CPAN::META->has_inst("Compress::Zlib") or return 58 0 58
$CPAN::META->has_inst("Compress::Zlib") or return 0 0 0
46 0 Compress::Zlib->can('gzopen');
47 }
48  
49 84 ▶sub _my_which {
Subroutine _my_which: called CC=8 SCAR=39.8
50 0 ▶ my($what) = @_;
Subroutine _my_which: not called CC=8 SCAR=39.8
51 0 ▶ if ($CPAN::Config->{$what}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Config->{$what}) 0 84 84
if ($CPAN::Config->{$what}) 0 0 0
52 0 return $CPAN::Config->{$what};
53 }
54 0 ▶ if ($CPAN::META->has_inst("File::Which")) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst("File::Which")) 84 0 84
if ($CPAN::META->has_inst("File::Which")) 0 0 0
55 0 return File::Which::which($what);
56 }
57 0 my @cand = MM->maybe_command($what);
58 0 ▶ return $cand[0] if @cand;
Branch: 2 branches
BranchTrueFalseTotal
if @cand 0 0 0
if @cand 0 0 0
59 0 require File::Spec;
60 0 my $component;
61 0 PATH_COMPONENT: foreach $component (File::Spec->path()) {
62 0 ▶ next unless defined($component) && $component;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $component and $component 0 0 0
unless defined $component and $component 0 0 0
Condition0%0/6
defined $component and $component
!ll&&!rl&&r
000
defined $component and $component
!ll&&!rl&&r
000
MC/DC0%0/2
defined $component and $component
defined $component $component
MC/DC0%0/2
defined $component and $component
defined $component $component
Truth table0%0/3
A and B
A= defined $componentB= $component
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $componentB= $component
ABresult
0X0
100
111
63 0 my($abs) = File::Spec->catfile($component,$what);
64 0 ▶ if (MM->maybe_command($abs)) {
Branch: 2 branches
BranchTrueFalseTotal
if ("MM"->maybe_command($abs)) 0 0 0
if ("MM"->maybe_command($abs)) 0 0 0
65 0 return $abs;
66 }
67 }
68 0 return;
69 }
70  
71 0 ▶sub gzip {
Subroutine gzip: not called CC=5 SCAR=34.0
Pod undocumented
72 0 ▶ my($self,$read) = @_;
Subroutine gzip: not called CC=5 SCAR=34.0
Pod undocumented
73 0 my $write = $self->{FILE};
74 0 ▶ if (_zlib_ok) {
Branch: 2 branches
BranchTrueFalseTotal
if (&_zlib_ok()) { } 0 0 0
if (&_zlib_ok()) { } 0 0 0
75 0 my($buffer,$fhw);
76 0 ▶ $fhw = FileHandle->new($read)
Branch: 2 branches
BranchTrueFalseTotal
$fhw = "FileHandle"->new($read) or $CPAN::Frontend->mydie("Could not open ${read}: $!") 0 0 0
$fhw = "FileHandle"->new($read) or $CPAN::Frontend->mydie("Could not open ${read}: $!") 0 0 0
77 or $CPAN::Frontend->mydie("Could not open $read: $!");
78 0 my $cwd = `pwd`;
79 0 ▶ my $gz = Compress::Zlib::gzopen($write, "wb")
Branch: 2 branches
BranchTrueFalseTotal
my $gz = Compress::Zlib::gzopen($write, "wb") or $CPAN::Frontend->mydie("Cannot gzopen ${write}: $! (pwd is $cwd)\n") 0 0 0
my $gz = Compress::Zlib::gzopen($write, "wb") or $CPAN::Frontend->mydie("Cannot gzopen ${write}: $! (pwd is $cwd)\n") 0 0 0
80 or $CPAN::Frontend->mydie("Cannot gzopen $write: $! (pwd is $cwd)\n");
81 0 binmode($fhw);
82 0 ▶ $gz->gzwrite($buffer)
Branch: 2 branches
BranchTrueFalseTotal
read($fhw, $buffer, 4096) > 0 and do { $gz->gzwrite($buffer) } 0 0 0
read($fhw, $buffer, 4096) > 0 and do { $gz->gzwrite($buffer) } 0 0 0
83 while read($fhw,$buffer,4096) > 0 ;
84 0 $gz->gzclose() ;
85 0 $fhw->close;
86 0 return 1;
87 } else {
88 0 my $command = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG});
89 0 system(qq{$command -c "$read" > "$write"})==0;
90 }
91 }
92  
93  
94 0 ▶sub gunzip {
Subroutine gunzip: not called CC=6 SCAR=37.4
Pod undocumented
95 0 ▶ my($self,$write) = @_;
Subroutine gunzip: not called CC=6 SCAR=37.4
Pod undocumented
96 0 my $read = $self->{FILE};
97 0 ▶ if (_zlib_ok) {
Branch: 2 branches
BranchTrueFalseTotal
if (&_zlib_ok()) { } 0 0 0
if (&_zlib_ok()) { } 0 0 0
98 0 my($buffer,$fhw);
99 0 ▶ $fhw = FileHandle->new(">$write")
Branch: 2 branches
BranchTrueFalseTotal
$fhw = "FileHandle"->new(">$write") or $CPAN::Frontend->mydie("Could not open >${write}: $!") 0 0 0
$fhw = "FileHandle"->new(">$write") or $CPAN::Frontend->mydie("Could not open >${write}: $!") 0 0 0
100 or $CPAN::Frontend->mydie("Could not open >$write: $!");
101 0 ▶ my $gz = Compress::Zlib::gzopen($read, "rb")
Branch: 2 branches
BranchTrueFalseTotal
my $gz = Compress::Zlib::gzopen($read, "rb") or $CPAN::Frontend->mydie("Cannot gzopen ${read}: $!\n") 0 0 0
my $gz = Compress::Zlib::gzopen($read, "rb") or $CPAN::Frontend->mydie("Cannot gzopen ${read}: $!\n") 0 0 0
102 or $CPAN::Frontend->mydie("Cannot gzopen $read: $!\n");
103 0 binmode($fhw);
104 0 ▶ $fhw->print($buffer)
Branch: 2 branches
BranchTrueFalseTotal
$gz->gzread($buffer) > 0 and do { $fhw->print($buffer) } 0 0 0
$gz->gzread($buffer) > 0 and do { $fhw->print($buffer) } 0 0 0
105 while $gz->gzread($buffer) > 0 ;
106 0 ▶ $CPAN::Frontend->mydie("Error reading from $read: $!\n")
Branch: 2 branches
BranchTrueFalseTotal
if $gz->gzerror != Compress::Zlib::Z_STREAM_END() 0 0 0
if $gz->gzerror != Compress::Zlib::Z_STREAM_END() 0 0 0
107 if $gz->gzerror != Compress::Zlib::Z_STREAM_END();
108 0 $gz->gzclose() ;
109 0 $fhw->close;
110 0 return 1;
111 } else {
112 0 my $command = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG});
113 0 system(qq{$command -d -c "$read" > "$write"})==0;
114 }
115 }
116  
117  
118 49 ▶sub gtest {
Subroutine gtest: called CC=20 SCAR=53.1
Pod undocumented
119 0 ▶ my($self) = @_;
Subroutine gtest: not called CC=20 SCAR=53.1
Pod undocumented
120 0 ▶ return $self->{GTEST} if exists $self->{GTEST};
Branch: 2 branches
BranchTrueFalseTotal
if exists $self->{"GTEST"} 7 42 49
if exists $self->{"GTEST"} 0 0 0
121 0 ▶ defined $self->{FILE} or $CPAN::Frontend->mydie("gtest called but no FILE specified");
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{"FILE"} or $CPAN::Frontend->mydie("gtest called but no FILE specified") 42 0 42
defined $self->{"FILE"} or $CPAN::Frontend->mydie("gtest called but no FILE specified") 0 0 0
122 0 my $read = $self->{FILE};
123 0 my $success;
124 0 ▶ if ($read=~/\.(?:bz2|tbz)$/ && $CPAN::META->has_inst("Compress::Bzip2")) {
Branch: 6 branches
BranchTrueFalseTotal
if ($read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst('Compress::Bzip2')) { } 0 42 42
elsif ($read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()) { } 29 13 42
elsif (not $self->{'ISCOMPRESSED'}) { } 13 0 13
if ($read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst('Compress::Bzip2')) { } 0 0 0
elsif ($read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()) { } 0 0 0
elsif (not $self->{'ISCOMPRESSED'}) { } 0 0 0
Condition16%1/6
$read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
!ll&&!rl&&r
4200
$read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
!ll&&!rl&&r
000
MC/DC0%0/2
$read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
$read =~ /\.(?:bz2|tbz)$/ $CPAN::META->has_inst("Compress::Bzip2")
MC/DC0%0/2
$read =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
$read =~ /\.(?:bz2|tbz)$/ $CPAN::META->has_inst("Compress::Bzip2")
Truth table33%1/3
A and B
A= $read =~ /\.(?:bz2|tbz)$/B= $CPAN::META->has_inst("Compress::Bzip2")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $read =~ /\.(?:bz2|tbz)$/B= $CPAN::META->has_inst("Compress::Bzip2")
ABresult
0X0
100
111
125 0 my($buffer,$len);
126 0 $len = 0;
127 0 ▶ my $gz = Compress::Bzip2::bzopen($read, "rb")
Branch: 2 branches
BranchTrueFalseTotal
my $gz = Compress::Bzip2::bzopen($read, "rb") or $CPAN::Frontend->mydie(sprintf("Cannot bzopen %s: %s\n", $read, $Compress::Bzip2::bzerrno)) 0 0 0
my $gz = Compress::Bzip2::bzopen($read, "rb") or $CPAN::Frontend->mydie(sprintf("Cannot bzopen %s: %s\n", $read, $Compress::Bzip2::bzerrno)) 0 0 0
128 or $CPAN::Frontend->mydie(sprintf("Cannot bzopen %s: %s\n",
129 $read,
130 $Compress::Bzip2::bzerrno));
131 0 ▶ while ($gz->bzread($buffer) > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($gz->bzread($buffer) > 0) 0 0 0
if ($gz->bzread($buffer) > 0) 0 0 0
132 0 $len += length($buffer);
133 0 $buffer = "";
134 }
135 0 my $err = $gz->bzerror;
136 0 ▶ $success = ! $err || $err == Compress::Bzip2::BZ_STREAM_END();
Condition0%0/6
!$err || $err == Compress::Bzip2::BZ_STREAM_END()
l!l&&r!l&&!r
000
!$err || $err == Compress::Bzip2::BZ_STREAM_END()
l!l&&r!l&&!r
000
MC/DC0%0/2
!$err || $err == Compress::Bzip2::BZ_STREAM_END()
!$err $err == Compress::Bzip2::BZ_STREAM_END()
MC/DC0%0/2
!$err || $err == Compress::Bzip2::BZ_STREAM_END()
!$err $err == Compress::Bzip2::BZ_STREAM_END()
Truth table0%0/3
not(A) || B
A= !$errB= $err == Compress::Bzip2::BZ_STREAM_END()
ABresult
1X1
011
000
Truth table0%0/3
not(A) || B
A= !$errB= $err == Compress::Bzip2::BZ_STREAM_END()
ABresult
1X1
011
000
137 0 ▶ if ($len == -s $read) {
Branch: 2 branches
BranchTrueFalseTotal
if ($len == -s $read) 0 0 0
if ($len == -s $read) 0 0 0
138 0 $success = 0;
139 0 ▶ CPAN->debug("hit an uncompressed file") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
140 }
141 0 $gz->gzclose();
142 0 ▶ CPAN->debug("err[$err]success[$success]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
143 ▶ } elsif ( $read=~/\.(?:gz|tgz)$/ && _zlib_ok ) {
Condition33%2/6
$read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
!ll&&!rl&&r
13029
$read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
!ll&&!rl&&r
000
MC/DC50%1/2
$read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
$read =~ /\.(?:gz|tgz)$/ &_zlib_ok()
MC/DC0%0/2
$read =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
$read =~ /\.(?:gz|tgz)$/ &_zlib_ok()
Truth table66%2/3
A and B
A= $read =~ /\.(?:gz|tgz)$/B= &_zlib_ok()
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $read =~ /\.(?:gz|tgz)$/B= &_zlib_ok()
ABresult
0X0
100
111
144 # After I had reread the documentation in zlib.h, I discovered that
145 # uncompressed files do not lead to an gzerror (anymore?).
146 0 my($buffer,$len);
147 0 $len = 0;
148 0 ▶ my $gz = Compress::Zlib::gzopen($read, "rb")
Branch: 2 branches
BranchTrueFalseTotal
my $gz = Compress::Zlib::gzopen($read, "rb") or $CPAN::Frontend->mydie(sprintf("Cannot gzopen %s: %s\n", $read, $Compress::Zlib::gzerrno)) 29 0 29
my $gz = Compress::Zlib::gzopen($read, "rb") or $CPAN::Frontend->mydie(sprintf("Cannot gzopen %s: %s\n", $read, $Compress::Zlib::gzerrno)) 0 0 0
149 or $CPAN::Frontend->mydie(sprintf("Cannot gzopen %s: %s\n",
150 $read,
151 $Compress::Zlib::gzerrno));
152 0 ▶ while ($gz->gzread($buffer) > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($gz->gzread($buffer) > 0) 62 29 91
if ($gz->gzread($buffer) > 0) 0 0 0
153 0 $len += length($buffer);
154 0 $buffer = "";
155 }
156 0 my $err = $gz->gzerror;
157 0 ▶ $success = ! $err || $err == Compress::Zlib::Z_STREAM_END();
Condition33%2/6
!$err || $err == Compress::Zlib::Z_STREAM_END()
l!l&&r!l&&!r
7220
!$err || $err == Compress::Zlib::Z_STREAM_END()
l!l&&r!l&&!r
000
MC/DC0%0/2
!$err || $err == Compress::Zlib::Z_STREAM_END()
!$err $err == Compress::Zlib::Z_STREAM_END()
MC/DC0%0/2
!$err || $err == Compress::Zlib::Z_STREAM_END()
!$err $err == Compress::Zlib::Z_STREAM_END()
Truth table66%2/3
not(A) || B
A= !$errB= $err == Compress::Zlib::Z_STREAM_END()
ABresult
1X1
011
000
Truth table0%0/3
not(A) || B
A= !$errB= $err == Compress::Zlib::Z_STREAM_END()
ABresult
1X1
011
000
158 0 ▶ if ($len == -s $read) {
Branch: 2 branches
BranchTrueFalseTotal
if ($len == -s $read) 0 29 29
if ($len == -s $read) 0 0 0
159 0 $success = 0;
160 0 ▶ CPAN->debug("hit an uncompressed file") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
161 }
162 0 $gz->gzclose();
163 0 ▶ CPAN->debug("err[$err]success[$success]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 29 29
if $CPAN::DEBUG 0 0 0
164 } elsif (!$self->{ISCOMPRESSED}) {
165 0 $success = 0;
166 } else {
167 0 my $command = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG});
168 0 $success = 0==system(qq{$command -qdt "$read"});
169 }
170 0 return $self->{GTEST} = $success;
171 }
172  
173  
174 34 ▶sub TIEHANDLE {
Subroutine TIEHANDLE: called CC=10 SCAR=39.5
175 0 ▶ my($class,$file) = @_;
Subroutine TIEHANDLE: not called CC=10 SCAR=39.5
176 0 my $ret;
177 0 $class->debug("file[$file]");
178 0 my $self = $class->new($file);
179 0 ▶ if (0) {
Branch: 6 branches
BranchTrueFalseTotal
if (do { not $self->gtest }) { } 13 21 34
elsif ($file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst('Compress::Bzip2')) { } 0 21 21
elsif ($file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()) { } 21 0 21
if (do { not $self->gtest }) { } 0 0 0
elsif ($file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst('Compress::Bzip2')) { } 0 0 0
elsif ($file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()) { } 0 0 0
180 } elsif (!$self->gtest) {
181 0 ▶ my $fh = FileHandle->new($file)
Branch: 2 branches
BranchTrueFalseTotal
my $fh = "FileHandle"->new($file) or $CPAN::Frontend->mydie("Could not open file[$file]: $!") 13 0 13
my $fh = "FileHandle"->new($file) or $CPAN::Frontend->mydie("Could not open file[$file]: $!") 0 0 0
182 or $CPAN::Frontend->mydie("Could not open file[$file]: $!");
183 0 binmode $fh;
184 0 $self->{FH} = $fh;
185 0 $class->debug("via uncompressed FH");
186 ▶ } elsif ($file =~ /\.(?:bz2|tbz)$/ && $CPAN::META->has_inst("Compress::Bzip2")) {
Condition16%1/6
$file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
!ll&&!rl&&r
2100
$file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
!ll&&!rl&&r
000
MC/DC0%0/2
$file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
$file =~ /\.(?:bz2|tbz)$/ $CPAN::META->has_inst("Compress::Bzip2")
MC/DC0%0/2
$file =~ /\.(?:bz2|tbz)$/ and $CPAN::META->has_inst("Compress::Bzip2")
$file =~ /\.(?:bz2|tbz)$/ $CPAN::META->has_inst("Compress::Bzip2")
Truth table33%1/3
A and B
A= $file =~ /\.(?:bz2|tbz)$/B= $CPAN::META->has_inst("Compress::Bzip2")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $file =~ /\.(?:bz2|tbz)$/B= $CPAN::META->has_inst("Compress::Bzip2")
ABresult
0X0
100
111
187 0 ▶ my $gz = Compress::Bzip2::bzopen($file,"rb") or
Branch: 2 branches
BranchTrueFalseTotal
my $gz = Compress::Bzip2::bzopen($file, "rb") or $CPAN::Frontend->mydie("Could not bzopen $file") 0 0 0
my $gz = Compress::Bzip2::bzopen($file, "rb") or $CPAN::Frontend->mydie("Could not bzopen $file") 0 0 0
188 $CPAN::Frontend->mydie("Could not bzopen $file");
189 0 $self->{GZ} = $gz;
190 0 $class->debug("via Compress::Bzip2");
191 ▶ } elsif ($file =~/\.(?:gz|tgz)$/ && _zlib_ok) {
Condition16%1/6
$file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
!ll&&!rl&&r
0021
$file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
!ll&&!rl&&r
000
MC/DC0%0/2
$file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
$file =~ /\.(?:gz|tgz)$/ &_zlib_ok()
MC/DC0%0/2
$file =~ /\.(?:gz|tgz)$/ and &_zlib_ok()
$file =~ /\.(?:gz|tgz)$/ &_zlib_ok()
Truth table33%1/3
A and B
A= $file =~ /\.(?:gz|tgz)$/B= &_zlib_ok()
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $file =~ /\.(?:gz|tgz)$/B= &_zlib_ok()
ABresult
0X0
100
111
192 0 ▶ my $gz = Compress::Zlib::gzopen($file,"rb") or
Branch: 2 branches
BranchTrueFalseTotal
my $gz = Compress::Zlib::gzopen($file, "rb") or $CPAN::Frontend->mydie("Could not gzopen $file") 21 0 21
my $gz = Compress::Zlib::gzopen($file, "rb") or $CPAN::Frontend->mydie("Could not gzopen $file") 0 0 0
193 $CPAN::Frontend->mydie("Could not gzopen $file");
194 0 $self->{GZ} = $gz;
195 0 $class->debug("via Compress::Zlib");
196 } else {
197 0 my $gzip = CPAN::HandleConfig->safe_quote($self->{UNGZIPPRG});
198 0 my $pipe = "$gzip -d -c $file |";
199 0 ▶ my $fh = FileHandle->new($pipe) or $CPAN::Frontend->mydie("Could not pipe[$pipe]: $!");
Branch: 2 branches
BranchTrueFalseTotal
my $fh = "FileHandle"->new($pipe) or $CPAN::Frontend->mydie("Could not pipe[$pipe]: $!") 0 0 0
my $fh = "FileHandle"->new($pipe) or $CPAN::Frontend->mydie("Could not pipe[$pipe]: $!") 0 0 0
200 0 binmode $fh;
201 0 $self->{FH} = $fh;
202 0 $class->debug("via external $gzip");
203 }
204 0 $self;
205 }
206  
207  
208 20 ▶sub READLINE {
Subroutine READLINE: called CC=3 SCAR=14.2
209 0 ▶ my($self) = @_;
Subroutine READLINE: not called CC=3 SCAR=14.2
210 0 ▶ if (exists $self->{GZ}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'GZ'}) { } 14 6 20
if (exists $self->{'GZ'}) { } 0 0 0
211 0 my $gz = $self->{GZ};
212 0 my($line,$bytesread);
213 0 $bytesread = $gz->gzreadline($line);
214 0 ▶ return undef if $bytesread <= 0;
Branch: 2 branches
BranchTrueFalseTotal
if $bytesread <= 0 7 7 14
if $bytesread <= 0 0 0 0
215 0 return $line;
216 } else {
217 0 my $fh = $self->{FH};
218 0 return scalar <$fh>;
219 }
220 }
221  
222  
223 36 ▶sub READ {
Subroutine READ: called CC=3 SCAR=14.9
224 0 ▶ my($self,$ref,$length,$offset) = @_;
Subroutine READ: not called CC=3 SCAR=14.9
225 0 ▶ $CPAN::Frontend->mydie("read with offset not implemented") if defined $offset;
Branch: 2 branches
BranchTrueFalseTotal
if defined $offset 0 36 36
if defined $offset 0 0 0
226 0 ▶ if (exists $self->{GZ}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'GZ'}) { } 14 22 36
if (exists $self->{'GZ'}) { } 0 0 0
227 0 my $gz = $self->{GZ};
228 0 my $byteread = $gz->gzread($$ref,$length);# 30eaf79e8b446ef52464b5422da328a8
229 0 return $byteread;
230 } else {
231 0 my $fh = $self->{FH};
232 0 return read($fh,$$ref,$length);
233 }
234 }
235  
236  
237 42 ▶sub DESTROY {
Subroutine DESTROY: called CC=4 SCAR=18.7
238 0 ▶ my($self) = @_;
Subroutine DESTROY: not called CC=4 SCAR=18.7
239 0 ▶ if (exists $self->{GZ}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'GZ'}) { } 21 21 42
if (exists $self->{'GZ'}) { } 0 0 0
240 0 my $gz = $self->{GZ};
241 0 ▶ $gz->gzclose() if defined $gz; # hard to say if it is allowed
Branch: 2 branches
BranchTrueFalseTotal
if defined $gz 21 0 21
if defined $gz 0 0 0
242 # to be undef ever. AK, 2000-09
243 } else {
244 0 my $fh = $self->{FH};
245 0 ▶ $fh->close if defined $fh;
Branch: 2 branches
BranchTrueFalseTotal
if defined $fh 13 8 21
if defined $fh 0 0 0
246 }
247 0 undef $self;
248 }
249  
250 8 ▶sub untar {
Subroutine untar: called CC=45 SCAR=72.9
Pod undocumented
251 0 ▶ my($self) = @_;
Subroutine untar: not called CC=45 SCAR=72.9
Pod undocumented
252 0 my $file = $self->{FILE};
253 0 my($prefer) = 0;
254  
255 0 ▶ my $exttar = $self->{TARPRG} || "";
Condition25%1/4
$self->{'TARPRG'} || ''
l!l
80
$self->{'TARPRG'} || ''
l!l
00
MC/DC0%0/1
$self->{'TARPRG'} || ''
$self->{'TARPRG'}
MC/DC0%0/1
$self->{'TARPRG'} || ''
$self->{'TARPRG'}
Truth table50%1/2
A
A= $self->{'TARPRG'}
Aresult
11
00
Truth table0%0/2
A
A= $self->{'TARPRG'}
Aresult
11
00
256 0 ▶ $exttar = "" if $exttar =~ /^\s+$/; # user refuses to use it
Branch: 2 branches
BranchTrueFalseTotal
if $exttar =~ /^\s+$/ 0 8 8
if $exttar =~ /^\s+$/ 0 0 0
257 0 ▶ my $extgzip = $self->{UNGZIPPRG} || "";
Condition25%1/4
$self->{'UNGZIPPRG'} || ''
l!l
80
$self->{'UNGZIPPRG'} || ''
l!l
00
MC/DC0%0/1
$self->{'UNGZIPPRG'} || ''
$self->{'UNGZIPPRG'}
MC/DC0%0/1
$self->{'UNGZIPPRG'} || ''
$self->{'UNGZIPPRG'}
Truth table50%1/2
A
A= $self->{'UNGZIPPRG'}
Aresult
11
00
Truth table0%0/2
A
A= $self->{'UNGZIPPRG'}
Aresult
11
00
258 0 ▶ $extgzip = "" if $extgzip =~ /^\s+$/; # user refuses to use it
Branch: 2 branches
BranchTrueFalseTotal
if $extgzip =~ /^\s+$/ 0 8 8
if $extgzip =~ /^\s+$/ 0 0 0
259  
260 0 ▶ if (0) { # makes changing order easier
Branch: 8 branches
BranchTrueFalseTotal
if (do { $CPAN::Tarzip::BUGHUNTING }) { } 0 8 8
elsif ($CPAN::Config->{'prefer_external_tar'}) { } 0 8 8
elsif ($CPAN::META->has_usable('Archive::Tar') and &_zlib_ok()) { } 8 0 8
elsif ($exttar and $extgzip) { } 0 0 0
if (do { $CPAN::Tarzip::BUGHUNTING }) { } 0 0 0
elsif ($CPAN::Config->{'prefer_external_tar'}) { } 0 0 0
elsif ($CPAN::META->has_usable('Archive::Tar') and &_zlib_ok()) { } 0 0 0
elsif ($exttar and $extgzip) { } 0 0 0
261 } elsif ($BUGHUNTING) {
262 0 $prefer=2;
263 } elsif ($CPAN::Config->{prefer_external_tar}) {
264 0 $prefer = 1;
265 ▶ } elsif (
Condition16%1/6
$CPAN::META->has_usable("Archive::Tar") and &_zlib_ok()
!ll&&!rl&&r
008
$CPAN::META->has_usable("Archive::Tar") and &_zlib_ok()
!ll&&!rl&&r
000
MC/DC0%0/2
$CPAN::META->has_usable("Archive::Tar") and &_zlib_ok()
$CPAN::META->has_usable("Archive::Tar") &_zlib_ok()
MC/DC0%0/2
$CPAN::META->has_usable("Archive::Tar") and &_zlib_ok()
$CPAN::META->has_usable("Archive::Tar") &_zlib_ok()
Truth table33%1/3
A and B
A= $CPAN::META->has_usable("Archive::Tar")B= &_zlib_ok()
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $CPAN::META->has_usable("Archive::Tar")B= &_zlib_ok()
ABresult
0X0
100
111
266 $CPAN::META->has_usable("Archive::Tar")
267 &&
268 _zlib_ok ) {
269 0 my $prefer_external_tar = $CPAN::Config->{prefer_external_tar};
270 0 ▶ unless (defined $prefer_external_tar) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $prefer_external_tar) 8 0 8
unless (defined $prefer_external_tar) 0 0 0
271 0 ▶ if ($^O =~ /(MSWin32|solaris)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O =~ /(MSWin32|solaris)/) { } 0 8 8
if ($^O =~ /(MSWin32|solaris)/) { } 0 0 0
272 0 $prefer_external_tar = 0;
273 } else {
274 0 $prefer_external_tar = 1;
275 }
276 }
277 0 ▶ $prefer = $prefer_external_tar ? 1 : 2;
Branch: 2 branches
BranchTrueFalseTotal
$prefer_external_tar ? : 8 0 8
$prefer_external_tar ? : 0 0 0
278 ▶ } elsif ($exttar && $extgzip) {
Condition0%0/6
$exttar and $extgzip
!ll&&!rl&&r
000
$exttar and $extgzip
!ll&&!rl&&r
000
MC/DC0%0/2
$exttar and $extgzip
$exttar $extgzip
MC/DC0%0/2
$exttar and $extgzip
$exttar $extgzip
Truth table0%0/3
A and B
A= $exttarB= $extgzip
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $exttarB= $extgzip
ABresult
0X0
100
111
279 # no modules and not bz2
280 0 $prefer = 1;
281 # but solaris binary tar is a problem
282 0 ▶ if ($^O eq 'solaris' && qx($exttar --version 2>/dev/null) !~ /gnu/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i) 0 0 0
if ($^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i) 0 0 0
Condition0%0/6
$^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i
!ll&&!rl&&r
000
$^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i
!ll&&!rl&&r
000
MC/DC0%0/2
$^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i
$^O eq "solaris" not `$exttar --version 2>/dev/null` =~ /gnu/i
MC/DC0%0/2
$^O eq "solaris" and not `$exttar --version 2>/dev/null` =~ /gnu/i
$^O eq "solaris" not `$exttar --version 2>/dev/null` =~ /gnu/i
Truth table0%0/3
A and not(B)
A= $^O eq "solaris"B= not `$exttar --version 2>/dev/null` =~ /gnu/i
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $^O eq "solaris"B= not `$exttar --version 2>/dev/null` =~ /gnu/i
ABresult
0X0
100
111
283 0 $CPAN::Frontend->mywarn(<< 'END_WARN');
284  
285 WARNING: Many CPAN distributions were archived with GNU tar and some of
286 them may be incompatible with Solaris tar. We respectfully suggest you
287 configure CPAN to use a GNU tar instead ("o conf init tar") or install
288 a recent Archive::Tar instead;
289  
290 END_WARN
291 }
292 } else {
293 0 ▶ my $foundtar = $exttar ? "'$exttar'" : "nothing";
Branch: 2 branches
BranchTrueFalseTotal
$exttar ? : 0 0 0
$exttar ? : 0 0 0
294 0 ▶ my $foundzip = $extgzip ? "'$extgzip'" : $foundtar ? "nothing" : "also nothing";
Branch: 4 branches
BranchTrueFalseTotal
$extgzip ? : 0 0 0
$foundtar ? : 0 0 0
$extgzip ? : 0 0 0
$foundtar ? : 0 0 0
295 0 my $foundAT;
296 0 ▶ if ($CPAN::META->has_usable("Archive::Tar")) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_usable('Archive::Tar')) { } 0 0 0
if ($CPAN::META->has_usable('Archive::Tar')) { } 0 0 0
297 0 $foundAT = sprintf "'%s'", "Archive::Tar::"->VERSION;
298 } else {
299 0 $foundAT = "nothing";
300 }
301 0 my $foundCZ;
302 0 ▶ if (_zlib_ok) {
Branch: 4 branches
BranchTrueFalseTotal
if (&_zlib_ok()) { } 0 0 0
elsif ($foundAT) { } 0 0 0
if (&_zlib_ok()) { } 0 0 0
elsif ($foundAT) { } 0 0 0
303 0 $foundCZ = sprintf "'%s'", "Compress::Zlib::"->VERSION;
304 } elsif ($foundAT) {
305 0 $foundCZ = "nothing";
306 } else {
307 0 $foundCZ = "also nothing";
308 }
309 0 $CPAN::Frontend->mydie(qq{
310  
311 CPAN.pm needs either the external programs tar and gzip -or- both
312 modules Archive::Tar and Compress::Zlib installed.
313  
314 For tar I found $foundtar, for gzip $foundzip.
315  
316 For Archive::Tar I found $foundAT, for Compress::Zlib $foundCZ;
317  
318 Can't continue cutting file '$file'.
319 });
320 }
321 0 my $tar_verb = "v";
322 0 ▶ if (defined $CPAN::Config->{tar_verbosity}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $CPAN::Config->{"tar_verbosity"}) 0 8 8
if (defined $CPAN::Config->{"tar_verbosity"}) 0 0 0
323 $tar_verb = $CPAN::Config->{tar_verbosity} eq "none" ? "" :
324 0 ▶ $CPAN::Config->{tar_verbosity};
Branch: 2 branches
BranchTrueFalseTotal
$CPAN::Config->{'tar_verbosity'} eq 'none' ? : 0 0 0
$CPAN::Config->{'tar_verbosity'} eq 'none' ? : 0 0 0
325 }
326 0 ▶ if ($prefer==1) { # 1 => external gzip+tar
Branch: 4 branches
BranchTrueFalseTotal
if ($prefer == 1) { } 8 0 8
elsif ($prefer == 2) { } 0 0 0
if ($prefer == 1) { } 0 0 0
elsif ($prefer == 2) { } 0 0 0
327 0 my($system);
328 0 my $is_compressed = $self->gtest();
329 0 my $tarcommand = CPAN::HandleConfig->safe_quote($exttar);
330 0 ▶ if ($is_compressed) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_compressed) { } 8 0 8
if ($is_compressed) { } 0 0 0
331 0 my $command = CPAN::HandleConfig->safe_quote($extgzip);
332 0 $system = qq{$command -d -c }.
333 qq{< "$file" | $tarcommand x${tar_verb}f -};
334 } else {
335 0 $system = qq{$tarcommand x${tar_verb}f "$file"};
336 }
337 0 ▶ if (system($system) != 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (system($system) != 0) { } 0 8 8
if (system($system) != 0) { } 0 0 0
338 # people find the most curious tar binaries that cannot handle
339 # pipes
340 0 ▶ if ($is_compressed) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_compressed) 0 0 0
if ($is_compressed) 0 0 0
341 0 (my $ungzf = $file) =~ s/\.gz(?!\n)\Z//;
342 0 $ungzf = basename $ungzf;
343 0 my $ct = CPAN::Tarzip->new($file);
344 0 ▶ if ($ct->gunzip($ungzf)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ct->gunzip($ungzf)) { } 0 0 0
if ($ct->gunzip($ungzf)) { } 0 0 0
345 0 $CPAN::Frontend->myprint(qq{Uncompressed $file successfully\n});
346 } else {
347 0 $CPAN::Frontend->mydie(qq{Couldn\'t uncompress $file\n});
348 }
349 0 $file = $ungzf;
350 }
351 0 $system = qq{$tarcommand x${tar_verb}f "$file"};
352 0 $CPAN::Frontend->myprint(qq{Using Tar:$system:\n});
353 0 my $ret = system($system);
354 0 ▶ if ($ret==0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ret == 0) { } 0 0 0
if ($ret == 0) { } 0 0 0
355 0 $CPAN::Frontend->myprint(qq{Untarred $file successfully\n});
356 } else {
357 0 ▶ if ($? == -1) {
Branch: 4 branches
BranchTrueFalseTotal
if ($? == -1) { } 0 0 0
elsif ($? & 127) { } 0 0 0
if ($? == -1) { } 0 0 0
elsif ($? & 127) { } 0 0 0
358 0 $CPAN::Frontend->mydie(sprintf qq{Couldn\'t untar %s: '%s'\n},
359 $file, $!);
360 } elsif ($? & 127) {
361 0 ▶ $CPAN::Frontend->mydie(sprintf qq{Couldn\'t untar %s: child died with signal %d, %s coredump\n},
Branch: 2 branches
BranchTrueFalseTotal
$? & 128 ? : 0 0 0
$? & 128 ? : 0 0 0
362 $file, ($? & 127), ($? & 128) ? 'with' : 'without');
363 } else {
364 0 $CPAN::Frontend->mydie(sprintf qq{Couldn\'t untar %s: child exited with value %d\n},
365 $file, $? >> 8);
366 }
367 }
368 0 return 1;
369 } else {
370 0 return 1;
371 }
372 } elsif ($prefer==2) { # 2 => modules
373 0 ▶ unless ($CPAN::META->has_usable("Archive::Tar")) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::META->has_usable("Archive::Tar")) 0 0 0
unless ($CPAN::META->has_usable("Archive::Tar")) 0 0 0
374 0 $CPAN::Frontend->mydie("Archive::Tar not installed, please install it to continue");
375 }
376 # Make sure AT does not use uid/gid/permissions in the archive
377 # This leaves it to the user's umask instead
378 0 local $Archive::Tar::CHMOD = 1;
379 0 local $Archive::Tar::SAME_PERMISSIONS = 0;
380 # Make sure AT leaves current user as owner
381 0 local $Archive::Tar::CHOWN = 0;
382 0 my $tar = Archive::Tar->new($file,1);
383 0 my $af; # archive file
384 my @af;
385 0 ▶ if ($BUGHUNTING) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Tarzip::BUGHUNTING) { } 0 0 0
if ($CPAN::Tarzip::BUGHUNTING) { } 0 0 0
386 # RCS 1.337 had this code, it turned out unacceptable slow but
387 # it revealed a bug in Archive::Tar. Code is only here to hunt
388 # the bug again. It should never be enabled in published code.
389 # GDGraph3d-0.53 was an interesting case according to Larry
390 # Virden.
391 0 warn(">>>Bughunting code enabled<<< " x 20);
392 0 for $af ($tar->list_files) {
393 0 ▶ if ($af =~ m!^(/|\.\./)!) {
Branch: 2 branches
BranchTrueFalseTotal
if ($af =~ m[^(/|\.\./)]) 0 0 0
if ($af =~ m[^(/|\.\./)]) 0 0 0
394 0 $CPAN::Frontend->mydie("ALERT: Archive contains ".
395 "illegal member [$af]");
396 }
397 0 $CPAN::Frontend->myprint("$af\n");
398 0 $tar->extract($af); # slow but effective for finding the bug
399 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
400 }
401 } else {
402 0 for $af ($tar->list_files) {
403 0 ▶ if ($af =~ m!^(/|\.\./)!) {
Branch: 2 branches
BranchTrueFalseTotal
if ($af =~ m[^(/|\.\./)]) 0 0 0
if ($af =~ m[^(/|\.\./)]) 0 0 0
404 0 $CPAN::Frontend->mydie("ALERT: Archive contains ".
405 "illegal member [$af]");
406 }
407 0 ▶ if ($tar_verb eq "v" || $tar_verb eq "vv") {
Branch: 2 branches
BranchTrueFalseTotal
if ($tar_verb eq "v" or $tar_verb eq "vv") 0 0 0
if ($tar_verb eq "v" or $tar_verb eq "vv") 0 0 0
Condition0%0/6
$tar_verb eq "v" or $tar_verb eq "vv"
l!l&&r!l&&!r
000
$tar_verb eq "v" or $tar_verb eq "vv"
l!l&&r!l&&!r
000
MC/DC0%0/2
$tar_verb eq "v" or $tar_verb eq "vv"
$tar_verb eq "v" $tar_verb eq "vv"
MC/DC0%0/2
$tar_verb eq "v" or $tar_verb eq "vv"
$tar_verb eq "v" $tar_verb eq "vv"
Truth table0%0/3
A or B
A= $tar_verb eq "v"B= $tar_verb eq "vv"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $tar_verb eq "v"B= $tar_verb eq "vv"
ABresult
1X1
011
000
408 0 $CPAN::Frontend->myprint("$af\n");
409 }
410 0 push @af, $af;
411 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
412 }
413 0 ▶ $tar->extract(@af) or
Branch: 2 branches
BranchTrueFalseTotal
$tar->extract(@af) or $CPAN::Frontend->mydie("Could not untar with Archive::Tar.") 0 0 0
$tar->extract(@af) or $CPAN::Frontend->mydie("Could not untar with Archive::Tar.") 0 0 0
414 $CPAN::Frontend->mydie("Could not untar with Archive::Tar.");
415 }
416  
417 0 return 1;
418 }
419 }
420  
421 0 ▶sub unzip {
Subroutine unzip: not called CC=10 SCAR=47.0
Pod undocumented
422 0 ▶ my($self) = @_;
Subroutine unzip: not called CC=10 SCAR=47.0
Pod undocumented
423 0 my $file = $self->{FILE};
424 0 ▶ if ($CPAN::META->has_inst("Archive::Zip")) {
Branch: 4 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst('Archive::Zip')) { } 0 0 0
elsif (my $unzip = $CPAN::Config->{'unzip'}) { } 0 0 0
if ($CPAN::META->has_inst('Archive::Zip')) { } 0 0 0
elsif (my $unzip = $CPAN::Config->{'unzip'}) { } 0 0 0
425 # blueprint of the code from Archive::Zip::Tree::extractTree();
426 0 my $zip = Archive::Zip->new();
427 0 my $status;
428 0 $status = $zip->read($file);
429 0 ▶ $CPAN::Frontend->mydie("Read of file[$file] failed\n")
Branch: 2 branches
BranchTrueFalseTotal
if $status != Archive::Zip::AZ_OK() 0 0 0
if $status != Archive::Zip::AZ_OK() 0 0 0
430 if $status != Archive::Zip::AZ_OK();
431 0 ▶ $CPAN::META->debug("Successfully read file[$file]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
432 0 my @members = $zip->members();
433 0 for my $member ( @members ) {
434 0 my $af = $member->fileName();
435 0 ▶ if ($af =~ m!^(/|\.\./)!) {
Branch: 2 branches
BranchTrueFalseTotal
if ($af =~ m[^(/|\.\./)]) 0 0 0
if ($af =~ m[^(/|\.\./)]) 0 0 0
436 0 $CPAN::Frontend->mydie("ALERT: Archive contains ".
437 "illegal member [$af]");
438 }
439 0 $status = $member->extractToFileNamed( $af );
440 0 ▶ $CPAN::META->debug("af[$af]status[$status]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
441 0 ▶ $CPAN::Frontend->mydie("Extracting of file[$af] from zipfile[$file] failed\n") if
Branch: 2 branches
BranchTrueFalseTotal
if $status != Archive::Zip::AZ_OK() 0 0 0
if $status != Archive::Zip::AZ_OK() 0 0 0
442 $status != Archive::Zip::AZ_OK();
443 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
444 }
445 0 return 1;
446 } elsif ( my $unzip = $CPAN::Config->{unzip} ) {
447 0 my @system = ($unzip, $file);
448 0 return system(@system) == 0;
449 }
450 else {
451 0 $CPAN::Frontend->mydie(<<"END");
452  
453 Can't unzip '$file':
454  
455 You have not configured an 'unzip' program and do not have Archive::Zip
456 installed. Please either install Archive::Zip or else configure 'unzip'
457 by running the command 'o conf init unzip' from the CPAN shell prompt.
458  
459 END
460 }
461 }
462  
463 26 1;
464  
465 __END__
« blib/lib/CPAN/Shell.pm ↑ Summary blib/lib/CPAN/Distribution.pm »