Skip to content

Commit

Permalink
mark deprecations in io
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Bedra and Stuart Halloway committed Jul 23, 2010
1 parent 0a3e680 commit b6c6f0f
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/main/clojure/clojure/contrib/io.clj
@@ -1,4 +1,4 @@
;;; duck_streams.clj -- duck-typed I/O streams for Clojure
;;; io.clj -- duck-typed I/O streams for Clojure

;; by Stuart Sierra, http://stuartsierra.com/
;; May 13, 2009
Expand Down Expand Up @@ -26,6 +26,9 @@

;; CHANGE LOG
;;
;; July 23, 2010: Most functions here are deprecated. Use
;; clojure.java.io
;;
;; May 13, 2009: added functions to open writers for appending
;;
;; May 3, 2009: renamed file to file-str, for compatibility with
Expand Down Expand Up @@ -277,13 +280,15 @@
(defn append-output-stream
"Like output-stream but opens file for appending. Does not work on streams
that are already open."
{:deprecated "1.2"}
[x]
(binding [*append* true]
(output-stream x)))

(defn append-writer
"Like writer but opens file for appending. Does not work on streams
that are already open."
{:deprecated "1.2"}
[x]
(binding [*append* true]
(writer x)))
Expand Down Expand Up @@ -312,6 +317,7 @@

(defn ^String slurp*
"Like clojure.core/slurp but opens f with reader."
{:deprecated "1.2"}
[f]
(with-open [^BufferedReader r (reader f)]
(let [sb (StringBuilder.)]
Expand All @@ -324,24 +330,25 @@
(defn spit
"Opposite of slurp. Opens f with writer, writes content, then
closes f."
{:deprecated "1.2"}
[f content]
(with-open [^Writer w (writer f)]
(.write w content)))

(defn append-spit
"Like spit but appends to file."
{:deprecated "1.2"}
[f content]
(with-open [^Writer w (append-writer f)]
(.write w content)))

(defn pwd
"Returns current working directory as a String. (Like UNIX 'pwd'.)
Note: In Java, you cannot change the current working directory."
{:deprecated "1.2"}
[]
(System/getProperty "user.dir"))



(defmacro with-out-writer
"Opens a writer on f, binds it to *out*, and evalutes body.
Anything printed within body will be written to f."
Expand All @@ -352,6 +359,7 @@

(defmacro with-out-append-writer
"Like with-out-writer but appends to file."
{:deprecated "1.2"}
[f & body]
`(with-open [stream# (append-writer ~f)]
(binding [*out* stream#]
Expand All @@ -365,7 +373,8 @@
~@body)))

(defmulti
^{:doc "Copies input to output. Returns nil.
^{:deprecated "1.2"
:doc "Copies input to output. Returns nil.
Input may be an InputStream, Reader, File, byte[], or String.
Output may be an OutputStream, Writer, or File.
Expand Down Expand Up @@ -459,7 +468,6 @@
(defmethod copy [*byte-array-type* File] [^"[B" input ^Writer output]
(copy (ByteArrayInputStream. input) output))


(defn make-parents
"Creates all parent directories of file."
[^File file]
Expand Down Expand Up @@ -494,6 +502,7 @@
(defmulti relative-path-string
"Interpret a String or java.io.File as a relative path string.
Building block for clojure.contrib.java/file."
{:deprecated "1.2"}
class)

(defmethod relative-path-string String [^String s]
Expand All @@ -508,12 +517,14 @@
"Interpret a String or a java.io.File as a File. Building block
for clojure.contrib.java/file, which you should prefer
in most cases."
{:deprecated "1.2"}
class)
(defmethod as-file String [^String s] (File. s))
(defmethod as-file File [f] f)

(defn ^File file
"Returns a java.io.File from string or file args."
{:deprecated "1.2"}
([arg]
(as-file arg))
([parent child]
Expand All @@ -539,8 +550,9 @@ Raise an exception if any deletion fails unless silently is true."
(delete-file f silently)))

(defmulti
^{:doc "Coerces argument (URL, URI, or String) to a java.net.URL."
:arglists '([arg])}
^{:deprecated "1.2"
:doc "Coerces argument (URL, URI, or String) to a java.net.URL."
:arglists '([arg])}
as-url type)

(defmethod as-url URL [x] x)
Expand Down

0 comments on commit b6c6f0f

Please sign in to comment.