line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cogit::PackIndex; |
2
|
|
|
|
|
|
|
$Cogit::PackIndex::VERSION = '0.001001'; |
3
|
4
|
|
|
4
|
|
1642
|
use Moo; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
19
|
|
4
|
4
|
|
|
4
|
|
6984
|
use Path::Class 'file'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
396
|
|
5
|
4
|
|
|
4
|
|
17
|
use Check::ISA; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
31
|
|
6
|
4
|
|
|
4
|
|
1500
|
use IO::File; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
469
|
|
7
|
4
|
|
|
4
|
|
16
|
use MooX::Types::MooseLike::Base qw( InstanceOf ArrayRef Str Int ); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
176
|
|
8
|
4
|
|
|
4
|
|
14
|
use namespace::clean; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
22
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has filename => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => InstanceOf['Path::Class::File'], |
13
|
|
|
|
|
|
|
coerce => sub { file($_[0]) }, |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has fh => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => InstanceOf['IO::File'], |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has offsets => ( |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
isa => ArrayRef[Int], |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has size => ( |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
isa => Int, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $FanOutCount = 256; |
33
|
|
|
|
|
|
|
my $SHA1Size = 20; |
34
|
|
|
|
|
|
|
my $IdxOffsetSize = 4; |
35
|
|
|
|
|
|
|
my $OffsetSize = 4; |
36
|
|
|
|
|
|
|
my $CrcSize = 4; |
37
|
|
|
|
|
|
|
my $OffsetStart = $FanOutCount * $IdxOffsetSize; |
38
|
|
|
|
|
|
|
my $SHA1Start = $OffsetStart + $OffsetSize; |
39
|
|
|
|
|
|
|
my $EntrySize = $OffsetSize + $SHA1Size; |
40
|
|
|
|
|
|
|
my $EntrySizeV2 = $SHA1Size + $CrcSize + $OffsetSize; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub BUILD { |
43
|
2
|
|
|
2
|
0
|
301
|
my $self = shift; |
44
|
2
|
|
|
|
|
14
|
my $filename = $self->filename; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
33
|
|
|
13
|
my $fh = IO::File->new($filename) || confess($!); |
47
|
2
|
|
|
|
|
244
|
$self->fh($fh); |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
130
|
my @offsets = (0); |
50
|
2
|
|
|
|
|
11
|
$fh->seek( $self->global_offset, 0 ); |
51
|
2
|
|
|
|
|
20
|
for my $i ( 0 .. $FanOutCount - 1 ) { |
52
|
512
|
|
|
|
|
664
|
$fh->read( my $data, $IdxOffsetSize ); |
53
|
512
|
|
|
|
|
1492
|
my $offset = unpack( 'N', $data ); |
54
|
512
|
50
|
|
|
|
663
|
confess("pack has discontinuous index") if $offset < $offsets[-1]; |
55
|
512
|
|
|
|
|
482
|
push @offsets, $offset; |
56
|
|
|
|
|
|
|
} |
57
|
2
|
|
|
|
|
55
|
$self->offsets( \@offsets ); |
58
|
2
|
|
|
|
|
2242
|
$self->size( $offsets[-1] ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Cogit::PackIndex |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.001001 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <cogit@afoolishmanifesto.com> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Arthur Axel "fREW" Schmidt. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |