line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Du::Analyze::Filter; |
2
|
|
|
|
|
|
|
$App::Du::Analyze::Filter::VERSION = '0.2.2'; |
3
|
2
|
|
|
2
|
|
124591
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1538
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub _my_all |
7
|
|
|
|
|
|
|
{ |
8
|
315
|
|
|
315
|
|
513
|
my $cb = shift; |
9
|
|
|
|
|
|
|
|
10
|
315
|
|
|
|
|
542
|
foreach my $x (@_) |
11
|
|
|
|
|
|
|
{ |
12
|
306
|
100
|
|
|
|
566
|
if ( not $cb->( local $_ = $x ) ) |
13
|
|
|
|
|
|
|
{ |
14
|
162
|
|
|
|
|
1072
|
return 0; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
153
|
|
|
|
|
428
|
return 1; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new |
22
|
|
|
|
|
|
|
{ |
23
|
18
|
|
|
18
|
1
|
5447
|
my $class = shift; |
24
|
|
|
|
|
|
|
|
25
|
18
|
|
|
|
|
42
|
my $self = bless {}, $class; |
26
|
|
|
|
|
|
|
|
27
|
18
|
|
|
|
|
60
|
$self->_init(@_); |
28
|
|
|
|
|
|
|
|
29
|
18
|
|
|
|
|
56
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _depth |
33
|
|
|
|
|
|
|
{ |
34
|
36
|
|
|
36
|
|
55
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
36
|
100
|
|
|
|
77
|
if (@_) |
37
|
|
|
|
|
|
|
{ |
38
|
18
|
|
|
|
|
35
|
$self->{_depth} = shift; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
36
|
|
|
|
|
56
|
return $self->{_depth}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _prefix |
45
|
|
|
|
|
|
|
{ |
46
|
36
|
|
|
36
|
|
53
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
36
|
100
|
|
|
|
87
|
if (@_) |
49
|
|
|
|
|
|
|
{ |
50
|
18
|
|
|
|
|
45
|
$self->{_prefix} = shift; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
36
|
|
|
|
|
74
|
return $self->{_prefix}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _should_sort |
57
|
|
|
|
|
|
|
{ |
58
|
48
|
|
|
48
|
|
98
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
48
|
100
|
|
|
|
95
|
if (@_) |
61
|
|
|
|
|
|
|
{ |
62
|
30
|
|
|
|
|
42
|
$self->{_should_sort} = shift; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
48
|
|
|
|
|
135
|
return $self->{_should_sort}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _init |
69
|
|
|
|
|
|
|
{ |
70
|
18
|
|
|
18
|
|
43
|
my ( $self, $args ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
18
|
|
|
|
|
54
|
$self->_prefix( $args->{prefix} ); |
73
|
18
|
|
|
|
|
48
|
$self->_depth( $args->{depth} ); |
74
|
18
|
|
|
|
|
44
|
$self->_should_sort(1); |
75
|
|
|
|
|
|
|
|
76
|
18
|
100
|
|
|
|
47
|
if ( exists( $args->{should_sort} ) ) |
77
|
|
|
|
|
|
|
{ |
78
|
12
|
|
|
|
|
24
|
$self->_should_sort( $args->{should_sort} ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
18
|
|
|
|
|
26
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub filter |
85
|
|
|
|
|
|
|
{ |
86
|
18
|
|
|
18
|
1
|
16580
|
my ( $self, $in_fh, $out_fh ) = @_; |
87
|
|
|
|
|
|
|
|
88
|
18
|
|
|
|
|
38
|
my $prefix = $self->_prefix; |
89
|
18
|
|
|
|
|
39
|
my $sort = $self->_should_sort; |
90
|
18
|
|
|
|
|
37
|
my $depth = $self->_depth; |
91
|
|
|
|
|
|
|
|
92
|
18
|
|
|
|
|
33
|
my $compare_depth = $depth - 1; |
93
|
18
|
|
|
|
|
26
|
my @results; |
94
|
|
|
|
|
|
|
|
95
|
18
|
|
|
|
|
41
|
$prefix =~ s#/+\z##; |
96
|
|
|
|
|
|
|
|
97
|
18
|
|
|
|
|
69
|
my @prefix_to_test = split( m#/#, $prefix ); |
98
|
|
|
|
|
|
|
|
99
|
18
|
|
|
|
|
439
|
while ( my $line = <$in_fh> ) |
100
|
|
|
|
|
|
|
{ |
101
|
6822
|
|
|
|
|
11028
|
chomp($line); |
102
|
6822
|
50
|
|
|
|
40700
|
if ( my ( $size, $total_path, $path ) = |
103
|
|
|
|
|
|
|
$line =~ m#\A(\d+)\t(\.(.*?))\z# ) |
104
|
|
|
|
|
|
|
{ |
105
|
6822
|
|
|
|
|
18960
|
my @path_to_test = split( m#/#, $total_path ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Get rid of the ".". |
108
|
6822
|
|
|
|
|
9540
|
shift(@path_to_test); |
109
|
|
|
|
|
|
|
|
110
|
6822
|
100
|
100
|
|
|
26097
|
if ( |
111
|
|
|
|
|
|
|
( @path_to_test == @prefix_to_test + $depth ) |
112
|
|
|
|
|
|
|
and ( |
113
|
|
|
|
|
|
|
_my_all( |
114
|
306
|
|
|
306
|
|
902
|
sub { $path_to_test[$_] eq $prefix_to_test[$_] }, |
115
|
|
|
|
|
|
|
( 0 .. $#prefix_to_test ) |
116
|
|
|
|
|
|
|
) |
117
|
|
|
|
|
|
|
) |
118
|
|
|
|
|
|
|
) |
119
|
|
|
|
|
|
|
{ |
120
|
153
|
|
|
|
|
492
|
$path =~ s#\A/##; |
121
|
153
|
|
|
|
|
957
|
push @results, [ $path, $size ]; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
18
|
50
|
|
|
|
62
|
if ($sort) |
127
|
|
|
|
|
|
|
{ |
128
|
18
|
|
|
|
|
77
|
@results = ( sort { $a->[1] <=> $b->[1] } @results ); |
|
393
|
|
|
|
|
589
|
|
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
18
|
|
|
|
|
41
|
foreach my $r (@results) |
132
|
|
|
|
|
|
|
{ |
133
|
153
|
|
|
|
|
296
|
print {$out_fh} "$r->[1]\t$r->[0]\n"; |
|
153
|
|
|
|
|
1516
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
18
|
|
|
|
|
119
|
return; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |