Created
May 1, 2013 20:14
-
-
Save ifesdjeen/5498006 to your computer and use it in GitHub Desktop.
Do something within temporary directory
This file contains hidden or 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
(defmacro with-temp-file | |
[f-sym & body] | |
`(let [prefix# (.toString (UUID/randomUUID)) | |
postfix# (.toString (UUID/randomUUID)) | |
~f-sym (java.io.File/createTempFile prefix# postfix#)] | |
(try | |
(do ~@body) | |
(finally | |
(.delete ~f-sym))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment