Created
November 28, 2011 03:37
-
-
Save trptcolin/1398988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/src/clj/clojure/java/io.clj | |
+++ b/src/clj/clojure/java/io.clj | |
@@ -18,7 +18,7 @@ | |
StringReader ByteArrayInputStream | |
BufferedInputStream BufferedOutputStream | |
CharArrayReader Closeable) | |
- (java.net URI URL MalformedURLException Socket))) | |
+ (java.net URI URL URLDecoder MalformedURLException Socket))) | |
(def | |
^{:doc "Type object for a Java primitive byte array." | |
@@ -47,13 +47,13 @@ | |
File | |
(as-file [f] f) | |
- (as-url [f] (.toURL f)) | |
+ (as-url [f] (.toURL (.toURI f))) | |
URL | |
(as-url [u] u) | |
(as-file [u] | |
(if (= "file" (.getProtocol u)) | |
- (as-file (.getPath u)) | |
+ (as-file (URLDecoder/decode (.getPath u))) | |
(throw (IllegalArgumentException. (str "Not a file: " u))))) | |
URI | |
@@ -229,11 +229,11 @@ | |
:make-input-stream (fn [^URL x opts] | |
(make-input-stream | |
(if (= "file" (.getProtocol x)) | |
- (FileInputStream. (.getPath x)) | |
+ (FileInputStream. (as-file x)) | |
(.openStream x)) opts)) | |
:make-output-stream (fn [^URL x opts] | |
(if (= "file" (.getProtocol x)) | |
- (make-output-stream (File. (.getPath x)) opts) | |
+ (make-output-stream (as-file x) opts) | |
(throw (IllegalArgumentException. (str "Can not write to non-file URL <" x ">"))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment