From 2b18eb68088715541e217e112871c14316403981 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 23 Mar 2021 10:33:30 -0700 Subject: add WITH-LOCAL-TEMPORARY-DIRECTORY and export some UIOP dir utils Signed-off-by: Sean Whitton --- src/util.lisp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/util.lisp') diff --git a/src/util.lisp b/src/util.lisp index f07e90e..2a0d6d5 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -129,6 +129,15 @@ supported." (doplist (k v plist args) (push (strcat "--" (string-downcase (symbol-name k)) "=" v) args))) +(defmacro with-local-temporary-directory ((dir) &body forms) + "Execute FORMS with a local temporary directory's pathname in DIR. +Currently assumes GNU mktemp(1)." + `(let ((,dir (ensure-directory-pathname + (stripln + (run-program "umask 077; mktemp -d" :output :string))))) + (unwind-protect (progn ,@forms) + (delete-directory-tree ,dir :validate t)))) + ;;;; Progress & debug printing -- cgit v1.2.3