line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# App::GitFind::Entry - Abstract base class representing a file or directory |
2
|
|
|
|
|
|
|
package App::GitFind::Entry; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
332
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
5
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
7
|
1
|
|
|
1
|
|
4
|
use App::GitFind::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
178
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000002'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use parent 'App::GitFind::Class'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Fields. Not all have values. The default stat() returns are provided |
14
|
|
|
|
|
|
|
# for the convenience of subclasses --- override them in any subclass |
15
|
|
|
|
|
|
|
# that does not provide _lstat. |
16
|
1
|
|
|
1
|
|
50
|
use Class::Tiny qw(searchbase); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Read-only lazy accessors |
19
|
|
|
|
|
|
|
use Class::Tiny::Immutable { |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# The lstat() results for this entry. lstat() rather than stat() |
22
|
|
|
|
|
|
|
# because searches treat links as individual entries rather than |
23
|
|
|
|
|
|
|
# as their referents. (TODO global option?) |
24
|
|
|
|
|
|
|
# This is a lazy initializer so we don't stat() if we don't have to. |
25
|
0
|
|
|
|
|
|
_lstat => sub { ... }, |
26
|
|
|
|
|
|
|
# Returns an arrayref of lstat() results. Must be overriden in |
27
|
|
|
|
|
|
|
# subclasses unless the below uses of _lstat are overridden. |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
dev => sub { $_[0]->_lstat->[0] }, # device number of filesystem |
30
|
0
|
|
|
|
|
|
ino => sub { $_[0]->_lstat->[1] }, # inode number |
31
|
0
|
|
|
|
|
|
mode => sub { $_[0]->_lstat->[2] }, # file mode (type and permissions) |
32
|
0
|
|
|
|
|
|
nlink => sub { $_[0]->_lstat->[3] }, # number of (hard) links to the file |
33
|
0
|
|
|
|
|
|
uid => sub { $_[0]->_lstat->[4] }, # numeric user ID of file's owner |
34
|
0
|
|
|
|
|
|
gid => sub { $_[0]->_lstat->[5] }, # numeric group ID of file's owner |
35
|
0
|
|
|
|
|
|
rdev => sub { $_[0]->_lstat->[6] }, # the device identifier (special files only) |
36
|
0
|
|
|
|
|
|
size => sub { $_[0]->_lstat->[7] }, # total size of file, in bytes |
37
|
0
|
|
|
|
|
|
atime => sub { $_[0]->_lstat->[8] }, # last access time in seconds since the epoch |
38
|
0
|
|
|
|
|
|
mtime => sub { $_[0]->_lstat->[9] }, # last modify time in seconds since the epoch |
39
|
0
|
|
|
|
|
|
ctime => sub { $_[0]->_lstat->[10] }, # inode change time in seconds since the epoch (*) |
40
|
0
|
|
|
|
|
|
blksize => sub { $_[0]->_lstat->[11] }, # preferred I/O size in bytes for interacting with the file (may vary from file to file) |
41
|
0
|
|
|
|
|
|
blocks => sub { $_[0]->_lstat->[12] }, # actual number of system-specific blocks allocated |
42
|
1
|
|
|
1
|
|
885
|
}; |
|
1
|
|
|
|
|
595
|
|
|
1
|
|
|
|
|
22
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Docs {{{1 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
App::GitFind::Entry - Abstract base class representing a file or directory |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This represents a single file or directory being checked against an expression. |
53
|
|
|
|
|
|
|
Concrete subclasses implement various types of entries. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 MEMBERS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 searchbase |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Required L<Path::Class::Dir>. Results will be reported relative to this |
60
|
|
|
|
|
|
|
directory. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# }}}1 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 isdir |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Truthy if it's a directory; falsy otherwise. |
71
|
|
|
|
|
|
|
Must be overriden by subclasses. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
sub isdir { ... } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 name |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Basename of this entry. |
80
|
|
|
|
|
|
|
Must be overriden by subclasses. |
81
|
|
|
|
|
|
|
TODO May be a string or a Path::Class instance? |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
1
|
|
sub name { ... } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 path |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Full path of the entry with respect to L</searchbase>. |
90
|
|
|
|
|
|
|
Must be overriden by subclasses. |
91
|
|
|
|
|
|
|
May be a string or a Path::Class instance? |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
0
|
1
|
|
sub path { ... } |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 prune |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
If this entry represents a directory, mark its children as not to be traversed. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
If this entry represents a file, no effect. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub prune { |
106
|
|
|
|
|
|
|
... |
107
|
0
|
|
|
0
|
1
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 BUILD |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Enforce abstractness, and the requirement to provide a C<searchbase>. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub BUILD { |
116
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
117
|
0
|
0
|
|
|
|
|
croak "Cannot instantiate abstract base class" if ref $self eq __PACKAGE__; |
118
|
|
|
|
|
|
|
|
119
|
0
|
0
|
|
|
|
|
croak "Usage: @{[ref $self]}->new(-searchbase=>...)" |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
unless $self->searchbase; |
121
|
0
|
0
|
|
|
|
|
croak "-searchbase must be a App::GitFind::PathClassMicro::Dir" |
122
|
|
|
|
|
|
|
unless $self->searchbase->DOES('App::GitFind::PathClassMicro::Dir'); |
123
|
|
|
|
|
|
|
} #BUILD() |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |