guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

05/13: build: syscalls: Add mkdtemp!


From: David Thompson
Subject: 05/13: build: syscalls: Add mkdtemp!
Date: Fri, 26 Jun 2015 00:27:33 +0000

davexunit pushed a commit to branch wip-container
in repository guix.

commit 542b36c5b79fb6d92afb47471a23b2e91b5088b7
Author: David Thompson <address@hidden>
Date:   Wed Jun 24 20:50:34 2015 -0400

    build: syscalls: Add mkdtemp!
    
    * guix/build/syscalls.scm (mkdtemp!): New procedure.
---
 guix/build/syscalls.scm |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index f89cf7e..b6e60c9 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -66,7 +66,9 @@
             set-network-interface-flags
             set-network-interface-address
             set-network-interface-up
-            configure-network-interface))
+            configure-network-interface
+
+            mkdtemp!))
 
 ;;; Commentary:
 ;;;
@@ -639,4 +641,18 @@ the same type as that returned by 'make-socket-address'."
       (lambda ()
         (close-port sock)))))
 
+(define mkdtemp!
+  (let* ((ptr  (dynamic-func "mkdtemp" (dynamic-link)))
+         (proc (pointer->procedure '* ptr '(*))))
+    (lambda (tmpl)
+      "Create a new unique directory in the file system using the template
+string TMPL and return its file name.  TMPL must end with 'XXXXXX'."
+      (let ((result (proc (string->pointer tmpl)))
+            (err    (errno)))
+        (when (null-pointer? result)
+          (throw 'system-error "mkdtemp!" "mkdtemp ~S: ~A"
+                 (list tmpl (strerror err))
+                 (list err)))
+        (pointer->string result)))))
+
 ;;; syscalls.scm ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]