kopia lustrzana https://github.com/tonsky/FiraCode
Use a threaded `->>` macro to simplify the code.
rodzic
1670bf02e5
commit
84d57b2678
|
@ -1,12 +1,17 @@
|
||||||
(ns fira-code.files
|
(ns fira-code.files
|
||||||
(:refer-clojure :exclude [find])
|
(:require [clojure.java.io :as io]
|
||||||
(:require
|
|
||||||
[clojure.java.io :as io]
|
|
||||||
[clojure.string :as str]))
|
[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 find [path re]
|
(defn- matching-files
|
||||||
(->> (file-seq (io/file path))
|
"Returns a vector of files in the directory tree rooted at the given path
|
||||||
(next) ;; skip directory itself
|
that match the given regular expression."
|
||||||
(filter #(re-matches re (.getPath %)))
|
[path re]
|
||||||
|
(->> (path-seq (io/file path))
|
||||||
|
(filterv #(matches-re? re %))
|
||||||
(sort-by #(.getPath %))))
|
(sort-by #(.getPath %))))
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue