This module contains predicates for invoking services which are typically provided by the operating system. Note that the predicates which take names of files or directories as arguments in this module expect atoms, not path aliases. I.e., generally these predicates will not call absolute_file_name/2 on names of files or directories taken as arguments.
Time is unified with the number of seconds elapsed since January, 1, 1970 (UTC).
Usage:
Datime is unified with a term of the form datime(Year,Month,Day,Hour,Minute,Second) which contains the current date and time.
Usage:
datime_struct(datime(Year,Month,Day,Hour,Min,Sec)) :- int(Year), int(Month), int(Day), int(Hour), int(Min), int(Sec).
Time is as in now/1. WeekDay is the number of days since Sunday, in the range 0 to 6. YearDay is the number of days since January 1, in the range 0 to 365.
Usage 1:
If Time is given, the rest of the arguments are unified with the date and time to which the Time argument refers.
Usage 2:
Bound Time, WeekDay and YearDay as determined by the input arguments.
Usage 3:
Bound Time to current time and the rest of the arguments refer to current time.
Usage:copy_option(Opt)
Opt is a file copy option.
copy_option(overwrite). copy_option(timestamp). copy_option(symlink). copy_option(append).
Usage:copy_options(Opts)
Opts is a list of file copy options.
Copies the file Source to Destination.
Usage:
Usage:
The environment variable Name has Value. Fails if variable Name is not defined.
Usage:
The environment variable Name is assigned Value.
Usage:
The environment variable Name is assigned Value.
Usage:
The environment variable Name is removed.
Usage:
If Name is an atom, then unifies the environment variable Name with its value. Note that this predicate can be used to enumerate all the environment variables using backtracking.
Usage:
Split PathList atom into the list of paths Paths. Paths in String are separated by the path list separator character (colons in POSIX-like systems, semicolons in Windows). Empty paths are removed from Paths. Paths is empty if PathList is the empty atom.
Usage:
Hostname is unified with the fully qualified name of the host.
Usage:
Unifies Path with the path to the current Ciao executable (which may be a standalone binary or bytecode executable)
Usage:
Usage 1:umask(OldMask,NewMask)
The process file creation mask was OldMask, and it is changed to NewMask.
Usage 2:umask(OldMask,NewMask)
Gets the process file creation mask without changing it.
Unifies current working directory with OldDir, and then changes the working directory to NewDir. Calling working_directory(Dir,Dir) simply unifies Dir with the current working directory without changing anything else.
Usage 1:
Changes current working directory.
Usage 2:working_directory(OldDir,NewDir)
Gets current working directory.
Changes working directory to Path.
Usage:
FileList is the unordered list of entries (files, directories, etc.) in Directory.
Usage:
Returns a unique Filename based on Template: Template must be a valid file name with six trailing X, which are substituted to create a new file name. Filename is created in read/write mode but closed immediately after creation.
Usage:
Succeeds if File (a file or directory) exists (and is accessible).
Usage:
File (a file or directory) exists and it is accessible with Mode, as in the Unix call access(2). Typically, Mode is 4 for read permission, 2 for write permission and 1 for execute permission.
Usage:
File has the property Property. The possible properties are:
If Property is uninstantiated, the predicate will enumerate the properties on backtracking.
Usage:
The file Path has the following properties:
Usage:
The file File was last modified at Time, which is in seconds since January, 1, 1970. Fails if File does not exist.
Usage:
If File exists, Time is its latest modification time, as in modif_time/2. Otherwise, if File does not exist, Time is zero.
Usage:
Change the modification time of File to the current time of day. If the file does not exist, it is created with default permissions.
Note: This operation cannot be fully implemented with modif_time/2. In POSIX systems, that can be done as long as the user has write permissions on the file, even if the owner is different. Change of modification time to arbitrary time values is not allowed in this case.
Usage:
The file File has protection mode Mode.
Usage:
Change the protection mode of file File to NewMode.
Usage:
The file File has protection mode OldMode and it is changed to NewMode.
Usage 1:
Usage 2:chmod(File,OldMode,NewMode)
If OldMode is identical to NewMode then it is equivalent to fmode(File,OldMode)
Copies the permissions of SourceName to ExecName adding permissions to execute.
Usage:
Delete the directory Directory.
Usage:
Delete the file File.
Usage:
Change the name of File1 to File2.
Usage:
Creates the directory DirName with a given Mode. This is, as usual, operated against the current umask value.
Usage:
Equivalent to make_directory(D,0o777).
Usage:
Usage:system_error_report(Report)
Report is the error message from the last system call, like strerror in POSIX.
Usage:get_tmp_dir(TmpDir)
TmpDir is the (normalized) temporary directory for scratch space. On POSIX systems it is computed from normalizing the path specified in the TMPDIR environment variable. On Windows it is determined by the TMP or TEMP environment variable. If none is defined, this predicate tries to guess it from some usual locations (/tmp, /var/tmp, /usr/tmp on POSIX, c:\temp, c:\tmp, \temp, \tmp on Windows) or use . as last resort.
Usage:dev_null(Path)
File path for the null device (/dev/null file in POSIX, nul in Windows)
Make this thread sleep for some Seconds.
Usage:
Usage:wait(Pid,RetCode)
wait/2 waits for the process numbered Pid. Fails if the process does not terminate normally or in case of error (see C waitpid() for details). RetCode is a positive number indicating the process return code if the process terminated normally, or a negative number if the process terminated due to a signal.
Usage:kill(Pid,Signal)
kill/2 sends the signal Signal to the process or process group specified by Pid. See Unix man page for a detailed description of signals.
Unifies Pid with the process identificator of the current process or thread.
Usage:
Unifies Uid with the user id of the current process.
Usage:
Unifies Gid with the group id of the current process.
Usage:
Unifies User with the user of the current process, as specified in the /etc/passwd file.
Usage:
Unifies Group with the group of the current process, as specified in the /etc/group file.
Usage:
Unifies N with the number of CPU cores.
Usage:
Usage:
Executes the OS-specific system shell. When the shell process terminates, control is returned to Prolog. See shell/2 for details.
Command is executed in the OS-specific system shell. It succeeds if the exit code is zero and fails otherwise. See shell/2 for details.
Usage:
Executes Command using the OS-specific system shell and stores the exit code in RetCode. If Command is the empty atom '', executes the OS-specific system shell.
On POSIX-like systems the system shell is specified by the SHELL environment variable ($SHELL -c "command" for passing user commands). On Windows (native builds, MinGW) it is specified by the COMSPEC environment variable (%COMSPEC% /s /c "command" for passing user commands).
Note that the use of shell/2 predicates is discouraged for portability and security reasons. Please consider process for a more robust way to launch external processes.
Usage:
Like shell/1 but ignores exit code.
Usage:
Synonym for shell/2.
Usage:
Duplicate the file descriptor FD into NewFD
Usage 1:
Duplicate a file description into a new free file descriptor (C dup())
Usage 2:
Duplicate a file description into a specified file descriptor (C dup2())
Usage:
Close the file descriptor (using C close())
Option specifies if you want to get a relative or a full path. Posix represent a path as usual in unix, and WinPath is the Windows-Style representation of Posix.
Usage 1:
Usage 2:
Usage 1:winpath(A,B)
Usage 2:winpath(A,B)
Usage 3:winpath(A,B)
Usage:cyg2win(CygWinPath,WindowsPath,SwapSlash)
Converts a posix path to a Windows-style path. If SwapSlash is swap, slashes are converted in to backslash. If it is noswap, they are preserved.
Usage:
Using the Windows native API (not POSIX)
Usage:get_home(H)
H is the home directory (HOME environment variable in POSIX systems and APPDATA in Windows)
Usage:find_executable(Name,Path)
Path is the absolute path of the command Name, reachable from the PATH (environment variable) directories if Name is not an absolute path. The suffix for executable files is optionally added to Path depending on the current operating system.