xref: /inferno-os/man/2/names (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
NAMES 2
NAME
Names: basename, cleanname, dirname, elements, isprefix, pathname, relative, rooted - file name manipulation
SYNOPSIS
.EX 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;
DESCRIPTION
Names provides operations on file names (path names): .TF cleanname

basename Return the trailing component of name (the text after the final .LR / ), shorn of suffix (which may be null).

cleanname Return a `cleaner' version of name : there are no redundant and trailing slashes, and directory names .L . and .L .. have been interpreted lexically. If the result would otherwise be the empty string, the name .L . is returned instead.

dirname Return the directory component of name : the string up to but not including the final slash(es).

elements Return a list of the path elements of name : the words between slashes. If name starts with a .LR / , the head of the list will be the string \f5"/" but otherwise slashes do not appear.

pathname Return a path name formed from a list of elements as produced by elements .

isprefix Return true iff path name a is a prefix of path name b .

relative If name is root / X for some X , return X ; otherwise return name unchanged.

rooted Return the path name for name relative to a given root directory (either name may be nil). If name itself starts with .L / or .LR # , the result is name ; otherwise it is root / name.

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

SOURCE
/appl/lib/names.b
SEE ALSO
sys-intro (2), sys-fd2path (2), workdir (2)