blib/lib/IO/Compress/Base.pm

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