[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.6.2 Pathname utilities

Function: build-path base-path component ...
Appends pathname components component to the base-path. Component can be a symbol up or same; in Unix, they are synonym to ".." and ".". This API is taken from MzScheme.

Function: absolute-path? path
Function: relative-path? path
Returns #t if path is absolute or relative, respectively.

Function: expand-path path
Expands tilda-notation of path if it contains one. Otherwise, path is returned. This function does not check if path exists and/or readable.

Function: resolve-path path
Expands path like expand-path, then resolve symbolic links for every components of the path. If path does not exist, or contains dangling link, or contains unreadable directory, an error is signalled.

Function: simplify-path path
Remove 'up' ("..") components and 'same' (".") components from path as much as possible. This function does not access the filesystem.

Function: find-file-in-paths name &keyword paths pred
Looks for a file that has name name in the given list of pathnames paths and that satisfies a predicate pred. If found, the absolute pathname of the file is returned. Otherwise, #f is returned.

If name is an absolute path, only the existence of name and whether it satisfies pred are checked.

The default value of paths is taken from the environment variable PATH, and the default value of pred is file-is-executable? (See section 11.6.3 File attibute utilities). That is, find-file-in-paths searches the named executable file in the command search paths by default.

 
(find-file-in-paths "ls")
  => "/bin/ls"

;; example of searchin user preference file of my application
(find-file-in-paths "userpref"
  :paths `(,(expand-path "~/.myapp")
           "/usr/local/share/myapp"
           "/usr/share/myapp")
  :pred  file-is-readable?)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html