jar works nearly

This commit is contained in:
jem 2020-02-04 20:17:11 +01:00
parent c6bca30c26
commit b466d14d4c
2 changed files with 10 additions and 5 deletions

View file

@ -52,7 +52,11 @@
[& path-elements ;:- VirtualPath
]
(try
(let [resource-uri (.toURI (io/resource (st/join "/" path-elements)))]
(let [resource-uri
(.toURI (io/resource
(st/join "/"
(filter #(not (empty? %))
path-elements))))]
(when (is-from-classpath-jar? resource-uri)
(init-file-system resource-uri))
;; TODO: hier steckt auch eine "from-fs-cp" funktionalität drinne
@ -91,6 +95,7 @@
(.entries
(jar-file-for-resource resource))))))
; TODO: Statt rekursion list-entries-for-dir direkt verwenden
(defn get-resources;:- [Resource]
[base-path ;:- VirtualPath
paths ;:- [VirtualPath]
@ -101,8 +106,8 @@
(do
(let [path-to-work-with (first paths)
resource-to-work-with (create-resource
(path-if-exists base-path path-to-work-with)
path-to-work-with)
path-to-work-with
(path-if-exists base-path path-to-work-with))
result (into result
[resource-to-work-with])]
(cond

View file

@ -28,7 +28,7 @@
(deftest test-get-resources
(is
(= [{:virtual-path "dummy" :source-type :filesystem :resource-type :dir}
{:virtual-path "dummy/dummy_from_jar" :source-type :filesystem :resource-type :file}]
(= [{:virtual-path "dummy" :source-type :java-classpath-jar :resource-type :dir}
{:virtual-path "dummy/dummy_from_jar" :source-type :java-classpath-jar :resource-type :file}]
(map ftt/filter-object
(sut/get-resources "" ["dummy"])))))