Provides a natural way to handle temponary files and directories in Clojure. For more info see clojure-cookbook
with-tempfile
can be useful for packaging .dll
or .dylib
into jar, because JNA
can read them only from filesystem.
;; (:require [tempfile.core :refer [tempdir tempfile with-tempfile])
(def text "some string")
;; writes stringified args to tempfile and returns java.io.File
(tempfile "some" text)
;; creates tempdir and returns java.io.File
(tempdir)
;; uses a tempfile for some scope and
;; deletes it immediately afterwards
(with-tempfile [t (tempfile text)] ;; with a tempfile
(pprint (.exists t))) ;; "true"
(with-tempfile [t (tempdir)] ;; now with a temponary directory
(pprint (.exists t))) ;; "true"
Copyright © 2014 Vlad Bokov
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.