[Git][cmucl/cmucl][issue-373-handle-temp-files] Add with-temporary-file to create a temporary file

Raymond Toy pushed to branch issue-373-handle-temp-files at cmucl / cmucl Commits: 578efc93 by Raymond Toy at 2025-02-17T17:48:37-08:00 Add with-temporary-file to create a temporary file Use mkstemp to create a file and return the file name. On completion, the file is deleted. - - - - - 1 changed file: - src/code/extensions.lisp Changes: ===================================== src/code/extensions.lisp ===================================== @@ -658,6 +658,21 @@ (close ,s) (unix:unix-close ,fd)))))) +;;; WITH-TEMPORARY-FILE -- Public +(defmacro with-temporary-file ((filename) + &parse-body (forms decls)) + (let ((fd (gensym "FD-"))) + `(let (,filename) + (unwind-protect + (let (,fd) + (multiple-value-setq (,fd ,filename) + (unix::unix-mkstemp "/tmp/cmucl-temp-file-XXXXXX")) + (unix:unix-close ,fd) + (locally ,@decls + ,@forms)) + (delete-file ,filename))))) + + ;;; WITH-TEMPORARY-DIRECTORY -- Public (defmacro with-temporary-directory ((dirname template) &parse-body (forms decls)) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/578efc93eb195def77a847a6... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/578efc93eb195def77a847a6... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)