- Documentation
- Reference manual
- Built-in Predicates
- File System Interaction
- access_file/2
- exists_file/1
- file_directory_name/2
- file_base_name/2
- same_file/2
- exists_directory/1
- delete_file/1
- rename_file/2
- size_file/2
- time_file/2
- absolute_file_name/2
- absolute_file_name/3
- is_absolute_file_name/1
- file_name_extension/3
- directory_files/2
- expand_file_name/2
- prolog_to_os_filename/2
- read_link/3
- tmp_file/2
- tmp_file_stream/3
- make_directory/1
- delete_directory/1
- working_directory/2
- chdir/1
- File System Interaction
- Built-in Predicates
- Packages
- Reference manual
Availability:built-in
(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. This predicate only returns
non-directories, unless the option
file_type(directory)
is specified or the requested access
is none
. Supported Options are:
- extensions(ListOfExtensions)
- List of file extensions to try. Default is exam['']. 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 plainext
. - relative_to(+FileOrDir)
- Resolve the path relative to the given directory or the directory holding the given file. Without this option, paths are resolved relative to the working directory (see working_directory/2) or, if Spec is atomic and absolute_file_name/[2,3] is executed in a directive, it uses the current source file as reference.
- access(Mode)
- Imposes the condition access_file(File, Mode). Mode
is one of
read
,write
,append
,execute
,search
,exist
ornone
. See also access_file/2. The default isnone
which, iffile_type
is not specified asdirectory
orregular
, returns absolute file names that result from expanding aliases without inspecting the actual file system. - file_type(Type)
- Defines extensions. Current mapping:
txt
implies['']
,prolog
implies['.pl',’’]
,executable
implies['.so',’’]
andqlf
implies['.qlf',’’]
. The Typedirectory
implies['']
and causes this predicate to generate (only) directories. The Typeregular
is the opposite ofdirectory
and is the default if no file type is specified and the effective access mode isnone
.The file type
source
is an alias forprolog
for compatibility with SICStus Prolog. See also prolog_file_type/2. - file_errors(fail/error)
- If
error
(default), throw anexistence_error
exception if the file cannot be found. Iffail
, stay silent.158Silent operation was the default up to version 3.2.6. - solutions(first/all)
- If
first
(default), the predicate leaves no choice point. Otherwise a choice point will be left and backtracking may yield more solutions. - expand(Boolean)
- If
true
(default isfalse
) 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.