12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- (defun cedet-directory-name-to-file-name (referencedir &optional testmode)
- "Convert the REFERENCEDIR (a full path name) into a filename.
- Convert directory separation characters into ! characters.
- Optional argument TESTMODE is used by tests to avoid conversion
- to the file's truename, and dodging platform tricks."
- (let ((file referencedir))
-
- (when (not testmode)
- (setq file (file-truename file)))
-
- (when (file-directory-p file)
- (setq file (file-name-as-directory file)))
-
- (when (or (memq system-type '(windows-nt ms-dos)) testmode)
-
-
- (when (not testmode)
- (setq file (expand-file-name (convert-standard-filename file))))
-
- (if (eq (aref file 1) ?:)
- (setq file (concat "/"
- "drive_"
- (char-to-string (downcase (aref file 0)))
- (if (eq (aref file 2) ?/)
- ""
- "/")
- (substring file 2)))))
-
-
-
- (setq file (subst-char-in-string
- ?/ ?!
- (replace-regexp-in-string "!" "!!" file)))
- file))
- (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))
-
- (setq file (subst-char-in-string ?! ?/ file))
-
- (setq file (replace-regexp-in-string "//" "!" file))
-
- (when (or (memq system-type '(windows-nt ms-dos)) testmode)
-
- (when (string-match "^/drive_\\([a-z]\\)/" file)
- (let ((driveletter (match-string 1 file))
- )
- (setq file (concat driveletter ":"
- (substring file (match-end 1))))))
-
- (when (string-match "^!" file)
- (setq file (concat "//" (substring file 1)))))
- file))
- (provide 'cedet-files)
|