Mercurial > emacs
comparison lisp/files.el @ 1406:62dae4a3c7fb
* files.el (file-truename): The variable ~ should be considered an
absolute pathname; handle it correctly. Concatenate the directory
onto the filename in the correct order.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 14 Oct 1992 16:45:31 +0000 |
parents | f6f838c4a26e |
children | fb2d16111e4b |
comparison
equal
deleted
inserted
replaced
1405:45d463eff0b3 | 1406:62dae4a3c7fb |
---|---|
266 (defun file-truename (filename) | 266 (defun file-truename (filename) |
267 "Return the truename of FILENAME, which should be absolute. | 267 "Return the truename of FILENAME, which should be absolute. |
268 The truename of a file name is found by chasing symbolic links | 268 The truename of a file name is found by chasing symbolic links |
269 both at the level of the file and at the level of the directories | 269 both at the level of the file and at the level of the directories |
270 containing it, until no links are left at any level." | 270 containing it, until no links are left at any level." |
271 (if (string= filename "~") | |
272 (setq filename (expand-file-name filename))) | |
271 (let ((dir (file-name-directory filename)) | 273 (let ((dir (file-name-directory filename)) |
272 target) | 274 target) |
273 ;; Get the truename of the directory. | 275 ;; Get the truename of the directory. |
274 (or (string= dir "/") | 276 (or (string= dir "/") |
275 (setq dir (file-name-as-directory (file-truename (directory-file-name dir))))) | 277 (setq dir (file-name-as-directory (file-truename (directory-file-name dir))))) |
276 ;; Put it back on the file name. | 278 ;; Put it back on the file name. |
277 (setq filename (concat (file-name-nondirectory filename) dir)) | 279 (setq filename (concat dir (file-name-nondirectory filename))) |
278 ;; Is the file name the name of a link? | 280 ;; Is the file name the name of a link? |
279 (setq target (file-symlink-p filename)) | 281 (setq target (file-symlink-p filename)) |
280 (if target | 282 (if target |
281 ;; Yes => chase that link, then start all over | 283 ;; Yes => chase that link, then start all over |
282 ;; since the link may point to a directory name that uses links. | 284 ;; since the link may point to a directory name that uses links. |