Previous: , Up: Pathnames   [Contents][Index]


15.1.4 Miscellaneous Pathname Procedures

This section gives some standard operations on host objects, and some procedures that return some useful pathnames.

variable: local-host

This variable has as its value the host object that describes the local host’s file system.

procedure: host? object

Returns #t if object is a pathname host; otherwise returns #f.

procedure: host=? host1 host2

Returns #t if host1 and host2 denote the same pathname host; otherwise returns #f.

procedure: init-file-pathname [host]

Returns a pathname for the user’s initialization file on host. The host argument defaults to the value of local-host. If the initialization file does not exist this procedure returns #f.

Under unix, the init file is called .scheme.init; under Windows, the init file is called scheme.ini. In either case, it is located in the user’s home directory, which is computed by user-homedir-pathname.

procedure: user-homedir-pathname [host]

Returns a pathname for the user’s “home directory” on host. The host argument defaults to the value of local-host. The concept of a “home directory” is itself somewhat implementation-dependent, but it should be the place where the user keeps personal files, such as initialization files and mail.

Under unix, the user’s home directory is specified by the HOME environment variable. If this variable is undefined, the user name is computed using the getlogin system call, or if that fails, the getuid system call. The resulting user name is passed to the getpwnam system call to obtain the home directory.

Under Windows, several heuristics are tried to find the user’s home directory. The user’s home directory is computed by examining several environment variables, in the following order:

  • HOMEDRIVE and HOMEPATH are both defined and %HOMEDRIVE%%HOMEPATH% is an existing directory. (These variables are automatically defined by Windows NT.)
  • HOME is defined and %HOME% is an existing directory.
  • USERDIR and USERNAME are defined and %USERDIR%\%USERNAME% is an existing directory.
  • USERDIR and USER are defined and %USERDIR%\%USER% is an existing directory.
  • USERNAME is defined and %USERNAME% is an existing directory on the Windows system drive.
  • USER is defined and %USER% is an existing directory on the Windows system drive.
  • Finally, if all else fails, the Windows system drive is used as the home directory.
procedure: system-library-pathname pathname

Locates pathname in MIT/GNU Scheme’s system library directory. An error of type condition-type:file-operation-error is signalled if pathname cannot be located on the library search path.

(system-library-pathname "compiler.com")
  ⇒ #[pathname 45 "/usr/local/lib/mit-scheme/compiler.com"]
procedure: system-library-directory-pathname pathname

Locates the pathname of an MIT/GNU Scheme system library directory. An error of type condition-type:file-operation-error is signalled if pathname cannot be located on the library search path.

(system-library-directory-pathname "options")
     ⇒ #[pathname 44 "/usr/local/lib/mit-scheme/options/"]

Previous: Operations on Pathnames, Up: Pathnames   [Contents][Index]