Raymond Toy pushed to branch master at cmucl / cmucl Commits: 9ea51cb2 by Raymond Toy at 2025-01-28T14:14:09+00:00 Fix #364: Add interface to mkstemp and mkdtemp - - - - - 98961a8b by Raymond Toy at 2025-01-28T14:14:10+00:00 Merge branch 'issue-364-add-mkstemp-mkdtemp' into 'master' Fix #364: Add interface to mkstemp and mkdtemp Closes #364 See merge request cmucl/cmucl!260 - - - - - 1 changed file: - src/code/unix.lisp Changes: ===================================== src/code/unix.lisp ===================================== @@ -2900,3 +2900,32 @@ (extern-alien "os_get_locale_codeset" (function (* char)))) c-string)) + +(defun unix-mkstemp (template) + _N"Generates a unique temporary file name from TEMPLATE, and creates + and opens the file. On success, the corresponding file descriptor + and name of the file is returned. + + The last six characters of the template must be \"XXXXXX\"." + ;; Hope this buffer is large enough! + (let ((octets (%name->file template))) + (syscall ("mkstemp" c-call:c-string) + (values result + ;; Convert the file name back to a Lisp string. + (%file->name octets)) + octets))) + +(defun unix-mkdtemp (template) + _N"Generate a uniquely named temporary directory from Template, + which must have \"XXXXXX\" as the last six characters. The + directory is created with permissions 0700. The name of the + directory is returned." + (let* ((octets (%name->file template)) + (result (alien-funcall + (extern-alien "mkdtemp" + (function (* char) + c-call:c-string)) + octets))) + (if (null-alien result) + (values nil (unix-errno)) + (%file->name octets)))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/fbe6f2d65cf23592a74ec51... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/fbe6f2d65cf23592a74ec51... You're receiving this email because of your account on gitlab.common-lisp.net.