Skip to content

Instantly share code, notes, and snippets.

@lukaszkorecki
Created February 15, 2017 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszkorecki/f179bf0783e795256d97b18dc7ec4793 to your computer and use it in GitHub Desktop.
Save lukaszkorecki/f179bf0783e795256d97b18dc7ec4793 to your computer and use it in GitHub Desktop.
(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