Skip to content

Instantly share code, notes, and snippets.

@ptaoussanis
Created June 15, 2012 11:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ptaoussanis/2936042 to your computer and use it in GitHub Desktop.
Fn to check for modified resource files
(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