line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cogit::Pack::WithIndex; |
2
|
|
|
|
|
|
|
$Cogit::Pack::WithIndex::VERSION = '0.001001'; |
3
|
4
|
|
|
4
|
|
15
|
use Moo; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
20
|
|
4
|
4
|
|
|
4
|
|
8682
|
use Cogit::PackIndex::Version1; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
115
|
|
5
|
4
|
|
|
4
|
|
1750
|
use Cogit::PackIndex::Version2; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
110
|
|
6
|
4
|
|
|
4
|
|
21
|
use MooX::Types::MooseLike::Base 'InstanceOf'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
209
|
|
7
|
4
|
|
|
4
|
|
17
|
use Path::Class; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
152
|
|
8
|
4
|
|
|
4
|
|
15
|
use Check::ISA; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
28
|
|
9
|
4
|
|
|
4
|
|
1514
|
use namespace::clean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
17
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'Cogit::Pack'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has index_filename => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
coerce => sub { file($_[0]) if !obj($_[0], 'Path::Class::File'); $_[0]; }, |
16
|
|
|
|
|
|
|
#isa => InstanceOf['Path::Class::File'], |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has index => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
isa => InstanceOf['Cogit::PackIndex'], |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILD { |
25
|
2
|
|
|
2
|
0
|
129
|
my $self = shift; |
26
|
2
|
|
|
|
|
13
|
my $index_filename = $self->filename; |
27
|
2
|
|
|
|
|
7
|
$index_filename =~ s/\.pack/.idx/; |
28
|
2
|
|
|
|
|
143
|
$self->index_filename($index_filename); |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
33
|
|
|
24
|
my $index_fh = IO::File->new($index_filename) || confess($!); |
31
|
2
|
|
|
|
|
129
|
$index_fh->binmode(); |
32
|
2
|
|
|
|
|
34
|
$index_fh->read( my $signature, 4 ); |
33
|
2
|
|
|
|
|
44
|
$index_fh->read( my $version, 4 ); |
34
|
2
|
|
|
|
|
18
|
$version = unpack( 'N', $version ); |
35
|
2
|
|
|
|
|
9
|
$index_fh->close; |
36
|
|
|
|
|
|
|
|
37
|
2
|
100
|
|
|
|
23
|
if ( $signature eq "\377tOc" ) { |
38
|
1
|
50
|
|
|
|
4
|
if ( $version == 2 ) { |
39
|
1
|
|
|
|
|
36
|
$self->index( |
40
|
|
|
|
|
|
|
Cogit::PackIndex::Version2->new( |
41
|
|
|
|
|
|
|
filename => $index_filename |
42
|
|
|
|
|
|
|
) |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
0
|
confess("Unknown version"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} else { |
48
|
1
|
|
|
|
|
23
|
$self->index( |
49
|
|
|
|
|
|
|
Cogit::PackIndex::Version1->new( |
50
|
|
|
|
|
|
|
filename => $index_filename |
51
|
|
|
|
|
|
|
) |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_object { |
57
|
48
|
|
|
48
|
0
|
56
|
my ( $self, $want_sha1 ) = @_; |
58
|
48
|
|
|
|
|
681
|
my $offset = $self->index->get_object_offset($want_sha1); |
59
|
48
|
50
|
|
|
|
90
|
return unless $offset; |
60
|
48
|
|
|
|
|
122
|
return $self->unpack_object($offset); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding UTF-8 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Cogit::Pack::WithIndex |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.001001 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <cogit@afoolishmanifesto.com> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Arthur Axel "fREW" Schmidt. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
88
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |