Last active
December 18, 2015 19:38
-
-
Save Kungi/47635b4ea28dae353be4 to your computer and use it in GitHub Desktop.
add-osx-watcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: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