#tif pathname1 is equivalent to pathname2; otherwise returns
#f. Pathnames are equivalent if all of their components are equivalent, hence two pathnames that are equivalent must identify the same file or equivalent partial pathnames. However, the converse is not true: non-equivalent pathnames may specify the same file (e.g. via absolute and relative directory components), and pathnames that specify no file at all (e.g. name and directory components unspecified) may be equivalent.
#tif pathname is an absolute rather than relative pathname object; otherwise returns
#f. Specifically, this procedure returns
#twhen the directory component of pathname is a list starting with the symbol
absolute, and returns
#fin all other cases. All pathnames are either absolute or relative, so if this procedure returns
#f, the argument is a relative pathname.
#tif pathname has only directory components and no file components. This is roughly equivalent to(define (directory-pathname? pathname) (string-null? (file-namestring pathname)))
except that it is faster.
#tif pathname contains any wildcard components; otherwise returns
The pathnames are combined by components: if pathname has a non-missing component, that is the resulting component, otherwise the component from defaults is used. The default version can be
#fto preserve the information that the component was missing from pathname. The directory component is handled specially: if both pathnames have directory components that are lists, and the directory component from pathname is relative (i.e. starts with
relative), then the resulting directory component is formed by appending pathname's component to defaults's component. For example:(define path1 (->pathname "scheme/foo.scm")) (define path2 (->pathname "/usr/morris")) path1 => #[pathname 74 "scheme/foo.scm"] path2 => #[pathname 75 "/usr/morris"] (merge-pathnames path1 path2) => #[pathname 76 "/usr/scheme/foo.scm"] (merge-pathnames path2 path1) => #[pathname 77 "/usr/morris.scm"]
The merging rules for the version are more complex and depend on whether pathname specifies a name. If pathname does not specify a name, then the version, if not provided, will come from defaults. However, if pathname does specify a name then the version is not affected by defaults. The reason is that the version “belongs to” some other file name and is unlikely to have anything to do with the new one. Finally, if this process leaves the version missing, then default-version is used.
The net effect is that if the user supplies just a name, then the host, device, directory and type will come from defaults, but the version will come from default-version. If the user supplies nothing, or just a directory, the name, type and version will come over from defaults together.
This procedure defaults all of the components of pathname simultaneously. It could have been defined by:(define (pathname-default pathname device directory name type version) (make-pathname (pathname-host pathname) (or (pathname-device pathname) device) (or (pathname-directory pathname) directory) (or (pathname-name pathname) name) (or (pathname-type pathname) type) (or (pathname-version pathname) version)))
These procedures return a string corresponding to a subset of the pathname information.
file-namestringreturns a string representing just the name, type and version components of pathname; the result of
directory-namestringrepresents just the host, device, and directory components; and
host-namestringreturns a string for just the host portion.
enough-namestringtakes another argument, defaults. It returns an abbreviated namestring that is just sufficient to identify the file named by pathname when considered relative to the defaults (which defaults to
*default-pathname-defaults*).(file-namestring "/usr/morris/minor.van") => "minor.van" (directory-namestring "/usr/morris/minor.van") => "/usr/morris/" (enough-namestring "/usr/morris/men") => "men" ;perhaps
These procedures return a pathname corresponding to a subset of the pathname information.
file-pathnamereturns a pathname with just the name, type and version components of pathname. The result of
directory-pathnameis a pathname containing the host, device and directory components of pathname.
enough-pathnametakes another argument, defaults. It returns an abbreviated pathname that is just sufficient to identify the file named by pathname when considered relative to the defaults (which defaults to
These procedures are similar to
enough-namestring, but they return pathnames instead of strings.
Returns a pathname that is equivalent to pathname, but in which the directory component is represented as a file. The last directory is removed from the directory component and converted into name and type components. This is the inverse operation to
pathname-as-directory.(directory-pathname-as-file (->pathname "/usr/blisp/")) => #[pathname "/usr/blisp"]
Returns a pathname that is equivalent to pathname, but in which any file components have been converted to a directory component. If pathname does not have name, type, or version components, it is returned without modification. Otherwise, these file components are converted into a string, and the string is added to the end of the list of directory components. This is the inverse operation to
directory-pathname-as-file.(pathname-as-directory (->pathname "/usr/blisp/rel5")) => #[pathname "/usr/blisp/rel5/"]