inotify
.
Behaviours: application, supervisor.
This module defines the inotify behaviour.
Required callback functions: inotify_event/3.
Application that monitors files via Linux inotify
. A user can tell
inotify
to watch/2
for specific events on several
files/directories. To actually get any events the User must call add_handler/3
.
To unwatch/1
something the User must pass the return value of watch/2
which is a unique reference to the monitor create by watch/2
.
This module also defines a behaviour, with a single function
inotify_event(Arg, EventRef, Msg)
A callback for file monitoring event handler added by add_handler/3
.
Arg
is the user provided extra argument.
EventRef
is the value returned by watch/2
.
The Msg
parameter of the callback function should be pattern-matched
with the macro ?inotify_msg(Mask, Cookie, OptionalName)
contained
in include/inotify.hrl
.
Mask
is a list of atoms describing the nature of the event. Refer to the
Linux inotify man page for a detailed description.
Cookie
is 0 except when a file is moved, where it is used to identify
move_from
and move_to
events belonging to the same move-operation.
OptionalName
contains the relative file name when monitoring whole
directories. E.g. when monitoring "/tmp" the following event might be
created when opening "/tmp/xxx": ?inotify_msg([open], 0, "xxx")
.
mask() = '?ALL' | '?ACCESS' | '?ATTRIB' | '?CLOSE_WRITE' | '?CLOSE_NOWRITE' | '?CLOSE' | '?CREATE' | '?DELETE' | '?DELETE_SELF' | '?MODIFY' | '?MOVE_SELF' | '?MOVED_FROM' | '?MOVED_TO' | '?MOVE' | '?OPEN' | '?DONT_FOLLOW' | '?MASK_ADD' | '?ONLYDIR'
The type of a file monitoring event.
msg() = '?inotify_msg'
add_handler/3 |
Add an event handler that receives all events generated by a file monitor
identified by a tag that was passed to inotify:watch/2 . |
inotify_event/3 |
This module actually implements the inotify_evt behaviour, with a
function that simply prints the events to stdout. |
print_events/1 | Add an event handler that prints to stdout events. |
unwatch/1 |
Remove a monitor added via watch/2 , Ref identifies the
monitor. |
watch/1 | Add or modify a file/directory monitor for all file events. |
watch/2 | Add or modify a file/directory monitor for specific events. |
add_handler(Ref::reference(), Module::module(), Arg::term()) -> ok
Add an event handler that receives all events generated by a file monitor
identified by a tag that was passed to inotify:watch/2
. When an event
occurs for Ref
the handler will call Module:inotify_event(Arg,
EventTag, Msg)
as defined by the callback
definition in inotify_event/3
.
inotify_event(X1, Ref, X3) -> any()
This module actually implements the inotify_evt
behaviour, with a
function that simply prints the events to stdout.
See also: print_events/1.
print_events(Ref::reference()) -> ok
Add an event handler that prints to stdout events. The events to print are
identified by a reference returned by watch/2
.
unwatch(Ref::reference()) -> ok
Remove a monitor added via watch/2
, Ref
identifies the
monitor.
watch(File::string()) -> reference()
Add or modify a file/directory monitor for all file events. Events for the
file/directory will be published via a inotify_evt
. The events
resulting from this call will be identified by the unique reference returned
by this function, no matter if the operation was successful or not.
unwatch/1
.
See also: inotify:add_handler/3, inotify:unwatch/1.
Add or modify a file/directory monitor for specific events. This
differs from watch/1
by the additional mask
argument.
Calling watch/1
is equivalant to calling watch/2
with ?ALL
as second parameter.
See also: inotify:watch/1.
Generated by EDoc