Added setHandler method.
This commit is contained in:
@@ -16,6 +16,7 @@ our @EXPORT = qw(FAILED SUCCESS ABORTED PRUNE);
|
|||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
use Carp;
|
||||||
|
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
@@ -45,29 +46,39 @@ sub new {
|
|||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub setHandler {
|
||||||
|
my ($self,$action,$func) = @_;
|
||||||
|
|
||||||
|
if (ref($func) ne 'CODE') {
|
||||||
|
croak("Second argument must be CODE reference.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{$action} = $func;
|
||||||
|
}
|
||||||
|
|
||||||
sub onBeginWalk {
|
sub onBeginWalk {
|
||||||
my ($self,$func) = @_;
|
my ($self,$func) = @_;
|
||||||
$self->{onBeginWalk} = $func;
|
$self->setHandler(onBeginWalk => $func);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub onLink {
|
sub onLink {
|
||||||
my ($self,$func) = @_;
|
my ($self,$func) = @_;
|
||||||
$self->{onLink} = $func;
|
$self->setHandler(onLink => $func);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub onFile {
|
sub onFile {
|
||||||
my ($self,$func) = @_;
|
my ($self,$func) = @_;
|
||||||
$self->{onFile} = $func;
|
$self->setHandler(onFile => $func);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub onDirEnter {
|
sub onDirEnter {
|
||||||
my ($self,$func) = @_;
|
my ($self,$func) = @_;
|
||||||
$self->{onDirEnter} = $func;
|
$self->setHandler(onDirEnter => $func);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub onDirLeave {
|
sub onDirLeave {
|
||||||
my ($self,$func) = @_;
|
my ($self,$func) = @_;
|
||||||
$self->{onDirLeave} = $func;
|
$self->setHandler(onDirLeave => $func);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub setDepth {
|
sub setDepth {
|
||||||
|
|||||||
Reference in New Issue
Block a user