Function: ange-ftp-fix-dir-name-for-cms

ange-ftp-fix-dir-name-for-cms is a byte-compiled function defined in ange-ftp.el.gz.

Signature

(ange-ftp-fix-dir-name-for-cms DIR-NAME)

Source Code

;; Defined in /usr/src/emacs/lisp/net/ange-ftp.el.gz
;; Convert name from UNIX-ish to CMS ready for a DIRectory listing.
(defun ange-ftp-fix-dir-name-for-cms (dir-name)
  (cond
   ((string-equal "/" dir-name)
    (error "Cannot get listing for fictitious \"/\" directory"))
   ((string-match "\\`/\\([-A-Z0-9$*._]+\\)/\\([-A-Z0-9$._]+\\)?\\'" dir-name)
    (let* ((minidisk (match-string 1 dir-name))
	   ;; host and user are bound in the call to ange-ftp-send-cmd
	   (proc (ange-ftp-get-process ange-ftp-this-host ange-ftp-this-user))
	   (cmd (concat "cd " minidisk))
	   (file (if (match-beginning 2)
		     ;; it's a single file
		     (match-string 2 dir-name)
		   ;; use the wild-card
		   "*")))
      (if (car (ange-ftp-raw-send-cmd proc cmd))
	  file
	;; try again...
	(setq proc (ange-ftp-get-process ange-ftp-this-host
					 ange-ftp-this-user))
	(let ((result (ange-ftp-raw-send-cmd proc cmd)))
	  (if (car result)
	      file
	    ;; give up
	    (ange-ftp-error ange-ftp-this-host ange-ftp-this-user
			    (format "cd to minidisk %s failed: %s"
				    minidisk (cdr result))))))))
   (t (error "Invalid CMS file name"))))