Branch Coverage

blib/lib/Tie/File/Indexed.pm
Criterion Covered Total %
branch 142 284 50.0


line true false branch
51 0 17 @_ % 2 == 0 ? :
58 17 0 if defined $tied->{'file'}
79 3 13 if $_[0]{'temp'}
92 0 474 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
95 457 17 if $mode =~ /^[0-9]+$/
99 15 2 $fwrite ? :
0 0 $fwrite ? :
17 0 $fread ? :
103 13 4 if $fwrite and not $fappend
110 0 0 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
118 0 80 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
126 0 135 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
134 0 122 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
141 0 0 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
149 0 54 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
151 27 21 fctrunc($flags) ? :
48 6 fcwrite($flags) ? :
0 0 fctrunc($flags) ? :
0 0 fcwrite($flags) ? :
54 0 fcread($flags) ? :
167 0 54 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
174 0 54 if (ref $file) { }
180 0 54 unless sysopen $sysfh, $file, $flags, $perms
184 0 54 unless CORE::open my $fh, "$mode&=", fileno $sysfh
185 21 33 if (fcwrite($flags) and not fctrunc($flags))
187 0 21 unless seek $fh, 0, 2
213 13 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
214 13 0 ref $_[0] ? :
216 0 13 if $opts{'json'}
222 13 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
224 0 13 ref $file ? :
225 0 13 unless $fh
229 13 0 unless ref $file
238 35 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
241 0 35 if $opts{'json'}
247 23 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
250 0 23 ref $file ? :
251 0 23 unless $fh
253 0 23 unless $fh->print($that->saveJsonString($data, @_))
254 0 23 unless CORE::close $fh
23 0 unless (ref $file)
265 0 0 unless $tied->opened
267 0 0 unless seek $fh, 0, 0
278 0 0 wantarray ? :
285 0 0 unless $tied->opened
287 0 0 unless seek $fh, 0, 0
310 0 106 unless read($_[0]{'datfh'}, my $buf, $_[1]) == $_[1]
324 0 133 unless not defined $_[1] or seek $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'}, 0
325 0 133 unless read($_[0]{'idxfh'}, my $buf, $_[0]{'len_ix'}) == $_[0]{'len_ix'}
335 0 75 unless not defined $_[1] or seek $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'}, 0
336 0 75 unless $_[0]{'idxfh'}->print(pack($_[0]{'pack_ix'}, $_[2], $_[3]))
357 2 2 if ($shift > 0) { }
359 0 2 unless seek $tied->{'idxfh'}, $bstart + $bn, 0
361 0 2 $bn > $bsize ? :
362 0 2 unless seek $idxfh, -$blen, 1
363 0 2 unless read($idxfh, $buf, $blen) == $blen
364 0 2 unless seek $idxfh, $bshift - $blen, 1
365 0 2 unless $idxfh->print($buf)
366 0 2 unless seek $idxfh, -$bshift, 1
371 0 2 unless seek $tied->{'idxfh'}, $bstart, 0
373 0 2 $bn > $bsize ? :
374 0 2 unless read($idxfh, $buf, $blen) == $blen
375 0 2 unless seek $idxfh, $bshift - $blen, 1
376 0 2 unless $idxfh->print($buf)
377 0 2 unless seek $idxfh, -$bshift, 1
412 13 0 if defined $tied->{'file'}
413 0 13 unless defined $hfile
414 0 13 unless my $hdata = $tied->loadJsonFile($hfile, %opts)
426 23 0 if defined $tied->{'file'}
427 0 23 unless defined $hfile
442 0 26 if $tied->opened
446 13 13 if (fcread($mode) and not fctrunc($mode))
447 0 13 unless not -e "$file.hdr" and fccreat($mode) or $tied->loadHeader
453 0 26 unless $tied->{'idxfh'} = fcopen("$file.idx", $mode, $tied->{'perms'})
455 0 26 unless $tied->{'datfh'} = fcopen("$file", $mode, $tied->{'perms'})
472 11 25 unless $tied->opened
473 23 2 if ($tied->opened and fcwrite($tied->{'mode'}))
474 0 23 unless $tied->saveHeader
518 5 0 $rc ? :
532 1 10 unless defined $file
534 0 30 unless CORE::unlink "$file$_"
547 0 1 unless $tied->opened and fcwrite($flags) and $tied->close
549 0 3 unless CORE::rename "$oldfile$_", "$newfile$_"
562 0 2 unless $src->opened and $src->flush
563 1 1 unless ref $dst
564 0 0 unless $dst->opened or $dst->open($opts{'file'}, 'rw')
567 0 4 unless seek $src->{$_}, 0, 0
568 0 4 unless seek $dst->{$_}, 0, 0
569 0 4 unless File::Copy::copy($src->{$_}, $dst->{$_})
582 0 1 unless $tied->opened and fcwrite($flags) and $tied->close
584 0 3 unless File::Copy::move("$oldfile$_", "$newfile$_")
605 0 1 unless my $tmpfh = fcopen($tmpfile, $tied->{'mode'}, $tied->{'perms'})
612 0 1 unless seek $idxfh, 0, 0
613 0 1 unless seek $tmpfh, 0, 0
615 0 3 unless read($idxfh, $buf, $len_ix) == $len_ix
619 0 3 unless seek $idxfh, $i * $len_ix, 0
620 0 3 unless $idxfh->print(pack($pack_ix, tell $tmpfh, $len))
623 0 3 if $len == 0
624 0 3 unless seek $datfh, $off, 0
625 0 3 unless read($datfh, $buf, $len) == $len
626 0 3 unless $tmpfh->print($buf)
630 0 1 unless CORE::close $tmpfh
632 0 1 unless CORE::close $datfh
639 0 1 unless CORE::unlink $file
642 0 1 unless File::Copy::move($tmpfile, $file)
647 0 1 unless $tied->{'datfh'} = fcopen("$file", fcflags($tied->{'mode'}) & 18446744073709551103, $tied->{'perms'})
661 0 0 unless $tied->opened
689 0 288 unless $_[0]{'idxfh'}
692 0 288 unless seek $_[0]{'idxfh'}, 0, 2
700 0 131 if $_[1] >= $_[0]->size
703 0 131 unless my($off, $len) = $_[0]->readIndex($_[1])
706 0 131 unless seek $_[0]{'datfh'}, $off, 0
714 0 74 unless seek $_[0]{'datfh'}, 0, 2
716 0 74 unless $_[0]->writeData($_[2])
720 0 74 unless $_[0]->writeIndex($_[1], $off0, $off1 - $off0)
731 0 0 if ($_[1] < $oldsize) { }
0 0 elsif ($_[1] > $oldsize) { }
733 0 0 unless truncate $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'}
736 0 0 unless seek $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'} - 1, 0
758 0 10 unless truncate $_[0]{'idxfh'}, 0
759 0 10 unless truncate $_[0]{'datfh'}, 0
767 0 1 unless seek $tied->{'datfh'}, 0, 2
768 0 1 unless seek $tied->{'idxfh'}, 0, 2
772 0 1 unless $tied->writeData($_)
776 0 1 unless $tied->writeIndex(undef, $off0, $off1 - $off0)
779 1 0 if defined wantarray
785 0 1 unless my $size = $_[0]->size
788 0 1 unless my($off, $len) = $_[0]->readIndex($size - 1)
789 0 1 unless truncate $_[0]{'idxfh'}, ($size - 1) * $_[0]{'len_ix'}
792 0 1 unless seek $_[0]{'datfh'}, $off, 0
796 1 0 if $off + $len == -s $_[0]{'datfh'}
804 0 1 unless my($off, $len) = $_[0]->readIndex(0)
810 0 1 if $off + $len == -s $_[0]{'datfh'}
819 4 0 @_ ? :
820 0 4 if $off < 0
821 4 0 @_ ? :
822 0 4 if $len < 0
826 3 1 if (wantarray) { }
1 0 elsif ($len > 0) { }
836 4 0 if $shift != 0
844 2 2 if $shift < 0
847 3 1 wantarray ? :