fixed remove path for paths deeper than one eleme
This commit is contained in:
parent
e7c853cd0f
commit
4d638f84d9
1 changed files with 112 additions and 107 deletions
|
@ -86,6 +86,7 @@
|
||||||
path
|
path
|
||||||
(Paths/get (user-dir) (into-array String path-elements)))))
|
(Paths/get (user-dir) (into-array String path-elements)))))
|
||||||
|
|
||||||
|
; TODO replace this fn ?
|
||||||
(defn path
|
(defn path
|
||||||
"Creates path from given parts, ignore empty elements"
|
"Creates path from given parts, ignore empty elements"
|
||||||
[& path-parts]
|
[& path-parts]
|
||||||
|
@ -165,18 +166,23 @@
|
||||||
(when (some? resource)
|
(when (some? resource)
|
||||||
(:java-path resource))))
|
(:java-path resource))))
|
||||||
|
|
||||||
(defn remove-first-path-item
|
(defn filter-and-remove-for-dir
|
||||||
[seq-of-paths]
|
[path-to-filter-for
|
||||||
(let [fun (fn [str-arg] (st/join "/" (rest (st/split str-arg #"/"))))]
|
elements-list]
|
||||||
(map fun seq-of-paths)))
|
(let [norm-path-to-filter-for (str path-to-filter-for "/")]
|
||||||
|
(map
|
||||||
|
#(subs % (count norm-path-to-filter-for))
|
||||||
|
(filter
|
||||||
|
(fn [element] (and (st/starts-with? element norm-path-to-filter-for)
|
||||||
|
(not (= element norm-path-to-filter-for))))
|
||||||
|
elements-list))))
|
||||||
|
|
||||||
(s/defn
|
(s/defn
|
||||||
list-entries-for-dir ;:- [VirtualPath]
|
list-entries-for-dir ;:- [VirtualPath]
|
||||||
[resource :- Resource]
|
[resource :- Resource]
|
||||||
(if (= :java-classpath-jar (:source-type resource))
|
(if (= :java-classpath-jar (:source-type resource))
|
||||||
(remove-first-path-item (filter
|
(filter-and-remove-for-dir
|
||||||
(fn [je] (and (st/starts-with? je (:virtual-path resource))
|
(:virtual-path resource)
|
||||||
(not (= je (str (:virtual-path resource) "/")))))
|
|
||||||
(map #(.getName ^JarEntry %)
|
(map #(.getName ^JarEntry %)
|
||||||
(enumeration-seq
|
(enumeration-seq
|
||||||
(.entries
|
(.entries
|
||||||
|
@ -185,8 +191,7 @@
|
||||||
(Paths/get
|
(Paths/get
|
||||||
(URI.
|
(URI.
|
||||||
(.getSchemeSpecificPart
|
(.getSchemeSpecificPart
|
||||||
(filesystem-uri (:java-uri resource))))))))))))
|
(filesystem-uri (:java-uri resource)))))))))))
|
||||||
; Bsp-Code: https://github.com/clojure/java.classpath/blob/c10fc96a8ff98db4eb925a13ef0f5135ad8dacc6/src/main/clojure/clojure/java/classpath.clj#L50
|
|
||||||
(.list (.toFile (:java-path resource)))))
|
(.list (.toFile (:java-path resource)))))
|
||||||
|
|
||||||
(defn get-resources-recursive ;:- [Resource]
|
(defn get-resources-recursive ;:- [Resource]
|
||||||
|
|
Loading…
Reference in a new issue