add function to drop first path item in list-entries-for-dir
This commit is contained in:
parent
4643343a02
commit
dee6d860b5
1 changed files with 17 additions and 12 deletions
|
@ -165,22 +165,27 @@
|
||||||
(when (some? resource)
|
(when (some? resource)
|
||||||
(:java-path 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)))
|
||||||
|
|
||||||
(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))
|
||||||
(filter
|
(remove-first-path-item (filter
|
||||||
(fn [je] (and (st/starts-with? je (:virtual-path resource))
|
(fn [je] (and (st/starts-with? je (:virtual-path resource))
|
||||||
(not (= je (str (:virtual-path resource) "/")))))
|
(not (= je (str (:virtual-path resource) "/")))))
|
||||||
(map #(.getName ^JarEntry %)
|
(map #(.getName ^JarEntry %)
|
||||||
(enumeration-seq
|
(enumeration-seq
|
||||||
(.entries
|
(.entries
|
||||||
(JarFile.
|
(JarFile.
|
||||||
(.toFile
|
(.toFile
|
||||||
(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
|
; 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)))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue