JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

filewatch/add

core-api


    cfunction
    src/core/filewatch.c on line 599, column 1

    (filewatch/add watcher path flag & more-flags)

    Add a path to the watcher. Available flags depend on the current 
    OS, and are as follows:

    Windows/MINGW (flags correspond to `FILE_NOTIFY_CHANGE_*` flags in 
    win32 documentation):

    * `:all` - trigger an event for all of the below triggers.

    * `:attributes` - `FILE_NOTIFY_CHANGE_ATTRIBUTES`

    * `:creation` - `FILE_NOTIFY_CHANGE_CREATION`

    * `:dir-name` - `FILE_NOTIFY_CHANGE_DIR_NAME`

    * `:last-access` - `FILE_NOTIFY_CHANGE_LAST_ACCESS`

    * `:last-write` - `FILE_NOTIFY_CHANGE_LAST_WRITE`

    * `:security` - `FILE_NOTIFY_CHANGE_SECURITY`

    * `:size` - `FILE_NOTIFY_CHANGE_SIZE`

    * `:recursive` - watch subdirectories recursively

    Linux (flags correspond to `IN_*` flags from <sys/inotify.h>):

    * `:access` - `IN_ACCESS`

    * `:all` - `IN_ALL_EVENTS`

    * `:attrib` - `IN_ATTRIB`

    * `:close-nowrite` - `IN_CLOSE_NOWRITE`

    * `:close-write` - `IN_CLOSE_WRITE`

    * `:create` - `IN_CREATE`

    * `:delete` - `IN_DELETE`

    * `:delete-self` - `IN_DELETE_SELF`

    * `:ignored` - `IN_IGNORED`

    * `:modify` - `IN_MODIFY`

    * `:move-self` - `IN_MOVE_SELF`

    * `:moved-from` - `IN_MOVED_FROM`

    * `:moved-to` - `IN_MOVED_TO`

    * `:open` - `IN_OPEN`

    * `:q-overflow` - `IN_Q_OVERFLOW`

    * `:unmount` - `IN_UNMOUNT`

    On Windows, events will have the following possible types:

    * `:unknown`

    * `:added`

    * `:removed`

    * `:modified`

    * `:renamed-old`

    * `:renamed-new`

    On Linux, events will have a `:type` corresponding to the possible 
    flags, excluding `:all`.


1 exampleSign in to add an example
Loading...
(def cc (ev/thread-chan 99))  # Sets up a message channel.
(def ww (filewatch/new cc))   # Creates the watcher.
(filewatch/add ww "ftest.janet" :all)     # Watch for all changes.
(filewatch/add ww "fadd.janet"  :modify)  # Only care if modified (Linux-specific flag).
(filewatch/listen ww)         # Start filewatcher listening for changes.

(pp (ev/take cc))             # Print info on first file to change.
(filewatch/unlisten ww)       # Stop caring about changes.
oofoePlayground