Raymond Toy pushed to branch issue-364-add-mkstemp-mkdtemp at cmucl / cmucl
Commits: 2ea25988 by Raymond Toy at 2025-01-01T14:17:46-08:00 Error out if mkstemp fails
If `mkstemp` can't create a temp file, signal an error about it.
- - - - -
1 changed file:
- src/code/extensions.lisp
Changes:
===================================== src/code/extensions.lisp ===================================== @@ -637,29 +637,34 @@ :decoding-error - How to handle decoding errors. See OPEN :encoding-error - How to handle encoding errors. See OPEN" (let ((abortp (gensym)) - (template (gensym "TEMPLATE-"))) + (template (gensym "TEMPLATE-")) + (fd (gensym "FD-")))
`(let* ((,template (concatenate 'string ,template-prefix "XXXXXX")) - (,var (lisp::make-fd-stream (unix::unix-mkstemp ,template) - :auto-close t - :file ,template - :output t - :input t - :element-type ',element-type - :external-format ,external-format - :decoding-error ,decoding-error - :encoding-error ,encoding-error - :buffering ,buffering)) - (,abortp t)) - ,@decls - (unwind-protect - (multiple-value-prog1 - (progn ,@forms) - (setq ,abortp nil)) - (when ,var - (close ,var :abort ,abortp)))))) + (,fd (unix::unix-mkstemp ,template))) + (unless ,fd + (error "Could not create temporary file using template ~A" + ,template)) + (let ((,var (lisp::make-fd-stream (unix::unix-mkstemp ,template) + :auto-close t + :file ,template + :output t + :input t + :element-type ',element-type + :external-format ,external-format + :decoding-error ,decoding-error + :encoding-error ,encoding-error + :buffering ,buffering)) + (,abortp t)) + ,@decls + (unwind-protect + (multiple-value-prog1 + (progn ,@forms) + (setq ,abortp nil)) + (when ,var + (close ,var :abort ,abortp)))))))
;; WITH-TEMPORARY-DIRECTORY -- Public (defmacro with-temporary-directory ((var template-prefix)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/2ea25988f79909ada0f02069...