- make-pathfinder paths #!key matcher test rootprocedure
Construct a pathfinder object with search path PATHS. PATHS is a list of absolute or relative pathnames; if relative, they are relative to the pathfinder ROOT.
Keyword ROOT specifies the root of this pathfinder and defaults to the current directory. ROOT specifies both the base for relative PATHS, and the base for absolute search terms (see path-find). ROOT itself can be absolute or relative; if relative, it is relative to the current directory at the time the object is created.
Keyword MATCHER specifies a pathfinder matcher for this object, and defaults to (pathfinder-default-matcher), usually the exact filename matcher pf:exact. This becomes the default matcher for this pathfinder object, and can be overridden later in path-find.
Keyword TEST specifies a pathfinder test for this object, and defaults to (pathfinder-default-test), usually pf:regular-file?. This becomes the default test for this pathfinder object, and can be overridden later in path-find. To avoid filtering, use the test pf:any?.
;; unix path search, exact filename match (define pu (make-pathfinder (string-split (get-environment-variable "PATH") ":"))) (path-find pu "csi") ; => "/usr/local/bin/csi" (path-find pu "bash") ; => "/bin/bash" ;; windows path search, using filepath egg; extension match (use filepath) (define pw (make-pathfinder (filepath:get-search-path) matcher: (pf:extensions '(".com" ".exe" ".bat")))) (path-find pw "csi") ; => "X:\\chicken4\\bin\\csi.exe" (path-find pw "command") ; => "c:\\windows\\system32\\command.com"