aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2003-04-09 01:34:38 +0000
committerRichard M. Stallman2003-04-09 01:34:38 +0000
commit302fcc98cca3da57c2ed856188ee3165fe8e1981 (patch)
tree4b7f5877ee43797917aa267c8165a29ec1edb082
parent7963c455646b0c0e8946bfaed549b11c86415a20 (diff)
downloademacs-302fcc98cca3da57c2ed856188ee3165fe8e1981.tar.gz
emacs-302fcc98cca3da57c2ed856188ee3165fe8e1981.zip
(file-chase-links): New arg LIMIT.
After that many iterations, just return what we've got.
-rw-r--r--lisp/files.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 97a1a490627..1d8cc2aa45e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -738,14 +738,19 @@ Do not specify them in other calls."
738 (setq done t)))))))) 738 (setq done t))))))))
739 filename)) 739 filename))
740 740
741(defun file-chase-links (filename) 741(defun file-chase-links (filename &optional limit)
742 "Chase links in FILENAME until a name that is not a link. 742 "Chase links in FILENAME until a name that is not a link.
743Does not examine containing directories for links, 743Unlike `file-truename', this does not check whether a parent
744unlike `file-truename'." 744directory name is a symbolic link.
745 (let (tem (count 100) (newname filename)) 745If the optional argument LIMIT is a number,
746 (while (setq tem (file-symlink-p newname)) 746it means chase no more than that many links and then stop."
747 (let (tem (newname filename)
748 (count 0)
749 (max (max limit 100)))
750 (while (and (or (null limit) (< count limit))
751 (setq tem (file-symlink-p newname)))
747 (save-match-data 752 (save-match-data
748 (if (= count 0) 753 (if (= count max)
749 (error "Apparent cycle of symbolic links for %s" filename)) 754 (error "Apparent cycle of symbolic links for %s" filename))
750 ;; In the context of a link, `//' doesn't mean what Emacs thinks. 755 ;; In the context of a link, `//' doesn't mean what Emacs thinks.
751 (while (string-match "//+" tem) 756 (while (string-match "//+" tem)