Did you know ... Search Documentation:
file_systems.pl -- SICStus 4 library(file_systems).
PublicShow source
See also
- https://sicstus.sics.se/sicstus/docs/4.6.0/html/sicstus.html/lib_002dfile_005fsystems.html
To be done
- This library is incomplete. As of SICStus 4.6.0, the following predicates are missing:
close_all_streams/0
Some predicates don't fully support all options available on SICStus. See the documentation for individual predicates for details.

The file access modes execute and search are interpreted slightly differently on SICStus and SWI. On SWI, execute and search are equivalent - both can be used with regular files and directories and will check execute or search permission depending on the file type, not the mode atom.

SICStus on the other hand checks the access modes only if the file in question has the appropriate type. Checking access mode execute on a directory or search on a regular file is equivalent to checking exist.

This difference affects not just file_exists/2 and directory_exists/2 in this library, but also the built-in absolute_file_name/3 with the option access(Mode).

On the other hand, file_property/2 and directory_property/2 with properties executable and searchable are not affected - here the emulation matches the native SICStus behavior.

Source rename_file(+OldName, +NewName) is det
Like SWI's built-in rename_file/2, but only works on regular files. To rename directories, rename_directory/2 must be used.
Source rename_directory(+OldName, +NewName) is det
Like SWI's built-in rename_file/2, but only works on directories. To rename regular files, rename_file/2 must be used.
Source delete_file(+OldName) is det
Like SWI's built-in delete_file/1, but only works on regular files. To delete directories, delete_directory/1 must be used.
Source delete_directory(+OldName, +Options) is semidet
Extended verison of delete_directory/1. The only available option is if_nonempty(Value), which controls the behavior when OldName is not empty. Value may be ignore (silently succeed without deleting anything), fail (silently fail without deleting anything), error (throw an error - default behavior), and delete (recursively delete the directory and its contents, as if by delete_directory_and_contents/1 from library(filesex)).
Source directory_exists(+Directory) is semidet
Source directory_exists(+Directory, +Mode) is semidet
True if a directory exists at path Directory and can be accessed according to Mode (defaults to exist). Accepts the same access modes as absolute_file_name/3's access option.
Source file_exists(+File) is semidet
Source file_exists(+File, +Mode) is semidet
True if a regular file exists at path File and can be accessed according to Mode (defaults to exist). Accepts the same access modes as absolute_file_name/3's access option.
Source file_must_exist(+File) is det
Source file_must_exist(+File, +Mode) is det
Ensure that a regular file exists at path File and can be accessed according to Mode (defaults to exist). Otherwise an exception is thrown. Accepts the same access modes as absolute_file_name/3's access option.
Source directory_must_exist(+Directory) is det
Source directory_must_exist(+Directory, +Mode) is det
Ensure that a directory exists at path Directory and can be accessed according to Mode (defaults to exist). Otherwise an exception is thrown. Accepts the same access modes as absolute_file_name/3's access option.
Source directory_member_of_directory(-BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
Source file_member_of_directory(-BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
True if Directory contains a directory or regular file (respectively) named BaseName and the file's absolute path is FullName. If Directory is not given, it defaults to the current working directory. If Pattern is given, only succeeds if BaseName also matches that glob pattern.

These predicates enumerate all matching files on backtracking. This is also the intended usage pattern. For checking if a specific file/directory exists, or to get its absolute path, it's better to use file_exists/1, directory_exists/1, or absolute_file_name/3.

Source directory_members_of_directory(-Set) is det
Source directory_members_of_directory(+Directory, -Set) is det
Source directory_members_of_directory(+Directory, +Pattern, -Set) is det
Source file_members_of_directory(-Set) is det
Source file_members_of_directory(+Directory, -Set) is det
Source file_members_of_directory(+Directory, +Pattern, -Set) is det
Unifies Set with a set of BaseName-FullName entries for all directories or regular files (respectively) in Directory. If Directory is not given, it defaults to the current working directory. If Pattern is given, Set only includes entries where BaseName matches that glob pattern.
Source file_property(+Path, ?Property) is semidet
Source file_property(+Path, ?Property, -Value) is semidet
Source directory_property(+Path, ?Property) is semidet
Source directory_property(+Path, ?Property, -Value) is semidet
True if a regular file or directory (respectively) exists at Path and it has the given property and value. Property may be unbound to backtrack over all available properties. If the Value parameter is omitted, succeeds if Property has value true.

The following properties are currently supported:

create_timestamp
modify_timestamp
access_timestamp
The file/directory's creation/modification/access time as a Unix timestamp (as returned by SWI's set_time_file/3).
create_localtime
modify_localtime
access_localtime
The file/directory's creation/modification/access time as a datime/6 term (as returned by datime/2 from SICStus library(system)).
readable
writable
executable
searchable
true or false depending on whether the file/directory is readable/writable/executable/searchable. executable is only supported on regular files and searchable only on directories.
size_in_bytes
The file's size in bytes. Not supported on directories.

On Unix systems, create_timestamp/create_localtime don't return the file's actual creation time, but rather its "ctime" or "metadata change time". This matches the behavior of SICStus 4.6.0.

As of SICStus 4.6.0, the following properties are not yet emulated:

set_user_id
set_group_id
save_text
who_can_read
who_can_write
who_can_execute
who_can_search
owner_user_id
owner_group_id
owner_user_name
owner_group_name
Source current_directory(-Directory) is det
Source current_directory(-Directory, +NewDirectory) is det
Unifies Directory with the current working directory path. In the 2-argument form, also changes the working directory to the path NewDirectory.

Re-exported predicates

The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.

Source directory_exists(+Directory) is semidet
Source directory_exists(+Directory, +Mode) is semidet
True if a directory exists at path Directory and can be accessed according to Mode (defaults to exist). Accepts the same access modes as absolute_file_name/3's access option.
Source file_exists(+File) is semidet
Source file_exists(+File, +Mode) is semidet
True if a regular file exists at path File and can be accessed according to Mode (defaults to exist). Accepts the same access modes as absolute_file_name/3's access option.
Source file_must_exist(+File) is det
Source file_must_exist(+File, +Mode) is det
Ensure that a regular file exists at path File and can be accessed according to Mode (defaults to exist). Otherwise an exception is thrown. Accepts the same access modes as absolute_file_name/3's access option.
Source directory_must_exist(+Directory) is det
Source directory_must_exist(+Directory, +Mode) is det
Ensure that a directory exists at path Directory and can be accessed according to Mode (defaults to exist). Otherwise an exception is thrown. Accepts the same access modes as absolute_file_name/3's access option.
Source directory_member_of_directory(-BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
Source file_member_of_directory(-BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
True if Directory contains a directory or regular file (respectively) named BaseName and the file's absolute path is FullName. If Directory is not given, it defaults to the current working directory. If Pattern is given, only succeeds if BaseName also matches that glob pattern.

These predicates enumerate all matching files on backtracking. This is also the intended usage pattern. For checking if a specific file/directory exists, or to get its absolute path, it's better to use file_exists/1, directory_exists/1, or absolute_file_name/3.

Source directory_member_of_directory(-BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
Source file_member_of_directory(-BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
True if Directory contains a directory or regular file (respectively) named BaseName and the file's absolute path is FullName. If Directory is not given, it defaults to the current working directory. If Pattern is given, only succeeds if BaseName also matches that glob pattern.

These predicates enumerate all matching files on backtracking. This is also the intended usage pattern. For checking if a specific file/directory exists, or to get its absolute path, it's better to use file_exists/1, directory_exists/1, or absolute_file_name/3.

Source directory_member_of_directory(-BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
Source file_member_of_directory(-BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
True if Directory contains a directory or regular file (respectively) named BaseName and the file's absolute path is FullName. If Directory is not given, it defaults to the current working directory. If Pattern is given, only succeeds if BaseName also matches that glob pattern.

These predicates enumerate all matching files on backtracking. This is also the intended usage pattern. For checking if a specific file/directory exists, or to get its absolute path, it's better to use file_exists/1, directory_exists/1, or absolute_file_name/3.

Source directory_member_of_directory(-BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
Source file_member_of_directory(-BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
True if Directory contains a directory or regular file (respectively) named BaseName and the file's absolute path is FullName. If Directory is not given, it defaults to the current working directory. If Pattern is given, only succeeds if BaseName also matches that glob pattern.

These predicates enumerate all matching files on backtracking. This is also the intended usage pattern. For checking if a specific file/directory exists, or to get its absolute path, it's better to use file_exists/1, directory_exists/1, or absolute_file_name/3.

Source directory_member_of_directory(-BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source directory_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
Source file_member_of_directory(-BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, -BaseName, -FullName) is nondet
Source file_member_of_directory(+Directory, +Pattern, -BaseName, -FullName) is nondet
True if Directory contains a directory or regular file (respectively) named BaseName and the file's absolute path is FullName. If Directory is not given, it defaults to the current working directory. If Pattern is given, only succeeds if BaseName also matches that glob pattern.

These predicates enumerate all matching files on backtracking. This is also the intended usage pattern. For checking if a specific file/directory exists, or to get its absolute path, it's better to use file_exists/1, directory_exists/1, or absolute_file_name/3.

Source directory_members_of_directory(-Set) is det
Source directory_members_of_directory(+Directory, -Set) is det
Source directory_members_of_directory(+Directory, +Pattern, -Set) is det
Source file_members_of_directory(-Set) is det
Source file_members_of_directory(+Directory, -Set) is det
Source file_members_of_directory(+Directory, +Pattern, -Set) is det
Unifies Set with a set of BaseName-FullName entries for all directories or regular files (respectively) in Directory. If Directory is not given, it defaults to the current working directory. If Pattern is given, Set only includes entries where BaseName matches that glob pattern.
Source directory_members_of_directory(-Set) is det
Source directory_members_of_directory(+Directory, -Set) is det
Source directory_members_of_directory(+Directory, +Pattern, -Set) is det
Source file_members_of_directory(-Set) is det
Source file_members_of_directory(+Directory, -Set) is det
Source file_members_of_directory(+Directory, +Pattern, -Set) is det
Unifies Set with a set of BaseName-FullName entries for all directories or regular files (respectively) in Directory. If Directory is not given, it defaults to the current working directory. If Pattern is given, Set only includes entries where BaseName matches that glob pattern.
Source directory_members_of_directory(-Set) is det
Source directory_members_of_directory(+Directory, -Set) is det
Source directory_members_of_directory(+Directory, +Pattern, -Set) is det
Source file_members_of_directory(-Set) is det
Source file_members_of_directory(+Directory, -Set) is det
Source file_members_of_directory(+Directory, +Pattern, -Set) is det
Unifies Set with a set of BaseName-FullName entries for all directories or regular files (respectively) in Directory. If Directory is not given, it defaults to the current working directory. If Pattern is given, Set only includes entries where BaseName matches that glob pattern.
Source directory_members_of_directory(-Set) is det
Source directory_members_of_directory(+Directory, -Set) is det
Source directory_members_of_directory(+Directory, +Pattern, -Set) is det
Source file_members_of_directory(-Set) is det
Source file_members_of_directory(+Directory, -Set) is det
Source file_members_of_directory(+Directory, +Pattern, -Set) is det
Unifies Set with a set of BaseName-FullName entries for all directories or regular files (respectively) in Directory. If Directory is not given, it defaults to the current working directory. If Pattern is given, Set only includes entries where BaseName matches that glob pattern.
Source directory_members_of_directory(-Set) is det
Source directory_members_of_directory(+Directory, -Set) is det
Source directory_members_of_directory(+Directory, +Pattern, -Set) is det
Source file_members_of_directory(-Set) is det
Source file_members_of_directory(+Directory, -Set) is det
Source file_members_of_directory(+Directory, +Pattern, -Set) is det
Unifies Set with a set of BaseName-FullName entries for all directories or regular files (respectively) in Directory. If Directory is not given, it defaults to the current working directory. If Pattern is given, Set only includes entries where BaseName matches that glob pattern.
Source file_property(+Path, ?Property) is semidet
Source file_property(+Path, ?Property, -Value) is semidet
Source directory_property(+Path, ?Property) is semidet
Source directory_property(+Path, ?Property, -Value) is semidet
True if a regular file or directory (respectively) exists at Path and it has the given property and value. Property may be unbound to backtrack over all available properties. If the Value parameter is omitted, succeeds if Property has value true.

The following properties are currently supported:

create_timestamp
modify_timestamp
access_timestamp
The file/directory's creation/modification/access time as a Unix timestamp (as returned by SWI's set_time_file/3).
create_localtime
modify_localtime
access_localtime
The file/directory's creation/modification/access time as a datime/6 term (as returned by datime/2 from SICStus library(system)).
readable
writable
executable
searchable
true or false depending on whether the file/directory is readable/writable/executable/searchable. executable is only supported on regular files and searchable only on directories.
size_in_bytes
The file's size in bytes. Not supported on directories.

On Unix systems, create_timestamp/create_localtime don't return the file's actual creation time, but rather its "ctime" or "metadata change time". This matches the behavior of SICStus 4.6.0.

As of SICStus 4.6.0, the following properties are not yet emulated:

set_user_id
set_group_id
save_text
who_can_read
who_can_write
who_can_execute
who_can_search
owner_user_id
owner_group_id
owner_user_name
owner_group_name
Source file_property(+Path, ?Property) is semidet
Source file_property(+Path, ?Property, -Value) is semidet
Source directory_property(+Path, ?Property) is semidet
Source directory_property(+Path, ?Property, -Value) is semidet
True if a regular file or directory (respectively) exists at Path and it has the given property and value. Property may be unbound to backtrack over all available properties. If the Value parameter is omitted, succeeds if Property has value true.

The following properties are currently supported:

create_timestamp
modify_timestamp
access_timestamp
The file/directory's creation/modification/access time as a Unix timestamp (as returned by SWI's set_time_file/3).
create_localtime
modify_localtime
access_localtime
The file/directory's creation/modification/access time as a datime/6 term (as returned by datime/2 from SICStus library(system)).
readable
writable
executable
searchable
true or false depending on whether the file/directory is readable/writable/executable/searchable. executable is only supported on regular files and searchable only on directories.
size_in_bytes
The file's size in bytes. Not supported on directories.

On Unix systems, create_timestamp/create_localtime don't return the file's actual creation time, but rather its "ctime" or "metadata change time". This matches the behavior of SICStus 4.6.0.

As of SICStus 4.6.0, the following properties are not yet emulated:

set_user_id
set_group_id
save_text
who_can_read
who_can_write
who_can_execute
who_can_search
owner_user_id
owner_group_id
owner_user_name
owner_group_name
Source file_property(+Path, ?Property) is semidet
Source file_property(+Path, ?Property, -Value) is semidet
Source directory_property(+Path, ?Property) is semidet
Source directory_property(+Path, ?Property, -Value) is semidet
True if a regular file or directory (respectively) exists at Path and it has the given property and value. Property may be unbound to backtrack over all available properties. If the Value parameter is omitted, succeeds if Property has value true.

The following properties are currently supported:

create_timestamp
modify_timestamp
access_timestamp
The file/directory's creation/modification/access time as a Unix timestamp (as returned by SWI's set_time_file/3).
create_localtime
modify_localtime
access_localtime
The file/directory's creation/modification/access time as a datime/6 term (as returned by datime/2 from SICStus library(system)).
readable
writable
executable
searchable
true or false depending on whether the file/directory is readable/writable/executable/searchable. executable is only supported on regular files and searchable only on directories.
size_in_bytes
The file's size in bytes. Not supported on directories.

On Unix systems, create_timestamp/create_localtime don't return the file's actual creation time, but rather its "ctime" or "metadata change time". This matches the behavior of SICStus 4.6.0.

As of SICStus 4.6.0, the following properties are not yet emulated:

set_user_id
set_group_id
save_text
who_can_read
who_can_write
who_can_execute
who_can_search
owner_user_id
owner_group_id
owner_user_name
owner_group_name
Source current_directory(-Directory) is det
Source current_directory(-Directory, +NewDirectory) is det
Unifies Directory with the current working directory path. In the 2-argument form, also changes the working directory to the path NewDirectory.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 delete_directory(Arg1)
 make_directory(Arg1)