Created
February 15, 2017 19:39
-
-
Save lukaszkorecki/f179bf0783e795256d97b18dc7ec4793 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
(defn create-tmp-file | |
"Create tmp file. Return path to the file! | |
Note file is deleted when JVM terminates" | |
[prefix suffix] | |
(let [file (File/createTempFile prefix suffix)] | |
(.deleteOnExit file) | |
(.getPath file))) | |
(defn create-tmp-directory | |
"Create tmp directory. | |
Note directory is deleted when JVM terminates | |
(directory needs to be empty)!" | |
[name] | |
(let [dir (Files/createTempDirectory | |
name | |
(into-array FileAttribute [])) | |
dir (.toFile dir)] | |
(.deleteOnExit dir) | |
dir)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment