ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/bin/treescan
Revision: 1.1
Committed: Mon Sep 10 11:24:20 2007 UTC (16 years, 8 months ago) by root
Branch: MAIN
CVS Tags: rel-2_6, rel-2_5, rel-2_51, rel-2_41
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/opt/bin/perl
2
3 # inspired by treescan by Jamie Lokier <jamie@imbolc.ucc.ie>
4 # about 40% faster than the original version (on my fs and raid :)
5
6 use Getopt::Long;
7 use IO::AIO;
8
9 Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order");
10
11 my ($opt_silent, $opt_print0, $opt_stat);
12
13 GetOptions
14 "quiet|q" => \$opt_silent,
15 "print0|0" => \$opt_print0,
16 "stat|s" => \$opt_stat,
17 ;
18
19 @ARGV = "." unless @ARGV;
20
21 sub printfn {
22 my ($path, $files, $suffix) = @_;
23
24 if ($opt_print0) {
25 print map "$path/$_$suffix\0", @$files;
26 } elsif (!$opt_silent) {
27 print map "$path/$_$suffix\n", @$files;
28 }
29 }
30
31 sub scan {
32 my ($path) = @_;
33
34 aio_scandir $path, 8, sub {
35 my ($dirs, $files) = @_;
36
37 if ($opt_stat) {
38 aio_stat "$path/$_" for @$files;
39 }
40
41 for (@$dirs) {
42 printfn $path, $dirs, "/";
43 &scan ("$path/$_")
44 }
45
46 printfn $path, $files;
47 };
48 }
49
50 IO::AIO::max_outstanding 64;
51 IO::AIO::min_parallel 32;
52
53 for my $seed (@ARGV) {
54 $seed =~ s/\/+$//;
55 aio_lstat "$seed/.", sub {
56 scan $seed if -d _;
57 };
58 }
59
60 IO::AIO::flush;
61