Function: ange-ftp-expand-dir

ange-ftp-expand-dir is a byte-compiled function defined in ange-ftp.el.gz.

Signature

(ange-ftp-expand-dir HOST USER DIR)

Documentation

Return the result of doing a PWD in the current FTP session.

Use the connection to machine HOST logged in as user USER and cd'd to directory DIR.

Source Code

;; Defined in /usr/src/emacs/lisp/net/ange-ftp.el.gz
;;; ------------------------------------------------------------
;;; expand-file-name and friends...which currently don't work
;;; ------------------------------------------------------------

(defun ange-ftp-expand-dir (host user dir)
  "Return the result of doing a PWD in the current FTP session.
Use the connection to machine HOST
logged in as user USER and cd'd to directory DIR."
  (let* ((host-type (ange-ftp-host-type host user))
	 ;; It is more efficient to call ange-ftp-host-type
	 ;; before binding res, because ange-ftp-host-type sometimes
	 ;; adds to the info in the expand-dir-hashtable.
	 (fix-name-func
	  (cdr (assq host-type ange-ftp-fix-name-func-alist)))
	 (key (concat host "/" user "/" dir))
	 (res (gethash key ange-ftp-expand-dir-hashtable)))
    (or res
	(progn
	  (or
	   (string-equal user "anonymous")
	   (string-equal user "ftp")
	   (not (eq host-type 'unix))
	   (let* ((ange-ftp-good-msgs (concat ange-ftp-expand-dir-regexp
					      "\\|"
					      ange-ftp-good-msgs))
		  (result (ange-ftp-send-cmd host user
					     (list 'get dir null-device)
					     (format "expanding %s" dir)))
		  (line (cdr result)))
	     (setq res
		   (if (string-match ange-ftp-expand-dir-regexp line)
		       (match-string 1 line)))))
	  (or res
	      (if (string-equal dir "~")
		  (setq res (car (ange-ftp-get-pwd host user)))
		(let ((home (ange-ftp-expand-dir host user "~")))
		  (unwind-protect
		      (and (ange-ftp-cd host user dir)
			   (setq res (car (ange-ftp-get-pwd host user))))
		    (ange-ftp-cd host user home)))))
	  (if res
	      (let ((ange-ftp-this-user user)
		    (ange-ftp-this-host host))
		(if fix-name-func
		    (setq res (funcall fix-name-func res 'reverse)))
		(puthash key res ange-ftp-expand-dir-hashtable)))
	  res))))