Skip to content

Instantly share code, notes, and snippets.

@rotaliator
Created June 29, 2021 06:54
Show Gist options
  • Select an option

  • Save rotaliator/9cd13bbb3d8e6bf1f86a6afd1a3cd158 to your computer and use it in GitHub Desktop.

Select an option

Save rotaliator/9cd13bbb3d8e6bf1f86a6afd1a3cd158 to your computer and use it in GitHub Desktop.
(require '[clojure.java.io :as io])
(defn filter-files [path mask]
(let [matcher (.getPathMatcher
(java.nio.file.FileSystems/getDefault)
(str "glob:" mask))]
(->> path
io/file
file-seq
(filter #(.isFile %))
(filter #(.matches matcher (.getFileName (.toPath %))))
(map #(.getAbsolutePath %)))))
(comment
(filter-files "." "*.clj")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment