safely: For -without-moaning functions, just do it and catch errors.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 11 Apr 2006 17:05:37 +0000 (18:05 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 11 Apr 2006 17:09:20 +0000 (18:09 +0100)
... rather than probing first and hoping for the best.

safely.lisp

index f62420c..c78492a 100644 (file)
@@ -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."