]> gitweb @ CieloNegro.org - sugar.git/blob - tools/list-files.pl
Initial commit: make lint prints only missing files.
[sugar.git] / tools / list-files.pl
1 use strict;
2 use warnings;
3 use Smart::Comments;
4 use List::MoreUtils qw(any);
5 use File::Spec;
6
7 my @RE_IGNORED = map {
8     s/\./\\./g;
9     s/\+/\\+/g;
10
11     s/\?/.?/g;
12     s/\*/.*?/g;
13
14     qr/^$_$/;
15   }
16   grep {length}
17   map  {tr/\n//d; $_}
18   <DATA>;
19
20 main();
21
22 sub main {
23     my @current = find($ENV{HOME}, '.', sub {$_[0] =~ m/^\./});
24
25     foreach (@current) {
26         print "$_\n";
27     }
28 }
29
30 sub find {
31     my $base = shift;
32     my $dir  = shift || '.';
33     my $sel  = shift || sub {1};
34
35     my $dirpath = File::Spec->catfile($base, $dir);
36     opendir my $dh, $dirpath or die "opendir: $dirpath: $!";
37
38     my @d;
39     while (my $name = readdir $dh) {
40         next if $name =~ /^\.\.?$/;
41         next if !$sel->($name);
42
43         my $abs = File::Spec->rel2abs($name, $dirpath);
44         my $rel = File::Spec->abs2rel($abs, $base);
45
46         next if any { $rel =~ m/$_/ } @RE_IGNORED;
47         next if !-f $abs;
48
49         if (-d $abs) {
50             push @d, find($base, $rel);
51         }
52         else {
53             push @d, $rel;
54         }
55     }
56     @d;
57 }
58
59 __DATA__
60 *~
61 .*cache*
62 .*history*
63 .CFUserTextEncoding
64 .DS_Store
65 .ICEauthority
66 .MacOSX
67 .Trash
68 .Xauthority
69 .cabal
70 .cpan
71 .dbus
72 .dvdcss
73 .easytag
74 .elisp
75 .esd_auth
76 .emacs.d
77 .eshell
78 .firefox
79 .fontconfig*
80 .fonts
81 .gconf*
82 .gimp*
83 .glimpse*
84 .gnome2*
85 .gnucash
86 .gnupg
87 .gstreamer-0.10
88 .htpasswd
89 .ido.last*
90 .jungledisk*
91 .kde
92 .localized
93 .mozilla
94 .mpd
95 .mplayer
96 .nautilus
97 .navi2ch
98 .nh-todo
99 .pan
100 .projects.ede
101 .qt
102 .recently-used*
103 .rnd
104 .s9x
105 .scribus
106 .skk-*
107 .snes*
108 .ssh
109 .thumbnails
110 .tome
111 .trackballs
112 .uim.d
113 .unison
114 .viminfo
115 .w3m
116 .xchat2*
117 .zcomp*
118 .zfunc