diff options
author | David Thompson <davet@gnu.org> | 2015-06-24 20:50:34 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-07-07 18:46:44 -0400 |
commit | b4abdeb63b4e29f89a0a8e54f7b442bb31da87c9 (patch) | |
tree | 31b46689ab9160a91c635a4ec248c4b0334e55fc /guix | |
parent | b16d138a0af44740894ecd42eca4d71fd74aea1a (diff) |
build: syscalls: Add mkdtemp!
* guix/build/syscalls.scm (mkdtemp!): New procedure.
* tests/syscalls.scm ("mkdtemp!"): New test.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/build/syscalls.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 6d3151051b..a464040e56 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -45,6 +45,7 @@ swapon swapoff processes + mkdtemp! IFF_UP IFF_BROADCAST @@ -265,6 +266,20 @@ user-land process." (scandir "/proc")) <)) +(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!" "~S: ~A" + (list tmpl (strerror err)) + (list err))) + (pointer->string result))))) + ;;; ;;; Packed structures. |