27 Commits

Author SHA1 Message Date
Jens Luedicke
5685fe8ba2 M: Prepare Version 0.5 release. 2013-03-10 18:14:38 +01:00
Jens Luedicke
0d51c0eae0 M: Fixed example code. 2013-03-10 18:07:01 +01:00
Jens Luedicke
538260b627 M: Check for defined command line argument. 2013-03-10 15:50:35 +01:00
Jens Luedicke
c2ce754d59 M: Minor unit-test tweaks. 2013-03-10 15:47:05 +01:00
Jens Luedicke
ee04ca7e4f M: Added more test-cases. 2013-03-09 21:25:33 +01:00
Jens Luedicke
945f88f45e M: Simplified sanity check. 2013-03-09 21:24:54 +01:00
Jens Luedicke
4cabd19964 M: Simplified initialization of action callbacks. 2013-03-09 21:24:05 +01:00
Jens Luedicke
456b79fb21 M: Replaced two nested if blocks with one. 2013-03-09 21:00:38 +01:00
Jens Luedicke
2b81882f1e M: Changed tabs to spaces. 2013-03-09 20:57:35 +01:00
Jens Luedicke
0a4d5862c2 M: Removed trailing whitespaces. 2013-03-09 20:54:27 +01:00
Jens Luedicke
5d44d60770 M: Renamed variable. 2013-03-09 20:38:40 +01:00
Jens Luedicke
ada7ad784b M: Improved and extended unit tests. 2013-03-09 16:27:02 +01:00
Jens Luedicke
42b1a13c62 M: Added entryList() method. 2013-03-09 16:27:02 +01:00
Jens Luedicke
0a3f85d5bf M: Renamed filesInDir() to count(). 2013-03-09 16:27:02 +01:00
Jens Luedicke
ff77f66d82 M: Added currentDepth() method.
The getDepth() method will return the default (or user-specified) directory traversel depth. Calling the setDepth method with a negative value will make the method die.
2013-03-09 16:27:02 +01:00
Jens Luedicke
7c0e8dfa92 M: Added Changelog information for version 0.5 2013-03-09 16:27:01 +01:00
Jens Luedicke
0db45b9ba8 M: Added note about GitHub to module documentation. 2013-03-09 16:27:01 +01:00
Jens Luedicke
e5fbd64b9c M: Extended unit test. 2013-03-09 16:27:01 +01:00
Jens Luedicke
1c890bec84 M: Added sanity check for $action argument of setHandler method. 2013-03-09 16:27:01 +01:00
Jens Luedicke
6b24a7950b M: Increased version number. 2013-03-09 16:27:01 +01:00
Jens Luedicke
b4c59e4fbd M: Copyright 2013. 2013-03-09 16:04:39 +01:00
Jens Luedicke
3da39eae0a M: Removed META.yml and MYMETA.yml from version control. 2013-03-09 15:50:53 +01:00
Jens Luedicke
dd9f7469f9 B: Add Build.PL script to MANIFEST file. 2013-03-09 15:50:36 +01:00
Jens Luedicke
7b3a6c2570 B: Do not try to walk /bin directory, as this may not work on Non-Unix systems. 2013-03-09 15:49:22 +01:00
Jens Luedicke
9f8defb0fe B: Increment directory depth count before calling onDirEnter handler. 2013-03-09 15:49:14 +01:00
Jens Luedicke
97f876d629 B: Require Test::More and Test::Exception (for unit tests). 2013-03-09 15:49:01 +01:00
Jens Luedicke
98266e1cd0 B: Avoid problem with operator precedence. 2013-03-09 15:48:36 +01:00
63 changed files with 431 additions and 250 deletions

5
Build.PL Normal file → Executable file
View File

@@ -10,11 +10,8 @@ Module::Build->new( module_name => 'File::DirWalk',
'Carp' => '1.08',
'File::Spec' => '3.2501',
'File::Basename' => '2.76',
},
recommends => {
'Test::More' => '0.72',
'Test::Exception' => '0.27'
},
sign => 1,
create_makefile_pl => 'traditional',
sign => 1
)->create_build_script;

View File

@@ -1,8 +1,65 @@
Build.PL
lib/File/DirWalk.pm
examples/find-perl-binary.pl
examples/ls.pl
SIGNATURE
MANIFEST
META.yml
MANIFEST.SKIP
README
Copying.txt
Artistic.txt
t/1.t
Makefile.PL
t/2.t
t/3.t
t/4.t
t/tree/dir1/file0
t/tree/dir1/file1
t/tree/dir1/file2
t/tree/dir1/file3
t/tree/dir1/file4
t/tree/dir1/file5
t/tree/dir1/file6
t/tree/dir1/file7
t/tree/dir1/file8
t/tree/dir1/file9
t/tree/dir2/file0
t/tree/dir2/file1
t/tree/dir2/file2
t/tree/dir2/file3
t/tree/dir2/file4
t/tree/dir2/file5
t/tree/dir2/file6
t/tree/dir2/file7
t/tree/dir2/file8
t/tree/dir2/file9
t/tree/dir3/file0
t/tree/dir3/file1
t/tree/dir3/file2
t/tree/dir3/file3
t/tree/dir3/file4
t/tree/dir3/file5
t/tree/dir3/file6
t/tree/dir3/file7
t/tree/dir3/file8
t/tree/dir3/file9
t/tree/dir4/file0
t/tree/dir4/file1
t/tree/dir4/file2
t/tree/dir4/file3
t/tree/dir4/file4
t/tree/dir4/file5
t/tree/dir4/file6
t/tree/dir4/file7
t/tree/dir4/file8
t/tree/dir4/file9
t/tree/dir5/file0
t/tree/dir5/file1
t/tree/dir5/file2
t/tree/dir5/file3
t/tree/dir5/file4
t/tree/dir5/file5
t/tree/dir5/file6
t/tree/dir5/file7
t/tree/dir5/file8
t/tree/dir5/file9
META.yml

View File

@@ -1 +1,6 @@
^MYMETA.yml$
.git
.DS_Store
Build
_build
blib

View File

@@ -1,26 +0,0 @@
---
abstract: "walk through a directory tree and run callbacks\non files, symlinks and directories."
author:
- 'Jens Luedicke E<lt>jensl@cpan.orgE<gt>'
configure_requires:
Module::Build: 0.36
generated_by: 'Module::Build version 0.3603'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: File-DirWalk
provides:
File::DirWalk:
file: lib/File/DirWalk.pm
version: 0.4
recommends:
Test::Exception: 0.27
Test::More: 0.72
requires:
Carp: 1.08
File::Basename: 2.76
File::Spec: 3.2501
resources:
license: http://dev.perl.org/licenses/
version: 0.4

View File

@@ -1,12 +0,0 @@
---
configure_requires:
Module::Build: 0.36
dynamic_config: 0
generated_by: 'Module::Build version 0.3603'
recommends:
Test::Exception: 0.27
Test::More: 0.72
requires:
Carp: 1.08
File::Basename: 2.76
File::Spec: 3.2501

8
README
View File

@@ -1,6 +1,6 @@
Copyright (c) 2005-2012 Jens Luedicke <jensl@cpan.org>.
Copyright (c) 2005-2013 Jens Luedicke <jensl@cpan.org>.
File-DirWalk version 0.4
File-DirWalk version 0.5
=========================
File::DirWalk is a Perl module to walk through a directory tree
@@ -19,10 +19,12 @@ DEPENDENCIES
This module requires these other modules which can be obtained from
the CPAN <http://cpan.org> if they are not allready installed on
your system :
your system:
File::Basename
File::Spec
Test::More
Test::Exception
LICENCE INFORMATION

View File

@@ -3,7 +3,6 @@
use strict;
use warnings;
use File::Basename;
use File::DirWalk;
my $dw = new File::DirWalk();
@@ -11,21 +10,20 @@ my $dw = new File::DirWalk();
$dw->onDirEnter(sub {
my ($path) = @_;
print "$path\n";
if (basename($path) =~ /sbin|lib|share|local|include|libexec|X11/) {
if ($dw->currentBasename() =~ /sbin|lib|share|local|include|libexec|X11/) {
return PRUNE;
}
return SUCCESS;
});
my $found = "";
$dw->onFile(sub {
my ($path) = @_;
print "$path\n";
if (basename($path) eq "perl") {
if ($dw->currentBasename() eq "perl") {
$found = $path;
return ABORTED;
}
@@ -33,3 +31,5 @@ $dw->onFile(sub {
});
$dw->walk("/usr");
print "perl is in $found\n";

View File

@@ -31,9 +31,10 @@ $dw->onDirLeave(sub {
return SUCCESS;
});
if (-e $ARGV[0]) {
$dw->walk($ARGV[0]);
} else {
my $cwd = getcwd();
$dw->walk($cwd);
my $path = cwd();
if ((defined $ARGV[0]) and (-e $ARGV[0])) {
$path = $ARGV[0];
}
$dw->walk($path);

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2005-2012 Jens Luedicke <jensl@cpan.org>.
# Copyright (c) 2005-2013 Jens Luedicke <jensl@cpan.org>.
#
# This module is free software; you can redistribute it and/or modify
# it under the same terms as Perl 5.10.0. For more details, see the
@@ -11,7 +11,7 @@
package File::DirWalk;
use base qw(Exporter);
our $VERSION = '0.4';
our $VERSION = '0.5';
our @EXPORT = qw(FAILED SUCCESS ABORTED PRUNE);
use warnings;
@@ -19,163 +19,181 @@ use strict;
use Carp;
use File::Basename;
use File::Spec;
use File::Spec::Functions qw(no_upwards splitdir catfile);
use constant SUCCESS => 1;
use constant FAILED => 0;
use constant ABORTED => -1;
use constant PRUNE => -10;
use constant SUCCESS => 1;
use constant FAILED => 0;
use constant ABORTED => -1;
use constant PRUNE => -10;
sub new {
my ($class) = @_;
my $self = bless {}, $class;
my ($class) = @_;
my $self = bless {}, $class;
$self->{onBeginWalk} = sub { SUCCESS };
$self->{onLink} = sub { SUCCESS };
$self->{onFile} = sub { SUCCESS };
$self->{onDirEnter} = sub { SUCCESS };
$self->{onDirLeave} = sub { SUCCESS };
foreach my $action (qw/onBeginWalk onLink onFile onDirEnter onDirLeave/) {
$self->{$action} = sub { SUCCESS };
}
$self->{depth} = 0;
$self->{depth_count} = 0;
$self->{depth} = 0;
$self->{currentDepth} = 0;
$self->{filesInDir} = 0;
$self->{entryList} = [];
$self->{count} = 0;
# $self->{customResponse} = {};
return $self;
return $self;
}
sub setHandler {
my ($self,$action,$func) = @_;
my ($self,$action,$func) = @_;
if (ref($func) ne 'CODE') {
croak("Second argument must be CODE reference.");
}
if (not exists $self->{$action}) {
croak("Invalid action argument: $action");
}
if (ref($func) ne 'CODE') {
croak("Second argument must be CODE reference.");
}
$self->{$action} = $func;
}
sub onBeginWalk {
my ($self,$func) = @_;
$self->setHandler(onBeginWalk => $func);
my ($self,$func) = @_;
$self->setHandler(onBeginWalk => $func);
}
sub onLink {
my ($self,$func) = @_;
$self->setHandler(onLink => $func);
my ($self,$func) = @_;
$self->setHandler(onLink => $func);
}
sub onFile {
my ($self,$func) = @_;
$self->setHandler(onFile => $func);
my ($self,$func) = @_;
$self->setHandler(onFile => $func);
}
sub onDirEnter {
my ($self,$func) = @_;
$self->setHandler(onDirEnter => $func);
my ($self,$func) = @_;
$self->setHandler(onDirEnter => $func);
}
sub onDirLeave {
my ($self,$func) = @_;
$self->setHandler(onDirLeave => $func);
my ($self,$func) = @_;
$self->setHandler(onDirLeave => $func);
}
sub setDepth {
my ($self,$v) = @_;
$self->{depth} = $v;
my ($self,$v) = @_;
if ($v < 0) {
croak("Directory depth is negative: $v");
}
$self->{depth} = $v;
}
sub getDepth {
my ($self) = @_;
return $self->{depth_count};
my ($self) = @_;
return $self->{depth};
}
sub currentDepth {
my ($self) = @_;
return $self->{currentDepth};
}
sub currentDir {
my ($self) = @_;
return $self->{currentDir};
my ($self) = @_;
return $self->{currentDir};
}
sub currentPath {
my ($self) = @_;
return $self->{currentPath};
my ($self) = @_;
return $self->{currentPath};
}
sub currentBasename {
my ($self) = @_;
return $self->{currentBasename};
my ($self) = @_;
return $self->{currentBasename};
}
sub filesInDir {
my ($self) = @_;
return $self->{filesInDir};
sub count {
my ($self) = @_;
return $self->{count};
}
sub entryList {
my ($self) = @_;
return $self->{entryList};
}
sub walk {
my ($self,$path) = @_;
my ($self,$path) = @_;
$self->{currentDir} = dirname($path);
$self->{currentBasename} = basename($path);
$self->{currentPath} = $path;
my $currentDir = dirname($path);
my $currentBasename = basename($path);
my $currentPath = $path;
if ((my $r = $self->{onBeginWalk}->($path)) != SUCCESS) {
return $r;
}
$self->{currentDir} = $currentDir;
$self->{currentBasename} = $currentBasename;
$self->{currentPath} = $path;
if (-l $path) {
if ((my $r = $self->{onBeginWalk}->($path)) != SUCCESS) {
return $r;
}
if ((my $r = $self->{onLink}->($path)) != SUCCESS) {
return $r;
}
if (-l $path) {
} elsif (-d $path) {
if ((my $r = $self->{onLink}->($path)) != SUCCESS) {
return $r;
}
if ($self->{depth} != 0) {
if ($self->{depth_count} == $self->{depth}) {
return SUCCESS;
}
}
} elsif (-d $path) {
opendir my $dirh, $path || return FAILED;
my @dir_contents = readdir $dirh;
@dir_contents = File::Spec->no_upwards(@dir_contents);
if (($self->{depth} > 0) and ($self->{currentDepth} == $self->{depth})) {
return SUCCESS;
}
$self->{filesInDir} = scalar @dir_contents;
opendir (my $dirh, $path) || return FAILED;
$self->{entryList} = [ no_upwards(readdir $dirh) ];
$self->{count} = scalar @{$self->{entryList}};
if ((my $r = $self->{onDirEnter}->($path)) != SUCCESS) {
return $r;
}
++$self->{depth_count};
++$self->{currentDepth};
if ((my $r = $self->{onDirEnter}->($path)) != SUCCESS) {
return $r;
}
# be portable.
my @dirs = File::Spec->splitdir($path);
# be portable.
my @dirs = splitdir($path);
foreach my $f (@{$self->{entryList}}) {
# be portable.
my $path = catfile(@dirs, $f);
foreach my $f (@dir_contents) {
# be portable.
my $path = File::Spec->catfile(@dirs, $f);
my $r = $self->walk($path);
my $r = $self->walk($path);
if ($r == PRUNE) {
next;
} elsif ($r != SUCCESS) {
return $r;
}
}
if ($r == PRUNE) {
next;
} elsif ($r != SUCCESS) {
return $r;
}
}
closedir $dirh;
closedir $dirh;
$self->{currentDir} = $currentDir;
$self->{currentBasename} = $currentBasename;
$self->{currentPath} = $path;
if ((my $r = $self->{onDirLeave}->($path)) != SUCCESS) {
return $r;
}
--$self->{depth_count};
} else {
if ((my $r = $self->{onFile}->($path)) != SUCCESS) {
return $r;
}
}
if ((my $r = $self->{onDirLeave}->($path)) != SUCCESS) {
return $r;
}
--$self->{currentDepth};
} else {
if ((my $r = $self->{onFile}->($path)) != SUCCESS) {
return $r;
}
}
return SUCCESS;
return SUCCESS;
}
1;
@@ -264,10 +282,16 @@ Specify a function to be run when leaving a directory.
Set the directory traversal depth. Once the specified directory depth
has been reached, the C<walk> method returns. The default value is 0.
Precondition: The value has to be positive. The method will die
if called with a negative value.
=item getDepth
Returns the directory traversal depth.
Returns the user-specified directory traversal depth. The default value is 0.
=item currentDepth
Returns the current directory traversal depth.
=item currentDir
@@ -309,9 +333,14 @@ Returns the current base name of the current path:
return SUCCESS;
});
=item filesInDir
=item count
Returns the number of files wthin the current directory.
Returns the number of elements wthin the current directory.
Excludes . and ..
=item entryList
Returns an array reference to the elements wthin the current directory.
Excludes . and ..
=item walk($path)
@@ -321,15 +350,15 @@ is finished or if one of the callbacks doesn't return SUCCESS. If the callback f
returns PRUNE, C<walk> will skip to the next element within the current directory
hierarchy. You can use PRUNE to exclude files or folders:
$dw->onBeginWalk(sub {
my ($path) = @_;
$dw->onBeginWalk(sub {
my ($path) = @_;
if ($path =~ /ignore/) {
return PRUNE;
}
if ($path =~ /ignore/) {
return PRUNE;
}
return SUCCESS;
});
return SUCCESS;
});
=back
@@ -358,12 +387,15 @@ as return values:
=back
=head1 BUGS
=head1 DEVELOPMENT
Please mail the author if you encounter any bugs.
Please mail the author if you encounter any bugs. The most recent development
version can be found on GitHub: L<https://github.com/nullmedium/File-DirWalk>
=head1 CHANGES
Version 0.5: bugfixes, improved testing, new currentDepth() method.
Version 0.4: add more methods, better testing, more documentation.
Version 0.3: add PRUNE constant. add option to specify the directory depth.
@@ -384,7 +416,7 @@ Jens Luedicke E<lt>jensl@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENCE
Copyright (c) 2005-2012 Jens Luedicke <jensl@cpan.org>.
Copyright (c) 2005-2013 Jens Luedicke <jensl@cpan.org>.
This module is free software; you can redistribute it and/or modify
it under the same terms as Perl 5.10.0. For more details, see the

107
t/1.t
View File

@@ -1,84 +1,37 @@
use Test::More qw(no_plan);
use Test::More tests => 29;
use Test::Exception;
use File::Basename;
use File::DirWalk;
my $perl_path = dirname($^X);
my $perl_interpreter = basename($^X);
BEGIN { use_ok( 'File::DirWalk' ); }
require_ok( 'File::DirWalk' );
$dw = new File::DirWalk();
is(ref($dw), 'File::DirWalk' );
ok( ref($dw) eq 'File::DirWalk' );
is ($dw->getDepth(), 0);
dies_ok { $dw->setDepth(-1) };
is ($dw->getDepth(), 0);
ok ($dw->setDepth(1));
is ($dw->getDepth(), 1);
dies_ok { $dw->setHandler(Foo => 0); }
ok ($dw->onBeginWalk(sub {}));
ok ($dw->onLink(sub {}));
ok ($dw->onFile(sub {}));
ok ($dw->onDirEnter(sub {}));
ok ($dw->onDirLeave(sub {}));
dies_ok {$dw->onBeginWalk(0)};
dies_ok {$dw->onLink(0)};
dies_ok {$dw->onFile(0)};
dies_ok {$dw->onDirEnter(0)};
dies_ok {$dw->onDirLeave(0)};
$dw->onFile(sub {
my ($path) = @_;
if (basename($path) eq "1.t") {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk($0) == ABORTED );
$dw->onDirEnter(sub {
my ($path) = @_;
if ($path eq $perl_path) {
return FAILED;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == FAILED );
$dw->onBeginWalk(sub {
my ($path) = @_;
if (dirname($path) eq $dw->currentDir) {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == ABORTED );
$dw->onBeginWalk(sub {
my ($path) = @_;
if ($path eq $dw->currentPath) {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == ABORTED );
$dw->onFile(sub {
my ($path) = @_;
if (basename($path) eq $perl_interpreter) {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == ABORTED );
$dw->onFile(sub {
my ($path) = @_;
if (basename($path) eq "sh") {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk("/bin") == ABORTED );
ok ($dw->setHandler(onBeginWalk => sub {}));
ok ($dw->setHandler(onLink => sub {}));
ok ($dw->setHandler(onFile => sub {}));
ok ($dw->setHandler(onDirEnter => sub {}));
ok ($dw->setHandler(onDirLeave => sub {}));
dies_ok {$dw->setHandler(onBeginWalk => 0)};
dies_ok {$dw->setHandler(onLink => 0)};
dies_ok {$dw->setHandler(onFile => 0)};
dies_ok {$dw->setHandler(onDirEnter => 0)};
dies_ok {$dw->setHandler(onDirLeave => 0)};
dies_ok {$dw->setHandler(Foo => sub {})};

29
t/2.t Normal file
View File

@@ -0,0 +1,29 @@
use Test::More qw(no_plan);
use Test::Exception;
use File::Basename;
BEGIN { use_ok( 'File::DirWalk' ); }
require_ok( 'File::DirWalk' );
ok(-e "t/");
ok(-d "t/");
foreach my $f qw(1.t 2.t 3.t 4.t) {
$dw = new File::DirWalk();
$dw->setDepth(1);
$dw->onFile(sub {
my ($path) = @_;
ok(-e $path);
ok(-f $path);
if ($dw->currentBasename() eq $f) {
return 42;
}
return SUCCESS;
});
is($dw->walk("t/"), 42);
}

55
t/3.t Normal file
View File

@@ -0,0 +1,55 @@
use Test::More qw(no_plan);
use Test::Exception;
use File::Basename;
BEGIN { use_ok( 'File::DirWalk' ); }
require_ok( 'File::DirWalk' );
my $perl_path = dirname($^X);
my $perl_interpreter = basename($^X);
$dw = new File::DirWalk();
$dw->onDirEnter(sub {
my ($path) = @_;
ok(-e $path);
ok(-d $path);
if ($dw->currentPath() eq $perl_path) {
return 42;
}
return SUCCESS;
});
is( $dw->walk($perl_path), 42 );
$dw = new File::DirWalk();
$dw->onDirEnter(sub {
my ($path) = @_;
ok(-e $path);
ok(-d $path);
if ($dw->currentDir() eq $perl_path) {
return 42;
}
return SUCCESS;
});
is( $dw->walk($perl_path), 42 );
$dw = new File::DirWalk();
$dw->onFile(sub {
my ($path) = @_;
ok(-e $path);
ok(-f $path);
if ($dw->currentBasename() eq $perl_interpreter) {
return 42;
}
return SUCCESS;
});
is( $dw->walk($perl_path), 42 );

88
t/4.t Normal file
View File

@@ -0,0 +1,88 @@
use Test::More qw(no_plan);
use Test::Exception;
use File::Basename;
use File::Spec::Functions;
BEGIN { use_ok( 'File::DirWalk' ); }
require_ok( 'File::DirWalk' );
$dw = new File::DirWalk();
ok( -e "t/tree" );
ok( -d "t/tree" );
foreach my $subdir (qw(dir1 dir2 dir3 dir4 dir5)) {
ok( -e "t/tree/$subdir" );
ok( -d "t/tree/$subdir" );
$dw = new File::DirWalk();
$dw->onBeginWalk(sub {
my ($path) = @_;
ok(-e $path);
if ($dw->currentBasename() eq $subdir) {
return 42;
}
return SUCCESS;
});
is( $dw->walk("t/tree"), 42 );
$dw = new File::DirWalk();
$dw->onDirEnter(sub {
my ($path) = @_;
ok(-e $path);
ok(-d $path);
if ($dw->currentBasename() eq $subdir) {
is( $dw->count(), 10 );
is( $dw->currentDepth(), 2 );
return 42;
}
return SUCCESS;
});
is( $dw->walk("t/tree"), 42 );
$dw = new File::DirWalk();
$dw->onDirLeave(sub {
my ($path) = @_;
ok(-e $path);
ok(-d $path);
if ($dw->currentBasename() eq $subdir) {
is( $dw->count(), 10 );
is( $dw->currentDepth(), 2 );
return 42;
}
return SUCCESS;
});
is( $dw->walk("t/tree"), 42 );
$dw = new File::DirWalk();
$dw->onFile(sub {
my ($path) = @_;
ok(-e $path);
ok(-f $path);
return SUCCESS;
});
is( $dw->walk("t/tree/$subdir"), SUCCESS );
is( $dw->count(), 10 );
}
$files = 0;
$dw = new File::DirWalk();
$dw->onFile(sub {
my ($path) = @_;
ok(-e $path);
ok(-f $path);
++$files;
return SUCCESS;
});
is( $dw->walk("t/tree"), SUCCESS );
is( $files, 50 );

0
t/tree/dir1/file0 Normal file
View File

0
t/tree/dir1/file1 Normal file
View File

0
t/tree/dir1/file2 Normal file
View File

0
t/tree/dir1/file3 Normal file
View File

0
t/tree/dir1/file4 Normal file
View File

0
t/tree/dir1/file5 Normal file
View File

0
t/tree/dir1/file6 Normal file
View File

0
t/tree/dir1/file7 Normal file
View File

0
t/tree/dir1/file8 Normal file
View File

0
t/tree/dir1/file9 Normal file
View File

0
t/tree/dir2/file0 Normal file
View File

0
t/tree/dir2/file1 Normal file
View File

0
t/tree/dir2/file2 Normal file
View File

0
t/tree/dir2/file3 Normal file
View File

0
t/tree/dir2/file4 Normal file
View File

0
t/tree/dir2/file5 Normal file
View File

0
t/tree/dir2/file6 Normal file
View File

0
t/tree/dir2/file7 Normal file
View File

0
t/tree/dir2/file8 Normal file
View File

0
t/tree/dir2/file9 Normal file
View File

0
t/tree/dir3/file0 Normal file
View File

0
t/tree/dir3/file1 Normal file
View File

0
t/tree/dir3/file2 Normal file
View File

0
t/tree/dir3/file3 Normal file
View File

0
t/tree/dir3/file4 Normal file
View File

0
t/tree/dir3/file5 Normal file
View File

0
t/tree/dir3/file6 Normal file
View File

0
t/tree/dir3/file7 Normal file
View File

0
t/tree/dir3/file8 Normal file
View File

0
t/tree/dir3/file9 Normal file
View File

0
t/tree/dir4/file0 Normal file
View File

0
t/tree/dir4/file1 Normal file
View File

0
t/tree/dir4/file2 Normal file
View File

0
t/tree/dir4/file3 Normal file
View File

0
t/tree/dir4/file4 Normal file
View File

0
t/tree/dir4/file5 Normal file
View File

0
t/tree/dir4/file6 Normal file
View File

0
t/tree/dir4/file7 Normal file
View File

0
t/tree/dir4/file8 Normal file
View File

0
t/tree/dir4/file9 Normal file
View File

0
t/tree/dir5/file0 Normal file
View File

0
t/tree/dir5/file1 Normal file
View File

0
t/tree/dir5/file2 Normal file
View File

0
t/tree/dir5/file3 Normal file
View File

0
t/tree/dir5/file4 Normal file
View File

0
t/tree/dir5/file5 Normal file
View File

0
t/tree/dir5/file6 Normal file
View File

0
t/tree/dir5/file7 Normal file
View File

0
t/tree/dir5/file8 Normal file
View File

0
t/tree/dir5/file9 Normal file
View File