mirror of
https://github.com/janet-lang/janet
synced 2026-03-29 19:11:28 +00:00
kqueue-based filewatch is more limited than inotify, but is still useful in many cases. Notably absent is any ability to monitor directories automatically without wasting a lot of file descriptors.
15 lines
417 B
Janet
15 lines
417 B
Janet
###
|
|
### example/filewatch.janet ...files
|
|
###
|
|
### Watch for all changes in a list of files and directories. Behavior
|
|
### depends on the filewatch module, and different operating systems will
|
|
### report different events.
|
|
|
|
(def chan (ev/chan 1000))
|
|
(def fw (filewatch/new chan))
|
|
(each arg (drop 1 (dyn *args* []))
|
|
(filewatch/add fw arg :all))
|
|
(filewatch/listen fw)
|
|
|
|
(forever (let [event (ev/take chan)] (pp event)))
|