git clone 'https://github.com/Raynes/filevents.git'
A simple Clojure library for doing file system monitoring.
It's pretty simple. There are individual
functions, but the one you should be most interested in is
watch. It can watch
both files and directories and any number of them at once.
(watch (fn [kind file] (println kind) (println file)) "foo" "bar/")
The above example sets up an event on the file
foo and all files
(recursively) under the directory
It's pretty simple:
fooor any file under
bar/), calls the function with the arguments
:modifiedand the file itself.
:deletedand the file itself.
:createdand the file itself.
The library works by polling. All intervals are dynamic vars that can be set before a watch function is called. By default, the time between checks for modification and deletion of a file is 300ms because these checks are very fast. The time between check for newly created files in watched directories is 1 second because this can be slow for large directories because it must populate a set of files on each iteration and check it against the old set. For large directories, you might need to set the number higher.
Think of filaments.
Copyright © 2012 Anthony Grimes
Distributed under the Eclipse Public License, the same as Clojure.