X-Git-Url: https://git.distorted.org.uk/~mdw/lisp/blobdiff_plain/ad8995ca2397db9b5d9e1d3357d5e1a6730fdfe4..bf0a8c394bdf34895ad53771665f70c3b80e272e:/safely.lisp diff --git a/safely.lisp b/safely.lisp index f62420c..abb2fb2 100644 --- a/safely.lisp +++ b/safely.lisp @@ -23,12 +23,12 @@ ;;; along with this program; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -(defpackage #:mdw.safely +(defpackage #:safely (:use #:common-lisp #:mdw.base #:mdw.unix) (:export #:safely #:safely-close #:safely-delete-file #:safely-open-output-stream #:safely-bail #:safely-commit #:safely-writing)) -(in-package #:mdw.safely) +(in-package #:safely) (defstruct (safely (:predicate safelyp)) "Stores information about how to commit or undo safe writes." @@ -67,14 +67,16 @@ Other OPEN-ARGS are passed to open." (defun delete-file-without-moaning (file) "Delete the FILE, ignoring errors." - (when (probe-file file) - (sys-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) - (sys-rename old new))) + (with-errno-handlers () + (sys-rename old new) + (ENOENT nil))) (defun safely-unwind (trail) "Roll back the TRAIL of operations."