Skip to content

Instantly share code, notes, and snippets.

@Kungi
Last active December 18, 2015 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kungi/47635b4ea28dae353be4 to your computer and use it in GitHub Desktop.
Save Kungi/47635b4ea28dae353be4 to your computer and use it in GitHub Desktop.
add-osx-watcher
(defn add-osx-watcher [f path]
(let [watcher (WatchService/newWatchService)
w (WatchableFile. (clojure.java.io/file path))]
(.register w
watcher
(into-array WatchEvent$Kind [StandardWatchEventKind/ENTRY_CREATE
StandardWatchEventKind/ENTRY_DELETE
StandardWatchEventKind/ENTRY_MODIFY]))
(wait-for-events watcher f)))
(:import (com.barbarysoftware.watchservice WatchableFile
WatchEvent
StandardWatchEventKind
WatchService)
(java.util.concurrent TimeUnit))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment