Jonathan Rockway > AnyEvent-Inotify-Simple-0.02 > AnyEvent::Inotify::Simple

Download:
AnyEvent-Inotify-Simple-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Module Version: 0.02   Source   Latest Release: AnyEvent-Inotify-Simple-0.03

NAME ^

AnyEvent::Inotify::Simple - monitor a directory tree in a non-blocking way

SYNOPSIS ^

   use AnyEvent::Inotify::Simple;
   use EV; # or POE, or Event, or ...

   my $inotify = AnyEvent::Inotify::Simple->new(
       directory      => '/tmp/uploads/',
       event_receiver => sub {
           my ($event, $file, $moved_to) = @_;
           given($event) {
               when('create'){
                  say "Someone just uploaded $file!"
               }
           };
       },
   );

   EV::loop;

DESCRIPTION ^

This module is a wrapper around Linux::Inotify2 that integrates it with an AnyEvent event loop and makes monitoring a directory simple. Provide it with a directory, event_receiver (AnyEvent::Inotify::Simple::EventReceiver), and an optional coderef filter, and it will monitor an entire directory tree. If something is added, it will start watching it. If something goes away, it will stop watching it. It also converts IN_MOVE_FROM and IN_MOVE_TO into one virtual event.

Someday I will write more, but that's really all that happens!

METHODS ^

None! Create the object, and it starts working immediately. Destroy the object, and the inotify state and watchers are automatically cleaned up.

REPOSITORY ^

Forks welcome!

http://github.com/jrockway/anyevent-inotify-simple

AUTHOR ^

Jonathan Rockway <jrockway@cpan.org>

COPYRIGHT ^

Copyright 2009 (c) Jonathan Rockway. This module is Free Software. You may redistribute it under the same terms as Perl itself.

syntax highlighting: