… | |
… | |
5 | |
5 | |
6 | use strict; |
6 | use strict; |
7 | use Getopt::Long; |
7 | use Getopt::Long; |
8 | use IO::AIO; |
8 | use IO::AIO; |
9 | |
9 | |
10 | Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order"); |
10 | our $VERSION = $IO::AIO::VERSION; |
11 | |
11 | |
|
|
12 | Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order", "auto_help", "auto_version"); |
|
|
13 | |
12 | my ($opt_silent, $opt_print0, $opt_stat); |
14 | my ($opt_silent, $opt_print0, $opt_stat, $opt_nodirs, $opt_nofiles); |
13 | |
15 | |
14 | GetOptions |
16 | GetOptions |
15 | "quiet|q" => \$opt_silent, |
17 | "quiet|q" => \$opt_silent, |
16 | "print0|0" => \$opt_print0, |
18 | "print0|0" => \$opt_print0, |
17 | "stat|s" => \$opt_stat, |
19 | "stat|s" => \$opt_stat, |
18 | ; |
20 | "dirs|d" => \$opt_nofiles, |
|
|
21 | "files|f" => \$opt_nodirs, |
|
|
22 | or die "Usage: try $0 --help"; |
19 | |
23 | |
20 | @ARGV = "." unless @ARGV; |
24 | @ARGV = "." unless @ARGV; |
21 | |
25 | |
22 | sub printfn { |
26 | sub printfn { |
23 | my ($prefix, $files, $suffix) = @_; |
27 | my ($prefix, $files, $suffix) = @_; |
… | |
… | |
36 | |
40 | |
37 | aioreq_pri -1; |
41 | aioreq_pri -1; |
38 | aio_scandir $path, 8, sub { |
42 | aio_scandir $path, 8, sub { |
39 | my ($dirs, $files) = @_; |
43 | my ($dirs, $files) = @_; |
40 | |
44 | |
41 | printfn "", [$path]; |
45 | printfn "", [$path] unless $opt_nodirs; |
42 | printfn $path, $files; |
46 | printfn $path, $files unless $opt_nofiles; |
43 | |
47 | |
44 | if ($opt_stat) { |
48 | if ($opt_stat) { |
45 | aio_lstat "$path$_" for @$files; |
49 | aio_lstat "$path$_" for @$files; |
46 | } |
50 | } |
47 | |
51 | |