| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Ack::Files; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2573
|
use App::Ack (); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
46
|
|
|
4
|
2
|
|
|
2
|
|
19
|
use App::Ack::File (); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
39
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use File::Next 1.16 (); |
|
|
2
|
|
|
|
|
42
|
|
|
|
2
|
|
|
|
|
48
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
50
|
|
|
9
|
2
|
|
|
2
|
|
9
|
use strict; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
56
|
|
|
10
|
2
|
|
|
2
|
|
30
|
use 5.010; |
|
|
2
|
|
|
|
|
6
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
App::Ack::Files |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
A factory object for creating a stream of L objects. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 from_argv( \%opt, \@starting_points ) |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Return an iterator that does the file finding for us. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub from_argv { |
|
29
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
30
|
0
|
|
|
|
|
|
my $opt = shift; |
|
31
|
0
|
|
|
|
|
|
my $start = shift; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $descend_filter = $opt->{descend_filter}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ( $opt->{n} ) { |
|
38
|
|
|
|
|
|
|
$descend_filter = sub { |
|
39
|
0
|
|
|
0
|
|
|
return 0; |
|
40
|
0
|
|
|
|
|
|
}; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->{iter} = |
|
44
|
|
|
|
|
|
|
File::Next::files( { |
|
45
|
|
|
|
|
|
|
file_filter => $opt->{file_filter}, |
|
46
|
|
|
|
|
|
|
descend_filter => $descend_filter, |
|
47
|
|
|
|
|
|
|
error_handler => _generate_error_handler(), |
|
48
|
|
|
|
0
|
|
|
warning_handler => sub {}, |
|
49
|
|
|
|
|
|
|
sort_files => $opt->{sort_files}, |
|
50
|
|
|
|
|
|
|
follow_symlinks => $opt->{follow}, |
|
51
|
0
|
|
|
|
|
|
}, @{$start} ); |
|
|
0
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $self; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 from_file( \%opt, $filename ) |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Return an iterator that reads the list of files to search from a |
|
59
|
|
|
|
|
|
|
given file. If I<$filename> is '-', then it reads from STDIN. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub from_file { |
|
64
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
65
|
0
|
|
|
|
|
|
my $opt = shift; |
|
66
|
0
|
|
|
|
|
|
my $file = shift; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $error_handler = _generate_error_handler(); |
|
69
|
|
|
|
|
|
|
my $iter = |
|
70
|
|
|
|
|
|
|
File::Next::from_file( { |
|
71
|
|
|
|
|
|
|
error_handler => $error_handler, |
|
72
|
|
|
|
|
|
|
warning_handler => $error_handler, |
|
73
|
|
|
|
|
|
|
sort_files => $opt->{sort_files}, |
|
74
|
0
|
0
|
|
|
|
|
}, $file ) or return undef; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return bless { |
|
77
|
|
|
|
|
|
|
iter => $iter, |
|
78
|
|
|
|
|
|
|
}, $class; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 from_stdin() |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is for reading input lines from STDIN, not the list of files |
|
85
|
|
|
|
|
|
|
from STDIN. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub from_stdin { |
|
91
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$self->{iter} = sub { |
|
96
|
0
|
|
|
0
|
|
|
state $has_been_called = 0; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
if ( !$has_been_called ) { |
|
99
|
0
|
|
|
|
|
|
$has_been_called = 1; |
|
100
|
0
|
|
|
|
|
|
return '-'; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
0
|
|
|
|
|
|
return; |
|
103
|
0
|
|
|
|
|
|
}; |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return $self; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub next { |
|
110
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $file = $self->{iter}->(); |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
|
return unless defined($file); |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return App::Ack::File->new( $file ); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _generate_error_handler { |
|
121
|
0
|
0
|
|
0
|
|
|
if ( $App::Ack::report_bad_filenames ) { |
|
122
|
|
|
|
|
|
|
return sub { |
|
123
|
0
|
|
|
0
|
|
|
my $msg = shift; |
|
124
|
0
|
|
|
|
|
|
App::Ack::warn( $msg ); |
|
125
|
0
|
|
|
|
|
|
}; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
else { |
|
128
|
0
|
|
|
0
|
|
|
return sub {}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |