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
|
||||
(Paths/get (user-dir) (into-array String path-elements)))))
|
||||
|
||||
; TODO replace this fn ?
|
||||
(defn path
|
||||
"Creates path from given parts, ignore empty elements"
|
||||
[& path-parts]
|
||||
|
@ -165,18 +166,23 @@
|
|||
(when (some? resource)
|
||||
(:java-path resource))))
|
||||
|
||||
(defn remove-first-path-item
|
||||
[seq-of-paths]
|
||||
(let [fun (fn [str-arg] (st/join "/" (rest (st/split str-arg #"/"))))]
|
||||
(map fun seq-of-paths)))
|
||||
(defn filter-and-remove-for-dir
|
||||
[path-to-filter-for
|
||||
elements-list]
|
||||
(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
|
||||
list-entries-for-dir ;:- [VirtualPath]
|
||||
[resource :- Resource]
|
||||
(if (= :java-classpath-jar (:source-type resource))
|
||||
(remove-first-path-item (filter
|
||||
(fn [je] (and (st/starts-with? je (:virtual-path resource))
|
||||
(not (= je (str (:virtual-path resource) "/")))))
|
||||
(filter-and-remove-for-dir
|
||||
(:virtual-path resource)
|
||||
(map #(.getName ^JarEntry %)
|
||||
(enumeration-seq
|
||||
(.entries
|
||||
|
@ -185,8 +191,7 @@
|
|||
(Paths/get
|
||||
(URI.
|
||||
(.getSchemeSpecificPart
|
||||
(filesystem-uri (:java-uri resource))))))))))))
|
||||
; Bsp-Code: https://github.com/clojure/java.classpath/blob/c10fc96a8ff98db4eb925a13ef0f5135ad8dacc6/src/main/clojure/clojure/java/classpath.clj#L50
|
||||
(filesystem-uri (:java-uri resource)))))))))))
|
||||
(.list (.toFile (:java-path resource)))))
|
||||
|
||||
(defn get-resources-recursive ;:- [Resource]
|
||||
|
|
Loading…
Reference in a new issue