Mercurial > emacs
changeset 1453:fb2d16111e4b
(file-truename): Check for root by seeing if
directory-file-name returns same as DIR.
Look for a file-truename handler for the file name.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 20 Oct 1992 06:39:24 +0000 |
parents | ed79bb8047e8 |
children | 035c3f9fa12f |
files | lisp/files.el |
diffstat | 1 files changed, 29 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/files.el Tue Oct 20 06:13:00 1992 +0000 +++ b/lisp/files.el Tue Oct 20 06:39:24 1992 +0000 @@ -270,21 +270,35 @@ containing it, until no links are left at any level." (if (string= filename "~") (setq filename (expand-file-name filename))) - (let ((dir (file-name-directory filename)) - target) - ;; Get the truename of the directory. - (or (string= dir "/") - (setq dir (file-name-as-directory (file-truename (directory-file-name dir))))) - ;; Put it back on the file name. - (setq filename (concat dir (file-name-nondirectory filename))) - ;; Is the file name the name of a link? - (setq target (file-symlink-p filename)) - (if target - ;; Yes => chase that link, then start all over - ;; since the link may point to a directory name that uses links. - (file-truename (expand-file-name target dir)) - ;; No, we are done! - filename))) + (let (handler (handlers file-name-handler-alist)) + (save-match-data + (while (and (consp handlers) (null handler)) + (if (and (consp (car handlers)) + (stringp (car (car handlers))) + (string-match (car (car handlers)) filename)) + (setq handler (cdr (car handlers)))) + (setq handlers (cdr handlers)))) + ;; For file name that has a special handler, call handler. + ;; This is so that ange-ftp can save time by doing a no-op. + (if handler + (funcall handler 'file-truename filename) + (let ((dir (file-name-directory filename)) + target dirfile) + ;; Get the truename of the directory. + (setq dirfile (directory-file-name dir)) + ;; If these are equal, we have the (or a) root directory. + (or (string= dir dirfile) + (setq dir (file-name-as-directory (file-truename dirfile)))) + ;; Put it back on the file name. + (setq filename (concat dir (file-name-nondirectory filename))) + ;; Is the file name the name of a link? + (setq target (file-symlink-p filename)) + (if target + ;; Yes => chase that link, then start all over + ;; since the link may point to a directory name that uses links. + (file-truename (expand-file-name target dir)) + ;; No, we are done! + filename))))) (defun switch-to-buffer-other-window (buffer) "Select buffer BUFFER in another window."