Function: tramp-archive-file-name-handler

tramp-archive-file-name-handler is an autoloaded and byte-compiled function defined in tramp-archive.el.gz.

Signature

(tramp-archive-file-name-handler OPERATION &rest ARGS)

Documentation

Invoke the file archive related OPERATION.

First arg specifies the OPERATION, second arg ARGS is a list of arguments to pass to the OPERATION.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-archive.el.gz
;;;###tramp-autoload
(defun tramp-archive-file-name-handler (operation &rest args)
  "Invoke the file archive related OPERATION.
First arg specifies the OPERATION, second arg ARGS is a list of
arguments to pass to the OPERATION."
    (if (not tramp-archive-enabled)
        ;; Unregister `tramp-archive-file-name-handler'.
        (progn
          (tramp-register-file-name-handlers)
          (tramp-archive-run-real-handler operation args))

      (let* ((filename (apply #'tramp-archive-file-name-for-operation
			      operation args))
	     (archive (tramp-archive-file-name-archive filename))
	     ;; Sometimes, it fails with "Variable binding depth exceeds
	     ;; max-specpdl-size".  Shall be fixed in Emacs 27.
	     (max-specpdl-size (* 2 max-specpdl-size)))

        ;; `filename' could be a quoted file name.  Or the file
        ;; archive could be a directory, see Bug#30293.
        (if (or (null archive)
                (not (tramp-archive-run-real-handler
                      #'file-exists-p (list archive)))
                (tramp-archive-run-real-handler
                 #'file-directory-p (list archive)))
            (tramp-archive-run-real-handler operation args)
	  ;; The default directory of the Tramp connection buffer
	  ;; cannot be accessed.  (Bug#56628)
	  ;; FIXME: It is superfluous to set it every single loop.
	  ;; But there is no place to set it when creating the buffer.
	  (with-current-buffer
	      (tramp-get-buffer (tramp-archive-dissect-file-name filename))
	    (setq default-directory (file-name-as-directory archive)))
          ;; Now run the handler.
          (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods))
                (tramp-gvfs-methods tramp-archive-all-gvfs-methods)
                ;; Set uid and gid.  gvfsd-archive could do it, but it doesn't.
                (tramp-unknown-id-integer (user-uid))
                (tramp-unknown-id-string (user-login-name))
                (fn (assoc operation tramp-archive-file-name-handler-alist)))
	    (when (eq (cdr fn) #'tramp-archive-handle-not-implemented)
	      (setq args (cons operation args)))
	    (if fn
                (save-match-data (apply (cdr fn) args))
	      (tramp-archive-run-real-handler operation args)))))))