line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Find::Parallel; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
125910
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
99
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
95
|
|
5
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
231
|
|
6
|
3
|
|
|
3
|
|
17
|
use File::Spec; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1923
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.52'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
5
|
|
|
5
|
1
|
10877
|
my $class = shift; |
12
|
5
|
|
33
|
|
|
48
|
my $self = bless { dirs => [], }, ref $class || $class; |
13
|
5
|
|
|
|
|
17
|
$self->add_dirs( @_ ); |
14
|
5
|
|
|
|
|
33
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub set_dirs { |
18
|
2
|
|
|
2
|
1
|
707
|
my $self = shift; |
19
|
2
|
|
|
|
|
8
|
$self->{dirs} = [@_]; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub get_dirs { |
23
|
16
|
|
|
16
|
1
|
26
|
my $self = shift; |
24
|
16
|
|
|
|
|
19
|
return @{ $self->{dirs} }; |
|
16
|
|
|
|
|
57
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub add_dirs { |
28
|
12
|
|
|
12
|
1
|
7837
|
my $self = shift; |
29
|
12
|
|
|
|
|
18
|
push @{ $self->{dirs} }, @_; |
|
12
|
|
|
|
|
44
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub want_iterator { |
33
|
8
|
|
|
8
|
1
|
12
|
my $self = shift; |
34
|
8
|
|
100
|
|
|
27
|
my $threshold = shift || 1; |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
18
|
my @dirs = $self->get_dirs; |
37
|
8
|
100
|
|
|
|
32
|
my @work = @dirs ? ( '.' ) : (); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Return an empty iterator if asked for more instances of an object |
40
|
|
|
|
|
|
|
# than we could ever have. |
41
|
2
|
|
|
2
|
|
984
|
return sub { return } |
42
|
8
|
100
|
|
|
|
33
|
if $threshold > @dirs; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return sub { |
45
|
74
|
100
|
|
74
|
|
399
|
return unless @work; |
46
|
68
|
|
|
|
|
215
|
my $rel = File::Spec->canonpath( shift @work ); |
47
|
68
|
|
|
|
|
110
|
my %got = (); |
48
|
68
|
|
|
|
|
98
|
for my $base ( @dirs ) { |
49
|
144
|
|
|
|
|
763
|
my $abs = File::Spec->catdir( $base, $rel ); |
50
|
144
|
100
|
|
|
|
2844
|
if ( -d $abs ) { |
51
|
65
|
50
|
|
|
|
6803
|
if ( opendir my $dh, $abs ) { |
52
|
65
|
|
|
|
|
956
|
$got{$_}++ for grep { $_ !~ /^[.][.]?$/ } readdir $dh; |
|
251
|
|
|
|
|
1471
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
0
|
|
|
|
|
0
|
carp "Can't read $abs ($!)"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
62
|
|
|
|
|
390
|
push @work, map { File::Spec->catdir( $rel, $_ ) } |
|
71
|
|
|
|
|
157
|
|
60
|
68
|
|
|
|
|
151
|
sort grep { $got{$_} >= $threshold } keys %got; |
61
|
68
|
|
|
|
|
249
|
return $rel; |
62
|
6
|
|
|
|
|
44
|
}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub all_iterator { |
66
|
4
|
|
|
4
|
1
|
3665
|
my $self = shift; |
67
|
4
|
|
|
|
|
13
|
return $self->want_iterator( scalar $self->get_dirs ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub any_iterator { |
71
|
4
|
|
|
4
|
1
|
3410
|
my $self = shift; |
72
|
4
|
|
|
|
|
13
|
return $self->want_iterator( 1 ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |