Function: ange-ftp-fix-name-for-vms

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

Signature

(ange-ftp-fix-name-for-vms NAME &optional REVERSE)

Source Code

;; Defined in /usr/src/emacs/lisp/net/ange-ftp.el.gz
;;;; ------------------------------------------------------------
;;;; VMS support.
;;;; ------------------------------------------------------------

;; Convert NAME from UNIX-ish to VMS.  If REVERSE given then convert from VMS
;; to UNIX-ish.
(defun ange-ftp-fix-name-for-vms (name &optional reverse)
  (save-match-data
    (if reverse
	(if (string-match "\\`\\([^:]+:\\)?\\(\\[.*\\]\\)?\\([^][]*\\)\\'" name)
	    (let (drive dir file)
	      (setq drive (match-string 1 name))
	      (setq dir (match-string 2 name))
	      (setq file (match-string 3 name))
	      (and dir
		   (setq dir (subst-char-in-string
                              ?/ ?. (substring dir 1 -1) t)))
	      (concat (and drive
			   (concat "/" drive "/"))
		      dir (and dir "/")
		      file))
          (error "Name %s didn't match" name))
      (let (drive dir file tmp quote)
	(if (string-match "\\`\".+\"\\'" name)
	    (setq name (substring name 1 -1)
		  quote "\"")
	  (setq quote ""))
	(if (string-match "\\`/[^:]+:/" name)
	    (setq drive (substring name 1
				   (1- (match-end 0)))
		  name (substring name (match-end 0))))
	(setq tmp (file-name-directory name))
	(if tmp
	    (setq dir (subst-char-in-string ?/ ?. (substring tmp 0 -1) t)))
	(setq file (file-name-nondirectory name))
	(concat quote drive
		(and dir (concat "[" (if drive nil ".") dir "]"))
		file quote)))))