Operating system utilities

Author(s): Daniel Cabeza, Manuel Carro.

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.

Documentation on exports

PREDICATE
pause(Seconds)

Make this thread sleep for some Seconds.

(Trust) Usage:

  • The following properties should hold at call time:
    (basic_props:int/1)Seconds is an integer.

PREDICATE
time(Time)

Time is unified with the number of seconds elapsed since January, 1, 1970 (UTC).

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)Time is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)Time is an integer.

PREDICATE
datime(Datime)

Datime is unified with a term of the form datime(Year,Month,Day,Hour,Minute,Second) which contains the current date and time.

Usage:

  • Call and exit should be compatible with:
    (system:datime_struct/1)system:datime_struct(Datime)
  • The following properties should hold upon exit:
    (system:datime_struct/1)system:datime_struct(Datime)

PREDICATE
datime(Time,Year,Month,Day,Hour,Min,Sec,WeekDay,YearDay)

Time is as in time/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.

(Trust) Usage 1:

If Time is given, the rest of the arguments are unified with the date and time to which the Time argument refers.

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)Year is an integer.
    (basic_props:int/1)Month is an integer.
    (basic_props:int/1)Day is an integer.
    (basic_props:int/1)Hour is an integer.
    (basic_props:int/1)Min is an integer.
    (basic_props:int/1)Sec is an integer.
    (basic_props:int/1)WeekDay is an integer.
    (basic_props:int/1)YearDay is an integer.
  • The following properties should hold at call time:
    (basic_props:int/1)Time is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)Year is an integer.
    (basic_props:int/1)Month is an integer.
    (basic_props:int/1)Day is an integer.
    (basic_props:int/1)Hour is an integer.
    (basic_props:int/1)Min is an integer.
    (basic_props:int/1)Sec is an integer.
    (basic_props:int/1)WeekDay is an integer.
    (basic_props:int/1)YearDay is an integer.

(Trust) Usage 2:

Bound Time, WeekDay and YearDay as determined by the input arguments.

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)Time is an integer.
    (basic_props:int/1)WeekDay is an integer.
    (basic_props:int/1)YearDay is an integer.
  • The following properties should hold at call time:
    (basic_props:int/1)Year is an integer.
    (basic_props:int/1)Month is an integer.
    (basic_props:int/1)Day is an integer.
    (basic_props:int/1)Hour is an integer.
    (basic_props:int/1)Min is an integer.
    (basic_props:int/1)Sec is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)Time is an integer.
    (basic_props:int/1)WeekDay is an integer.
    (basic_props:int/1)YearDay is an integer.

(Trust) Usage 3:

Bound Time to current time and the rest of the arguments refer to current time.

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)WeekDay is an integer.
    (basic_props:int/1)YearDay is an integer.
  • The following properties should hold at call time:
    (term_typing:var/1)Time is a free variable.
    (term_typing:var/1)Year is a free variable.
    (term_typing:var/1)Month is a free variable.
    (term_typing:var/1)Day is a free variable.
    (term_typing:var/1)Hour is a free variable.
    (term_typing:var/1)Min is a free variable.
    (term_typing:var/1)Sec is a free variable.
  • The following properties hold upon exit:
    (basic_props:int/1)Time is an integer.
    (basic_props:int/1)Year is an integer.
    (basic_props:int/1)Month is an integer.
    (basic_props:int/1)Day is an integer.
    (basic_props:int/1)Hour is an integer.
    (basic_props:int/1)Min is an integer.
    (basic_props:int/1)Sec is an integer.
    (basic_props:int/1)WeekDay is an integer.
    (basic_props:int/1)YearDay is an integer.

REGTYPE
A regular type, defined as follows:
datime_struct(datime(Year,Month,Day,Hour,Min,Sec)) :-
        int(Year),
        int(Month),
        int(Day),
        int(Hour),
        int(Min),
        int(Sec).

PREDICATE
getenvstr(Name,Value)

The environment variable Name has Value. Fails if variable Name is not defined.

Usage:

  • Call and exit should be compatible with:
    (basic_props:string/1)Value is a string (a list of character codes).
  • The following properties should hold at call time:
    (basic_props:atm/1)Name is an atom.
  • The following properties should hold upon exit:
    (basic_props:string/1)Value is a string (a list of character codes).

PREDICATE
setenvstr(Name,Value)

The environment variable Name is assigned Value.

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)Name is an atom.
    (basic_props:string/1)Value is a string (a list of character codes).

PREDICATE
current_env(Name,Value)

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:

  • Call and exit should be compatible with:
    (basic_props:atm/1)Name is an atom.
    (basic_props:atm/1)Value is an atom.
  • The following properties should hold upon exit:
    (basic_props:atm/1)Name is an atom.
    (basic_props:atm/1)Value is an atom.

PREDICATE
set_env(Name,Value)

The environment variable Name is assigned Value.

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)Name is an atom.
    (basic_props:atm/1)Value is an atom.

PREDICATE
del_env(Name)

The environment variable Name is removed.

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)Name is an atom.

PREDICATE

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)Arg1 is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)Arg1 is an integer.

PREDICATE
copy_file(Source,Destination)

Copies the file Source to Destination.

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)Source is an atom.
    (basic_props:atm/1)Destination is an atom.

PREDICATE

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)Arg1 is an atom.
    (basic_props:atm/1)Arg2 is an atom.
    (system:copy_options/1)system:copy_options(Arg3)

PREDICATE
No further documentation available for this predicate.

PREDICATE
extract_paths(String,Paths)

Interpret String as the value of a UNIX environment variable holding a list of paths and return in Paths the list of the paths. Paths in String are separated by colons, and an empty path is considered a shorthand for '.' (current path). The most typical environment variable with this format is PATH. For example, this is a typical use:

?- set_prolog_flag(write_strings, on).

yes
?- getenvstr('PATH', PATH), extract_paths(PATH, Paths).

PATH = ":/home/bardo/bin:/home/clip/bin:/opt/bin/:/bin",
Paths = [".","/home/bardo/bin","/home/clip/bin","/opt/bin/","/bin"] ?

yes
?- 

Usage:

  • Call and exit should be compatible with:
    (basic_props:list/2)Paths is a list of strings.
  • The following properties should hold at call time:
    (basic_props:string/1)String is a string (a list of character codes).
  • The following properties should hold upon exit:
    (basic_props:list/2)Paths is a list of strings.

PREDICATE
file_dir_name(File,Dir,Name)

Discomposes a given File in its directory and name

(True) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:atm/1)File is an atom.
    (basic_props:atm/1)Dir is an atom.
    (basic_props:atm/1)Name is an atom.
  • The following properties hold upon exit:
    (basic_props:atm/1)File is an atom.
    (basic_props:atm/1)Dir is an atom.
    (basic_props:atm/1)Name is an atom.

PREDICATE
get_pid(Pid)

Unifies Pid with the process identificator of the current process or thread.

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)Pid is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)Pid is an integer.

PREDICATE
get_uid(Uid)

Unifies Uid with the user id of the current process.

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)Uid is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)Uid is an integer.

PREDICATE
get_gid(Uid)

Unifies Gid with the group id of the current process.

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:int/1)Uid is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)Uid is an integer.

PREDICATE
get_pwnam(User)

Unifies User with the user of the current process, as specified in the /etc/passwd file.

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:atm/1)User is an atom.
  • The following properties hold upon exit:
    (basic_props:atm/1)User is an atom.

PREDICATE
get_grnam(Group)

Unifies Group with the group of the current process, as specified in the /etc/group file.

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:atm/1)Group is an atom.
  • The following properties hold upon exit:
    (basic_props:atm/1)Group is an atom.

PREDICATE

Usage:get_tmp_dir(TmpDir)

Gets the directory name used to store temporary files. In Unix is /tmp, in Windows is determined by the TMP environment variable.

  • The following properties should hold at call time:
    (term_typing:var/1)TmpDir is a free variable.
  • The following properties should hold upon exit:
    (basic_props:atm/1)TmpDir is an atom.

PREDICATE
No further documentation available for this predicate.

PREDICATE
current_host(Hostname)

Hostname is unified with the fully qualified name of the host.

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:atm/1)Hostname is an atom.
  • The following properties hold upon exit:
    (basic_props:atm/1)Hostname is an atom.

PREDICATE
current_executable(Path)

Unifies Path with the path to the current executable.

(Trust) Usage:

  • Calls should, and exit will be compatible with:
    (basic_props:atm/1)Path is an atom.
  • The following properties hold upon exit:
    (basic_props:atm/1)Path is an atom.

PREDICATE

(Trust) Usage 1:umask(OldMask,NewMask)

The process file creation mask was OldMask, and it is changed to NewMask.

  • The following properties should hold at call time:
    (basic_props:int/1)NewMask is an integer.
  • The following properties hold upon exit:
    (basic_props:int/1)OldMask is an integer.

(Trust) Usage 2:umask(OldMask,NewMask)

Gets the process file creation mask without changing it.

  • The following properties should hold at call time:
    (term_typing:var/1)OldMask is a free variable.
    (term_typing:var/1)NewMask is a free variable.
    (term_compare:== /2)The terms OldMask and NewMask are strictly identical.
  • The following properties hold upon exit:
    (basic_props:int/1)OldMask is an integer.
    (basic_props:int/1)NewMask is an integer.

PREDICATE
make_directory(DirName,Mode)

Creates the directory DirName with a given Mode. This is, as usual, operated against the current umask value.

(Trust) Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)DirName is an atom.
    (basic_props:int/1)Mode is an integer.

PREDICATE
make_directory(DirName)

Equivalent to make_directory(D,0o777).

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)DirName is an atom.

PREDICATE
make_dirpath(Path,Mode)

Creates the whole Path for a given directory with a given Mode. As an example, make_dirpath('/tmp/var/mydir/otherdir').

Usage:

  • The following properties should hold at call time:
    (streams_basic:sourcename/1)Path is a source name.
    (basic_props:int/1)Mode is an integer.

PREDICATE
make_dirpath(Path)

Equivalent to make_dirpath(D,0o777).

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)Path is an atom.

PREDICATE
working_directory(OldDir,NewDir)

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.

(Trust) Usage 1:

Changes current working directory.

  • Calls should, and exit will be compatible with:
    (basic_props:atm/1)OldDir is an atom.
  • The following properties should hold at call time:
    (basic_props:atm/1)NewDir is an atom.
  • The following properties hold upon exit:
    (basic_props:atm/1)OldDir is an atom.

(Trust) Usage 2:working_directory(OldDir,NewDir)

Gets current working directory.

  • The following properties should hold at call time:
    (term_typing:var/1)OldDir is a free variable.
    (term_typing:var/1)NewDir is a free variable.
    (term_compare:== /2)The terms OldDir and NewDir are strictly identical.
  • The following properties hold upon exit:
    (basic_props:atm/1)OldDir is an atom.
    (basic_props:atm/1)NewDir is an atom.

PREDICATE
cd(Path)

Changes working directory to Path.

Usage:

  • The following properties should hold at call time:
    (basic_props:atm/1)Path is an atom.

PREDICATE

(Trust) Usage:

Execs the shell specified by the environment variable SHELL. When the shell process terminates, control is returned to Prolog.

    PREDICATE
    shell(Command)

    Command is executed in the shell specified by the environment variable SHELL. It succeeds if the exit code is zero and fails otherwise.

    Usage:

    • The following properties should hold at call time:
      (basic_props:atm/1)Command is an atom.

    PREDICATE
    shell(Command,ReturnCode)

    Executes Command in the shell specified by the environment variable SHELL and stores the exit code in ReturnCode.

    (Trust) Usage:

    • Calls should, and exit will be compatible with:
      (basic_props:int/1)ReturnCode is an integer.
    • The following properties should hold at call time:
      (basic_props:atm/1)Command is an atom.
    • The following properties hold upon exit:
      (basic_props:int/1)ReturnCode is an integer.

    PREDICATE
    system(Command)

    Executes Command using the shell /bin/sh.

    Usage:

    • The following properties should hold at call time:
      (basic_props:atm/1)Command is an atom.

    PREDICATE
    system(Command,ReturnStatus)

    Executes Command in the /bin/sh shell and stores the return status in ReturnStatus. Note that the exit code is masked as the low order 8 bits of the return status:

    ReturnCode is ( ReturnStatus /\ 0xFF00 ) >> 8.

    (Trust) Usage:

    • Calls should, and exit will be compatible with:
      (basic_props:int/1)ReturnStatus is an integer.
    • The following properties should hold at call time:
      (basic_props:atm/1)Command is an atom.
    • The following properties hold upon exit:
      (basic_props:int/1)ReturnStatus is an integer.

    PREDICATE
    popen(Command,Mode,Stream)

    Open a pipe to process Command in a new shell with a given Mode and return a communication Stream (as in UNIX popen(3)). If Mode is read the output from the process is sent to Stream. If Mode is write, Stream is sent as input to the process. Stream may be read from or written into using the ordinary stream I/O predicates. Stream must be closed explicitly using close/1, i.e., it is not closed automatically when the process dies. Note that popen/2 is defined in ***x as using /bin/sh, which usually does not exist in Windows systems. In this case, a sh shell which comes with Windows is used.

    Usage:

    • The following properties should hold at call time:
      (basic_props:atm/1)Command is an atom.
      (system:popen_mode/1)Mode is 'read' or 'write'.
      (term_typing:var/1)Stream is a free variable.
    • The following properties should hold upon exit:
      (streams_basic:stream/1)Stream is an open stream.

    REGTYPE

    Usage:popen_mode(M)

    M is 'read' or 'write'.

      PREDICATE
      exec(Command,StdIn,StdOut,StdErr)

      Starts the process Command and returns the standart I/O streams of the process in StdIn, StdOut, and StdErr. If Command contains blank spaces, these are taken as separators between a program name (the first chunk of contiguous non-blank characters) and options for the program (the subsequent contiguous pieces of non-blank characters), as in exec('ls -lRa ../sibling_dir', In, Out, Err).

      Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)Command is an atom.
        (term_typing:var/1)StdIn is a free variable.
        (term_typing:var/1)StdOut is a free variable.
        (term_typing:var/1)StdErr is a free variable.
      • The following properties should hold upon exit:
        (streams_basic:stream/1)StdIn is an open stream.
        (streams_basic:stream/1)StdOut is an open stream.
        (streams_basic:stream/1)StdErr is an open stream.

      PREDICATE
      exec(Command,StdIn,StdOut)

      Starts the process Command and returns the standart I/O streams of the process in StdIn and StdOut. Standard error is connected to whichever the parent process had it connected to. Command is treated and split in components as in exec/4.

      Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)Command is an atom.
        (term_typing:var/1)StdIn is a free variable.
        (term_typing:var/1)StdOut is a free variable.
      • The following properties should hold upon exit:
        (streams_basic:stream/1)StdIn is an open stream.
        (streams_basic:stream/1)StdOut is an open stream.

      PREDICATE

      Usage:exec(Command,Arguments,StdIn,StdOut,StdErr,Background,PID,ErrCode)

      exec/8 gives a finer control on execution of process. Command is the command to be executed and Arguments is a list of atoms to be passed as arguments to the command. When called with free variables, StdIn, StdOut, and StdErr are instantiated to streams connected to the standard output, input, and error of the created process. Background controls whether the caller waits for Command to finish, or if the process executing Command is completely detached (it can be waited for using wait/3). ErrCode is the error code returned by the lower-level exec() system call (this return code is system-dependent, but a non-zero value usually means that something has gone wrong). If Command does not start by a slash, exec/8 uses the environment variable PATH to search for it. If PATH is not set, /bin and /usr/bin are searched.

      • The following properties should hold at call time:
        (term_typing:nonvar/1)Command is currently a term which is not a free variable.
        (term_typing:nonvar/1)Arguments is currently a term which is not a free variable.
        (term_typing:nonvar/1)Background is currently a term which is not a free variable.
        (term_typing:var/1)PID is a free variable.
        (term_typing:var/1)ErrCode is a free variable.
        (basic_props:atm/1)Command is an atom.
        (basic_props:list/2)Arguments is a list of atms.
        (basic_props:atm/1)Background is an atom.
      • The following properties should hold upon exit:
        (streams_basic:stream/1)StdIn is an open stream.
        (streams_basic:stream/1)StdOut is an open stream.
        (streams_basic:stream/1)StdErr is an open stream.
        (basic_props:int/1)PID is an integer.
        (basic_props:int/1)ErrCode is an integer.

      PREDICATE

      (Trust) Usage:wait(Pid,RetCode,Status)

      wait/3 waits for the process numbered Pid. If PID equals -1, it will wait for any children process. RetCode is usually the PID of the waited-for process, and -1 in case in case of error. Status is related to the exit value of the process in a system-dependent fashion.

      • The following properties should hold at call time:
        (term_typing:nonvar/1)Pid is currently a term which is not a free variable.
        (term_typing:var/1)RetCode is a free variable.
        (term_typing:var/1)Status is a free variable.
        (basic_props:int/1)Pid is an integer.
        (term_typing:var/1)RetCode is a free variable.
        (term_typing:var/1)Status is a free variable.
      • The following properties hold upon exit:
        (basic_props:int/1)RetCode is an integer.
        (basic_props:int/1)Status is an integer.

      PREDICATE
      directory_files(Directory,FileList)

      FileList is the unordered list of entries (files, directories, etc.) in Directory.

      (Trust) Usage:

      • Calls should, and exit will be compatible with:
        (basic_props:list/2)FileList is a list of atms.
      • The following properties should hold at call time:
        (basic_props:atm/1)Directory is an atom.
      • The following properties hold upon exit:
        (basic_props:list/2)FileList is a list of atms.

      PREDICATE
      mktemp(Template,Filename)

      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.

      (Trust) Usage:

      • Calls should, and exit will be compatible with:
        (basic_props:atm/1)Filename is an atom.
      • The following properties should hold at call time:
        (basic_props:atm/1)Template is an atom.
      • The following properties hold upon exit:
        (basic_props:atm/1)Filename is an atom.

      PREDICATE
      No further documentation available for this predicate.

      PREDICATE
      file_exists(File)

      Succeeds if File (a file or directory) exists (and is accessible).

      Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.

      PREDICATE
      file_exists(File,Mode)

      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.

      (Trust) Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
        (basic_props:int/1)Mode is an integer.
      • The following properties hold upon exit:
        (basic_props:atm/1)File is an atom.
        (basic_props:int/1)Mode is an integer.

      PREDICATE
      file_property(File,Property)

      File has the property Property. The possible properties are:

      type(Type)
      Type is one of regular, directory, fifo, socket or unknown.

      linkto(Linkto)
      If File is a symbolic link, Linkto is the file pointed to by the link (and the other properties come from that file, not from the link itself).

      mod_time(ModTime)
      ModTime is the time of last modification (seconds since January, 1, 1970).

      mode(Protection)
      Protection is the protection mode.

      size(Size)
      Size is the size.

      If Property is uninstantiated, the predicate will enumerate the properties on backtracking.

      Usage:

      • Call and exit should be compatible with:
        (basic_props:struct/1)Property is a compound term.
      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
      • The following properties should hold upon exit:
        (basic_props:struct/1)Property is a compound term.

      PREDICATE
      file_properties(Path,Type,Linkto,Time,Protection,Size)

      The file Path has the following properties:

      • File type Type (one of regular, directory, fifo, socket or unknown).

      • If Path is a symbolic link, Linkto is the file pointed to. All other properties come from the file pointed, not the link. Linkto is ” if Path is not a symbolic link.

      • Time of last modification Time (seconds since January, 1, 1970).

      • Protection mode Protection.

      • Size in bytes Size.

      (Trust) Usage:

      • Calls should, and exit will be compatible with:
        (basic_props:atm/1)Type is an atom.
        (basic_props:atm/1)Linkto is an atom.
        (basic_props:int/1)Time is an integer.
        (basic_props:int/1)Protection is an integer.
        (basic_props:int/1)Size is an integer.
      • The following properties should hold at call time:
        (basic_props:atm/1)Path is an atom.
      • The following properties hold upon exit:
        (basic_props:atm/1)Type is an atom.
        (basic_props:atm/1)Linkto is an atom.
        (basic_props:int/1)Time is an integer.
        (basic_props:int/1)Protection is an integer.
        (basic_props:int/1)Size is an integer.

      PREDICATE
      modif_time(File,Time)

      The file File was last modified at Time, which is in seconds since January, 1, 1970. Fails if File does not exist.

      Usage:

      • Call and exit should be compatible with:
        (basic_props:int/1)Time is an integer.
      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
      • The following properties should hold upon exit:
        (basic_props:int/1)Time is an integer.

      PREDICATE
      modif_time0(File,Time)

      If File exists, Time is its latest modification time, as in modif_time/2. Otherwise, if File does not exist, Time is zero.

      Usage:

      • Call and exit should be compatible with:
        (basic_props:int/1)Time is an integer.
      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
      • The following properties should hold upon exit:
        (basic_props:int/1)Time is an integer.

      PREDICATE
      touch(File)

      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 following properties should hold at call time:
        (basic_props:atm/1)File is an atom.

      PREDICATE
      fmode(File,Mode)

      The file File has protection mode Mode.

      Usage:

      • Call and exit should be compatible with:
        (basic_props:int/1)Mode is an integer.
      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
      • The following properties should hold upon exit:
        (basic_props:int/1)Mode is an integer.

      PREDICATE
      chmod(File,NewMode)

      Change the protection mode of file File to NewMode.

      (Trust) Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
        (basic_props:int/1)NewMode is an integer.

      PREDICATE
      chmod(File,OldMode,NewMode)

      The file File has protection mode OldMode and it is changed to NewMode.

      Usage 1:

      • Call and exit should be compatible with:
        (basic_props:int/1)OldMode is an integer.
      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
        (basic_props:int/1)NewMode is an integer.
      • The following properties should hold upon exit:
        (basic_props:int/1)OldMode is an integer.

      Usage 2:chmod(File,OldMode,NewMode)

      If OldMode is identical to NewMode then it is equivalent to fmode(File,OldMode)

      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.
        (term_typing:var/1)OldMode is a free variable.
        (term_typing:var/1)NewMode is a free variable.
      • The following properties should hold upon exit:
        (basic_props:atm/1)File is an atom.
        (basic_props:atm/1)OldMode is an atom.
        (basic_props:atm/1)NewMode is an atom.

      PREDICATE
      set_exec_mode(SourceName,ExecName)

      Copies the permissions of SourceName to ExecName adding permissions to execute.

      (True) Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)SourceName is an atom.
        (basic_props:atm/1)ExecName is an atom.

      PREDICATE
      delete_file(File)

      Delete the file File.

      (Trust) Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.

      PREDICATE
      delete_directory(File)

      Delete the directory Directory.

      (Trust) Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)File is an atom.

      PREDICATE
      rename_file(File1,File2)

      Change the name of File1 to File2.

      (Trust) Usage:

      • The following properties should hold at call time:
        (basic_props:atm/1)File1 is an atom.
        (basic_props:atm/1)File2 is an atom.

      PREDICATE

      (True) Usage:

      Success if the operating system is using windows instead of a posix operating system (which includes cygwin under windows). To do this, we look at the CIAOSCRIPT environment variable, so if it is defined we suppose we are inside a posix operating system (and not windows).

        PREDICATE

        Usage 1:winpath(A,B)

        • The following properties should hold at call time:
          (basic_props:atm/1)A is an atom.
          (term_typing:var/1)B is a free variable.
        • The following properties should hold upon exit:
          (basic_props:atm/1)A is an atom.
          (basic_props:atm/1)B is an atom.

        Usage 2:winpath(A,B)

        • The following properties should hold at call time:
          (term_typing:var/1)A is a free variable.
          (basic_props:atm/1)B is an atom.
        • The following properties should hold upon exit:
          (basic_props:atm/1)A is an atom.
          (basic_props:atm/1)B is an atom.

        Usage 3:winpath(A,B)

        • The following properties should hold at call time:
          (basic_props:atm/1)A is an atom.
          (basic_props:atm/1)B is an atom.
        • The following properties should hold upon exit:
          (basic_props:atm/1)A is an atom.
          (basic_props:atm/1)B is an atom.

        PREDICATE
        winpath(Option,Posix,WinPath)

        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:

        • The following properties should hold at call time:
          (term_typing:var/1)Option is a free variable.
          (term_typing:var/1)Posix is a free variable.
          (basic_props:atm/1)WinPath is an atom.
        • The following properties should hold upon exit:
          (system:winpath_option/1)system:winpath_option(Option)
          (basic_props:atm/1)Posix is an atom.

        Usage 2:

        • The following properties should hold at call time:
          (term_typing:var/1)Option is a free variable.
          (basic_props:atm/1)Posix is an atom.
          (term_typing:var/1)WinPath is a free variable.
        • The following properties should hold upon exit:
          (system:winpath_option/1)system:winpath_option(Option)
          (basic_props:atm/1)WinPath is an atom.

        PREDICATE
        Same as winpath/3, but for strings.

        PREDICATE

        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.

        • The following properties should hold at call time:
          (basic_props:string/1)CygWinPath is a string (a list of character codes).
          (term_typing:var/1)WindowsPath is a free variable.
          (term_typing:atom/1)SwapSlash is currently instantiated to an atom.
        • The following properties should hold upon exit:
          (basic_props:string/1)CygWinPath is a string (a list of character codes).
          (basic_props:string/1)WindowsPath is a string (a list of character codes).
          (term_typing:atom/1)SwapSlash is currently instantiated to an atom.

        PREDICATE
        No further documentation available for this predicate.

        PREDICATE
        replace_characters(String,SearchChar,ReplaceChar,Output)

        Replaces all the occurrences of SearchChar by ReplaceChar and unifies the result with Output

        PREDICATE

        Usage:system_error_report(Report)

        Report is the error message from the last system call, like strerror in POSIX.

        • The following properties should hold at call time:
          (term_typing:var/1)Report is a free variable.
        • The following properties should hold upon exit:
          (basic_props:atm/1)Report is an atom.

        Documentation on multifiles

        PREDICATE

        (Trust) Usage:define_flag(Flag,FlagValues,Default)

        • The following properties hold upon exit:
          (basic_props:atm/1)Flag is an atom.
          (basic_props:flag_values/1)Define the valid flag values
        The predicate is multifile.

        Known bugs and planned improvements

        • Run-time checks have been reported not to work with this code. That means that either the assertions here, or the code that implements the run-time checks are erroneous.
        • In some situations, copy_file don't work when the second argument is a directory, example:

          copy_file( 'site/ciaopp_online.html' , ~distdir, yes),

        • shell/n commands have a bug in Windows: if the environment variable SHELL is instantiated to some Windows shell implementation, then it is very possible that shell/{1,2} will not work, as it is always called with the -c flag to start the user command. For example, COMMAND.COM might need the flag /C -- but there is no way to know a priori which command line option is necessary for every shell! It does not seems usual that Windows sets the SHELL environment variable: if it is not set, we set it up at startup time to point to the sh.exe provided with Ciao, which is able to start Windows aplications. Therefore, ?- shell('command.com'). just works.
        • If exec/4 does not find the command to be executed, there is no visible error message: it is sent to a error output which has already been assigned to a different stream, disconnected from the one the user sees.