commit 325318efb57fb60a7d134c9e95843c6ce14ca586
parent b9430d02d40ae3aa73e09bc0486e28dba23562ec
Author: Tomas Hlavaty <tom@logand.com>
Date:   Fri, 20 Sep 2013 00:32:05 +0200
added rw.os:with-temporary-file
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/os.lisp b/os.lisp
@@ -25,7 +25,8 @@
   (:export :make-program
            :run-command
            :sha1sum
-           :with-program-output))
+           :with-program-output
+           :with-temporary-file))
 
 (in-package :rw.os)
 
@@ -162,3 +163,9 @@
 
 ;;(sha1sum "/etc/passwd")
 ;;(sha1sum "/etc/passwd2")
+
+(defmacro with-temporary-file ((var) &body body)
+  `(let ((,var (with-program-output (s "mktemp" nil)
+                 (read-line s))))
+     (unwind-protect (progn ,@body)
+       (delete-file ,var))))