guix-commits
[Top][All Lists]
Advanced

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

04/11: build: syscalls: Add mkdtemp!


From: David Thompson
Subject: 04/11: build: syscalls: Add mkdtemp!
Date: Thu, 25 Jun 2015 01:48:12 +0000

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

commit ad3145e4cd47e7731395f15a054e58dca97f3521
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 |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index 72a91a5..0d4d37e 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -62,7 +62,9 @@
             set-network-interface-flags
             set-network-interface-address
             set-network-interface-up
-            configure-network-interface))
+            configure-network-interface
+
+            mkdtemp!))
 
 ;;; Commentary:
 ;;;
@@ -630,4 +632,18 @@ the same type as that returned by 'make-socket-address'."
       (lambda ()
         (close-port sock)))))
 
-;;; syscalls.scm ends here
+(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 her



reply via email to

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