Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tokenrove/erl-dirwatch
Simple directory watching for Erlang
https://github.com/tokenrove/erl-dirwatch
erlang inotify kqueue library simplest-possible-thing
Last synced: about 1 month ago
JSON representation
Simple directory watching for Erlang
- Host: GitHub
- URL: https://github.com/tokenrove/erl-dirwatch
- Owner: tokenrove
- Created: 2016-06-14T14:08:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-24T20:52:24.000Z (almost 8 years ago)
- Last Synced: 2024-10-29T13:02:03.741Z (3 months ago)
- Topics: erlang, inotify, kqueue, library, simplest-possible-thing
- Language: C
- Homepage: https://github.com/adgear/erl-dirwatch
- Size: 708 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**You probably don't want to use this.**
If you have serious file watching needs, you are probably looking for
[synrc/fs](https://github.com/synrc/fs).This provides absolutely minimal directory watching for Erlang; just
enough to support `bertconf`.That is, for each directory specified, we watch only this directory
for move, create, and delete events, and do not setup recursive
watches.Uses `inotify` on Linux, `kqueue` on BSDs.
Does _not_ use `fsevents` on OS X, and probably never will: the only
exposed API requires you to use a `CFRunLoop`, even though I'm sure
there's a nice UNIX-y `fd` in there somewhere.It would have been nice to do this as a NIF that returns an fd from
inotify and used `open_port({fd, ...` and Erlang's binary matching to
parse inotify messages, but this wouldn't permit us to handle other
OSes where less-UNIX-y approaches are used. Instead we use a
linked-in driver which allows us to do the right thing for inotify,
and still offers some portability options.== Building
```
rebar3 compile
```== Usage
=== `dirwatch:start(Self, Path, CooldownMs = 5000) -> {ok,Handle} | {error,_}`
Start watching the files in `Path`. After events have occurred, will
wait `CooldownMs` before sending a message of the form
`{dirwatch,Handle,changed}` to the `Self` process.The dirwatch process referred to by `Handle` monitors `Self` and
terminates if it terminates.=== `dirwatch:stop(Handle) -> ok | {error,_}`
Explicitly stops a dirwatch process.