2020-05-13 20:52:31 +00:00
|
|
|
(ns fira-code.files
|
2023-04-02 13:33:26 +00:00
|
|
|
(:require [clojure.java.io :as io]
|
|
|
|
[clojure.string :as str]))
|
2020-05-13 20:52:31 +00:00
|
|
|
|
2023-04-02 13:33:26 +00:00
|
|
|
(defn- matches-re?
|
|
|
|
"Returns true if the file name matches the given regular expression."
|
|
|
|
[re file]
|
|
|
|
(re-matches re (.getName file)))
|
|
|
|
|
|
|
|
(defn- matching-files
|
|
|
|
"Returns a vector of files in the directory tree rooted at the given path
|
|
|
|
that match the given regular expression."
|
|
|
|
[path re]
|
|
|
|
(->> (path-seq (io/file path))
|
|
|
|
(filterv #(matches-re? re %))
|
|
|
|
(sort-by #(.getPath %))))
|
2020-05-13 20:52:31 +00:00
|
|
|
|