This module provides some basic file operations. The
implementation is backed by some Java code that delivers some
primitives to access files. The Prolog text invokes
absolute_file_name/[2,3] before accessing these primitives. The
result is that file name resolution and encoding is applied for
these primitives and that they accept URIs.
?- directory_file('file:/C:/Program+Files/Java/', X).
X = 'jdk1.6.0_45' ;
X = 'jdk1.7.0_67' ;
X = 'jdk1.8.0_20' ;
Currently only URIs of protocol “file:” are supported. But future
implementations might support further protocols such as “jar:” or
service based protocols such as Google Drive, DropBox or others.
The realization might depend on the platform, so that the Swing
variant and Android might support different protocols in the
The following file predicates are provided:
- make_name(B, E, N):
- If B or E is a variable then the predicate succeeds when B and
E unify with the base name and the extension respectively of the
file name N. Otherwise the predicates succeeds when N unifies
with the constructed name.
- make_path(D, N, P):
- If D or N is a variable then the predicate succeeds when D and
N unify with the direc-tory and the name respectively of the
path P. Otherwise the predicates succeeds when P unifies with
the constructed path.
- Succeeds when the file F could be deleted.
- rename_file(F, G):
- Succeeds when the file F could be renamed to the file G.
- Succeeds when the file F exists and when it isn't a directory.
- Succeeds when the file F exists and when it is a directory.
- The predicate succeeds when the directory F could be created.
- directory_file(F, N):
- Succeeds whenever N unifies with an entry if the directory F.
- get_time_file(F, T):
- Succeeds when T unifies with the last modified date of the
file F. T is measured in milliseconds since the epoch.
- set_time_file(F, T):
- Succeeds when the last modified date of the file F could be
set to T. T is measured in milliseconds since the epoch but
might be rounded by the system.
- The predicate succeeds when the path P is a relative path.
- follow_path(B, R, A):
- If R is a variable then the predicate succeeds when R unifies
with the relative or abso-lute path that leads from B to A.
Otherwise the predicate succeeds when A unifies with the path
that results from B by following R.
- canonical_path(P, C):
- The predicate succeeds when C unifies with the canonical path