line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Filter::Library::FileSystem; |
2
|
1
|
|
|
1
|
|
6
|
use base qw( Class::Base ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
129
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
List::Filter::Library::FileSystem - filters for unix file listings |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# This is a plugin, not intended for direct use. |
11
|
|
|
|
|
|
|
# See: List::Filter::Storage::CODE |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
A library of L filters for use on file listings. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
See L for a information |
18
|
|
|
|
|
|
|
about the filters defined here. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
30
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
23
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
24
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
25
|
|
|
|
|
|
|
my $DEBUG = 0; |
26
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
27
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
60
|
|
28
|
1
|
|
|
1
|
|
6
|
use Hash::Util qw(lock_keys unlock_keys); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Instantiates a new List::Filter::Transform::Library::FileSystem object. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Note: |
43
|
|
|
|
|
|
|
# "new" is inherited from Class::Base. |
44
|
|
|
|
|
|
|
# It calls the following "init" routine automatically. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item init |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Initialize object attributes and then lock them down to prevent |
49
|
|
|
|
|
|
|
accidental creation of new ones. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Note: there is no leading underscore on name "init", though it's |
52
|
|
|
|
|
|
|
arguably an "internal" routine (i.e. not likely to be of use to |
53
|
|
|
|
|
|
|
client code). |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub init { |
58
|
4
|
|
|
4
|
1
|
102
|
my $self = shift; |
59
|
4
|
|
|
|
|
6
|
my $args = shift; |
60
|
4
|
|
|
|
|
5
|
unlock_keys( %{ $self } ); |
|
4
|
|
|
|
|
22
|
|
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
45
|
my $lfs = List::Filter::Storage->new( storage => |
63
|
|
|
|
|
|
|
{ format => 'MEM', } ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# define new attributes |
66
|
|
|
|
|
|
|
my $attributes = { |
67
|
4
|
|
33
|
|
|
48
|
storage_handler => $args->{ storage_handler } || $lfs, |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# add attributes to object |
71
|
4
|
|
|
|
|
8
|
my @fields = (keys %{ $attributes }); |
|
4
|
|
|
|
|
14
|
|
72
|
4
|
|
|
|
|
7
|
@{ $self }{ @fields } = @{ $attributes }{ @fields }; # hash slice |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
9
|
|
73
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
6
|
lock_keys( %{ $self } ); |
|
4
|
|
|
|
|
15
|
|
75
|
4
|
|
|
|
|
38
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item define_filters_href |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns a hash reference (keyed by filter name) of filter hash references. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub define_filters_href { |
85
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
178
|
my $filters = |
88
|
|
|
|
|
|
|
{ |
89
|
|
|
|
|
|
|
':jpeg' => |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
'description' => 'Find jpegs, for all common extensions.', |
92
|
|
|
|
|
|
|
'method' => 'find_any', |
93
|
|
|
|
|
|
|
'terms' => |
94
|
|
|
|
|
|
|
[ |
95
|
|
|
|
|
|
|
'\.jpeg$', |
96
|
|
|
|
|
|
|
'\.JPEG$', |
97
|
|
|
|
|
|
|
'\.jpg$', |
98
|
|
|
|
|
|
|
'\.JPG$', |
99
|
|
|
|
|
|
|
], |
100
|
|
|
|
|
|
|
'modifiers' => 'x', |
101
|
|
|
|
|
|
|
}, |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
':web_img' => # |
104
|
|
|
|
|
|
|
{ |
105
|
|
|
|
|
|
|
'description' => 'Find files with common web image format extensions.', |
106
|
|
|
|
|
|
|
'method' => 'find_any', |
107
|
|
|
|
|
|
|
'terms' => |
108
|
|
|
|
|
|
|
[ |
109
|
|
|
|
|
|
|
'\.jpeg$', |
110
|
|
|
|
|
|
|
'\.JPEG$', |
111
|
|
|
|
|
|
|
'\.jpg$', |
112
|
|
|
|
|
|
|
'\.JPG$', |
113
|
|
|
|
|
|
|
'\.gif$', |
114
|
|
|
|
|
|
|
'\.GIF$', |
115
|
|
|
|
|
|
|
'\.png$', |
116
|
|
|
|
|
|
|
'\.PNG$', |
117
|
|
|
|
|
|
|
], |
118
|
|
|
|
|
|
|
'modifiers' => 'x', |
119
|
|
|
|
|
|
|
}, |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
':dired-x-omit' => # |
122
|
|
|
|
|
|
|
{ |
123
|
|
|
|
|
|
|
'description' => 'Filters files like the emacs dired-x omit feature.', |
124
|
|
|
|
|
|
|
'method' => 'skip_any', |
125
|
|
|
|
|
|
|
'terms' => |
126
|
|
|
|
|
|
|
[ |
127
|
|
|
|
|
|
|
'^\.?\#', # need to escape '#' in a //x match |
128
|
|
|
|
|
|
|
'^\.$', |
129
|
|
|
|
|
|
|
'^\.\.$', |
130
|
|
|
|
|
|
|
'CVS/$', |
131
|
|
|
|
|
|
|
'\.o$', |
132
|
|
|
|
|
|
|
'~$', |
133
|
|
|
|
|
|
|
'\.bin$', |
134
|
|
|
|
|
|
|
'\.lbin$', |
135
|
|
|
|
|
|
|
'\.fasl$', |
136
|
|
|
|
|
|
|
'\.ufsl$', |
137
|
|
|
|
|
|
|
'\.a$', |
138
|
|
|
|
|
|
|
'\.ln$', |
139
|
|
|
|
|
|
|
'\.blg$', |
140
|
|
|
|
|
|
|
'\.bbl$', |
141
|
|
|
|
|
|
|
'\.elc$', |
142
|
|
|
|
|
|
|
'\.lof$', |
143
|
|
|
|
|
|
|
'\.glo$', |
144
|
|
|
|
|
|
|
'\.idx$', |
145
|
|
|
|
|
|
|
'\.lot$', |
146
|
|
|
|
|
|
|
'\.dvi$', |
147
|
|
|
|
|
|
|
'\.fmt$', |
148
|
|
|
|
|
|
|
'\.tfm$', |
149
|
|
|
|
|
|
|
'\.pdf$', |
150
|
|
|
|
|
|
|
'\.class$', |
151
|
|
|
|
|
|
|
'\.fas$', |
152
|
|
|
|
|
|
|
'\.lib$', |
153
|
|
|
|
|
|
|
'\.x86f$', |
154
|
|
|
|
|
|
|
'\.sparcf$', |
155
|
|
|
|
|
|
|
'\.lo$', |
156
|
|
|
|
|
|
|
'\.la$', |
157
|
|
|
|
|
|
|
'\.toc$', |
158
|
|
|
|
|
|
|
'\.log$', |
159
|
|
|
|
|
|
|
'\.aux$', |
160
|
|
|
|
|
|
|
'\.cp$', |
161
|
|
|
|
|
|
|
'\.fn$', |
162
|
|
|
|
|
|
|
'\.ky$', |
163
|
|
|
|
|
|
|
'\.pg$', |
164
|
|
|
|
|
|
|
'\.tp$', |
165
|
|
|
|
|
|
|
'\.vr$', |
166
|
|
|
|
|
|
|
'\.cps$', |
167
|
|
|
|
|
|
|
'\.fns$', |
168
|
|
|
|
|
|
|
'\.kys$', |
169
|
|
|
|
|
|
|
'\.pgs$', |
170
|
|
|
|
|
|
|
'\.tps$', |
171
|
|
|
|
|
|
|
'\.vrs$', |
172
|
|
|
|
|
|
|
'\.pyc$', |
173
|
|
|
|
|
|
|
'\.pyo$', |
174
|
|
|
|
|
|
|
'\.idx$', |
175
|
|
|
|
|
|
|
'\.lof$', |
176
|
|
|
|
|
|
|
'\.lot$', |
177
|
|
|
|
|
|
|
'\.glo$', |
178
|
|
|
|
|
|
|
'\.blg$', |
179
|
|
|
|
|
|
|
'\.bbl$', |
180
|
|
|
|
|
|
|
'\.cp$', |
181
|
|
|
|
|
|
|
'\.cps$', |
182
|
|
|
|
|
|
|
'\.fn$', |
183
|
|
|
|
|
|
|
'\.fns$', |
184
|
|
|
|
|
|
|
'\.ky$', |
185
|
|
|
|
|
|
|
'\.kys$', |
186
|
|
|
|
|
|
|
'\.pg$', |
187
|
|
|
|
|
|
|
'\.pgs$', |
188
|
|
|
|
|
|
|
'\.tp$', |
189
|
|
|
|
|
|
|
'\.tps$', |
190
|
|
|
|
|
|
|
'\.vr$', |
191
|
|
|
|
|
|
|
'\.vrs$', |
192
|
|
|
|
|
|
|
], |
193
|
|
|
|
|
|
|
'modifiers' => 'x', |
194
|
|
|
|
|
|
|
}, |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
':doom-omit' => # the way I like my emacs omit feature set-up |
197
|
|
|
|
|
|
|
{ |
198
|
|
|
|
|
|
|
'description' => q, |
199
|
|
|
|
|
|
|
'method' => 'skip_any', |
200
|
|
|
|
|
|
|
'terms' => |
201
|
|
|
|
|
|
|
[ |
202
|
|
|
|
|
|
|
'^\.?\#', |
203
|
|
|
|
|
|
|
'^\.$', |
204
|
|
|
|
|
|
|
'^\.\.$', |
205
|
|
|
|
|
|
|
'CVS', |
206
|
|
|
|
|
|
|
'RCS', |
207
|
|
|
|
|
|
|
'~$', |
208
|
|
|
|
|
|
|
'\.a$', |
209
|
|
|
|
|
|
|
'\.elc$', |
210
|
|
|
|
|
|
|
'\.idx$', |
211
|
|
|
|
|
|
|
'\.dvi$', |
212
|
|
|
|
|
|
|
], |
213
|
|
|
|
|
|
|
'modifiers' => 'x', |
214
|
|
|
|
|
|
|
}, |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
':skipdull' => |
217
|
|
|
|
|
|
|
{ |
218
|
|
|
|
|
|
|
'description' => 'Screen out some uninteresting files.', |
219
|
|
|
|
|
|
|
'method' => 'skip_any', |
220
|
|
|
|
|
|
|
'terms' => |
221
|
|
|
|
|
|
|
[ |
222
|
|
|
|
|
|
|
'~$', # emacs backups |
223
|
|
|
|
|
|
|
'/\#', # emacs autosaves |
224
|
|
|
|
|
|
|
'/\.\#', # emacs symlinks to autosaves |
225
|
|
|
|
|
|
|
',v$', # cvs/rcs repository files |
226
|
|
|
|
|
|
|
'/CVS$', # CVS directories |
227
|
|
|
|
|
|
|
'/CVS/', # files in CVS directories |
228
|
|
|
|
|
|
|
'/RCS$', # RCS directories |
229
|
|
|
|
|
|
|
'\.elc$', # compiled elisp |
230
|
|
|
|
|
|
|
], |
231
|
|
|
|
|
|
|
'modifiers' => 'x', |
232
|
|
|
|
|
|
|
}, |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
':skipdull_not' => |
235
|
|
|
|
|
|
|
{ |
236
|
|
|
|
|
|
|
'description' => 'bogus filter for testing.', |
237
|
|
|
|
|
|
|
'method' => 'skip_any', |
238
|
|
|
|
|
|
|
'terms' => |
239
|
|
|
|
|
|
|
[ |
240
|
|
|
|
|
|
|
'e', |
241
|
|
|
|
|
|
|
], |
242
|
|
|
|
|
|
|
'modifiers' => 'x', |
243
|
|
|
|
|
|
|
}, |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
':c-omit' => # |
246
|
|
|
|
|
|
|
{ |
247
|
|
|
|
|
|
|
'description' => q, |
248
|
|
|
|
|
|
|
'method' => 'skip_any', |
249
|
|
|
|
|
|
|
'terms' => |
250
|
|
|
|
|
|
|
[ |
251
|
|
|
|
|
|
|
'\.o$', # compiled "object" files |
252
|
|
|
|
|
|
|
'~$', # emacs backups |
253
|
|
|
|
|
|
|
'/\#', # emacs autosaves |
254
|
|
|
|
|
|
|
'/\.\#', # emacs symlinks to autosaves |
255
|
|
|
|
|
|
|
',v$', # cvs/rcs repository files |
256
|
|
|
|
|
|
|
'\.elc$', # compiled elisp |
257
|
|
|
|
|
|
|
], |
258
|
|
|
|
|
|
|
'modifiers' => 'x', |
259
|
|
|
|
|
|
|
}, |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
':updatedb_prune' => # |
262
|
|
|
|
|
|
|
{ |
263
|
|
|
|
|
|
|
'description' => q, |
264
|
|
|
|
|
|
|
'method' => 'skip_any', |
265
|
|
|
|
|
|
|
'terms' => |
266
|
|
|
|
|
|
|
[ |
267
|
|
|
|
|
|
|
'^/tmp$', |
268
|
|
|
|
|
|
|
'^/usr/tmp$', |
269
|
|
|
|
|
|
|
'^/var/tmp$', |
270
|
|
|
|
|
|
|
'^/afs$', |
271
|
|
|
|
|
|
|
'^amd$', |
272
|
|
|
|
|
|
|
'^/alex$', |
273
|
|
|
|
|
|
|
'^/var/spool$', |
274
|
|
|
|
|
|
|
'^/sfs$', |
275
|
|
|
|
|
|
|
'^/media$', |
276
|
|
|
|
|
|
|
], |
277
|
|
|
|
|
|
|
'modifiers' => 'x', |
278
|
|
|
|
|
|
|
}, |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
':hide_vc' => # |
281
|
|
|
|
|
|
|
{ |
282
|
|
|
|
|
|
|
'description' => q, |
283
|
|
|
|
|
|
|
'method' => 'skip_any', |
284
|
|
|
|
|
|
|
'terms' => |
285
|
|
|
|
|
|
|
[ |
286
|
|
|
|
|
|
|
',v$', # cvs/rcs repository files |
287
|
|
|
|
|
|
|
'/CVS$', # CVS directories |
288
|
|
|
|
|
|
|
'/CVS/', # files in CVS directories |
289
|
|
|
|
|
|
|
'/RCS$', # RCS directories |
290
|
|
|
|
|
|
|
'/RCS/', # files in RCS directories |
291
|
|
|
|
|
|
|
'/_MTN$', # monotone directories |
292
|
|
|
|
|
|
|
'/_MTN/', # files in monotone directories |
293
|
|
|
|
|
|
|
'/.svn$', # SVN directories |
294
|
|
|
|
|
|
|
'/.svn/', # files in SVN directories |
295
|
|
|
|
|
|
|
'/_darcs$', # darcs directories |
296
|
|
|
|
|
|
|
'/_darcs/', # files in darcs directories |
297
|
|
|
|
|
|
|
'/.git$', # GIT directories |
298
|
|
|
|
|
|
|
'/.git/', # files in GIT directories |
299
|
|
|
|
|
|
|
], |
300
|
|
|
|
|
|
|
'modifiers' => 'x', |
301
|
|
|
|
|
|
|
}, |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
}; |
304
|
4
|
|
|
|
|
16
|
return $filters; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=back |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head2 setters and getters |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=over |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=item storage_handler |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Getter for object attribute storage_handler |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=cut |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
sub storage_handler { |
321
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
322
|
0
|
|
|
|
|
|
my $lfs = $self->{ storage_handler }; |
323
|
0
|
|
|
|
|
|
return $lfs; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=item set_storage_handler |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
Setter for object attribute set_storage_handler |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=cut |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
sub set_storage_handler { |
333
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
334
|
0
|
|
|
|
|
|
my $lfs = shift; |
335
|
0
|
|
|
|
|
|
$self->{ storage_handler } = $lfs; |
336
|
0
|
|
|
|
|
|
return $lfs; |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
1; |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=back |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=head1 SEE ALSO |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
L |
346
|
|
|
|
|
|
|
L |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=head1 AUTHOR |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Joseph Brenner, Edoom@kzsu.stanford.eduE |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
Copyright (C) 2007 by Joseph Brenner |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
357
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
358
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=head1 BUGS |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
None reported... yet. |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=cut |