line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Cpio::FileHandle_with_pushback; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
sub new { |
4
|
0
|
|
|
0
|
0
|
|
my ($class, $F) = @_; |
5
|
0
|
|
|
|
|
|
bless { F => $F, already_read => '' }, $class; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub pushback { |
9
|
0
|
|
|
0
|
0
|
|
my ($FHwp, $s) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
$FHwp->{already_read} .= $s; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub read { |
15
|
0
|
|
|
0
|
0
|
|
my ($FHwp, $size) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
$size or return; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
$size =~ /^\d+$/ or die "bad size $size\n"; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $tmp = ''; |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
if ($FHwp->{already_read}) { |
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
|
0
|
|
|
|
|
read($FHwp->{F}, $tmp, $size, length($tmp)) == $size or die "unexpected end of file while reading (got $tmp)\n"; |
29
|
0
|
|
|
|
|
|
$tmp; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub read_ahead { |
33
|
0
|
|
|
0
|
0
|
|
my ($FHwp, $size) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $s = $FHwp->read($size); |
36
|
0
|
|
|
|
|
|
$FHwp->pushback($s); |
37
|
0
|
|
|
|
|
|
$s; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |