Raynes.filevents

https://github.com/Raynes/filevents.git

git clone 'https://github.com/Raynes/filevents.git'

(ql:quickload :Raynes.filevents)
7

filevents

A simple Clojure library for doing file system monitoring.

Usage

It's pretty simple. There are individual watch-file and watch-directory 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 bar/.

It's pretty simple:

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.

Pronunciation

Think of filaments.

License

Copyright © 2012 Anthony Grimes

Distributed under the Eclipse Public License, the same as Clojure.