file-watch
Canonical Import
fennel
(local file-watch (require :file-watch))Source Files
src/lua_file_watch.cppsrc/lua_runtime.cpp
What It Provides
file-watch creates file watchers backed by efsw and polls file add, delete, modify, move, and missed-event notifications.
API Summary
FileWatcher([options])creates a watcher. Options includegeneric,generic?,follow-symlinks,follow-symlinks?,allow-out-of-scope-links, andallow-out-of-scope-links?.- Module values:
actionstable andlast-error(). - Watcher methods:
add-watch(directory [recursive?]),remove-watch(id),start(),poll(),directories(),follow-symlinks(bool),allow-out-of-scope-links(bool),follow-symlinks-enabled?(),allow-out-of-scope-links?(),started?(), anddrop().
Examples
fennel
(local file-watch (require :file-watch))
(local watcher (file-watch.FileWatcher {:generic false}))
(watcher:add-watch "." false)
(watcher:start)
(each [_ event (ipairs (watcher:poll))]
(print event.action event.path))Errors and Platform Notes
Adding an empty directory or a watch that efsw rejects raises an error. Methods raise after drop. Events are delivered by polling and include fields such as watch-id, dir, filename, path, action, missed, old-filename, and old-path.
Related Modules
Aliases and Search Terms
Search terms: file watcher, directory watcher, efsw, filesystem events.
