do not need allways a new fs

This commit is contained in:
jem 2020-01-17 19:08:15 +01:00
parent 72e8eec3d5
commit 02f9c57612

View file

@ -10,7 +10,8 @@
(:require [clojure.java.io :as io] (:require [clojure.java.io :as io]
[clojure.string :as st] [clojure.string :as st]
[schema.core :as s]) [schema.core :as s])
(:import [java.nio.file FileSystems Paths Files SimpleFileVisitor LinkOption StandardCopyOption] (:import [java.net Uri]
[java.nio.file FileSystems Paths Files SimpleFileVisitor LinkOption StandardCopyOption]
[java.nio.file.attribute FileAttribute])) [java.nio.file.attribute FileAttribute]))
(def SourceType (s/enum :classpath :filesystem)) (def SourceType (s/enum :classpath :filesystem))
@ -77,13 +78,11 @@
(s/defn init-file-system (s/defn init-file-system
[resource-uri :- ResourceUri] [resource-uri :- ResourceUri]
(let [path-to-filesystem (pop (st/split (.toString resource-uri) #"!"))] (let [filesystem-uri (Uri. (pop (st/split (.toString resource-uri) #"!")))]
(try (try
(FileSystems/newFileSystem (FileSystems/getFileSystem filesystem-uri)
(java.net.URI. path-to-filesystem)
{})
(catch Exception e (catch Exception e
nil)))) (FileSystems/newFileSystem filesystem-uri {})))))
; contains either a jar or a file ; contains either a jar or a file
(s/defn path-from-cp ; :- JavaPath (s/defn path-from-cp ; :- JavaPath