ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/bin/treescan
(Generate patch)

Comparing IO-AIO/bin/treescan (file contents):
Revision 1.3 by root, Sun Jun 7 22:28:05 2009 UTC vs.
Revision 1.6 by root, Tue Sep 27 01:43:03 2011 UTC

9 9
10our $VERSION = $IO::AIO::VERSION; 10our $VERSION = $IO::AIO::VERSION;
11 11
12Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order", "auto_help", "auto_version"); 12Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order", "auto_help", "auto_version");
13 13
14my ($opt_silent, $opt_print0, $opt_stat, $opt_nodirs, $opt_nofiles); 14my ($opt_silent, $opt_print0, $opt_stat, $opt_nodirs, $opt_nofiles, $opt_grep);
15 15
16GetOptions 16GetOptions
17 "quiet|q" => \$opt_silent, 17 "quiet|q" => \$opt_silent,
18 "print0|0" => \$opt_print0, 18 "print0|0" => \$opt_print0,
19 "stat|s" => \$opt_stat, 19 "stat|s" => \$opt_stat,
20 "dirs|d" => \$opt_nofiles, 20 "dirs|d" => \$opt_nofiles,
21 "files|f" => \$opt_nodirs, 21 "files|f" => \$opt_nodirs,
22 "grep|g=s" => \$opt_grep,
22 or die "Usage: try $0 --help"; 23 or die "Usage: try $0 --help";
23 24
24@ARGV = "." unless @ARGV; 25@ARGV = "." unless @ARGV;
25 26
27$opt_grep &&= qr{$opt_grep}s;
28
26sub printfn { 29sub printfn {
27 my ($prefix, $files, $suffix) = @_; 30 my ($prefix, $files, $suffix) = @_;
28 31
32 if ($opt_grep) {
33 @$files = grep "$prefix$_" =~ $opt_grep, @$files;
34 }
35
29 if ($opt_print0) { 36 if ($opt_print0) {
30 print map "$prefix$_$suffix\0", @$files; 37 print map "$prefix$_$suffix\0", @$files;
31 } elsif (!$opt_silent) { 38 } elsif (!$opt_silent) {
32 print map "$prefix$_$suffix\n", @$files; 39 print map "$prefix$_$suffix\n", @$files;
33 } 40 }
44 51
45 printfn "", [$path] unless $opt_nodirs; 52 printfn "", [$path] unless $opt_nodirs;
46 printfn $path, $files unless $opt_nofiles; 53 printfn $path, $files unless $opt_nofiles;
47 54
48 if ($opt_stat) { 55 if ($opt_stat) {
56 aio_wd $path, sub {
57 my $wd = shift;
58
49 aio_lstat "$path$_" for @$files; 59 aio_lstat [$wd, $_] for @$files;
60 };
50 } 61 }
51 62
52 &scan ("$path$_") for @$dirs; 63 &scan ("$path$_") for @$dirs;
53 }; 64 };
54} 65}
57IO::AIO::min_parallel 32; 68IO::AIO::min_parallel 32;
58 69
59for my $seed (@ARGV) { 70for my $seed (@ARGV) {
60 $seed =~ s/\/+$//; 71 $seed =~ s/\/+$//;
61 aio_lstat "$seed/.", sub { 72 aio_lstat "$seed/.", sub {
73 if ($_[0]) {
74 print STDERR "$seed: $!\n";
62 if (-d _) { 75 } elsif (-d _) {
63 scan $seed; 76 scan $seed;
64 } else { 77 } else {
65 printfn "", $seed, "/"; 78 printfn "", $seed, "/";
66 } 79 }
67 }; 80 };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines