From 9f8defb0febbe574a9aed0c50034a28ac809d5ea Mon Sep 17 00:00:00 2001 From: Jens Luedicke Date: Sat, 9 Mar 2013 11:48:36 +0100 Subject: [PATCH] B: Increment directory depth count before calling onDirEnter handler. --- lib/File/DirWalk.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/File/DirWalk.pm b/lib/File/DirWalk.pm index 5836255..239f90c 100644 --- a/lib/File/DirWalk.pm +++ b/lib/File/DirWalk.pm @@ -37,7 +37,7 @@ sub new { $self->{onDirLeave} = sub { SUCCESS }; $self->{depth} = 0; - $self->{depth_count} = 0; + $self->{depthCount} = 0; $self->{filesInDir} = 0; @@ -88,7 +88,7 @@ sub setDepth { sub getDepth { my ($self) = @_; - return $self->{depth_count}; + return $self->{depthCount}; } sub currentDir { @@ -131,7 +131,7 @@ sub walk { } elsif (-d $path) { if ($self->{depth} != 0) { - if ($self->{depth_count} == $self->{depth}) { + if ($self->{depthCount} == $self->{depth}) { return SUCCESS; } } @@ -141,11 +141,11 @@ sub walk { @dir_contents = File::Spec->no_upwards(@dir_contents); $self->{filesInDir} = scalar @dir_contents; + ++$self->{depthCount}; if ((my $r = $self->{onDirEnter}->($path)) != SUCCESS) { return $r; } - ++$self->{depth_count}; # be portable. my @dirs = File::Spec->splitdir($path); @@ -168,7 +168,7 @@ sub walk { if ((my $r = $self->{onDirLeave}->($path)) != SUCCESS) { return $r; } - --$self->{depth_count}; + --$self->{depthCount}; } else { if ((my $r = $self->{onFile}->($path)) != SUCCESS) { return $r;