absolute_file_name(+Spec,
-Absolute, +Options)(library(lists)), a
relative filename or an absolute filename. The primary intention of this
predicate is to resolve files specified as Alias(Relative), which use
file_search_path/2
to look up the possibilities for Alias. With the default options no file
system check is performed and the alias-resolved path is returned as is;
in particular, it may name a directory. To require a non-directory pass file_type(regular),
file_type(prolog), or an access(Mode) other
than
none. Pass file_type(directory) to look up
directories. For example, when the library holds both a chr.pl
file and a
chr directory, absolute_file_name(library(chr), F)
resolves to the directory, while
absolute_file_name(library(chr), F, [file_type(prolog)])
resolves to chr.pl. The result always uses the directory
separator /; if the operating system uses
something different, SWI-Prolog converts the file name before it makes
an OS call. If you need the filename in the OS's preferred form, use prolog_to_os_filename/2.
Supported Options are:
[’’].
For each extension, absolute_file_name/3
will first add the extension and then verify the conditions imposed by
the other options. If the condition fails, the next extension on the
list is tried. Extensions may be specified both as .ext or
plain ext.Up to version 9.3.9, the system tried both the directory holding the current source and the current working directory.
read, write, append, execute,
search, exist or none. See also access_file/2.
The default is none which, if file_type is not
specified as directory or regular, returns
absolute file names that result from expanding aliases without
inspecting the actual file system.txt implies [’’],
prolog implies [’.pl’,’’], executable
implies
[’.so’,’’] and qlf
implies [’.qlf’,’’]. The
Type directory implies [’’]
and causes this predicate to generate (only) directories. The Type regular
is the opposite of directory and is the default if no file
type is specified and the requested access is not none.
Since the default access is none, file_type(regular)
is
not implied by default; see the introduction above.
The file type source is an alias for prolog
for compatibility with SICStus Prolog. See also prolog_file_type/2.
error (default), throw an existence_error
exception if the file cannot be found. If fail, stay
silent.160Silent operation was the
default up to version 3.2.6.first (default), the predicate leaves no choice point.
Otherwise a choice point will be left and backtracking may yield more
solutions.true (default is false) and Spec
is atomic, call expand_file_name/2
followed by member/2
on Spec before proceeding. This is a SWI-Prolog extension
intended to minimise porting effort after SWI-Prolog stopped expanding
environment variables and the ~ by default.
This option should be considered deprecated. In particular the use of wildcard
patterns such as * should be avoided.
The Prolog flag verbose_file_search
can be set to true to help debugging Prolog's search for
files. See also file_search_path/2.
This predicate is derived from Quintus Prolog. In Quintus Prolog, the
argument order was absolute_file_name(+Spec, +Options, -Path).
The argument order has been changed for compatibility with ISO and
SICStus. The Quintus argument order is still accepted.