Computes a pathname relative to the current path.
lispworks
current-pathname &optional relative-pathname type => pathname
| relative-pathname⇩ |
A pathname designator. |
| type⇩ |
A string or nil. |
| pathname⇩ |
A pathname. |
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 | Uses *load-pathname*. |
| When compiling a file | Uses *compile-file-pathname*. |
| 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.
defsystem uses current-pathname with its :default-host argument.
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))
LispWorks® User Guide and Reference Manual - 18 Feb 2025 15:32:27