Marking as invalid: I don't think this belongs in SBCL as such.
It seems to me that right choices are:
1. Use OSICAT:WITH-TEMPORARY-FILE or OSICAT:OPEN-TEMPORARY-FILE.
2. Roll your own using SBCL interfaces, for example:
(defun open-temporary-file (&key (element-type 'character) (external-format :default)) (multiple-value-bind (fd namestring) (sb-posix:mkstemp "/tmp/XXXXXXXXXXXX") (handler-case (sb-posix:unlink namestring) (error (e) (sb-posix:close fd) (error "Could not unlink created temporary file ~A:~% ~A" namestring e))) (sb-sys:make-fd-stream fd :input t :output t :element-type element-type :external-format external-format :auto-close t)))
(let ((f (open-temporary-file))) (write-line "foo" f) (file-position f :start) (read-line f)) ; => "foo", NIL
-- all the APIs here are public (though SB-SYS:MAKE-FD-STREAM isn't documented yet, unfortunately.)
3. If something like the above is wanted in SBCL, I think it belongs in a higher-level contrib akin to Osicat -- say SB-OSI, or something.
Marking as invalid: I don't think this belongs in SBCL as such.
It seems to me that right choices are:
1. Use OSICAT: WITH-TEMPORARY- FILE or OSICAT: OPEN-TEMPORARY- FILE.
2. Roll your own using SBCL interfaces, for example:
(defun open-temporary-file (&key (element-type 'character) (external-format :default)) value-bind (fd namestring) (sb-posix:mkstemp "/tmp/XXXXXXXXX XXX")
(sb-posix: unlink namestring)
(sb-posix: close fd) sys:make- fd-stream fd
: input t :output t
: element- type element-type
: external- format external-format
: auto-close t)))
(multiple-
(handler-case
(error (e)
(error "Could not unlink created temporary file ~A:~% ~A" namestring e)))
(sb-
(let ((f (open-temporary -file)) )
(write-line "foo" f)
(file-position f :start)
(read-line f)) ; => "foo", NIL
-- all the APIs here are public (though SB-SYS: MAKE-FD- STREAM isn't documented yet, unfortunately.)
3. If something like the above is wanted in SBCL, I think it belongs in a higher-level contrib akin to Osicat -- say SB-OSI, or something.