NAMES(2) System Calls Manual NAMES(2)

Names: basename, cleanname, dirname, elements, isprefix, pathname, relative, rooted - file name manipulation

include "names.m";
names := load Names Names->PATH;
basename:  fn(name: string, suffix: string): string;
cleanname: fn(name: string): string;
dirname:   fn(name: string): string;
elements:  fn(name: string): list of string;
isprefix:  fn(a: string, b: string): int;
pathname:  fn(els: list of string): string;
relative:  fn(name: string, root: string): string;
rooted:    fn(root: string, name: string): string;

Names provides operations on file names (path names):

Return the trailing component of name (the text after the final shorn of suffix (which may be null).
Return a `cleaner' version of name: there are no redundant and trailing slashes, and directory names and have been interpreted lexically. If the result would otherwise be the empty string, the name is returned instead.
Return the directory component of name: the string up to but not including the final slash(es).
Return a list of the path elements of name: the words between slashes. If name starts with a the head of the list will be the string "/" but otherwise slashes do not appear.
Return a path name formed from a list of elements as produced by elements.
Return true iff path name a is a prefix of path name b.
If name is root/X for some X, return X; otherwise return name unchanged.
Return the path name for name relative to a given root directory (either name may be nil). If name itself starts with or the result is name; otherwise it is root/name.

See sys-intro (2) for details of file name syntax and its interpretation.

/appl/lib/names.b

sys-intro (2), sys-fd2path (2), workdir (2)