Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
-
9ea51cb2
by Raymond Toy at 2025-01-28T14:14:09+00:00
-
98961a8b
by Raymond Toy at 2025-01-28T14:14:10+00:00
1 changed file:
Changes:
... | ... | @@ -2900,3 +2900,32 @@ |
2900 | 2900 | (extern-alien "os_get_locale_codeset"
|
2901 | 2901 | (function (* char))))
|
2902 | 2902 | c-string))
|
2903 | + |
|
2904 | +(defun unix-mkstemp (template)
|
|
2905 | + _N"Generates a unique temporary file name from TEMPLATE, and creates
|
|
2906 | + and opens the file. On success, the corresponding file descriptor
|
|
2907 | + and name of the file is returned.
|
|
2908 | + |
|
2909 | + The last six characters of the template must be \"XXXXXX\"."
|
|
2910 | + ;; Hope this buffer is large enough!
|
|
2911 | + (let ((octets (%name->file template)))
|
|
2912 | + (syscall ("mkstemp" c-call:c-string)
|
|
2913 | + (values result
|
|
2914 | + ;; Convert the file name back to a Lisp string.
|
|
2915 | + (%file->name octets))
|
|
2916 | + octets)))
|
|
2917 | + |
|
2918 | +(defun unix-mkdtemp (template)
|
|
2919 | + _N"Generate a uniquely named temporary directory from Template,
|
|
2920 | + which must have \"XXXXXX\" as the last six characters. The
|
|
2921 | + directory is created with permissions 0700. The name of the
|
|
2922 | + directory is returned."
|
|
2923 | + (let* ((octets (%name->file template))
|
|
2924 | + (result (alien-funcall
|
|
2925 | + (extern-alien "mkdtemp"
|
|
2926 | + (function (* char)
|
|
2927 | + c-call:c-string))
|
|
2928 | + octets)))
|
|
2929 | + (if (null-alien result)
|
|
2930 | + (values nil (unix-errno))
|
|
2931 | + (%file->name octets)))) |