Skip to content

Instantly share code, notes, and snippets.

@seancorfield
Created October 21, 2011 19:47
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 seancorfield/1304756 to your computer and use it in GitHub Desktop.
Save seancorfield/1304756 to your computer and use it in GitHub Desktop.
(defn- wildcard-filter
"Given a regex, return a FilenameFilter that matches."
[re]
(reify java.io.FilenameFilter
(accept [_ dir name] (not (nil? (re-find re name))))))
(defn- directory-list
"Given a directory and a regex, return a sorted seq of matching filenames."
[dir re]
(sort (.list (clojure.java.io/file dir) (wildcard-filter re))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment