Resolves an include against the local filesystem.
Search order
- the directory of the including file, when there is one;
:root, or$TPTP_ROOTif the option is absent;$TPTP, the older variable the TPTP tools have always used;:cwd, or the current working directory.
$TPTP_ROOT is the documented environment variable and :root is the local
override, so that a caller directing resolution at a vendored copy, a fixture
directory or a second library need not set an environment variable for the whole
VM.
Tptp.Unit.from_file("PUZ001+1.p", resolver: Tptp.Resolver.Fs)
Tptp.Unit.from_file("PUZ001+1.p", resolver: {Tptp.Resolver.Fs, root: "/opt/TPTP"}):root takes a list too, tried in order, for a caller layering a local override
over a shared library:
{Tptp.Resolver.Fs, root: ["priv/my_axioms", "/opt/TPTP"]}:root does not suppress $TPTP or the working directory; it is inserted ahead
of them. To search only the named directories, pass cwd: false and leave the
environment variables unset, or use Tptp.Resolver.Map.
$TPTP is honoured after :root because a machine with the TPTP distribution
installed usually already has it set, and failing to find Axioms/SET007+0.ax on
such a machine would be a silly way to lose.
Confinement
An include name originates in a file that may not be trusted, so it must be a
relative path that does not ascend; see Tptp.Resolver.safe?/1. The name is
checked rather than the joined result, which makes the condition independent of
the candidate directory: no absolute paths and no .., in any position.
Canonicalisation
The returned path is expanded, so two routes to one file — Axioms/a.ax from the
root and a.ax from the Axioms directory — memoise to the same entry and a
diamond in the include graph is read once.
Summary
Functions
The directories this resolver would look in, in order.