guix-commits
[Top][All Lists]
Advanced

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

05/14: build: syscalls: Add mkdtemp!


From: David Thompson
Subject: 05/14: build: syscalls: Add mkdtemp!
Date: Tue, 30 Jun 2015 01:54:06 +0000

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

commit a06507d635a5d8aba948630f8771959852517f63
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 61877bf..d877a12 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:
 ;;;
@@ -644,4 +646,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]