-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnuke_non_highlightable_files.perl
executable file
·51 lines (37 loc) · 1.3 KB
/
nuke_non_highlightable_files.perl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl -w
# We end up with some files in our directory of things that we want to
# highlight that actually cause a bunch of trouble when we hightlight them
# (stupid double links due to multiple possible definitions, etc.), so we
# use this script to get rid of them. These mostly come from the Arduino
# libs which we often having lying around during adaptation.
use strict;
@ARGV == 1 or die "wrong number of arguments";
my $xld = $ARGV[0]; # xlinked sources dir
my @nuke_pats = ( '[A-Z]',
'binary\.h',
'wiring.*\.[ch]',
'new\.h',
'pins_arduino\.h',
'sd_card_info\.h' );
chdir($xld) or die "cd to '$xld' failed: $!";
opendir(XLD, ".") or die;
sub matches_a_nuke_pattern
{
# Remove file named arg2 if it matches any of the (anchored) pattens in
# the array referenced by arg2.
@_ == 2 or die "wrong number of arguments";
my ($file, $nps) = @_; # File, nuke patterns
foreach ( @{$nps} ) {
if ( $file =~ m/^$_/ ) {
return 1;
}
}
return 0;
}
while ( my $cf = readdir(XLD) ) {
if ( matches_a_nuke_pattern($cf, \@nuke_pats) ) {
unlink($cf) == 1 or die "unlink failed on '$cf': $!";
}
}
closedir(XLD) or die "close failed on '$xld': $!";
exit 0;