B: Increment directory depth count before calling onDirEnter handler.
This commit is contained in:
@@ -37,7 +37,7 @@ sub new {
|
|||||||
$self->{onDirLeave} = sub { SUCCESS };
|
$self->{onDirLeave} = sub { SUCCESS };
|
||||||
|
|
||||||
$self->{depth} = 0;
|
$self->{depth} = 0;
|
||||||
$self->{depth_count} = 0;
|
$self->{depthCount} = 0;
|
||||||
|
|
||||||
$self->{filesInDir} = 0;
|
$self->{filesInDir} = 0;
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ sub setDepth {
|
|||||||
|
|
||||||
sub getDepth {
|
sub getDepth {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
return $self->{depth_count};
|
return $self->{depthCount};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub currentDir {
|
sub currentDir {
|
||||||
@@ -131,7 +131,7 @@ sub walk {
|
|||||||
} elsif (-d $path) {
|
} elsif (-d $path) {
|
||||||
|
|
||||||
if ($self->{depth} != 0) {
|
if ($self->{depth} != 0) {
|
||||||
if ($self->{depth_count} == $self->{depth}) {
|
if ($self->{depthCount} == $self->{depth}) {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,11 +141,11 @@ sub walk {
|
|||||||
@dir_contents = File::Spec->no_upwards(@dir_contents);
|
@dir_contents = File::Spec->no_upwards(@dir_contents);
|
||||||
|
|
||||||
$self->{filesInDir} = scalar @dir_contents;
|
$self->{filesInDir} = scalar @dir_contents;
|
||||||
|
++$self->{depthCount};
|
||||||
|
|
||||||
if ((my $r = $self->{onDirEnter}->($path)) != SUCCESS) {
|
if ((my $r = $self->{onDirEnter}->($path)) != SUCCESS) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
++$self->{depth_count};
|
|
||||||
|
|
||||||
# be portable.
|
# be portable.
|
||||||
my @dirs = File::Spec->splitdir($path);
|
my @dirs = File::Spec->splitdir($path);
|
||||||
@@ -168,7 +168,7 @@ sub walk {
|
|||||||
if ((my $r = $self->{onDirLeave}->($path)) != SUCCESS) {
|
if ((my $r = $self->{onDirLeave}->($path)) != SUCCESS) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
--$self->{depth_count};
|
--$self->{depthCount};
|
||||||
} else {
|
} else {
|
||||||
if ((my $r = $self->{onFile}->($path)) != SUCCESS) {
|
if ((my $r = $self->{onFile}->($path)) != SUCCESS) {
|
||||||
return $r;
|
return $r;
|
||||||
|
|||||||
Reference in New Issue
Block a user