Function: tramp-barf-if-file-missing

tramp-barf-if-file-missing is a macro defined in tramp.el.gz.

Signature

(tramp-barf-if-file-missing VEC FILENAME &rest BODY)

Documentation

Execute BODY and return the result.

In case of an error, raise a file-missing error if FILENAME does not exist, otherwise propagate the error.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
;; This macro shall optimize the cases where a `file-exists-p' call is
;; invoked first.  Often, the file exists, so the remote command is
;; superfluous.
(defmacro tramp-barf-if-file-missing (vec filename &rest body)
  "Execute BODY and return the result.
In case of an error, raise a `file-missing' error if FILENAME
does not exist, otherwise propagate the error."
  (declare (indent 2) (debug (tramp-file-name-p form &rest body)))
  (let ((err (make-symbol "err")))
    `(condition-case ,err
	 (let (signal-hook-function) ,@body)
       (error
	(if (not (or (file-exists-p ,filename) (file-symlink-p ,filename)))
	    (when (tramp-connectable-p ,vec)
	      (tramp-error ,vec 'file-missing ,filename))
	  (signal (car ,err) (cdr ,err)))))))