added todo's
This commit is contained in:
parent
579193f735
commit
151be9f92f
2 changed files with 23 additions and 3 deletions
|
@ -68,17 +68,18 @@
|
|||
:source-type source-type
|
||||
:resource-type (cond
|
||||
(Files/isDirectory java-path NoLinkOption) :dir
|
||||
(Files/isRegularFile java-path NoLinkOption) :java-path
|
||||
(Files/isRegularFile java-path NoLinkOption) :file
|
||||
:else :unknown)}))
|
||||
|
||||
(s/defn is-file? :- s/Bool
|
||||
[resource :- Resource]
|
||||
(= :file (:resource-type resource)))
|
||||
|
||||
; contains either a jar or a file
|
||||
(s/defn path-from-cp ; :- JavaPath
|
||||
[resource-path :- ShortPath]
|
||||
(try
|
||||
(let [path-from-cp (Paths/get (.toURI (io/resource resource-path)))]
|
||||
(let [path-from-cp (Paths/get (.toURI (io/resource resource-path)))] ; check if contains jar:
|
||||
(when (Files/exists path-from-cp NoLinkOption)
|
||||
path-from-cp))
|
||||
(catch Exception e
|
||||
|
@ -87,7 +88,17 @@
|
|||
(s/defn path-from-fs ; :- JavaPath
|
||||
[fs-prefix :- Prefix
|
||||
resource-path :- ShortPath]
|
||||
(let [path-from-fs (Paths/get (java.net.URI. (str "file://" fs-prefix resource-path)))] ;with this, you need to give the absolute path
|
||||
(let [path-from-fs (Paths/get (java.net.URI. (str "file://" fs-prefix resource-path)))] ;fragile
|
||||
(try
|
||||
(when (Files/exists path-from-fs NoLinkOption)
|
||||
path-from-fs)
|
||||
(catch Exception e
|
||||
nil))))
|
||||
|
||||
; TODO move to path-from-cp
|
||||
(s/defn path-from-jar ; :- JavaPath
|
||||
[resource-path :- ShortPath]
|
||||
(let [uri (.toUri (io/resource "dummy"))]
|
||||
(try
|
||||
(when (Files/exists path-from-fs NoLinkOption)
|
||||
path-from-fs)
|
||||
|
|
|
@ -50,3 +50,12 @@
|
|||
(doseq [resource resources]
|
||||
(io/make-parents (io/file (str target-path "/" (:path resource))))
|
||||
(.mkdir (io/file (str target-path "/" (:path resource)))))))
|
||||
|
||||
; TODO lookup if we need to close the stream
|
||||
(defn extract-file-from-jar
|
||||
[Uri
|
||||
file-path]
|
||||
(let [zippath (.getPath
|
||||
(FileSystems/getFileSystem (java.net.URI. Uri)) file-path
|
||||
(into-array String '()))]
|
||||
(apply str (map char (Files/readAllBytes zippath)))))
|
||||
|
|
Loading…
Reference in a new issue