Comment 5 for bug 406271

Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

I would be inclined to go with something like this:

(defun delete-file (file)
  #!+sb-doc
  "Delete the specified FILE.

If FILE is a stream, on Windows the stream is closed immediately. On Unix
plaforms the stream remains open, allowing IO to continue: the resources
associated with the deleted file remain available till the stream is closed as
per standard Unix unlink() behaviour."
  (let* ((truename (truename file))
         (namestring (native-namestring truename :as-file t)))
    #!+win32
    (when (streamp file)
      (close file))
    (multiple-value-bind (res err) (sb!unix:unix-unlink namestring)
      (unless res
        (simple-file-perror "couldn't delete ~A" namestring err))))
  t)