X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/lisp/blobdiff_plain/5e04ac396871d9b15a4cbcdb7de9084b650176f0..287fd2e6b9ff8d33434595d8e6b6b61fc4a7f9cc:/safely.lisp diff --git a/safely.lisp b/safely.lisp index 5eddef3..c78492a 100644 --- a/safely.lisp +++ b/safely.lisp @@ -67,14 +67,16 @@ (defun safely-open-output-stream (safe file &rest open-args) (defun delete-file-without-moaning (file) "Delete the FILE, ignoring errors." - (when (probe-file file) - (unix-try unlink file))) + (with-errno-handlers () + (sys-unlink file) + (ENOENT nil))) (defun rename-file-without-moaning (old new) "Rename OLD to NEW, ignoring errors, and without doing any stupid name mangling." - (when (probe-file old) - (unix-try rename old new))) + (with-errno-handlers () + (sys-rename old new) + (ENOENT nil))) (defun safely-unwind (trail) "Roll back the TRAIL of operations." @@ -131,11 +133,11 @@ (defun safely-commit (safe) (copy-file file old) (push `(:revert ,old ,file) revert)) (push `(:rmtmp ,file) revert)) - (unix-try rename new file))) + (sys-rename new file))) (:delete (destructuring-bind (tag file old) job (declare (ignore tag)) (push `(:revert ,old ,file) revert) - (unix-try rename file old) + (sys-rename file old) (push `(:rmtmp old) cleanup)))))) (setf revert nil)) (safely-unwind trail)