From 443fcfc494ed940c60d94c70e3391bf3c79c915f Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 22 May 2011 15:30:41 +0100 Subject: [PATCH] safely.lisp: Hacking for CLisp support. CLisp's RENAME-FILE doesn't like it if the target exists. Insert a shim function, and get it to use low-level hacking on CLisp. --- safely.lisp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/safely.lisp b/safely.lisp index 2477f9a..8cd0f9a 100644 --- a/safely.lisp +++ b/safely.lisp @@ -104,6 +104,11 @@ (safely-trail safe)) stream)) +(declaim (inline rename)) +(defun rename (old new) + #-clisp (rename-file old new) + #+clisp (posix:copy-file old new :method :rename)) + (defun delete-file-without-moaning (file) "Delete the FILE, ignoring errors." (handler-case (delete-file file) @@ -112,7 +117,7 @@ (defun rename-file-without-moaning (old new) "Rename OLD to NEW, ignoring errors, and without doing any stupid name mangling." - (handler-case (rename-file old new) + (handler-case (rename old new) (file-error () nil))) (defun safely-unwind (trail) @@ -158,6 +163,14 @@ (and from to (unix-link from to))))) + #+clisp + (generate-fresh-file-name file tag + (lambda (name) + (>= (unix:link (namestring file) + (namestring name)) + 0))) + + #-(or cmu sbcl) ;; Otherwise just copy the file contents and hope for the best. (with-open-file (input file :element-type :default) @@ -207,7 +220,7 @@ (push `(:rmtmp ,old) cleanup) (push `(:revert ,old ,file) revert)) (push `(:rmtmp ,file) revert)) - (rename-file new file))) + (rename new file))) (:delete (destructuring-bind (tag file) job (declare (ignore tag)) (let ((old (safe-copy file "delete"))) -- 2.11.0