cl-rw

Layered streams for Common Lisp
git clone https://logand.com/git/cl-rw.git/
Log | Files | Refs

commit e03abfde2ac5800dff931f921ef5dda7470ea7a5
parent 65fa35fde63b362ec099e886cfe1c6cd4794eaad
Author: Tomas Hlavaty <tom@logand.com>
Date:   Thu, 24 Oct 2013 01:11:08 +0200

make-temporary-file added

Diffstat:
Mos.lisp | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/os.lisp b/os.lisp @@ -23,6 +23,7 @@ (defpackage :rw.os (:use :cl) (:export :make-program + :make-temporary-file :run-command :sha1sum :with-program-output @@ -168,8 +169,16 @@ ;;(sha1sum "/etc/passwd") ;;(sha1sum "/etc/passwd2") -(defmacro with-temporary-file ((var) &body body) - `(let ((,var (with-program-output (s "mktemp" nil) - (read-line s)))) +(defun make-temporary-file (&key directoryp template) + (with-program-output (s "mktemp" (append (when directoryp '("-d")) + (when template (list template)))) + (read-line s))) + +;;(make-temporary-file) +;;(make-temporary-file :directoryp t) +;;(make-temporary-file :template "/tmp/hi-XXXXX.log") + +(defmacro with-temporary-file ((var &key directoryp template) &body body) + `(let ((,var (make-temporary-file :directoryp directoryp :template template))) (unwind-protect (progn ,@body) (delete-file ,var))))