skaji / Mac-FSEvents

https://metacpan.org/dist/Mac-FSEvents
Other
0 stars 0 forks source link

Actions Status

NAME

Mac::FSEvents - Monitor a directory structure for changes

SYNOPSIS

use Mac::FSEvents;

my $fs = Mac::FSEvents->new(
    path          => '/',         # required, the path(s) to watch
                                  # optionally specify an arrayref of multiple paths
    latency       => 2.0,         # optional, time to delay before returning events
    since         => 451349510,   # optional, return events from this eventId
    watch_root    => 1,           # optional, fire events if the watched path changes
    ignore_self   => 1,           # optional, ignore events from this process
    file_events   => 1,           # optional, fire events on files instead of dirs
);
### OR
my $fs = Mac::FSEvents->new( '/' ); # Only specify the path

my $fh = $fs->watch;

# Select on this filehandle, or use an event loop:
my $sel = IO::Select->new($fh);
while ( $sel->can_read ) {
    my @events = $fs->read_events;
    for my $event ( @events ) {
        printf "Directory %s changed\n", $event->path;
    }
}

# or use blocking polling:
while ( my @events = $fs->read_events ) {
    ...
}

# stop watching
$fs->stop;

DESCRIPTION

This module implements the FSEvents API present in Mac OSX 10.5 and later. It enables you to watch a large directory tree and receive events when any changes are made to directories or files within the tree.

Event monitoring occurs in a separate C thread from the rest of your application.

METHODS

AUTHOR

Andy Grundman, andy@hybridized.org

Rob Hoelz, rob@hoelz.ro

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Andy Grundman

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.