All Manuals > LispWorks® User Guide and Reference Manual > 38 The LISPWORKS Package

current-pathname Function

Summary

Computes a pathname relative to the current path.

Package

lispworks

Signature

current-pathname &optional relative-pathname type => pathname

Arguments
relative-pathname
A pathname designator.
type
A string or nil.
Values
pathname
A pathname.
Description

The function current-pathname is useful for loading other files relative to a file.

current-pathname computes a pathname from the current operation as follows:

When loading a file
When compiling a file
When evaluating or compiling an Editor buffer

Uses the pathname of the buffer, if available, otherwise uses the current working directory.

Otherwise

Uses the current working directory.

The pathname computed above is then translated to a physical pathname, and the argument relative-pathname is merged with this physical pathname. The pathname-type of the result pathname is set to type if supplied, the pathname-version is set to :newest, and pathname is returned.

A useful value for type is nil, which can be used to allow load to choose between lisp or fasl regardless of the type of the current pathname.

Notes

defsystem uses current-pathname with its :default-host argument.

Examples

Suppose you want the file foo to load the file bar.

While loading the source file foo.lisp:

(current-pathname "bar")
=>
#P"C:/temp/bar.lisp"

While loading the binary file foo.ofasl:

(current-pathname "bar")
=>
#P"C:/temp/bar.ofasl"

To load bar.lisp or bar.ofasl according to the value of *load-fasl-or-lisp-file*, regardless of whether foo.lisp or foo.ofasl is being loaded, specify type nil:

(load (current-pathname "bar" nil))
See also

defsystem
pathname-location


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:41