[#457] Add java.nio.file.PathMatcher
This commit is contained in:
parent
4d937406a8
commit
0389ed7127
4 changed files with 22 additions and 3 deletions
|
|
@ -18,7 +18,6 @@ For a list of breaking changes, check [here](#breaking-changes)
|
|||
Details about releases prior to v0.1.0 can be found
|
||||
[here](https://github.com/borkdude/babashka/releases).
|
||||
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### v0.0.90
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@
|
|||
java.nio.file.LinkOption
|
||||
java.nio.file.NoSuchFileException
|
||||
java.nio.file.Path
|
||||
java.nio.file.PathMatcher
|
||||
java.nio.file.Paths
|
||||
java.nio.file.StandardCopyOption
|
||||
java.nio.file.attribute.FileAttribute
|
||||
|
|
@ -248,7 +249,9 @@
|
|||
(instance? java.io.OutputStream v)
|
||||
java.io.OutputStream
|
||||
(instance? java.nio.file.FileSystem v)
|
||||
java.nio.file.FileSystem)))))
|
||||
java.nio.file.FileSystem
|
||||
(instance? java.nio.file.PathMatcher v)
|
||||
java.nio.file.PathMatcher)))))
|
||||
|
||||
(def class-map (gen-class-map))
|
||||
|
||||
|
|
|
|||
|
|
@ -350,7 +350,10 @@
|
|||
(catch java.nio.file.FileAlreadyExistsException _
|
||||
(java.nio.file.Files/copy p p' (into-array [java.nio.file.StandardCopyOption/REPLACE_EXISTING]))))))"
|
||||
temp-path))
|
||||
(is (.exists f2))))
|
||||
(is (.exists f2))
|
||||
(let [v (bb nil "-f" (.getPath (io/file "test" "babashka" "scripts" "glob.bb")))]
|
||||
(is (vector? v))
|
||||
(is (.exists (io/file (first v)))))))
|
||||
|
||||
(deftest future-print-test
|
||||
(testing "the root binding of sci/*out*"
|
||||
|
|
|
|||
14
test/babashka/scripts/glob.bb
Normal file
14
test/babashka/scripts/glob.bb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(require '[clojure.java.io :as io])
|
||||
|
||||
(defn glob [pattern]
|
||||
(let [matcher (.getPathMatcher
|
||||
(java.nio.file.FileSystems/getDefault)
|
||||
(str "glob:" pattern))]
|
||||
(into []
|
||||
(comp (filter #(.isFile %))
|
||||
(filter #(.matches matcher (.normalize (.toPath %))))
|
||||
(map #(.relativize (.toURI (io/file ".")) (.toURI %)))
|
||||
(map #(.getPath %)))
|
||||
(file-seq (io/file ".")))))
|
||||
|
||||
(glob "*/doc/*.md") ;;=> ["sci/doc/libsci.md" "babashka.nrepl/doc/intro.md"]
|
||||
Loading…
Reference in a new issue