[Git][cmucl/cmucl][issue-364-add-mkstemp-mkdtemp] mkdtemp needs to encode/decode Lisp strings
![](https://secure.gravatar.com/avatar/a3ab1b334e0d6f917a672b6a2209db67.jpg?s=120&d=mm&r=g)
Raymond Toy pushed to branch issue-364-add-mkstemp-mkdtemp at cmucl / cmucl Commits: 3d4af597 by Raymond Toy at 2025-01-03T13:35:21-08:00 mkdtemp needs to encode/decode Lisp strings Before calling `mkdtemp`, we need to convert the Lisp string to octets. On return, the octets that were passed to `mkdtemp` have been modified to hold the directory name. These octets need to be converted back to a Lisp string. Tested with the template "/tmp/α-dir-XXXXXX". The result was "/tmp/α-dir-jSt2SC". I verified that this directory was actually created. - - - - - 1 changed file: - src/code/unix.lisp Changes: ===================================== src/code/unix.lisp ===================================== @@ -2932,27 +2932,12 @@ which must have \"XXXXXX\" as the last six characters. The directory is created with permissions 0700. The name of the directory is returned." - (let* ((new-template (copy-seq template)) + (let* ((octets (%name->file template)) (result (alien-funcall (extern-alien "mkdtemp" (function (* char) c-call:c-string)) - new-template))) - (if (zerop (deref result 0)) - (values nil (unix-errno)) - (cast result c-call:c-string)))) - -(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* ((new-template (copy-seq template)) - (result (alien-funcall - (extern-alien "mkdtemp" - (function (* char) - c-call:c-string)) - new-template))) + octets))) (if (zerop (sap-int (alien-sap result))) (values nil (unix-errno)) - (cast result c-string)))) + (%file->name octets)))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/3d4af597c0f7216441996488... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/3d4af597c0f7216441996488... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)