Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/whitequark/ocaml-inotify
OCaml bindings for inotify.
https://github.com/whitequark/ocaml-inotify
Last synced: 18 days ago
JSON representation
OCaml bindings for inotify.
- Host: GitHub
- URL: https://github.com/whitequark/ocaml-inotify
- Owner: whitequark
- License: other
- Created: 2014-04-08T16:36:08.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-07-26T14:51:46.000Z (4 months ago)
- Last Synced: 2024-10-13T01:45:34.496Z (about 1 month ago)
- Language: OCaml
- Homepage:
- Size: 772 KB
- Stars: 40
- Watchers: 6
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.txt
Awesome Lists containing this project
README
OCaml Inotify bindings [![build](https://github.com/whitequark/ocaml-inotify/actions/workflows/main.yml/badge.svg)](https://github.com/whitequark/ocaml-inotify/actions/workflows/main.yml)
======================This package contains bindings for Linux's filesystem monitoring
interface, [inotify][man].[man]: http://man7.org/linux/man-pages/man7/inotify.7.html
Installation
------------The bindings are available via [OPAM](https://opam.ocaml.org):
$ opam install inotify
Alternatively, you can do it manually:
# If you want to use lwt_inotify
$ opam install lwt
# If you want to use eio_inotify
$ opam install eio
$ opam install .Usage
-----Unix-style interface (findlib package `inotify`):
``` ocaml
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`):
``` ocaml
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" *)
```Eio-style interface (findlib package `inotify-eio`):
``` ocaml
Eio_main.run @@ fun _env ->
let inotify = Eio_inotify.create () in
let _watch = Eio_inotify.add_watch inotify "dir" [Inotify.S_Create] in
let event = Eio_inotify.read inotify in
print_endline (Inotify.string_of_event event)
(* watch=1 cookie=0 events=CREATE "file" *)
```Note that Lwt-style & Eio-style interfaces returns events one-by-one, but the Unix-style one returns
them in small batches.Documentation
-------------The API documentation is available at [GitHub pages](http://whitequark.github.io/ocaml-inotify/).
License
-------[LGPL 2.1 with linking exception](LICENSE.txt)