chiark / gitweb /
safely.lisp: CLisp's POSIX:COPY-FILE :METHOD :RENAME is a disaster.
[lisp] / safely.lisp
index 13671a4698df327efcfc59696ff305559e4ca991..9809f07ee5bf87fe257131a66a0012c28b57cf4e 100644 (file)
@@ -112,8 +112,10 @@ (defun safely-open-output-stream (safe file &rest open-args)
 
 (declaim (inline rename))
 (defun rename (old new)
-  #-clisp (rename-file old new)
-  #+clisp (posix:copy-file old new :method :rename))
+  (let ((target (make-pathname :directory '(:relative)
+                              :defaults new)))
+    #-clisp (rename-file old target)
+    #+clisp (rename-file old target :if-exists :overwrite)))
 
 (defun delete-file-without-moaning (file)
   "Delete the FILE, ignoring errors."