Next: ref-fdi-syn, Up: ref-fdi [Contents][Index]
• ref-fdi-fsp-def | Defining File Search Paths | |
• ref-fdi-fsp-ffs | Frequently Used File Specifications | |
• ref-fdi-fsp-pre | Predefined File Search Paths |
As a convenience for the developer and as a means for extended portability of the final application, SICStus Prolog provides a flexible mechanism to localize the definitions of the system dependent parts of the file and directory structure a program relies on, in such a way that the application can be moved to a different directory hierarchy or to a completely new file system, with a minimum of effort.
This mechanism, which can be seen as a generalization of the
user:library_directory/1
scheme available in previous releases, presents
two main features:
The directory aliasing mechanism, together with the additional file search
capabilities of absolute_file_name/3
, can effectively serve
as an intermediate layer between the external world and a portable program.
For instance, the developer can hide
the directory representation by defining directory aliases, and he can
automatically get a proper file extension added, dependent on the type
of file he wants to access, by using the appropriate options to
absolute_file_name/3
.
A number of directory aliases and file search paths, are predefined in
the SICStus Prolog system.
The most important of those is the library
file search path,
giving the user instant access to the SICStus library, consisting of
several sub-directories and extensive supported programs and tools.
Specifying a library file, using the alias, is possible simply by replacing the explicit file (and directory) specification with the following term:
library(file)
The name of the file search path, in this case library
, is
the main functor
of the term, and indicates that file is to be found in one of the
library directories.
The association between the alias library
(the name of the
search path) and the library directories (the definitions of the
search path), is extended by Prolog facts,
user:library_directory/1
, which are searched in sequence to
locate the file. Each of these facts specifies a directory where to
search for file, whenever a file specification of the form
library(file)
is encountered.
The library mechanism discussed above, which can be extended with
new directories associated with the alias library
, has become
subsumed by a more general aliasing mechanism,
in which arbitrary names can be used as aliases for directories. The
general mechanism also gives the possibility of defining
path aliases in terms of already defined aliases.
In addition to library
, the following aliases are predefined in
SICStus Prolog: runtime
, system
,
application
, temp
, and path
. The interpretation of the predefined aliases are
explained below.