Function: hpath:exists-p
hpath:exists-p is a byte-compiled function defined in hpath.el.
Signature
(hpath:exists-p PATH &optional SUFFIX-FLAG)
Documentation
Return PATH if it exists. (This does not mean you can read it).
If PATH exists with or without a suffix from hpath:suffixes, then that pathname is returned.
With optional SUFFIX-FLAG and PATH exists, return suffix added or removed from path or t.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:exists-p (path &optional suffix-flag)
"Return PATH if it exists. (This does not mean you can read it).
If PATH exists with or without a suffix from hpath:suffixes, then that
pathname is returned.
With optional SUFFIX-FLAG and PATH exists, return suffix added or removed
from path or t."
(setq path (hpath:expand path))
(let ((return-path)
(suffix) suffixes)
(if (file-exists-p path)
(setq return-path path)
(setq suffixes hpath:suffixes)
(while suffixes
(setq suffix (car suffixes))
(if (string-match (concat (regexp-quote suffix) "\\'") path)
;; Remove suffix
(setq return-path (substring path 0 (match-beginning 0)))
;; Add suffix
(setq return-path (concat path suffix)))
(if (file-exists-p return-path)
(setq suffixes nil) ;; found a match
(setq suffix nil
suffixes (cdr suffixes)
return-path nil))))
(if return-path
(if suffix-flag
(or suffix t)
return-path))))