Skip to content

Commit

Permalink
Rename dir to url-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Jun 14, 2015
1 parent 4266e99 commit dbf7aa9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/resauce/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
(if (.startsWith ^String path dir)
(str (add-ending-slash (str base-url)) (subs path (count dir)))))

(defmulti dir
"Return a list of resources under this URL, if possible."
(defmulti url-dir
"Return a list of URLs contained by this URL, if the protocol supports it."
(fn [url] (.getScheme (URI. (str url)))))

(defmethod dir "file" [url]
(defmethod url-dir "file" [url]
(if-let [path (.getPath (URI. (str url)))]
(let [file (io/file path)]
(if (.isDirectory file)
(map io/as-url (.listFiles file))))))

(defmethod dir "jar" [url]
(defmethod url-dir "jar" [url]
(let [conn (.openConnection (URL. (str url)))
jar (.getJarFile ^JarURLConnection conn)
path (add-ending-slash (.getEntryName ^JarURLConnection conn))
Expand Down

0 comments on commit dbf7aa9

Please sign in to comment.