NAME
    File::Hotfolder - recursive watch directory for new or modified files

SYNOPSIS
        use File::Hotfolder;

        # object interface
        File::Hotfolder->new(
            watch    => '/some/directory',  # which directory to watch
            callback => sub {               # what to do with each new/modified file
                my $path = shift;
                ...
            },
            delete   => 1,                  # delete each file if callback returns true
            filter   => qr/\.json$/,        # only watch selected files
            print    => WATCH_DIR,          # show which directories are watched
            catch    => sub {               # catch callback errors
                my ($path, $error) = @_;
                ...
            }
        )->loop;

        # function interface
        watch( '/some/directory', callback => sub { say shift } )->loop;

        # watch a given directory and delete all new or modified files
        watch( $ARGV[0] // '.', delete  => 1, print => DELETE_FILE )->loop;

DESCRIPTION
    This module uses Linux::Inotify2 to recursively watch a directory for
    new or modified files. A callback is called on each file with its path.

    Deletions and new subdirectories are not reported but new subdirectories
    will be watched as well.

CONFIGURATION
    watch
        Base directory to watch

    callback
        Callback for each new or modified file. The callback is not called
        during a write but after a file has been closed.

    delete
        Delete the modified file if a callback returned a true value
        (disabled by default).

    fullname
        Return absolute path names (disabled by default).

    filter
        Filter filenames with regular expression before passing to callback.

    print
        Print to STDOUT each new directory ("WATCH_DIR"), each file path
        before callback execution ("FOUND_FILE"), and/or each deletion
        ("DELETE_FILE"). Also use "CATCH_ERROR" (implying "catch") to print
        callback errors.

    catch
        Error callback for failing callbacks. Disabled by default, so a
        dying callback will terminate the program.

    scan
        First call the callback for all existing files. This does not
        guarantee that found files have been closed.

METHODS
  loop
    Watch with a manual event loop. This method never returns.

  anyevent
    Watch with AnyEvent. Returns a new AnyEvent watch.

  inotify
    Returns the internal Linux::Inotify2 object.

SEE ALSO
    File::ChangeNotify, Filesys::Notify::Simple, AnyEvent::Inotify::Simple

    AnyEvent

    rrr-server from File::Rsync::Mirror::Recent

COPYRIGHT AND LICENSE
    Copyright Jakob Voss, 2015-

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.