From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:56060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHU8b-0004aq-Qq for guix-patches@gnu.org; Fri, 19 Apr 2019 10:05:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHU8a-0005x0-CY for guix-patches@gnu.org; Fri, 19 Apr 2019 10:05:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hHU8X-0005oT-Cv for guix-patches@gnu.org; Fri, 19 Apr 2019 10:05:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hHU8X-0002SP-6b for guix-patches@gnu.org; Fri, 19 Apr 2019 10:05:05 -0400 Subject: [bug#34638] [PATCH v2 1/4] utils: Add #:base-directory to call-with-temporary-directory. References: <875zt9go87.fsf@cbaines.net> In-Reply-To: <875zt9go87.fsf@cbaines.net> Resent-Message-ID: From: Christopher Baines Date: Fri, 19 Apr 2019 15:04:24 +0100 Message-Id: <20190419140427.15183-1-mail@cbaines.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 34638@debbugs.gnu.org This allows more easily creating temporary directories within a specific directory. This is motivated by using this in inferior-eval-with-store. * guix/utils.scm (call-with-temporary-directory): Add optional keyword argument, base-directory. --- guix/utils.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guix/utils.scm b/guix/utils.scm index ed1a418cca..abeb156f40 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -620,10 +620,10 @@ call." (false-if-exception (close out)) (false-if-exception (delete-file template)))))) -(define (call-with-temporary-directory proc) +(define* (call-with-temporary-directory proc #:key base-directory) "Call PROC with a name of a temporary directory; close the directory and delete it when leaving the dynamic extent of this call." - (let* ((directory (or (getenv "TMPDIR") "/tmp")) + (let* ((directory (or base-directory (getenv "TMPDIR") "/tmp")) (template (string-append directory "/guix-directory.XXXXXX")) (tmp-dir (mkdtemp! template))) (dynamic-wind -- 2.21.0