The following list-resources
function returns a list of all files in the jar that's in path
. running-jar
holds the path to the currently running jar if it is in fact a jar.
(def ^:private running-jar
"Resolves the path to the current running jar file."
(-> :keyword class (.. getProtectionDomain getCodeSource getLocation getPath)))
(defn list-resources [path]
(let [jar (java.util.jar.JarFile. path)
entries (.entries jar)]
(loop [result []]
(if (.hasMoreElements entries)
(recur (conj result (.. entries nextElement getName)))
result))))
(take 10 (list-resources running-jar))