protocol
osp
Portable operating-system access protocol.
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.
staticpid(PID)pid(-integer) - oneshell/2
Runs an operating-system shell command and returns its exit status.
staticshell(Command,Status)shell(+atom,-integer) - oneshell/1
Runs an operating-system shell command.
staticshell(Command)shell(+atom) - zero_or_oneis_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.
staticis_absolute_file_name(File)is_absolute_file_name(+atom) - zero_or_oneabsolute_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.
staticabsolute_file_name(File,Path)absolute_file_name(+atom,-atom) - onedecompose_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).
staticdecompose_file_name(File,Directory,Basename)decompose_file_name(+atom,?atom,?atom) - onedecompose_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).
staticdecompose_file_name(File,Directory,Name,Extension)decompose_file_name(+atom,?atom,?atom,?atom) - onepath_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.
staticpath_concat(Prefix,Suffix,Path)path_concat(+atom,+atom,--atom) - oneinternal_os_path/2
Converts between the internal path representation (which is backend dependent) and the operating-system native path representation.
staticinternal_os_path(InternalPath,OSPath)internal_os_path(+atom,-atom) - oneinternal_os_path(-atom,+atom) - onemake_directory/1
Makes a new directory. Succeeds if the directory already exists.
staticmake_directory(Directory)make_directory(+atom) - onemake_directory_path/1
Makes a new directory creating all the intermediate directories if necessary. Succeeds if the directory already exists.
staticmake_directory_path(Directory)make_directory_path(+atom) - onedelete_directory/1
Deletes an empty directory. Throws an error if the directory does not exist.
staticdelete_directory(Directory)delete_directory(+atom) - one_or_errorchange_directory/1
Changes current working directory. Throws an error if the directory does not exist.
staticchange_directory(Directory)change_directory(+atom) - one_or_errorworking_directory/1
Current working directory.
staticworking_directory(Directory)working_directory(?atom) - zero_or_onetemporary_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.
statictemporary_directory(Directory)temporary_directory(?atom) - onenull_device_path/1
Null device path: nul on Windows systems and /dev/null on POSIX systems.
staticnull_device_path(Path)null_device_path(?atom) - onedirectory_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.
staticdirectory_files(Directory,Files)directory_files(+atom,-list(atom)) - one_or_errordirectory_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.
staticdirectory_files(Directory,Files,Options)directory_files(+atom,-list(atom),+list(compound)) - one_or_error
Option
paths/1: Possible values arerelativeandabsolute. 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 aretrueandfalse. Default istrue.
directory_exists/1
True if the specified directory exists (irrespective of directory permissions).
staticdirectory_exists(Directory)directory_exists(+atom) - zero_or_oneensure_directory/1
Ensures that a directory exists, creating it if necessary.
staticensure_directory(Directory)ensure_directory(+atom) - onefile_exists/1
True if the specified file exists and is a regular file (irrespective of file permissions).
staticfile_exists(File)file_exists(+atom) - zero_or_onefile_modification_time/2
File modification time (which can be used for comparison). Throws an error if the file does not exist.
staticfile_modification_time(File,Time)file_modification_time(+atom,-integer) - one_or_errorfile_size/2
File size (in bytes). Throws an error if the file does not exist.
staticfile_size(File,Size)file_size(+atom,-integer) - one_or_errorfile_permission/2
True iff the specified file has the specified permission (read, write, or execute). Throws an error if the file does not exist.
staticfile_permission(File,Permission)file_permission(+atom,+atom) - zero_or_one_or_errorcopy_file/2
Copies a file. Throws an error if the original file does not exist or if the copy cannot be created.
staticcopy_file(File,Copy)copy_file(+atom,+atom) - one_or_errorrename_file/2
Renames a file or a directory. Throws an error if the file or directory does not exist.
staticrename_file(Old,New)rename_file(+atom,+atom) - one_or_errordelete_file/1
Deletes a file. Throws an error if the file does not exist.
staticdelete_file(File)delete_file(+atom) - one_or_errorensure_file/1
Ensures that a file exists, creating it if necessary.
staticensure_file(File)ensure_file(+atom) - oneenvironment_variable/2
Returns an environment variable value. Fails if the variable does not exists.
staticenvironment_variable(Variable,Value)environment_variable(+atom,?atom) - zero_or_onetime_stamp/1
Returns a system-dependent time stamp, which can be used for sorting, but should be regarded otherwise as an opaque term.
statictime_stamp(Time)time_stamp(-ground) - onedate_time/7
Returns the current date and time.
staticdate_time(Year,Month,Day,Hours,Minutes,Seconds,Milliseconds)date_time(-integer,-integer,-integer,-integer,-integer,-integer,-integer) - onecpu_time/1
System cpu time in seconds.
staticcpu_time(Seconds)cpu_time(-number) - onewall_time/1
Wall time in seconds.
staticwall_time(Seconds)wall_time(-number) - oneoperating_system_type/1
Operating system type. Possible values are unix, windows, and unknown.
staticoperating_system_type(Type)operating_system_type(?atom) - onecommand_line_arguments/1
Returns a list with the command line arguments that occur after --.
staticcommand_line_arguments(Arguments)command_line_arguments(-list(atom)) - onesleep/1
Suspends execution the given number of seconds.
staticsleep(Seconds)sleep(+number) - oneProtected predicates
(none)
Private predicates
(none)
Operators
(none)