Cpio/FileHandle_with_pushback.pm

filter: Statementstmt 5.2% 1 / 19 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 4 totaltotal 2.8% 1 / 35 CC 5 SCAR 29.7
CC
5
Cov
4%
read
30.0
new
2.0
pushback
2.0
CRAP 19.5
↑ Summary Cpio.pm »
1 package Archive::Cpio::FileHandle_with_pushback;
2  
3 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
4 0 my ($class, $F) = @_;
5 0 bless { F => $F, already_read => '' }, $class;
6 }
7  
8 0 ▶sub pushback {
Subroutine pushback: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my ($FHwp, $s) = @_;
10  
11 0 $FHwp->{already_read} .= $s;
12 }
13  
14 0 ▶sub read {
Subroutine read: not called CC=5 SCAR=34.0
Pod undocumented
15 0 my ($FHwp, $size) = @_;
16  
17 0 ▶ $size or return;
Branch: 1 branch
BranchTrueFalseTotal
$size or return 0 0 0
18  
19 0 ▶ $size =~ /^\d+$/ or die "bad size $size\n";
Branch: 1 branch
BranchTrueFalseTotal
$size =~ /^\d+$/ or die "bad size $size\n" 0 0 0
20  
21 0 my $tmp = '';
22  
23 0 ▶ if ($FHwp->{already_read}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($FHwp->{"already_read"}) 0 0 0
24 0 $tmp = substr($FHwp->{already_read}, 0, $size);
25 0 substr($FHwp->{already_read}, 0, $size) = '';
26 0 $size -= length($tmp);
27 }
28 0 ▶ read($FHwp->{F}, $tmp, $size, length($tmp)) == $size or die "unexpected end of file while reading (got $tmp)\n";
Branch: 1 branch
BranchTrueFalseTotal
CORE::read($FHwp->{"F"}, $tmp, $size, length $tmp) == $size or die "unexpected end of file while reading (got $tmp)\n" 0 0 0
29 0 $tmp;
30 }
31  
32 0 ▶sub read_ahead {
Subroutine read_ahead: not called CC=1 SCAR=6.9
Pod undocumented
33 0 my ($FHwp, $size) = @_;
34  
35 0 my $s = $FHwp->read($size);
36 0 $FHwp->pushback($s);
37 0 $s;
38 }
39  
40 1 1;
↑ Summary Cpio.pm »