diff options
-rw-r--r-- | utilities.lisp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utilities.lisp b/utilities.lisp index fb684d4..9fe3dc2 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -74,4 +74,21 @@ (nth m list) tmp) list)) +(defmacro -> (&body body) + "Anaphoric lambda of one argument" + `(lambda (it) + (declare (ignorable it)) + ,@body)) +(defun tmp-dir-name () + (merge-pathnames + (format nil "~a/" (gensym "tmpdir")) + (uiop:temporary-directory))) + +(defmacro with-temp-dir ((dir) &body body) + "Create temporary directory and bind its full path name to the variable DIR" + `(let ((,dir (tmp-dir-name))) + (ensure-directories-exist ,dir) + (unwind-protect + (progn ,@body) + (uiop:delete-directory-tree ,dir :validate t)))) |