blib/lib/IO/Compress/Base.pm

filter: Statementstmt 94.9% 394 / 415 Branchbran 77.9% 184 / 236 Conditioncond 79.0% 68 / 86 MC/DCmcdc 45.8% 22 / 48 Subroutinesub 94.4% 51 / 54 Podpod 19.3% 6 / 31 totaltotal 83.3% 725 / 870 CC 150 SCAR 25.2
CC
150
Cov
88%
_create
29.1
syswrite
22.2
_wr2
17.2
CRAP 12.5
« blib/lib/IO/Compress/Zlib/Extra.pm ↑ Summary blib/lib/File/GlobMapper.pm »
1  
2 package IO::Compress::Base ;
3  
4 115 require 5.006 ;
5  
6 115 ▶use strict ;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 115 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 115 ▶use IO::Compress::Base::Common 2.223 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 115 ▶use IO::File ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 115 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 #use File::Glob;
15 #require Exporter ;
16 115 ▶use Carp() ;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 115 ▶use Symbol();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 #use bytes;
19  
20 115 our (@ISA, $VERSION);
21 115 @ISA = qw(IO::File Exporter);
22  
23 115 $VERSION = '2.223';
24  
25 #Can't locate object method "SWASHNEW" via package "utf8" (perhaps you forgot to load "utf8"?) at .../ext/Compress-Zlib/Gzip/blib/lib/Compress/Zlib/Common.pm line 16.
26  
27 sub saveStatus
28 {
29 1856 ▶ my $self = shift ;
Subroutine saveStatus: called CC=1 SCAR=0.0
Pod undocumented
30 1856 ${ *$self->{ErrorNo} } = shift() + 0 ;
31 1856 ${ *$self->{Error} } = '' ;
32  
33 1856 return ${ *$self->{ErrorNo} } ;
34 }
35  
36  
37 sub saveErrorString
38 {
39 202 ▶ my $self = shift ;
Subroutine saveErrorString: called CC=2 SCAR=6.9
Pod undocumented
40 202 my $retval = shift ;
41 202 ${ *$self->{Error} } = shift ;
42 202 ▶ ${ *$self->{ErrorNo} } = shift() + 0 if @_ ;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 33 169 202
43  
44 202 return $retval;
45 }
46  
47 sub croakError
48 {
49 149 ▶ my $self = shift ;
Subroutine croakError: called CC=1 SCAR=0.0
Pod undocumented
50 149 $self->saveErrorString(0, $_[0]);
51 149 Carp::croak $_[0];
52 }
53  
54 sub closeError
55 {
56 0 ▶ my $self = shift ;
Subroutine closeError: not called CC=1 SCAR=6.9
Pod undocumented
57 0 my $retval = shift ;
58  
59 0 my $errno = *$self->{ErrorNo};
60 0 my $error = ${ *$self->{Error} };
61  
62 0 $self->close();
63  
64 0 *$self->{ErrorNo} = $errno ;
65 0 ${ *$self->{Error} } = $error ;
66  
67 0 return $retval;
68 }
69  
70  
71  
72 sub error
73 {
74 42 ▶ my $self = shift ;
Subroutine error: called CC=1 SCAR=0.0
Pod documented
75 42 return ${ *$self->{Error} } ;
76 }
77  
78 sub errorNo
79 {
80 81 ▶ my $self = shift ;
Subroutine errorNo: called CC=1 SCAR=0.0
Pod undocumented
81 81 return ${ *$self->{ErrorNo} } ;
82 }
83  
84  
85 sub writeAt
86 {
87 130 ▶ my $self = shift ;
Subroutine writeAt: called CC=6 SCAR=18.3
Pod undocumented
88 130 my $offset = shift;
89 130 my $data = shift;
90  
91 130 ▶ if (defined *$self->{FH}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{'FH'}) { } 124 6 130
92 124 my $here = tell(*$self->{FH});
93 124 ▶ return $self->saveErrorString(undef, "Cannot seek to end of output filehandle: $!", $!)
Branch: 1 branch
BranchTrueFalseTotal
if $here < 0 0 124 124
94 if $here < 0 ;
95 124 ▶ seek(*$self->{FH}, $offset, IO::Handle::SEEK_SET)
Branch: 1 branch
BranchTrueFalseTotal
CORE::seek *$self->{"FH"}, $offset, 0 or return $self->saveErrorString(undef, "Cannot seek to end of output filehandle: $!", $!) 0 124 124
96 or return $self->saveErrorString(undef, "Cannot seek to end of output filehandle: $!", $!) ;
97 124 ▶ defined *$self->{FH}->write($data, length $data)
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{"FH"}->write($data, length $data) or return $self->saveErrorString(undef, $!, $!) 0 124 124
98 or return $self->saveErrorString(undef, $!, $!) ;
99 124 ▶ seek(*$self->{FH}, $here, IO::Handle::SEEK_SET)
Branch: 1 branch
BranchTrueFalseTotal
CORE::seek *$self->{"FH"}, $here, 0 or return $self->saveErrorString(undef, "Cannot seek to end of output filehandle: $!", $!) 0 124 124
100 or return $self->saveErrorString(undef, "Cannot seek to end of output filehandle: $!", $!) ;
101 }
102 else {
103 6 substr(${ *$self->{Buffer} }, $offset, length($data)) = $data ;
104 }
105  
106 130 return 1;
107 }
108  
109 sub outputPayload
110 {
111  
112 1552 ▶ my $self = shift ;
Subroutine outputPayload: called CC=1 SCAR=0.0
Pod undocumented
113 1552 return $self->output(@_);
114 }
115  
116  
117 sub output
118 {
119 9579 ▶ my $self = shift ;
Subroutine output: called CC=7 SCAR=19.9
Pod undocumented
120 9579 my $data = shift ;
121 9579 my $last = shift ;
122  
123 9579 ▶ return 1
Branch: 1 branch
BranchTrueFalseTotal
if length $data == 0 and not $last 4311 5268 9579
Condition100%3/3
length $data == 0 and not $last
!ll&&!rl&&r
343318354311
MC/DC100%2/2
length $data == 0 and not $last
length $data == 0 not $last
Truth table100%3/3
A and not(B)
A= length $data == 0B= not $last
ABresult
0X0
100
111
124 if length $data == 0 && ! $last ;
125  
126 5268 ▶ if ( *$self->{FilterContainer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{"FilterContainer"}) 0 5268 5268
127 0 *_ = \$data;
128 0 &{ *$self->{FilterContainer} }();
129 }
130  
131 5268 ▶ if (length $data) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $data) 3433 1835 5268
132 3433 ▶ if ( defined *$self->{FH} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{'FH'}) { } 2039 1394 3433
133 2039 ▶ defined *$self->{FH}->write( $data, length $data )
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{"FH"}->write($data, length $data) or return $self->saveErrorString(0, $!, $!) 0 2039 2039
134 or return $self->saveErrorString(0, $!, $!);
135 }
136 else {
137 1394 ${ *$self->{Buffer} } .= $data ;
138 }
139 }
140  
141 5268 return 1;
142 }
143  
144 sub getOneShotParams
145 {
146 695 ▶ return ( 'multistream' => [IO::Compress::Base::Common::Parse_boolean, 1],
Subroutine getOneShotParams: called CC=1 SCAR=0.0
Pod undocumented
147 );
148 }
149  
150 115 our %PARAMS = (
151 # Generic Parameters
152 'autoclose' => [IO::Compress::Base::Common::Parse_boolean, 0],
153 'encode' => [IO::Compress::Base::Common::Parse_any, undef],
154 'strict' => [IO::Compress::Base::Common::Parse_boolean, 1],
155 'append' => [IO::Compress::Base::Common::Parse_boolean, 0],
156 'binmodein' => [IO::Compress::Base::Common::Parse_boolean, 0],
157  
158 'filtercontainer' => [IO::Compress::Base::Common::Parse_code, undef],
159 );
160  
161 sub checkParams
162 {
163 2077 ▶ my $self = shift ;
Subroutine checkParams: called CC=4 SCAR=13.9
Pod undocumented
164 2077 my $class = shift ;
165  
166 2077 ▶ my $got = shift || IO::Compress::Base::Parameters::new();
Condition66%2/3
shift() || IO::Compress::Base::Parameters::new()
l!l&&r!l&&!r
17419030
MC/DC0%0/2
shift() || IO::Compress::Base::Parameters::new()
shift() IO::Compress::Base::Parameters::new()
Truth table66%2/3
A || B
A= shift()B= IO::Compress::Base::Parameters::new()
ABresult
1X1
011
000
167  
168 $got->parse(
169 {
170 %PARAMS,
171  
172  
173 $self->getExtraParams(),
174 2077 ▶ *$self->{OneShot} ? $self->getOneShotParams()
Branch: 2 branches
BranchTrueFalseTotal
$got->parse({%IO::Compress::Base::PARAMS, $self->getExtraParams, *$self->{"OneShot"} ? $self->getOneShotParams : ()}, @_) or $self->croakError("${class}: " . $got->getError) 25 2052 2077
*$self->{'OneShot'} ? : 695 1382 2077
175 : (),
176 },
177 @_) or $self->croakError("${class}: " . $got->getError()) ;
178  
179 2052 return $got ;
180 }
181  
182 sub _create
183 {
184 1928 ▶ my $obj = shift;
Subroutine _create: called CC=29 SCAR=33.7
185 1928 my $got = shift;
186  
187 1928 *$obj->{Closed} = 1 ;
188  
189 1928 my $class = ref $obj;
190 1928 ▶ $obj->croakError("$class: Missing Output parameter")
Branch: 1 branch
BranchTrueFalseTotal
unless @_ or $got 5 1923 1928
Condition66%2/3
@_ or $got
l!l&&r!l&&!r
192305
MC/DC50%1/2
@_ or $got
@_ $got
Truth table66%2/3
A or B
A= @_B= $got
ABresult
1X1
011
000
191 if ! @_ && ! $got ;
192  
193 1923 my $outValue = shift ;
194 1923 my $oneShot = 1 ;
195  
196 1923 ▶ if (! $got)
Branch: 1 branch
BranchTrueFalseTotal
unless ($got) 1208 715 1923
197 {
198 1208 $oneShot = 0 ;
199 1208 ▶ $got = $obj->checkParams($class, undef, @_)
Branch: 1 branch
BranchTrueFalseTotal
$got = $obj->checkParams($class, undef, @_) or return undef 0 1188 1188
200 or return undef ;
201 }
202  
203 1903 my $lax = ! $got->getValue('strict') ;
204  
205 1903 my $outType = IO::Compress::Base::Common::whatIsOutput($outValue);
206  
207 1903 ▶ $obj->ckOutputParam($class, $outValue)
Branch: 1 branch
BranchTrueFalseTotal
$obj->ckOutputParam($class, $outValue) or return undef 0 1893 1893
208 or return undef ;
209  
210 1893 ▶ if ($outType eq 'buffer') {
Branch: 1 branch
BranchTrueFalseTotal
if ($outType eq 'buffer') { } 790 1103 1893
211 790 *$obj->{Buffer} = $outValue;
212 }
213 else {
214 1103 my $buff = "" ;
215 1103 *$obj->{Buffer} = \$buff ;
216 }
217  
218 # Merge implies Append
219 1893 my $merge = $got->getValue('merge') ;
220 1893 ▶ my $appendOutput = $got->getValue('append') || $merge ;
Condition100%3/3
$got->getValue('append') || $merge
l!l&&r!l&&!r
237871569
MC/DC100%2/2
$got->getValue('append') || $merge
$got->getValue('append') $merge
Truth table100%3/3
A || B
A= $got->getValue('append')B= $merge
ABresult
1X1
011
000
221 1893 *$obj->{Append} = $appendOutput;
222 1893 *$obj->{FilterContainer} = $got->getValue('filtercontainer') ;
223  
224 1893 ▶ if ($merge)
Branch: 1 branch
BranchTrueFalseTotal
if ($merge) 87 1806 1893
225 {
226 # Switch off Merge mode if output file/buffer is empty/doesn't exist
227 87 ▶ if (($outType eq 'buffer' && length $$outValue == 0 ) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($outType eq "buffer" and length $$outValue == 0 or $outType ne "buffer" and !(-e $outValue) || -w _ && -z _) 12 75 87
Condition100%15/15
$outType eq "buffer" and length $$outValue == 0 or $outType ne "buffer" and !(-e $outValue) || -w _ && -z _
l!l&&r!l&&!r
3678
$outType eq "buffer" and length $$outValue == 0
!ll&&!rl&&r
57273
$outType ne "buffer" and !(-e $outValue) || -w _ && -z _
!ll&&!rl&&r
27516
not -e $outValue or -w _ and -z _
l!l&&r!l&&!r
3648
-w _ and -z _
!ll&&!rl&&r
6426
MC/DC33%2/6
$outType eq "buffer" and length $$outValue == 0 or $outType ne "buffer" and !(-e $outValue) || -w _ && -z _
$outType eq "buffer" length $$outValue == 0 $outType ne "buffer" not -e $outValue -w _ -z _
Truth table27%3/11
A and B or C and not(D) or E and F
A= $outType eq "buffer"B= length $$outValue == 0C= $outType ne "buffer"D= not -e $outValueE= -w _F= -z _
ABCDEFresult
11XXXX1
0X11XX1
0X10111
1011XX1
1010111
0X0XXX0
0X100X0
0X10100
100XXX0
10100X0
1010100
228 ($outType ne 'buffer' && (! -e $outValue || (-w _ && -z _))) )
229 12 { $merge = 0 }
230 }
231  
232 # If output is a file, check that it is writable
233 #no warnings;
234 #if ($outType eq 'filename' && -e $outValue && ! -w _)
235 # { return $obj->saveErrorString(undef, "Output file '$outValue' is not writable" ) }
236  
237 1893 ▶ $obj->ckParams($got)
Branch: 1 branch
BranchTrueFalseTotal
$obj->ckParams($got) or $obj->croakError("${class}: " . $obj->error) 32 1861 1893
238 or $obj->croakError("${class}: " . $obj->error());
239  
240 1861 ▶ if ($got->getValue('encode')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($got->getValue('encode')) { } 20 1841 1861
241 20 my $want_encoding = $got->getValue('encode');
242 20 *$obj->{Encoding} = IO::Compress::Base::Common::getEncoding($obj, $class, $want_encoding);
243 15 my $x = *$obj->{Encoding};
244 }
245 else {
246 1841 *$obj->{Encoding} = undef;
247 }
248  
249 1856 $obj->saveStatus(STATUS_OK) ;
250  
251 1856 my $status ;
252 1856 ▶ if (! $merge)
Branch: 1 branch
BranchTrueFalseTotal
if (not $merge) { } 1781 75 1856
253 {
254 1781 ▶ *$obj->{Compress} = $obj->mkComp($got)
Branch: 1 branch
BranchTrueFalseTotal
*$obj->{"Compress"} = $obj->mkComp($got) or return undef 0 1781 1781
255 or return undef;
256  
257 1781 *$obj->{UnCompSize} = U64->new;
258 1781 *$obj->{CompSize} = U64->new;
259  
260 1781 ▶ if ( $outType eq 'buffer') {
Branch: 1 branch
BranchTrueFalseTotal
if ($outType eq 'buffer') { } 727 1054 1781
261 727 ▶ ${ *$obj->{Buffer} } = ''
Branch: 1 branch
BranchTrueFalseTotal
unless $appendOutput 589 138 727
262 unless $appendOutput ;
263 }
264 else {
265 1054 ▶ if ($outType eq 'handle') {
Branch: 2 branches
BranchTrueFalseTotal
if ($outType eq 'handle') { } 214 840 1054
elsif ($outType eq 'filename') { } 840 0 840
266 214 *$obj->{FH} = $outValue ;
267 214 setBinModeOutput(*$obj->{FH}) ;
268 #$outValue->flush() ;
269 214 *$obj->{Handle} = 1 ;
270 214 ▶ if ($appendOutput)
Branch: 1 branch
BranchTrueFalseTotal
if ($appendOutput) 53 161 214
271 {
272 53 ▶ seek(*$obj->{FH}, 0, IO::Handle::SEEK_END)
Branch: 1 branch
BranchTrueFalseTotal
CORE::seek *$obj->{"FH"}, 0, 2 or return $obj->saveErrorString(undef, "Cannot seek to end of output filehandle: $!", $!) 0 53 53
273 or return $obj->saveErrorString(undef, "Cannot seek to end of output filehandle: $!", $!) ;
274  
275 }
276 }
277 elsif ($outType eq 'filename') {
278 115 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
279 840 my $mode = '>' ;
280 840 ▶ $mode = '>>'
Branch: 1 branch
BranchTrueFalseTotal
if $appendOutput 58 782 840
281 if $appendOutput;
282 840 ▶ *$obj->{FH} = IO::File->new( "$mode $outValue" )
Branch: 1 branch
BranchTrueFalseTotal
*$obj->{"FH"} = "IO::File"->new("$mode $outValue") or return $obj->saveErrorString(undef, "cannot open file '${outValue}': $!", $!) 5 835 840
283 or return $obj->saveErrorString(undef, "cannot open file '$outValue': $!", $!) ;
284 835 *$obj->{StdIO} = ($outValue eq '-');
285 835 setBinModeOutput(*$obj->{FH}) ;
286 }
287 }
288  
289 1776 *$obj->{Header} = $obj->mkHeader($got) ;
290 $obj->output( *$obj->{Header} )
291 1775 ▶ or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$obj->output(*$obj->{"Header"}) or return undef 0 1775 1775
292 1775 $obj->beforePayload();
293 }
294 else
295 {
296 75 ▶ *$obj->{Compress} = $obj->createMerge($outValue, $outType)
Branch: 1 branch
BranchTrueFalseTotal
*$obj->{"Compress"} = $obj->createMerge($outValue, $outType) or return undef 15 60 75
297 or return undef;
298 }
299  
300 1835 *$obj->{Closed} = 0 ;
301 1835 *$obj->{AutoClose} = $got->getValue('autoclose') ;
302 1835 *$obj->{Output} = $outValue;
303 1835 *$obj->{ClassName} = $class;
304 1835 *$obj->{Got} = $got;
305 1835 *$obj->{OneShot} = 0 ;
306  
307 1835 return $obj ;
308 }
309  
310 sub ckOutputParam
311 {
312 1903 ▶ my $self = shift ;
Subroutine ckOutputParam: called CC=4 SCAR=13.9
Pod undocumented
313 1903 my $from = shift ;
314 1903 my $outType = IO::Compress::Base::Common::whatIsOutput($_[0]);
315  
316 1903 ▶ $self->croakError("$from: output parameter not a filename, filehandle or scalar ref")
Branch: 1 branch
BranchTrueFalseTotal
unless $outType 5 1898 1903
317 if ! $outType ;
318  
319 #$self->croakError("$from: output filename is undef or null string")
320 #if $outType eq 'filename' && (! defined $_[0] || $_[0] eq '') ;
321  
322 $self->croakError("$from: output buffer is read-only")
323 1898 ▶ if $outType eq 'buffer' && Scalar::Util::readonly(${ $_[0] });
Branch: 1 branch
BranchTrueFalseTotal
if $outType eq "buffer" and &Scalar::Util::readonly(${$_[0];}) 5 1893 1898
Condition100%3/3
$outType eq "buffer" and &Scalar::Util::readonly(${$_[0];})
!ll&&!rl&&r
11037905
MC/DC100%2/2
$outType eq "buffer" and &Scalar::Util::readonly(${$_[0];})
$outType eq "buffer" &Scalar::Util::readonly(${$_[0];})
Truth table100%3/3
A and B
A= $outType eq "buffer"B= &Scalar::Util::readonly(${$_[0];})
ABresult
0X0
100
111
324  
325 1893 return 1;
326 }
327  
328  
329 sub _def
330 {
331 830 ▶ my $obj = shift ;
Subroutine _def: called CC=15 SCAR=27.4
332  
333 830 my $class= (caller)[0] ;
334 830 my $name = (caller(1))[3] ;
335  
336 830 ▶ $obj->croakError("$name: expected at least 1 parameters\n")
Branch: 1 branch
BranchTrueFalseTotal
unless @_ >= 1 5 825 830
337 unless @_ >= 1 ;
338  
339 825 my $input = shift ;
340 825 my $haveOut = @_ ;
341 825 my $output = shift ;
342  
343 825 ▶ my $x = IO::Compress::Base::Validator->new($class, *$obj->{Error}, $name, $input, $output)
Branch: 1 branch
BranchTrueFalseTotal
my $x = "IO::Compress::Base::Validator"->new($class, *$obj->{"Error"}, $name, $input, $output) or return undef 30 695 725
344 or return undef ;
345  
346 695 ▶ push @_, $output if $haveOut && $x->{Hash};
Branch: 1 branch
BranchTrueFalseTotal
if $haveOut and $x->{"Hash"} 0 695 695
Condition33%1/3
$haveOut and $x->{"Hash"}
!ll&&!rl&&r
06950
MC/DC0%0/2
$haveOut and $x->{"Hash"}
$haveOut $x->{"Hash"}
Truth table33%1/3
A and B
A= $haveOutB= $x->{"Hash"}
ABresult
0X0
100
111
347  
348 695 *$obj->{OneShot} = 1 ;
349  
350 695 ▶ my $got = $obj->checkParams($name, undef, @_)
Branch: 1 branch
BranchTrueFalseTotal
my $got = $obj->checkParams($name, undef, @_) or return undef 0 690 690
351 or return undef ;
352  
353 690 $x->{Got} = $got ;
354  
355 # if ($x->{Hash})
356 # {
357 # while (my($k, $v) = each %$input)
358 # {
359 # $v = \$input->{$k}
360 # unless defined $v ;
361 #
362 # $obj->_singleTarget($x, 1, $k, $v, @_)
363 # or return undef ;
364 # }
365 #
366 # return keys %$input ;
367 # }
368  
369 690 ▶ if ($x->{GlobMap})
Branch: 1 branch
BranchTrueFalseTotal
if ($x->{"GlobMap"}) 10 680 690
370 {
371 10 $x->{oneInput} = 1 ;
372 10 foreach my $pair (@{ $x->{Pairs} })
373 {
374 20 my ($from, $to) = @$pair ;
375 20 ▶ $obj->_singleTarget($x, 1, $from, $to, @_)
Branch: 1 branch
BranchTrueFalseTotal
$obj->_singleTarget($x, 1, $from, $to, @_) or return undef 0 20 20
376 or return undef ;
377 }
378  
379 10 return scalar @{ $x->{Pairs} } ;
380 }
381  
382 680 ▶ if (! $x->{oneOutput} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($x->{"oneOutput"}) 75 605 680
383 {
384 my $inFile = ($x->{inType} eq 'filenames'
385 75 ▶ || $x->{inType} eq 'filename');
Condition100%3/3
$x->{'inType'} eq 'filenames' || $x->{'inType'} eq 'filename'
l!l&&r!l&&!r
40530
MC/DC100%2/2
$x->{'inType'} eq 'filenames' || $x->{'inType'} eq 'filename'
$x->{'inType'} eq 'filenames' $x->{'inType'} eq 'filename'
Truth table100%3/3
A || B
A= $x->{'inType'} eq 'filenames'B= $x->{'inType'} eq 'filename'
ABresult
1X1
011
000
386  
387 75 ▶ $x->{inType} = $inFile ? 'filename' : 'buffer';
Branch: 1 branch
BranchTrueFalseTotal
$inFile ? : 45 30 75
388  
389 75 ▶ foreach my $in ($x->{oneInput} ? $input : @$input)
Branch: 1 branch
BranchTrueFalseTotal
$x->{'oneInput'} ? : 35 40 75
390 {
391 90 my $out ;
392 90 $x->{oneInput} = 1 ;
393  
394 90 ▶ $obj->_singleTarget($x, $inFile, $in, \$out, @_)
Branch: 1 branch
BranchTrueFalseTotal
$obj->_singleTarget($x, $inFile, $in, \$out, @_) or return undef 0 90 90
395 or return undef ;
396  
397 90 push @$output, \$out ;
398 #if ($x->{outType} eq 'array')
399 # { push @$output, \$out }
400 #else
401 # { $output->{$in} = \$out }
402 }
403  
404 75 return 1 ;
405 }
406  
407 # finally the 1 to 1 and n to 1
408 605 return $obj->_singleTarget($x, 1, $input, $output, @_);
409  
410 0 Carp::croak "should not be here" ;
411 }
412  
413 sub _singleTarget
414 {
415 715 ▶ my $obj = shift ;
Subroutine _singleTarget: called CC=14 SCAR=27.0
416 715 my $x = shift ;
417 715 my $inputIsFilename = shift;
418 715 my $input = shift;
419  
420 715 ▶ if ($x->{oneInput})
Branch: 1 branch
BranchTrueFalseTotal
if ($x->{'oneInput'}) { } 640 75 715
421 {
422 640 ▶ $obj->getFileInfo($x->{Got}, $input)
Branch: 1 branch
BranchTrueFalseTotal
if isaScalar($input) or &isaFilename($input) and $inputIsFilename 432 208 640
Condition83%5/6
isaScalar($input) or &isaFilename($input) and $inputIsFilename
l!l&&r!l&&!r
20239642
&isaFilename($input) and $inputIsFilename
!ll&&!rl&&r
2080230
MC/DC0%0/3
isaScalar($input) or &isaFilename($input) and $inputIsFilename
isaScalar($input) &isaFilename($input) $inputIsFilename
Truth table50%2/4
A or B and C
A= isaScalar($input)B= &isaFilename($input)C= $inputIsFilename
ABCresult
1XX1
0111
00X0
0100
423 if isaScalar($input) || (isaFilename($input) and $inputIsFilename) ;
424  
425 640 ▶ my $z = $obj->_create($x->{Got}, @_)
Branch: 1 branch
BranchTrueFalseTotal
my $z = $obj->_create($x->{"Got"}, @_) or return undef 5 635 640
426 or return undef ;
427  
428  
429 635 ▶ defined $z->_wr2($input, $inputIsFilename)
Branch: 1 branch
BranchTrueFalseTotal
defined $z->_wr2($input, $inputIsFilename) or return $z->closeError(undef) 0 635 635
430 or return $z->closeError(undef) ;
431  
432 635 return $z->close() ;
433 }
434 else
435 {
436 75 my $afterFirst = 0 ;
437 75 my $inputIsFilename = ($x->{inType} ne 'array');
438 75 my $keep = $x->{Got}->clone();
439  
440 #for my $element ( ($x->{inType} eq 'hash') ? keys %$input : @$input)
441 75 for my $element ( @$input)
442 {
443 180 my $isFilename = isaFilename($element);
444  
445 180 ▶ if ( $afterFirst ++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($afterFirst++) { } 105 75 180
446 {
447 105 ▶ defined addInterStream($obj, $element, $isFilename)
Branch: 1 branch
BranchTrueFalseTotal
defined addInterStream($obj, $element, $isFilename) or return $obj->closeError(undef) 0 105 105
448 or return $obj->closeError(undef) ;
449 }
450 else
451 {
452 75 ▶ $obj->getFileInfo($x->{Got}, $element)
Branch: 1 branch
BranchTrueFalseTotal
if isaScalar($element) or $isFilename 75 0 75
Condition33%1/3
isaScalar($element) or $isFilename
l!l&&r!l&&!r
0750
MC/DC0%0/2
isaScalar($element) or $isFilename
isaScalar($element) $isFilename
Truth table33%1/3
A or B
A= isaScalar($element)B= $isFilename
ABresult
1X1
011
000
453 if isaScalar($element) || $isFilename;
454  
455 75 ▶ $obj->_create($x->{Got}, @_)
Branch: 1 branch
BranchTrueFalseTotal
$obj->_create($x->{"Got"}, @_) or return undef 0 75 75
456 or return undef ;
457 }
458  
459 180 ▶ defined $obj->_wr2($element, $isFilename)
Branch: 1 branch
BranchTrueFalseTotal
defined $obj->_wr2($element, $isFilename) or return $obj->closeError(undef) 0 180 180
460 or return $obj->closeError(undef) ;
461  
462 180 *$obj->{Got} = $keep->clone();
463 }
464 75 return $obj->close() ;
465 }
466  
467 }
468  
469 sub _wr2
470 {
471 815 ▶ my $self = shift ;
Subroutine _wr2: called CC=16 SCAR=28.5
472  
473 815 my $source = shift ;
474 815 my $inputIsFilename = shift;
475  
476 815 my $input = $source ;
477 815 ▶ if (! $inputIsFilename)
Branch: 1 branch
BranchTrueFalseTotal
unless ($inputIsFilename) 30 785 815
478 {
479 30 ▶ $input = \$source
Branch: 1 branch
BranchTrueFalseTotal
unless ref $source 0 30 30
480 if ! ref $source;
481 }
482  
483 815 ▶ if ( ref $input && ref $input eq 'SCALAR' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $input and ref $input eq "SCALAR") 248 567 815
Condition100%3/3
ref $input and ref $input eq "SCALAR"
!ll&&!rl&&r
47097248
MC/DC100%2/2
ref $input and ref $input eq "SCALAR"
ref $input ref $input eq "SCALAR"
Truth table100%3/3
A and B
A= ref $inputB= ref $input eq "SCALAR"
ABresult
0X0
100
111
484 {
485 248 return $self->syswrite($input, @_) ;
486 }
487  
488 567 ▶ if ( ! ref $input || isaFilehandle($input))
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $input or &isaFilehandle($input)) 567 0 567
Condition66%2/3
not ref $input or &isaFilehandle($input)
l!l&&r!l&&!r
470970
MC/DC0%0/2
not ref $input or &isaFilehandle($input)
not ref $input &isaFilehandle($input)
Truth table66%2/3
not(A) or B
A= not ref $inputB= &isaFilehandle($input)
ABresult
1X1
011
000
489 {
490 567 my $isFilehandle = isaFilehandle($input) ;
491  
492 567 my $fh = $input ;
493  
494 567 ▶ if ( ! $isFilehandle )
Branch: 1 branch
BranchTrueFalseTotal
unless ($isFilehandle) 410 157 567
495 {
496 410 ▶ $fh = IO::File->new( "<$input" )
Branch: 1 branch
BranchTrueFalseTotal
$fh = "IO::File"->new("<$input") or return $self->saveErrorString(undef, "cannot open file '${input}': $!", $!) 0 410 410
497 or return $self->saveErrorString(undef, "cannot open file '$input': $!", $!) ;
498 }
499 567 binmode $fh ;
500  
501 567 my $status ;
502 my $buff ;
503 567 my $count = 0 ;
504 567 ▶ while ($status = read($fh, $buff, 16 * 1024)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status = CORE::read($fh, $buff, 16384)) 407 567 974
505 407 $count += length $buff;
506 407 ▶ defined $self->syswrite($buff, @_)
Branch: 1 branch
BranchTrueFalseTotal
defined $self->syswrite($buff, @_) or return undef 0 407 407
507 or return undef ;
508 }
509  
510 567 ▶ return $self->saveErrorString(undef, $!, $!)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $status 0 567 567
511 if ! defined $status ;
512  
513 567 ▶ if ( (!$isFilehandle || *$self->{AutoClose}) && $input ne '-')
Branch: 1 branch
BranchTrueFalseTotal
if (!$isFilehandle || *$self->{"AutoClose"} and $input ne "-") 440 127 567
Condition83%5/6
!$isFilehandle || *$self->{"AutoClose"} and $input ne "-"
!ll&&!rl&&r
1270440
not $isFilehandle or *$self->{"AutoClose"}
l!l&&r!l&&!r
41030127
MC/DC66%2/3
!$isFilehandle || *$self->{"AutoClose"} and $input ne "-"
not $isFilehandle *$self->{"AutoClose"} $input ne "-"
Truth table60%3/5
not(A) or B and C
A= not $isFilehandleB= *$self->{"AutoClose"}C= $input ne "-"
ABCresult
00X0
1X00
0100
1X11
0111
514 {
515 440 ▶ $fh->close()
Branch: 1 branch
BranchTrueFalseTotal
$fh->close or return undef 0 440 440
516 or return undef ;
517 }
518  
519 567 return $count ;
520 }
521  
522 0 Carp::croak "Should not be here";
523 0 return undef;
524 }
525  
526 sub addInterStream
527 {
528 105 ▶ my $self = shift ;
Subroutine addInterStream: called CC=5 SCAR=16.8
Pod undocumented
529 105 my $input = shift ;
530 105 my $inputIsFilename = shift ;
531  
532 105 ▶ if (*$self->{Got}->getValue('multistream'))
Branch: 2 branches
BranchTrueFalseTotal
if (*$self->{'Got'}->getValue('multistream')) { } 60 45 105
elsif (*$self->{'Got'}->getValue('autoflush')) { } 0 45 45
533 {
534 60 ▶ $self->getFileInfo(*$self->{Got}, $input)
Branch: 1 branch
BranchTrueFalseTotal
if isaScalar($input) or &isaFilename($input) 60 0 60
Condition33%1/3
isaScalar($input) or &isaFilename($input)
l!l&&r!l&&!r
0600
MC/DC0%0/2
isaScalar($input) or &isaFilename($input)
isaScalar($input) &isaFilename($input)
Truth table33%1/3
A or B
A= isaScalar($input)B= &isaFilename($input)
ABresult
1X1
011
000
535 #if isaFilename($input) and $inputIsFilename ;
536 if isaScalar($input) || isaFilename($input) ;
537  
538 # TODO -- newStream needs to allow gzip/zip header to be modified
539 60 return $self->newStream();
540 }
541 elsif (*$self->{Got}->getValue('autoflush'))
542 {
543 #return $self->flush(Z_FULL_FLUSH);
544 }
545  
546 45 return 1 ;
547 }
548  
549 sub getFileInfo
550 ▶{
Subroutine getFileInfo: not called CC=1 SCAR=0.0
Pod undocumented
551 }
552  
553 sub TIEHANDLE
554 {
555 2043 ▶ return $_[0] if ref($_[0]);
Subroutine TIEHANDLE: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 2043 0 2043
556 0 die "OOPS\n" ;
557 }
558  
559 sub UNTIE
560 {
561 1810 ▶ my $self = shift ;
Subroutine UNTIE: called CC=1 SCAR=0.0
562 }
563  
564 sub DESTROY
565 {
566 2042 ▶ my $self = shift ;
Subroutine DESTROY: called CC=1 SCAR=0.0
567 2042 local ($., $@, $!, $^E, $?);
568  
569 2042 $self->close() ;
570  
571 # TODO - memory leak with 5.8.0 - this isn't called until
572 # global destruction
573 #
574 2042 %{ *$self } = () ;
575 2042 undef $self ;
576 }
577  
578  
579  
580 sub filterUncompressed
581 ▶{
Subroutine filterUncompressed: called CC=1 SCAR=0.0
Pod undocumented
582 }
583  
584 sub syswrite
585 {
586 2142 ▶ my $self = shift ;
Subroutine syswrite: called CC=21 SCAR=31.0
Pod undocumented
587  
588 2142 my $buffer ;
589 2142 ▶ if (ref $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 283 1859 2142
590 283 ▶ $self->croakError( *$self->{ClassName} . "::write: not a scalar reference" )
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "SCALAR" 35 248 283
591 unless ref $_[0] eq 'SCALAR' ;
592 248 $buffer = $_[0] ;
593 }
594 else {
595 1859 $buffer = \$_[0] ;
596 }
597  
598 2107 ▶ if (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 85 2022 2107
599 85 ▶ my $slen = defined $$buffer ? length($$buffer) : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $$buffer ? : 85 0 85
600 85 my $len = $slen;
601 85 my $offset = 0;
602 85 ▶ $len = $_[1] if $_[1] < $len;
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] < $len 10 75 85
603  
604 85 ▶ if (@_ > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) 40 45 85
605 40 ▶ $offset = $_[2] || 0;
Condition50%1/2
$_[2] || 0
l!l
400
MC/DC0%0/1
$_[2] || 0
$_[2]
Truth table50%1/2
A
A= $_[2]
Aresult
11
00
606 40 ▶ $self->croakError(*$self->{ClassName} . "::write: offset outside string")
Branch: 1 branch
BranchTrueFalseTotal
if $offset > $slen 5 35 40
607 if $offset > $slen;
608 35 ▶ if ($offset < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset < 0) 20 15 35
609 20 $offset += $slen;
610 20 ▶ $self->croakError( *$self->{ClassName} . "::write: offset outside string") if $offset < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $offset < 0 5 15 20
611 }
612 30 my $rem = $slen - $offset;
613 30 ▶ $len = $rem if $rem < $len;
Branch: 1 branch
BranchTrueFalseTotal
if $rem < $len 30 0 30
614 }
615  
616 75 $buffer = \substr($$buffer, $offset, $len) ;
617 }
618  
619 2097 ▶ return 0 if (! defined $$buffer || length $$buffer == 0) && ! *$self->{FlushPending};
Branch: 1 branch
BranchTrueFalseTotal
if !defined($$buffer) || length $$buffer == 0 and not *$self->{"FlushPending"} 175 1922 2097
Condition83%5/6
!defined($$buffer) || length $$buffer == 0 and not *$self->{"FlushPending"}
!ll&&!rl&&r
19220175
not defined $$buffer or length $$buffer == 0
l!l&&r!l&&!r
85901922
MC/DC66%2/3
!defined($$buffer) || length $$buffer == 0 and not *$self->{"FlushPending"}
not defined $$buffer length $$buffer == 0 not *$self->{"FlushPending"}
Truth table60%3/5
not(A) or B and not(C)
A= not defined $$bufferB= length $$buffer == 0C= not *$self->{"FlushPending"}
ABCresult
00X0
1X00
0100
1X11
0111
620  
621 # *$self->{Pending} .= $$buffer ;
622 #
623 # return length $$buffer
624 # if (length *$self->{Pending} < 1024 * 16 && ! *$self->{FlushPending}) ;
625 #
626 # $$buffer = *$self->{Pending} ;
627 # *$self->{Pending} = '';
628  
629 1922 ▶ if (*$self->{Encoding}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*$self->{'Encoding'}) { } 15 1907 1922
630 15 $$buffer = *$self->{Encoding}->encode($$buffer);
631 }
632 else {
633 $] >= 5.008 and ( utf8::downgrade($$buffer, 1)
634 1907 ▶ or Carp::croak "Wide character in " . *$self->{ClassName} . "::write:");
Branch: 1 branch
BranchTrueFalseTotal
$] >= "5.008" and utf8::downgrade($$buffer, 1) || Carp::croak('Wide character in ' . *$self->{"ClassName"} . '::write:') 1907 0 1907
Condition50%3/6
$] >= 5.008 && (utf8::downgrade($$buffer, 1) || Carp::croak('Wide character in ' . *$self->{'ClassName'} . '::write:'))
!ll&&!rl&&r
019070
utf8::downgrade($$buffer, 1) or Carp::croak('Wide character in ' . *$self->{"ClassName"} . '::write:')
l!l&&r!l&&!r
190250
MC/DC0%0/3
$] >= 5.008 && (utf8::downgrade($$buffer, 1) || Carp::croak('Wide character in ' . *$self->{'ClassName'} . '::write:'))
$] >= 5.008 utf8::downgrade($$buffer, 1) Carp::croak('Wide character in ' . *$self->{"ClassName"} . '::write:')
Truth table0%0/4
A && B or C
A= $] >= 5.008B= utf8::downgrade($$buffer, 1)C= Carp::croak('Wide character in ' . *$self->{"ClassName"} . '::write:')
ABCresult
0XX0
1000
11X1
1011
635 }
636  
637 1917 $self->filterUncompressed($buffer);
638  
639 1917 ▶ my $buffer_length = defined $$buffer ? length($$buffer) : 0 ;
Branch: 1 branch
BranchTrueFalseTotal
defined $$buffer ? : 1917 0 1917
640 1917 *$self->{UnCompSize}->add($buffer_length) ;
641  
642 1917 my $outBuffer='';
643 1917 my $status = *$self->{Compress}->compr($buffer, $outBuffer) ;
644  
645 return $self->saveErrorString(undef, *$self->{Compress}{Error},
646 *$self->{Compress}{ErrorNo})
647 1917 ▶ if $status == STATUS_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
if $status == -1 0 1917 1917
648  
649 1917 *$self->{CompSize}->add(length $outBuffer) ;
650  
651 1917 ▶ $self->outputPayload($outBuffer)
Branch: 1 branch
BranchTrueFalseTotal
$self->outputPayload($outBuffer) or return undef 0 1917 1917
652 or return undef;
653  
654 1917 return $buffer_length;
655 }
656  
657 sub print
658 {
659 316 ▶ my $self = shift;
Subroutine print: called CC=4 SCAR=13.9
Pod undocumented
660  
661 #if (ref $self) {
662 # $self = *$self{GLOB} ;
663 #}
664  
665 316 ▶ if (defined $\) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $\) { } 30 286 316
666 30 ▶ if (defined $,) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $,) { } 15 15 30
667 15 defined $self->syswrite(join($,, @_) . $\);
668 } else {
669 15 defined $self->syswrite(join("", @_) . $\);
670 }
671 } else {
672 286 ▶ if (defined $,) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $,) { } 5 281 286
673 5 defined $self->syswrite(join($,, @_));
674 } else {
675 281 defined $self->syswrite(join("", @_));
676 }
677 }
678 }
679  
680 sub printf
681 {
682 90 ▶ my $self = shift;
Subroutine printf: called CC=1 SCAR=0.0
Pod undocumented
683 90 my $fmt = shift;
684 90 defined $self->syswrite(sprintf($fmt, @_));
685 }
686  
687 sub _flushCompressed
688 {
689 35 ▶ my $self = shift ;
Subroutine _flushCompressed: called CC=4 SCAR=13.9
690  
691 35 my $outBuffer='';
692 35 my $status = *$self->{Compress}->flush($outBuffer, @_) ;
693 return $self->saveErrorString(0, *$self->{Compress}{Error},
694 *$self->{Compress}{ErrorNo})
695 35 ▶ if $status == STATUS_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
if $status == -1 1 34 35
696  
697 34 ▶ if ( defined *$self->{FH} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"FH"}) 25 9 34
698 25 *$self->{FH}->clearerr();
699 }
700  
701 34 *$self->{CompSize}->add(length $outBuffer) ;
702  
703 34 ▶ $self->outputPayload($outBuffer)
Branch: 1 branch
BranchTrueFalseTotal
$self->outputPayload($outBuffer) or return 0 0 34 34
704 or return 0;
705 34 return 1;
706 }
707  
708 sub flush
709 {
710 35 ▶ my $self = shift ;
Subroutine flush: called CC=4 SCAR=13.9
Pod documented
711  
712 35 ▶ $self->_flushCompressed(@_)
Branch: 1 branch
BranchTrueFalseTotal
$self->_flushCompressed(@_) or return 0 1 34 35
713 or return 0;
714  
715 34 ▶ if ( defined *$self->{FH} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"FH"}) 25 9 34
716 defined *$self->{FH}->flush()
717 25 ▶ or return $self->saveErrorString(0, $!, $!);
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{"FH"}->flush or return $self->saveErrorString(0, $!, $!) 0 25 25
718 }
719  
720 34 return 1;
721 }
722  
723 sub beforePayload
724 ▶{
Subroutine beforePayload: called CC=1 SCAR=0.0
Pod undocumented
725 }
726  
727 sub _newStream
728 {
729 174 ▶ my $self = shift ;
Subroutine _newStream: called CC=6 SCAR=19.0
730 174 my $got = shift;
731  
732 174 my $class = ref $self;
733  
734 174 ▶ $self->_writeTrailer()
Branch: 1 branch
BranchTrueFalseTotal
$self->_writeTrailer or return 0 0 174 174
735 or return 0 ;
736  
737 174 ▶ $self->ckParams($got)
Branch: 1 branch
BranchTrueFalseTotal
$self->ckParams($got) or $self->croakError(qq[newStream: $self->{"Error"}]) 0 174 174
738 or $self->croakError("newStream: $self->{Error}");
739  
740 174 ▶ if ($got->getValue('encode')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($got->getValue('encode')) { } 0 174 174
741 0 my $want_encoding = $got->getValue('encode');
742 0 *$self->{Encoding} = IO::Compress::Base::Common::getEncoding($self, $class, $want_encoding);
743 }
744 else {
745 174 *$self->{Encoding} = undef;
746 }
747  
748 174 ▶ *$self->{Compress} = $self->mkComp($got)
Branch: 1 branch
BranchTrueFalseTotal
*$self->{"Compress"} = $self->mkComp($got) or return 0 0 174 174
749 or return 0;
750  
751 174 *$self->{Header} = $self->mkHeader($got) ;
752 $self->output(*$self->{Header} )
753 174 ▶ or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->output(*$self->{"Header"}) or return 0 0 174 174
754  
755 174 *$self->{UnCompSize}->reset();
756 174 *$self->{CompSize}->reset();
757  
758 174 $self->beforePayload();
759  
760 174 return 1 ;
761 }
762  
763 sub newStream
764 {
765 174 ▶ my $self = shift ;
Subroutine newStream: called CC=2 SCAR=7.1
Pod undocumented
766  
767 174 ▶ my $got = $self->checkParams('newStream', *$self->{Got}, @_)
Branch: 1 branch
BranchTrueFalseTotal
my $got = $self->checkParams("newStream", *$self->{"Got"}, @_) or return 0 0 174 174
768 or return 0 ;
769  
770 174 $self->_newStream($got);
771  
772 # *$self->{Compress} = $self->mkComp($got)
773 # or return 0;
774 #
775 # *$self->{Header} = $self->mkHeader($got) ;
776 # $self->output(*$self->{Header} )
777 # or return 0;
778 #
779 # *$self->{UnCompSize}->reset();
780 # *$self->{CompSize}->reset();
781 #
782 # $self->beforePayload();
783 #
784 # return 1 ;
785 }
786  
787 sub reset
788 {
789 0 ▶ my $self = shift ;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
790 0 return *$self->{Compress}->reset() ;
791 }
792  
793 sub _writeTrailer
794 {
795 2009 ▶ my $self = shift ;
Subroutine _writeTrailer: called CC=3 SCAR=11.1
796  
797 2009 my $trailer = '';
798  
799 2009 my $status = *$self->{Compress}->close($trailer) ;
800  
801 return $self->saveErrorString(0, *$self->{Compress}{Error}, *$self->{Compress}{ErrorNo})
802 2009 ▶ if $status == STATUS_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
if $status == -1 0 2009 2009
803  
804 2009 *$self->{CompSize}->add(length $trailer) ;
805  
806 2009 $trailer .= $self->mkTrailer();
807 2009 ▶ defined $trailer
Branch: 1 branch
BranchTrueFalseTotal
defined $trailer or return 0 0 2009 2009
808 or return 0;
809 2009 return $self->output($trailer);
810 }
811  
812 sub _writeFinalTrailer
813 {
814 1835 ▶ my $self = shift ;
Subroutine _writeFinalTrailer: called CC=1 SCAR=0.0
815  
816 1835 return $self->output($self->mkFinalTrailer());
817 }
818  
819 sub close
820 {
821 3810 ▶ my $self = shift ;
Subroutine close: called CC=12 SCAR=25.5
Pod undocumented
822 3810 ▶ return 1 if *$self->{Closed} || ! *$self->{Compress} ;
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"Closed"} or not *$self->{"Compress"} 1975 1835 3810
Condition66%2/3
*$self->{"Closed"} or not *$self->{"Compress"}
l!l&&r!l&&!r
197501835
MC/DC50%1/2
*$self->{"Closed"} or not *$self->{"Compress"}
*$self->{"Closed"} not *$self->{"Compress"}
Truth table66%2/3
A or not(B)
A= *$self->{"Closed"}B= not *$self->{"Compress"}
ABresult
1X1
011
000
823 1835 *$self->{Closed} = 1 ;
824  
825 1835 ▶ untie *$self
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.008" 1835 0 1835
826 if $] >= 5.008 ;
827  
828 1835 *$self->{FlushPending} = 1 ;
829 1835 ▶ $self->_writeTrailer()
Branch: 1 branch
BranchTrueFalseTotal
$self->_writeTrailer or return 0 0 1835 1835
830 or return 0 ;
831  
832 1835 ▶ $self->_writeFinalTrailer()
Branch: 1 branch
BranchTrueFalseTotal
$self->_writeFinalTrailer or return 0 0 1835 1835
833 or return 0 ;
834  
835 1835 ▶ $self->output( "", 1 )
Branch: 1 branch
BranchTrueFalseTotal
$self->output("", 1) or return 0 0 1835 1835
836 or return 0;
837  
838 1835 ▶ if (defined *$self->{FH}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *$self->{"FH"}) 1084 751 1835
839  
840 1084 ▶ if ((! *$self->{Handle} || *$self->{AutoClose}) && ! *$self->{StdIO}) {
Branch: 1 branch
BranchTrueFalseTotal
if (!*$self->{"Handle"} || *$self->{"AutoClose"} and not *$self->{"StdIO"}) 1018 66 1084
Condition83%5/6
!*$self->{"Handle"} || *$self->{"AutoClose"} and not *$self->{"StdIO"}
!ll&&!rl&&r
6601018
not *$self->{"Handle"} or *$self->{"AutoClose"}
l!l&&r!l&&!r
85816066
MC/DC66%2/3
!*$self->{"Handle"} || *$self->{"AutoClose"} and not *$self->{"StdIO"}
not *$self->{"Handle"} *$self->{"AutoClose"} not *$self->{"StdIO"}
Truth table60%3/5
not(A) or B and not(C)
A= not *$self->{"Handle"}B= *$self->{"AutoClose"}C= not *$self->{"StdIO"}
ABCresult
00X0
1X00
0100
1X11
0111
841 1018 $! = 0 ;
842 *$self->{FH}->close()
843 1018 ▶ or return $self->saveErrorString(0, $!, $!);
Branch: 1 branch
BranchTrueFalseTotal
*$self->{"FH"}->close or return $self->saveErrorString(0, $!, $!) 0 1018 1018
844 }
845 1084 delete *$self->{FH} ;
846 # This delete can set $! in older Perls, so reset the errno
847 1084 $! = 0 ;
848 }
849  
850 1835 return 1;
851 }
852  
853  
854 #sub total_in
855 #sub total_out
856 #sub msg
857 #
858 #sub crc
859 #{
860 # my $self = shift ;
861 # return *$self->{Compress}->crc32() ;
862 #}
863 #
864 #sub msg
865 #{
866 # my $self = shift ;
867 # return *$self->{Compress}->msg() ;
868 #}
869 #
870 #sub dict_adler
871 #{
872 # my $self = shift ;
873 # return *$self->{Compress}->dict_adler() ;
874 #}
875 #
876 #sub get_Level
877 #{
878 # my $self = shift ;
879 # return *$self->{Compress}->get_Level() ;
880 #}
881 #
882 #sub get_Strategy
883 #{
884 # my $self = shift ;
885 # return *$self->{Compress}->get_Strategy() ;
886 #}
887  
888  
889 sub tell
890 {
891 151 ▶ my $self = shift ;
Subroutine tell: called CC=1 SCAR=0.0
Pod documented
892  
893 151 return *$self->{UnCompSize}->get32bit() ;
894 }
895  
896 sub eof
897 {
898 116 ▶ my $self = shift ;
Subroutine eof: called CC=1 SCAR=0.0
Pod undocumented
899  
900 116 return *$self->{Closed} ;
901 }
902  
903  
904 sub seek
905 {
906 65 ▶ my $self = shift ;
Subroutine seek: called CC=7 SCAR=19.5
Pod documented
907 65 my $position = shift;
908 65 my $whence = shift ;
909  
910 65 my $here = $self->tell() ;
911 65 my $target = 0 ;
912  
913 #use IO::Handle qw(SEEK_SET SEEK_CUR SEEK_END);
914 115 ▶ use IO::Handle ;
Subroutine BEGIN: called CC=1 SCAR=0.0
915  
916 65 ▶ if ($whence == IO::Handle::SEEK_SET) {
Branch: 2 branches
BranchTrueFalseTotal
if ($whence == 0) { } 11 54 65
elsif ($whence == 1 or $whence == 2) { } 43 11 54
917 11 $target = $position ;
918 }
919 ▶ elsif ($whence == IO::Handle::SEEK_CUR || $whence == IO::Handle::SEEK_END) {
Condition100%3/3
$whence == 1 or $whence == 2
l!l&&r!l&&!r
321111
MC/DC100%2/2
$whence == 1 or $whence == 2
$whence == 1 $whence == 2
Truth table100%3/3
A or B
A= $whence == 1B= $whence == 2
ABresult
1X1
011
000
920 43 $target = $here + $position ;
921 }
922 else {
923 11 $self->croakError(*$self->{ClassName} . "::seek: unknown value, $whence, for whence parameter");
924 }
925  
926 # short circuit if seeking to current offset
927 54 ▶ return 1 if $target == $here ;
Branch: 1 branch
BranchTrueFalseTotal
if $target == $here 16 38 54
928  
929 # Outlaw any attempt to seek backwards
930 38 ▶ $self->croakError(*$self->{ClassName} . "::seek: cannot seek backwards")
Branch: 1 branch
BranchTrueFalseTotal
if $target < $here 11 27 38
931 if $target < $here ;
932  
933 # Walk the file to the new offset
934 27 my $offset = $target - $here ;
935  
936 27 my $buffer ;
937 27 ▶ defined $self->syswrite("\x00" x $offset)
Branch: 1 branch
BranchTrueFalseTotal
defined $self->syswrite("\0" x $offset) or return 0 0 27 27
938 or return 0;
939  
940 27 return 1 ;
941 }
942  
943 sub binmode
944 {
945 5 ▶ 1;
Subroutine binmode: called CC=1 SCAR=0.0
Pod documented
946 # my $self = shift ;
947 # return defined *$self->{FH}
948 # ? binmode *$self->{FH}
949 # : 1 ;
950 }
951  
952 sub fileno
953 {
954 30 ▶ my $self = shift ;
Subroutine fileno: called CC=2 SCAR=6.9
Pod undocumented
955 return defined *$self->{FH}
956 ? *$self->{FH}->fileno()
957 30 ▶ : undef ;
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{'FH'} ? : 25 5 30
958 }
959  
960 sub opened
961 {
962 10 ▶ my $self = shift ;
Subroutine opened: called CC=1 SCAR=0.0
Pod documented
963 10 return ! *$self->{Closed} ;
964 }
965  
966 sub autoflush
967 {
968 20 ▶ my $self = shift ;
Subroutine autoflush: called CC=2 SCAR=6.9
Pod undocumented
969 return defined *$self->{FH}
970 20 ▶ ? *$self->{FH}->autoflush(@_)
Branch: 1 branch
BranchTrueFalseTotal
defined *$self->{'FH'} ? : 10 10 20
971 : undef ;
972 }
973  
974 sub input_line_number
975 {
976 10 ▶ return undef ;
Subroutine input_line_number: called CC=1 SCAR=0.0
Pod undocumented
977 }
978  
979  
980 sub _notAvailable
981 {
982 690 ▶ my $name = shift ;
Subroutine _notAvailable: called CC=1 SCAR=0.0
983 690 ▶ return sub { Carp::croak "$name Not Available: File opened only for output" ; } ;
Subroutine __ANON__: called CC=1 SCAR=0.0
984 }
985  
986 {
987 115 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
988  
989 115 *read = _notAvailable('read');
990 115 *READ = _notAvailable('read');
991 115 *readline = _notAvailable('readline');
992 115 *READLINE = _notAvailable('readline');
993 115 *getc = _notAvailable('getc');
994 115 *GETC = _notAvailable('getc');
995  
996 115 *FILENO = \&fileno;
997 115 *PRINT = \&print;
998 115 *PRINTF = \&printf;
999 115 *WRITE = \&syswrite;
1000 115 *write = \&syswrite;
1001 115 *SEEK = \&seek;
1002 115 *TELL = \&tell;
1003 115 *EOF = \&eof;
1004 115 *CLOSE = \&close;
1005 115 *BINMODE = \&binmode;
1006 }
1007  
1008 #*sysread = \&_notAvailable;
1009 #*syswrite = \&_write;
1010  
1011 115 1;
1012  
1013 __END__
« blib/lib/IO/Compress/Zlib/Extra.pm ↑ Summary blib/lib/File/GlobMapper.pm »