I couldn't find an equivalent to "rm -rf" in the JDK, so I wrote these
functions:
(defn delete-file
"Delete file f. Raise an exception if it fails."
[f]
(or (.delete (file f))
(throw (java.io.IOException. (str "Couldn't delete " f)))))
(defn delete-file-recursively
"Delete file f. If it's a directory, recursively delete all its
contents. Raise an exception if any deletion fails."
[f]
(let [f (file f)]
(if (.isDirectory f)
(doseq [child (.listFiles f)]
(delete-file-recursively child)))
(delete-file f)))
This seems like it would be a helpful addition to contrib, since you
have to do this a lot with unit tests that write to disk in order to
clean up after yourself. I can create an issue+patch if others think
this is desirable.
-Phil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---