JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

filewatch/remove

core-api


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

    (filewatch/remove watcher path)

    Remove a path from the watcher.


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.
(filewatch/listen ww)         # Start filewatcher listening for changes.

# Note that we may still get events for files that have been removed
# so we have to make sure we don't remove them twice.

(var careless "Have we already removed %fadd.janet?" false)
(forever
 (let (item (ev/take cc))
   (pp (ev/take cc))
   (when (and (not careless) (= "fadd.janet" (item :wd-path)))
     (print "I don't care about this file anymore.")
     (filewatch/remove ww (item :wd-path))
     (set careless true)
     )))
oofoePlayground