From dee6d860b5c1d139d49bc660fa12519c684ad812 Mon Sep 17 00:00:00 2001 From: Jan Krebs Date: Mon, 27 Jan 2020 22:40:31 +0100 Subject: [PATCH] add function to drop first path item in list-entries-for-dir --- src/cryogen_core/classpath_able_io.clj | 29 +++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/cryogen_core/classpath_able_io.clj b/src/cryogen_core/classpath_able_io.clj index 7e161de..b11aaaa 100644 --- a/src/cryogen_core/classpath_able_io.clj +++ b/src/cryogen_core/classpath_able_io.clj @@ -165,22 +165,27 @@ (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))) + (s/defn list-entries-for-dir ;:- [VirtualPath] [resource :- Resource] (if (= :java-classpath-jar (:source-type resource)) - (filter - (fn [je] (and (st/starts-with? je (:virtual-path resource)) - (not (= je (str (:virtual-path resource) "/"))))) - (map #(.getName ^JarEntry %) - (enumeration-seq - (.entries - (JarFile. - (.toFile - (Paths/get - (URI. - (.getSchemeSpecificPart - (filesystem-uri (:java-uri resource))))))))))) + (remove-first-path-item (filter + (fn [je] (and (st/starts-with? je (:virtual-path resource)) + (not (= je (str (:virtual-path resource) "/"))))) + (map #(.getName ^JarEntry %) + (enumeration-seq + (.entries + (JarFile. + (.toFile + (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 (.list (.toFile (:java-path resource)))))