Function: tramp-handle-access-file

tramp-handle-access-file is a byte-compiled function defined in tramp.el.gz.

Signature

(tramp-handle-access-file FILENAME STRING)

Documentation

Like access-file for Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-handle-access-file (filename string)
  "Like `access-file' for Tramp files."
  (let ((timeout
	 ;; This variable exists since Emacs 30.1.
	 (bound-and-true-p remote-file-name-access-timeout))
	(v (tramp-dissect-file-name
	    (if (file-name-absolute-p filename) filename default-directory)))
	;; We rely on timers, so don't suspend them.
	(tramp-dont-suspend-timers t))
    (with-tramp-timeout
	(timeout
	 (unless (and (not non-essential) (tramp-connectable-p v))
	   (tramp-cleanup-connection v 'keep-debug 'keep-password))
	 (tramp-error
	  v 'file-error
	  (format
	   "%s: Timeout %s second(s) accessing %s" string timeout filename)))
      (setq filename (file-truename filename))
      (if (file-exists-p filename)
	  (unless
	      (funcall
	       (if (file-directory-p filename)
		   #'file-accessible-directory-p #'file-readable-p)
	       filename)
	    (tramp-compat-permission-denied
	     v (format "%s: Permission denied, %s" string filename)))
	(tramp-error
	 v 'file-missing
	 (format "%s: No such file or directory, %s" string filename))))))