Skip to content

whitequark/ocaml-inotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5e58536 · Nov 21, 2023

History

83 Commits
May 31, 2022
Nov 21, 2023
Nov 18, 2021
Nov 7, 2022
Mar 10, 2016
Nov 21, 2023
Apr 11, 2014
Nov 18, 2021
May 31, 2022
Nov 21, 2023
Nov 21, 2023
Nov 7, 2022

Repository files navigation

OCaml Inotify bindings build

This package contains bindings for Linux's filesystem monitoring interface, inotify.

Installation

The bindings are available via OPAM:

$ opam install inotify

Alternatively, you can do it manually:

# If you want to lwt_inotify
$ opam install lwt
$ opam install .

Usage

Unix-style interface (findlib package inotify):

let inotify = Inotify.create () in
let watch   = Inotify.add_watch inotify "dir" [Inotify.S_Create] in
print_endline (Inotify.string_of_event (List.hd (Inotify.read inotify)))
(* watch=1 cookie=0 events=CREATE "file" *)

Lwt-style interface (findlib package inotify.lwt):

Lwt_main.run (
  let%lwt inotify = Lwt_inotify.create () in
  let%lwt watch   = Lwt_inotify.add_watch inotify "dir" [Inotify.S_Create] in
  let%lwt event   = Lwt_inotify.read inotify in
  Lwt_io.printl (Inotify.string_of_event event))
  (* watch=1 cookie=0 events=CREATE "file" *)

Note that Lwt-style interface returns events one-by-one, but the Unix-style one returns them in small batches.

Documentation

The API documentation is available at GitHub pages.

License

LGPL 2.1 with linking exception