diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-23 10:33:30 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-23 12:11:08 -0700 |
commit | 2b18eb68088715541e217e112871c14316403981 (patch) | |
tree | 6b09de1ef75f7e20c174e1ed333f7e6de4276b43 /src/util.lisp | |
parent | f775cbadd2139d64fc58ca2d4ec2060841d8971a (diff) | |
download | consfigurator-2b18eb68088715541e217e112871c14316403981.tar.gz |
add WITH-LOCAL-TEMPORARY-DIRECTORY and export some UIOP dir utils
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r-- | src/util.lisp | 9 |
1 files changed, 9 insertions, 0 deletions
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 |