Function: cedet-file-name-to-directory-name

cedet-file-name-to-directory-name is a byte-compiled function defined in cedet-files.el.gz.

Signature

(cedet-file-name-to-directory-name REFERENCEFILE &optional TESTMODE)

Documentation

Reverse the process of cedet-directory-name-to-file-name.

Convert REFERENCEFILE to a directory name replacing ! with /. Optional TESTMODE is used in tests to avoid doing some platform specific conversions during tests.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/cedet-files.el.gz
(defun cedet-file-name-to-directory-name (referencefile &optional testmode)
  "Reverse the process of `cedet-directory-name-to-file-name'.
Convert REFERENCEFILE to a directory name replacing ! with /.
Optional TESTMODE is used in tests to avoid doing some platform
specific conversions during tests."
  (let ((file referencefile))
    ;; Replace the ! with /
    (setq file (subst-char-in-string ?! ?/ file))
    ;; Occurrences of // meant there was once a single !.
    (setq file (string-replace "//" "!" file))

    ;; Handle Windows special cases
    (when (or (memq system-type '(windows-nt ms-dos)) testmode)

      ;; Handle drive letters from DOSish file names.
      (when (string-match "^/drive_\\([a-z]\\)/" file)
	(let ((driveletter (match-string 1 file))
	      )
	  (setq file (concat driveletter ":"
			     (substring file (match-end 1))))))

      ;; Handle the \\file\name nomenclature on some Windows boxes.
      (when (string-match "^!" file)
	(setq file (concat "//" (substring file 1)))))
    file))