Use a threaded ->>
macro to simplify the code.
This commit is contained in:
parent
1670bf02e5
commit
84d57b2678
|
@ -1,12 +1,17 @@
|
|||
(ns fira-code.files
|
||||
(:refer-clojure :exclude [find])
|
||||
(:require
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]))
|
||||
(:require [clojure.java.io :as io]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(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 %))))
|
||||
|
||||
(defn find [path re]
|
||||
(->> (file-seq (io/file path))
|
||||
(next) ;; skip directory itself
|
||||
(filter #(re-matches re (.getPath %)))
|
||||
(sort-by #(.getPath %))))
|
Loading…
Reference in a new issue