Next: , Previous: , Up: Universal SLIB Procedures   [Contents][Index]

2.1 Vicinity

A vicinity is a descriptor for a place in the file system. Vicinities hide from the programmer the concepts of host, volume, directory, and version. Vicinities express only the concept of a file environment where a file name can be resolved to a file in a system independent manner. Vicinities can even be used on flat file systems (which have no directory structure) by having the vicinity express constraints on the file name.

All of these procedures are file-system dependent. Use of these vicinity procedures can make programs file-system independent.

These procedures are provided by all implementations. On most systems a vicinity is a string.

Function: make-vicinity dirpath

Returns dirpath as a vicinity for use as first argument to in-vicinity.

Function: pathname->vicinity path

Returns the vicinity containing path.

(pathname->vicinity "/usr/local/lib/scm/Link.scm")
                    ⇒ "/usr/local/lib/scm/"
Function: program-vicinity

Returns the vicinity of the currently loading Scheme code. For an interpreter this would be the directory containing source code. For a compiled system (with multiple files) this would be the directory where the object or executable files are. If no file is currently loading, then the result is undefined. Warning: program-vicinity can return incorrect values if your program escapes back into a load continuation.

Function: library-vicinity

Returns the vicinity of the shared Scheme library.

Function: implementation-vicinity

Returns the vicinity of the underlying Scheme implementation. This vicinity will likely contain startup code and messages and a compiler.

Function: user-vicinity

Returns the vicinity of the current directory of the user. On most systems this is "" (the empty string).

Function: home-vicinity

Returns the vicinity of the user’s HOME directory, the directory which typically contains files which customize a computer environment for a user. If scheme is running without a user (eg. a daemon) or if this concept is meaningless for the platform, then home-vicinity returns #f.

Function: vicinity:suffix? chr

Returns the ‘#t’ if chr is a vicinity suffix character; and #f otherwise. Typical vicinity suffixes are ‘/’, ‘:’, and ‘\’,

Function: in-vicinity vicinity filename

Returns a filename suitable for use by slib:load, slib:load-source, slib:load-compiled, open-input-file, open-output-file, etc. The returned filename is filename in vicinity. in-vicinity should allow filename to override vicinity when filename is an absolute pathname and vicinity is equal to the value of (user-vicinity). The behavior of in-vicinity when filename is absolute and vicinity is not equal to the value of (user-vicinity) is unspecified. For most systems in-vicinity can be string-append.

Function: sub-vicinity vicinity name

Returns the vicinity of vicinity restricted to name. This is used for large systems where names of files in subsystems could conflict. On systems with directory structure sub-vicinity will return a pathname of the subdirectory name of vicinity.

Function: with-load-pathname path thunk

path should be a string naming a file being read or loaded. with-load-pathname evaluates thunk in a dynamic scope where an internal variable is bound to path; the internal variable is used for messages and program-vicinity. with-load-pathname returns the value returned by thunk.

Next: , Previous: , Up: Universal SLIB Procedures   [Contents][Index]