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 [& path-elements ;:- VirtualPath
] ]
(try (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) (when (is-from-classpath-jar? resource-uri)
(init-file-system resource-uri)) (init-file-system resource-uri))
;; TODO: hier steckt auch eine "from-fs-cp" funktionalität drinne ;; TODO: hier steckt auch eine "from-fs-cp" funktionalität drinne
@ -91,6 +95,7 @@
(.entries (.entries
(jar-file-for-resource resource)))))) (jar-file-for-resource resource))))))
; TODO: Statt rekursion list-entries-for-dir direkt verwenden
(defn get-resources;:- [Resource] (defn get-resources;:- [Resource]
[base-path ;:- VirtualPath [base-path ;:- VirtualPath
paths ;:- [VirtualPath] paths ;:- [VirtualPath]
@ -101,8 +106,8 @@
(do (do
(let [path-to-work-with (first paths) (let [path-to-work-with (first paths)
resource-to-work-with (create-resource 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 result (into result
[resource-to-work-with])] [resource-to-work-with])]
(cond (cond

View file

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