Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jun 7, 2012
1 parent 0fa50d0 commit fd62b13
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/bultitude/core.clj
Expand Up @@ -2,6 +2,7 @@
(:require [clojure.java.io :as io]
[clojure.string :as string])
(:import (java.util.jar JarFile)
(java.net URI URLDecoder)
(java.io File BufferedReader PushbackReader InputStreamReader)
(clojure.lang DynamicClassLoader)))

Expand Down Expand Up @@ -64,6 +65,19 @@
#(java.io.File. (.getPath ^java.net.URL %))
(.getURLs ^java.net.URLClassLoader loader))))

(defn loader-classpath
"Returns a sequence of File paths from a classloader."
[loader]
(when (instance? java.net.URLClassLoader loader)
(map
#(java.io.File.
(.getPath (URI. (.getProtocol ^java.net.URL %)
nil
(URLDecoder/decode (.getPath ^java.net.URL %) "UTF-8")
nil
nil)))
(.getURLs ^java.net.URLClassLoader loader))))

(defn classpath-files
"Returns a sequence of File objects of the elements on the classpath."
([classloader]
Expand Down

0 comments on commit fd62b13

Please sign in to comment.