AnyEvent::Filesys::Notify::Event - Object to report changes in the monitored filesystem


AnyEvent-Filesys-Notify documentation Contained in the AnyEvent-Filesys-Notify distribution.

Index


Code Index:

NAME

Top

AnyEvent::Filesys::Notify::Event - Object to report changes in the monitored filesystem

SYNOPSIS

Top

    use AnyEvent::Filesys::Notify;

    my $notifier = AnyEvent::Filesys::Notify->new(
        dir      => [ qw( this_dir that_dir ) ],
        interval => 2.0,    # Optional depending on underlying watcher
        cb       => sub {
            my (@events) = @_;

            for my $event (@events){
                process_created_file($event->path)  if $event->is_created;
                process_modified_file($event->path) if $event->is_modified;
                process_deleted_file($event->path)  if $event->is_deleted;
            }
        },
    );

DESCRIPTION

Top

Simple object to encapsulate information about the filesystem modifications.

METHODS

Top

path()

    my $modified_file = $event->path();

Returns the path to the modified file. This is the path as given by the user, ie not modified by abs_path.

type()

    my $modificaiton_type = $event->type();

Returns the type of change made to the file or directory. Will be one of created, modified, or deleted.

is_dir()

    my $is_dir  = $event->is_dir();

Returns a true value if the path is a directory.

is_created()

    do_something($event) if $event->is_created;

True if $event->type eq 'created'.

is_modified()

    do_something($event) if $event->is_modified;

True if $event->type eq 'modified'.

is_deleted()

    do_something($event) if $event->is_deleted;

True if $event->type eq 'deleted'.

SEE ALSO

Top

AnyEvent::Filesys::Notify::Event

BUGS

Top

Please report any bugs or suggestions at http://rt.cpan.org/

AUTHOR

Top

Mark Grimes, <mgrimes@cpan.org>

COPYRIGHT AND LICENSE

Top


AnyEvent-Filesys-Notify documentation Contained in the AnyEvent-Filesys-Notify distribution.

package AnyEvent::Filesys::Notify::Event;

use Moose;

has path => ( is => 'ro', isa => 'Str', required => 1 );
has type => ( is => 'ro', isa => 'Str', required => 1 );
has is_dir => ( is => 'ro', isa => 'Bool', default => 0 );

sub is_created {
    return shift->type eq 'created';
}
sub is_modified {
    return shift->type eq 'modified';
}
sub is_deleted {
    return shift->type eq 'deleted';
}

1;