line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DataStore::CAS::FS::Dir; |
2
|
9
|
|
|
9
|
|
1480
|
use 5.008; |
|
9
|
|
|
|
|
20
|
|
3
|
9
|
|
|
9
|
|
29
|
use strict; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
134
|
|
4
|
9
|
|
|
9
|
|
23
|
use warnings; |
|
9
|
|
|
|
|
8
|
|
|
9
|
|
|
|
|
160
|
|
5
|
9
|
|
|
9
|
|
25
|
use Carp; |
|
9
|
|
|
|
|
8
|
|
|
9
|
|
|
|
|
432
|
|
6
|
9
|
|
|
9
|
|
393
|
use Try::Tiny; |
|
9
|
|
|
|
|
1410
|
|
|
9
|
|
|
|
|
3247
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION= '0.010000'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Object representing a directory of file entries, indexed by filename. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
1
|
308
|
sub file { $_[0]{file} } |
14
|
1
|
|
|
1
|
1
|
306
|
sub store { $_[0]{file}->store } |
15
|
97
|
|
|
97
|
1
|
479
|
sub hash { $_[0]{file}->hash } |
16
|
1
|
|
|
1
|
1
|
4
|
sub size { $_[0]{file}->size } |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
1
|
331
|
sub format { $_[0]{format} } |
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
7
|
1
|
998
|
sub metadata { $_[0]{metadata} } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
68
|
|
|
68
|
1
|
30697
|
my $class= shift; |
25
|
68
|
50
|
33
|
|
|
324
|
my %p= (1 == @_ && ref $_[0] eq 'HASH')? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
26
|
68
|
50
|
|
|
|
116
|
defined $p{file} or croak "Attribute 'file' is required"; |
27
|
68
|
50
|
|
|
|
131
|
defined $p{format} or croak "Attribute 'format' is required"; |
28
|
68
|
|
100
|
|
|
120
|
$p{metadata} ||= {}; |
29
|
68
|
|
100
|
|
|
157
|
$p{_entries}= delete $p{entries} || []; |
30
|
68
|
|
|
|
|
308
|
bless \%p, $class; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub iterator { |
35
|
112
|
|
|
112
|
1
|
730
|
my $list= $_[0]{_entries}; |
36
|
112
|
|
|
|
|
133
|
my ($i, $n)= (0, scalar @$list); |
37
|
112
|
100
|
|
372
|
|
472
|
return sub { $i < $n? $list->[$i++] : undef }; |
|
372
|
|
|
|
|
14922
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_entry { |
41
|
203
|
|
|
203
|
1
|
830
|
my ($self, $name, $flags)= @_; |
42
|
|
|
|
|
|
|
return $flags->{case_insensitive}? |
43
|
|
|
|
|
|
|
($self->{_entry_name_map_caseless} ||= do { |
44
|
2
|
|
|
|
|
2
|
my (%lookup, $ent, $iter); |
45
|
2
|
|
|
|
|
3
|
for ($iter= $self->iterator; defined ($ent= $iter->()); ) { |
46
|
1
|
|
|
|
|
24
|
$lookup{uc $ent->name}= $ent |
47
|
|
|
|
|
|
|
} |
48
|
2
|
|
|
|
|
13
|
\%lookup; |
49
|
|
|
|
|
|
|
})->{uc $name} |
50
|
|
|
|
|
|
|
: |
51
|
|
|
|
|
|
|
($self->{_entry_name_map} ||= do { |
52
|
48
|
|
|
|
|
55
|
my (%lookup, $ent, $iter); |
53
|
48
|
|
|
|
|
71
|
for ($iter= $self->iterator; defined ($ent= $iter->()); ) { |
54
|
116
|
|
|
|
|
2196
|
$lookup{$ent->name}= $ent |
55
|
|
|
|
|
|
|
} |
56
|
48
|
|
|
|
|
288
|
\%lookup; |
57
|
203
|
100
|
33
|
|
|
788
|
})->{$name}; |
|
|
|
66
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |