:- multifile user:file_search_path/2.
Defines a symbolic name for a directory or a path. Used by predicates taking file_spec as input argument.
An atom that represents the path given by DirSpec.
Either an atom giving the path to
a file or directory, or PathAlias(DirSpec), where PathAlias is
defined by another
file_search_path mechanism provides an extensible way of
specifying a sequence of directories to search to locate a file. For
instance, if a filename is given as a structure term,
library(between). The principle functor of the term,
is taken to be another
file_search_path/2 definition of the form
between is assumed to be relative to the path given by
LibPath may also be another structure term, in which case another
file_search_path/2 fact gives its definition. The search continues
until the path is resolved to an atom.
There may also be several definitions for the same PathAlias. Certain
predicates, such as
search all these definitions until the path resolves to an existing file.
There are several predefined search paths, such as
These are tried before the user-defined ones.
The predicate is undefined at startup, but behaves as if it were a
multifile predicate with the following
clauses. The system properties
SP_RT_DIR expand respectively to the absolute path of the
directory that contains the executable and the directory that contains
the SICStus runtime (see System Properties and Environment Variables),
SP_TEMP_DIR expand to a directory suitable for
storing temporary files.
file_search_path(library, Path) :- library_directory(Path). file_search_path(system, Platform) :- prolog_flag(host_type, Platform). file_search_path(application, '$SP_APP_DIR'). file_search_path(runtime, '$SP_RT_DIR'). file_search_path(temp, '$SP_TEMP_DIR'). file_search_path(path, Dir) :- … backtracks through the $PATH environment variable …
| ?- [user]. % compiling user... | :- multifile user:file_search_path/2. | user:file_search_path(home, '/usr/joe_bob'). | user:file_search_path(review, home('movie/review')). | end_of_file. % compiled user in module user, 0 msec 768 bytes yes | ?- compile(review(blob)). % compiling /usr/joe_bob/movie/review/blob.pl
All error handling is done by the predicates extended by this hook.
System Properties and Environment Variables.