Branch Coverage

blib/lib/Tie/File/Indexed.pm
Criterion Covered Total %
branch 143 284 50.3


line true false branch
51 0 17 @_ % 2 == 0 ? :
58 17 0 if defined $tied->{'file'}
79 3 13 if $_[0]{'temp'}
92 0 384 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
95 367 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 65 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
118 0 110 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
126 0 97 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
133 0 0 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
141 0 44 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
143 27 11 fctrunc($flags) ? :
38 6 fcwrite($flags) ? :
0 0 fctrunc($flags) ? :
0 0 fcwrite($flags) ? :
44 0 fcread($flags) ? :
159 0 44 if UNIVERSAL::isa($_[0], 'Tie::File::Indexed')
166 0 44 if (ref $file) { }
172 0 44 unless sysopen $sysfh, $file, $flags, $perms
176 0 44 unless CORE::open my $fh, "$mode&=", fileno $sysfh
177 11 33 if (fcwrite($flags) and not fctrunc($flags))
179 0 11 unless seek $fh, 0, 2
205 8 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
206 8 0 ref $_[0] ? :
208 0 8 if $opts{'json'}
214 8 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
216 0 8 ref $file ? :
217 0 8 unless $fh
221 8 0 unless ref $file
230 30 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
233 0 30 if $opts{'json'}
239 18 0 UNIVERSAL::isa($_[0], 'Tie::File::Indexed') ? :
242 0 18 ref $file ? :
243 0 18 unless $fh
245 0 18 unless $fh->print($that->saveJsonString($data, @_))
246 0 18 unless CORE::close $fh
18 0 unless (ref $file)
257 0 0 unless $tied->opened
259 0 0 unless seek $fh, 0, 0
270 0 0 wantarray ? :
277 0 0 unless $tied->opened
279 0 0 unless seek $fh, 0, 0
302 0 106 unless read($_[0]{'datfh'}, my $buf, $_[1]) == $_[1]
316 0 133 unless not defined $_[1] or seek $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'}, 0
317 0 133 unless read($_[0]{'idxfh'}, my $buf, $_[0]{'len_ix'}) == $_[0]{'len_ix'}
327 0 75 unless not defined $_[1] or seek $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'}, 0
328 0 75 unless $_[0]{'idxfh'}->print(pack($_[0]{'pack_ix'}, $_[2], $_[3]))
349 2 2 if ($shift > 0) { }
351 0 2 unless seek $tied->{'idxfh'}, $bstart + $bn, 0
353 0 2 $bn > $bsize ? :
354 0 2 unless seek $idxfh, -$blen, 1
355 0 2 unless read($idxfh, $buf, $blen) == $blen
356 0 2 unless seek $idxfh, $bshift - $blen, 1
357 0 2 unless $idxfh->print($buf)
358 0 2 unless seek $idxfh, -$bshift, 1
363 0 2 unless seek $tied->{'idxfh'}, $bstart, 0
365 0 2 $bn > $bsize ? :
366 0 2 unless read($idxfh, $buf, $blen) == $blen
367 0 2 unless seek $idxfh, $bshift - $blen, 1
368 0 2 unless $idxfh->print($buf)
369 0 2 unless seek $idxfh, -$bshift, 1
404 8 0 if defined $tied->{'file'}
405 0 8 unless defined $hfile
406 0 8 unless my $hdata = $tied->loadJsonFile($hfile, %opts)
418 18 0 if defined $tied->{'file'}
419 0 18 unless defined $hfile
434 0 21 if $tied->opened
438 8 13 if (fcread($mode) and not fctrunc($mode))
439 0 8 unless not -e "$file.hdr" and fccreat($mode) or $tied->loadHeader
445 0 21 unless $tied->{'idxfh'} = fcopen("$file.idx", $mode, $tied->{'perms'})
447 0 21 unless $tied->{'datfh'} = fcopen("$file", $mode, $tied->{'perms'})
464 11 20 unless $tied->opened
465 18 2 if ($tied->opened and fcwrite($tied->{'mode'}))
466 0 18 unless $tied->saveHeader
502 5 0 if ($rc and UNIVERSAL::can($tied->{'idxfh'}, 'flush') and UNIVERSAL::can($tied, 'flush')) { }
510 5 0 $rc ? :
524 1 10 unless defined $file
526 0 30 unless CORE::unlink "$file$_"
539 0 1 unless $tied->opened and fcwrite($flags) and $tied->close
541 0 3 unless CORE::rename "$oldfile$_", "$newfile$_"
554 0 2 unless $src->opened and $src->flush
555 1 1 unless ref $dst
556 0 0 unless $dst->opened or $dst->open($opts{'file'}, 'rw')
559 0 4 unless seek $src->{$_}, 0, 0
560 0 4 unless seek $dst->{$_}, 0, 0
561 0 4 unless File::Copy::copy($src->{$_}, $dst->{$_})
574 0 1 unless $tied->opened and fcwrite($flags) and $tied->close
576 0 3 unless File::Copy::move("$oldfile$_", "$newfile$_")
597 0 1 unless my $tmpfh = fcopen($tmpfile, $tied->{'mode'}, $tied->{'perms'})
604 0 1 unless seek $idxfh, 0, 0
605 0 1 unless seek $tmpfh, 0, 0
607 0 3 unless read($idxfh, $buf, $len_ix) == $len_ix
611 0 3 unless seek $idxfh, $i * $len_ix, 0
612 0 3 unless $idxfh->print(pack($pack_ix, tell $tmpfh, $len))
615 0 3 if $len == 0
616 0 3 unless seek $datfh, $off, 0
617 0 3 unless read($datfh, $buf, $len) == $len
618 0 3 unless $tmpfh->print($buf)
622 0 1 unless CORE::close $tmpfh
624 0 1 unless CORE::close $datfh
631 0 1 unless CORE::unlink $file
634 0 1 unless File::Copy::move($tmpfile, $file)
639 0 1 unless $tied->{'datfh'} = fcopen("$file", fcflags($tied->{'mode'}) & 18446744073709551103, $tied->{'perms'})
653 0 0 unless $tied->opened
681 0 288 unless $_[0]{'idxfh'}
684 0 288 unless seek $_[0]{'idxfh'}, 0, 2
692 0 131 if $_[1] >= $_[0]->size
695 0 131 unless my($off, $len) = $_[0]->readIndex($_[1])
698 0 131 unless seek $_[0]{'datfh'}, $off, 0
706 0 74 unless seek $_[0]{'datfh'}, 0, 2
708 0 74 unless $_[0]->writeData($_[2])
712 0 74 unless $_[0]->writeIndex($_[1], $off0, $off1 - $off0)
723 0 0 if ($_[1] < $oldsize) { }
0 0 elsif ($_[1] > $oldsize) { }
725 0 0 unless truncate $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'}
728 0 0 unless seek $_[0]{'idxfh'}, $_[1] * $_[0]{'len_ix'} - 1, 0
750 0 10 unless truncate $_[0]{'idxfh'}, 0
751 0 10 unless truncate $_[0]{'datfh'}, 0
759 0 1 unless seek $tied->{'datfh'}, 0, 2
760 0 1 unless seek $tied->{'idxfh'}, 0, 2
764 0 1 unless $tied->writeData($_)
768 0 1 unless $tied->writeIndex(undef, $off0, $off1 - $off0)
771 1 0 if defined wantarray
777 0 1 unless my $size = $_[0]->size
780 0 1 unless my($off, $len) = $_[0]->readIndex($size - 1)
781 0 1 unless truncate $_[0]{'idxfh'}, ($size - 1) * $_[0]{'len_ix'}
784 0 1 unless seek $_[0]{'datfh'}, $off, 0
788 1 0 if $off + $len == -s $_[0]{'datfh'}
796 0 1 unless my($off, $len) = $_[0]->readIndex(0)
802 0 1 if $off + $len == -s $_[0]{'datfh'}
811 4 0 @_ ? :
812 0 4 if $off < 0
813 4 0 @_ ? :
814 0 4 if $len < 0
818 3 1 if (wantarray) { }
1 0 elsif ($len > 0) { }
828 4 0 if $shift != 0
836 2 2 if $shift < 0
839 3 1 wantarray ? :