package async_inotify
Module Async_inotifySource
Async-friendly bindings to inotify, see man 7 inotify.
Be aware that the interface of inotify makes it easy to write code with race conditions or other subtle pitfalls. For instance, stat'ing a file then watching it means you have lost any events between the stat and the watch. Or the behavior when watching a path whose inode has multiple hardlinks is non-obvious.
type modify_event_selector = [ | `Any_change(*Send a Modified event whenever the contents of the file changes (which can be very often when writing a large file)
*)| `Closed_writable_fd(*Only send a Modify event when someone with a file descriptor with write permission to that file is closed. There are usually many fewer of these events (for large files), but they come later.
*)
]val create :
?modify_event_selector:modify_event_selector ->
?recursive:bool ->
?watch_new_dirs:bool ->
string ->
(t * file_info list) Async.Deferred.tcreate path creates an inotify watching path. Returns the inotify type t itself and the list of files currently being watched. By default, recursively watches all subdirectories of the given path. See add_all for caveats.
create_empty modify_event_selector creates an inotify that watches nothing until add or add_all is called.
stop t stop watching t
add t path add the path to t to be watched
val add_all :
?skip_dir:((string * Async.Unix.Stats.t) -> bool Async.Deferred.t) ->
t ->
string ->
file_info list Async.Deferred.tadd_all t path watches path and all its current subdirectories recursively. This may generate events in the event pipe that are older than the returned file info, in the presence of concurrent modification to the filesystem.
remove t path remove the path from t