Function: hpath:validate
hpath:validate is a byte-compiled function defined in hpath.el.
Signature
(hpath:validate PATH)
Documentation
Validate PATH is readable and return it in Posix format.
Signal an error if not validated. Info and remote pathnames are considered readable without any validation checks.
Default-directory should be equal to the current Hyperbole button source directory when called, so that PATH is expanded relative to it.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:validate (path)
"Validate PATH is readable and return it in Posix format.
Signal an error if not validated.
Info and remote pathnames are considered readable without any
validation checks.
Default-directory should be equal to the current Hyperbole button
source directory when called, so that PATH is expanded relative
to it."
(unless (stringp path)
(error "(hpath:validate): \"%s\" is not a pathname" path))
(setq path (hpath:mswindows-to-posix path))
(if (file-readable-p path)
path
(let* ((suffix-start (cl-position ?# path))
(path-only (substring path 0 suffix-start))
(suffix (when suffix-start (substring path suffix-start))))
;; `suffix-start' may be nil, so don't use `zerop' or `=' in next line
(cond ((equal suffix-start 0) ;; all suffix, nothing to validate
path)
((or (string-match "[()]" path-only) (hpath:remote-p path-only))
;; info or remote path, so don't validate
path)
((unless (hpath:www-p path-only)
;; Otherwise, must not be a WWW link ref and must be a readable path.
(let ((return-path (hpath:exists-p path-only)))
(and return-path (file-readable-p return-path)
(concat return-path suffix)))))
(t (error "(hpath:validate): \"%s\" is not a readable path" path))))))