line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VCS::Lite::Element::Binary; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
5391
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
99
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
11
|
use base qw/VCS::Lite::Element/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
710
|
|
11
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
120
|
|
12
|
2
|
|
|
2
|
|
11
|
use File::Spec::Functions qw/:ALL !path/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
481
|
|
13
|
2
|
|
|
2
|
|
12
|
use Params::Validate qw(:all); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1384
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @CARP_NOT = qw/VCS::Lite::Element/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
1
|
|
|
1
|
1
|
412
|
my $pkg = shift; |
21
|
1
|
|
|
|
|
3
|
my $name = shift; |
22
|
1
|
|
|
|
|
49
|
my %args = validate ( @_, |
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
store => 0, # Handled by SUPER::new |
25
|
|
|
|
|
|
|
verbose => 0, |
26
|
|
|
|
|
|
|
recordsize => { type => SCALAR, default => 128 }, |
27
|
|
|
|
|
|
|
} ); |
28
|
1
|
|
|
|
|
17
|
$pkg->SUPER::new($name,%args); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _slurp_lite { |
32
|
5
|
|
|
5
|
|
1313
|
my $self = shift; |
33
|
5
|
|
|
|
|
10
|
my $name = shift; |
34
|
5
|
|
|
|
|
12
|
my $recsiz = $self->{recordsize}; |
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
|
|
6
|
my $in; |
37
|
|
|
|
|
|
|
|
38
|
5
|
50
|
|
|
|
230
|
open $in,'<',$name or croak "$name: $!"; |
39
|
5
|
|
|
|
|
10
|
binmode $in; |
40
|
5
|
|
|
|
|
7
|
my @fil; |
41
|
|
|
|
|
|
|
my $buff; |
42
|
5
|
|
|
|
|
140
|
while (sysread($in,$buff,$recsiz)) { |
43
|
122
|
|
|
|
|
776
|
push @fil,$buff; |
44
|
|
|
|
|
|
|
} |
45
|
5
|
|
|
|
|
39
|
VCS::Lite->new($name,undef,\@fil); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _contents { |
49
|
7
|
|
|
7
|
|
15
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
13
|
my $recsiz = $self->{recordsize}; |
52
|
7
|
|
|
|
|
25
|
my $bin = $self->{store}->store_path($self->path,'vbin'); |
53
|
7
|
|
|
|
|
98
|
my $cont; |
54
|
7
|
100
|
|
|
|
17
|
if (@_) { |
55
|
2
|
|
|
|
|
4
|
$cont = shift; |
56
|
2
|
|
|
|
|
4
|
my $out; |
57
|
2
|
50
|
|
|
|
185
|
open $out,'>',$bin or croak "$bin: $!"; |
58
|
2
|
|
|
|
|
5
|
binmode $out; |
59
|
2
|
|
|
|
|
6
|
for (@$cont) { |
60
|
101
|
|
|
|
|
181
|
my $str = pack 'n',length $_; |
61
|
101
|
|
|
|
|
1009
|
syswrite($out,$str.$_); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} else { |
64
|
5
|
100
|
|
|
|
136
|
return [] unless -f $bin; |
65
|
3
|
|
|
|
|
5
|
my $in; |
66
|
|
|
|
|
|
|
|
67
|
3
|
50
|
|
|
|
152
|
open $in,'<',$bin or croak "$bin: $!"; |
68
|
3
|
|
|
|
|
8
|
binmode $in; |
69
|
3
|
|
|
|
|
6
|
my @fil; |
70
|
|
|
|
|
|
|
my $buff; |
71
|
3
|
|
|
|
|
25
|
while (sysread($in,$buff,2)) { |
72
|
170
|
|
|
|
|
304
|
my $rsz = unpack 'n',$buff; |
73
|
170
|
|
|
|
|
841
|
sysread($in,$buff,$rsz); |
74
|
170
|
|
|
|
|
1131
|
push @fil,$buff; |
75
|
|
|
|
|
|
|
} |
76
|
3
|
|
|
|
|
46
|
$cont = \@fil; |
77
|
|
|
|
|
|
|
} |
78
|
5
|
|
|
|
|
24
|
$cont; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; #this line is important and will help the module return a true value |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |