protocol
osp
ï
Portable operating-system access protocol.
logtalk_load(os(loader))
static
Error handling: Predicates that require a file or directory to exist throw an error when that is not the case. But the exact exception term is currently backend Prolog compiler dependent.
Public predicatesï
pid/1
ï
Returns the process identifier of the running process.
static
pid(PID)
pid(-integer)
- one
shell/2
ï
Runs an operating-system shell command and returns its exit status.
static
shell(Command,Status)
shell(+atom,-integer)
- one
shell/1
ï
Runs an operating-system shell command.
static
shell(Command)
shell(+atom)
- zero_or_one
is_absolute_file_name/1
ï
True iff the argument is an absolute file path. On POSIX systems, this predicate is true if File
starts with a /
. On Windows systems, this predicate is true if File
starts with a drive letter. No attempt is made to expand File
as a path.
static
is_absolute_file_name(File)
is_absolute_file_name(+atom)
- zero_or_one
absolute_file_name/2
ï
Expands a file name to an absolute file path. An environment variable at the beginning of the file name is also expanded.
static
absolute_file_name(File,Path)
absolute_file_name(+atom,-atom)
- one
decompose_file_name/3
ï
Decomposes a file name into its directory (which always ends with a slash; ./
is returned if absent) and its basename (which can be the empty atom).
static
decompose_file_name(File,Directory,Basename)
decompose_file_name(+atom,?atom,?atom)
- one
decompose_file_name/4
ï
Decomposes a file name into its directory (which always ends with a slash; ./
is returned if absent), name (that can be the empty atom), and extension (which starts with a .
when defined; the empty atom otherwise).
static
decompose_file_name(File,Directory,Name,Extension)
decompose_file_name(+atom,?atom,?atom,?atom)
- one
path_concat/3
ï
Concatenates a path prefix and a path suffix, adding a /
separator if required. Returns Suffix
when it is an absolute path. Returns Prefix
with a trailing /
appended if missing when Suffix
is the empty atom.
static
path_concat(Prefix,Suffix,Path)
path_concat(+atom,+atom,--atom)
- one
internal_os_path/2
ï
Converts between the internal path representation (which is backend dependent) and the operating-system native path representation.
static
internal_os_path(InternalPath,OSPath)
internal_os_path(+atom,-atom)
- one
internal_os_path(-atom,+atom)
- one
make_directory/1
ï
Makes a new directory. Succeeds if the directory already exists.
static
make_directory(Directory)
make_directory(+atom)
- one
make_directory_path/1
ï
Makes a new directory creating all the intermediate directories if necessary. Succeeds if the directory already exists.
static
make_directory_path(Directory)
make_directory_path(+atom)
- one
delete_directory/1
ï
Deletes an empty directory. Throws an error if the directory does not exist.
static
delete_directory(Directory)
delete_directory(+atom)
- one_or_error
delete_directory_contents/1
ï
Deletes directory contents. Throws an error if the directory does not exist.
static
delete_directory_contents(Directory)
delete_directory_contents(+atom)
- one_or_error
delete_directory_and_contents/1
ï
Deletes directory and its contents. Throws an error if the directory does not exist.
static
delete_directory_and_contents(Directory)
delete_directory_and_contents(+atom)
- one_or_error
change_directory/1
ï
Changes current working directory. Throws an error if the directory does not exist.
static
change_directory(Directory)
change_directory(+atom)
- one_or_error
working_directory/1
ï
Current working directory.
static
working_directory(Directory)
working_directory(?atom)
- zero_or_one
temporary_directory/1
ï
Temporary directory. Tries first environment variables: TEMP
and TMP
on Windows systems; TMPDIR
, TMP
, TEMP
, and TEMPDIR
on POSIX systems. When not defined, tries default locations. Returns the working directory as last resort.
static
temporary_directory(Directory)
temporary_directory(?atom)
- one
null_device_path/1
ï
Null device path: nul
on Windows systems and /dev/null
on POSIX systems.
static
null_device_path(Path)
null_device_path(?atom)
- one
full_device_path/1
ï
Full device path: /dev/full
on Linux and BSD systems. Fails on other systems. Experimental.
static
full_device_path(Path)
full_device_path(?atom)
- zero_or_one
read_only_device_path/1
ï
Read-only device path: /dev/urandom
on macOS. Fails on other systems. Experimental.
static
read_only_device_path(Path)
read_only_device_path(?atom)
- zero_or_one
directory_files/2
ï
Returns a list of all files (including directories, regular files, and hidden directories and files) in a directory. File paths are relative to the directory. Throws an error if the directory does not exist.
static
directory_files(Directory,Files)
directory_files(+atom,-list(atom))
- one_or_error
directory_files/3
ï
Returns a list of files filtered using the given list of options. Invalid options are ignored. Default option values are equivalent to directory_files/2
. Throws an error if the directory does not exist.
static
directory_files(Directory,Files,Options)
directory_files(+atom,-list(atom),+list(compound))
- one_or_error
Option
paths/1
: Possible values arerelative
andabsolute
. Default isrelative
.Option
type/1
: Possible values areall
,regular
,directory
. Default isall
.Option
extensions/1
: Argument is a list of required extensions (using the format'.ext'
). Default is the empty list.Option
prefixes/1
: Argument is a list of required file prefixes (atoms). Default is the empty list.Option
suffixes/1
: Argument is a list of required file suffixes (atoms). Default is the empty list.Option
dot_files/1
: Possible values aretrue
andfalse
. Default istrue
.
directory_exists/1
ï
True if the specified directory exists (irrespective of directory permissions).
static
directory_exists(Directory)
directory_exists(+atom)
- zero_or_one
ensure_directory/1
ï
Ensures that a directory exists, creating it if necessary.
static
ensure_directory(Directory)
ensure_directory(+atom)
- one
file_exists/1
ï
True if the specified file exists and is a regular file (irrespective of file permissions).
static
file_exists(File)
file_exists(+atom)
- zero_or_one
file_modification_time/2
ï
File modification time (which can be used for comparison). Throws an error if the file does not exist.
static
file_modification_time(File,Time)
file_modification_time(+atom,-integer)
- one_or_error
file_size/2
ï
File size (in bytes). Throws an error if the file does not exist.
static
file_size(File,Size)
file_size(+atom,-integer)
- one_or_error
file_permission/2
ï
True iff the specified file has the specified permission (read
, write
, or execute
). Throws an error if the file does not exist.
static
file_permission(File,Permission)
file_permission(+atom,+atom)
- zero_or_one_or_error
copy_file/2
ï
Copies a file. Throws an error if the original file does not exist or if the copy cannot be created.
static
copy_file(File,Copy)
copy_file(+atom,+atom)
- one_or_error
rename_file/2
ï
Renames a file or a directory. Throws an error if the file or directory does not exist.
static
rename_file(Old,New)
rename_file(+atom,+atom)
- one_or_error
delete_file/1
ï
Deletes a file. Throws an error if the file does not exist.
static
delete_file(File)
delete_file(+atom)
- one_or_error
ensure_file/1
ï
Ensures that a file exists, creating it if necessary.
static
ensure_file(File)
ensure_file(+atom)
- one
environment_variable/2
ï
Returns an environment variable value. Fails if the variable does not exists.
static
environment_variable(Variable,Value)
environment_variable(+atom,?atom)
- zero_or_one
time_stamp/1
ï
Returns a system-dependent time stamp, which can be used for sorting, but should be regarded otherwise as an opaque term.
static
time_stamp(Time)
time_stamp(-ground)
- one
date_time/7
ï
Returns the current date and time. Note that most backends do not provide sub-second accuracy and in those cases the value of the Milliseconds
argument is always zero.
static
date_time(Year,Month,Day,Hours,Minutes,Seconds,Milliseconds)
date_time(-integer,-integer,-integer,-integer,-integer,-integer,-integer)
- one
cpu_time/1
ï
System cpu time in seconds.
static
cpu_time(Seconds)
cpu_time(-number)
- one
wall_time/1
ï
Wall time in seconds.
static
wall_time(Seconds)
wall_time(-number)
- one
operating_system_type/1
ï
Operating system type. Possible values are unix
, windows
, and unknown
.
static
operating_system_type(Type)
operating_system_type(?atom)
- zero_or_one
operating_system_name/1
ï
Operating system name. On POSIX systems, it returns the value of uname -s
. On Windows systems, it returns 'Windows'
.
static
operating_system_name(Name)
operating_system_name(?atom)
- zero_or_one
operating_system_machine/1
ï
Operating system hardware platform. On POSIX systems, it returns the value of uname -m
. On Windows systems, it returns the value of the PROCESSOR_ARCHITECTURE
environment variable.
static
operating_system_machine(Machine)
operating_system_machine(?atom)
- zero_or_one
operating_system_release/1
ï
Operating system release. On POSIX systems, it returns the value of uname -r
. On Windows systems, it uses WMI
code.
static
operating_system_release(Release)
operating_system_release(?atom)
- zero_or_one
command_line_arguments/1
ï
Returns a list with the command line arguments that occur after --
.
static
command_line_arguments(Arguments)
command_line_arguments(-list(atom))
- one
sleep/1
ï
Suspends execution the given number of seconds.
static
sleep(Seconds)
sleep(+number)
- one
Protected predicatesï
(none)
Private predicatesï
(none)
Operatorsï
(none)