diff options
author | Richard M. Stallman <rms@gnu.org> | 1993-06-12 01:44:48 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1993-06-12 01:44:48 +0000 |
commit | c3bf10c278bee183f267d9593a892021b89bc5e2 (patch) | |
tree | 2629348a267cfcaeb417c6ccda4e1261a979add6 /lisp/files.el | |
parent | a135645ac27ba7bc6e143e26852e99ab8708c848 (diff) | |
download | emacs-c3bf10c278bee183f267d9593a892021b89bc5e2.tar.gz |
(file-truename): Don't use expand-file-name to merge
a link target into the previous dir. Handle .. and . explicitly.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lisp/files.el b/lisp/files.el index c31b75e1ce6..96cc510a61c 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -329,16 +329,25 @@ containing it, until no links are left at any level." ;; 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))))) + (if (equal ".." (file-name-nondirectory filename)) + (directory-file-name (file-name-directory (directory-file-name dir))) + (if (equal "." (file-name-nondirectory filename)) + (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. + ;; We can't safely use expand-file-name here + ;; since target might look like foo/../bar where foo + ;; is itself a link. Instead, we handle . and .. above. + (if (file-name-absolute-p target) + (file-truename target) + (file-truename (concat dir target))) + ;; No, we are done! + filename))))))) (defun file-chase-links (filename) "Chase links in FILENAME until a name that is not a link. |