Created
June 15, 2012 11:48
-
-
Save ptaoussanis/2936042 to your computer and use it in GitHub Desktop.
Fn to check for modified resource files
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
(def some-file-resources-modified? | |
"Returns true iff any of the files backing given resources have changed | |
since this function was last called." | |
(let [times (atom {})] | |
(fn modified? | |
([resource-name & more] (some modified? (cons resource-name more))) | |
([resource-name] | |
(when-let [^File file (try (->> resource-name io/resource io/file) | |
(catch Exception _ nil))] | |
(let [last-modified (.lastModified file)] | |
(let [file-name (str file) | |
modified? (> last-modified (@times file-name 0))] | |
(when modified? (swap! times assoc file-name last-modified)) | |
modified?))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment