Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 2fc07611b08d4a735fd34d5eb60d8e16 > files > 2229

ciao-1.10p8-3mdv2010.0.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 -->

<LINK rel="stylesheet" href="ciao.css" type="text/css">
<TITLE>The Ciao Prolog System               - Operating system utilities</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_51.html">previous</A>, <A HREF="ciao_53.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC244" HREF="ciao_toc.html#TOC244">Operating system utilities</A></H1>
<P>
<A NAME="IDX3307"></A>


<P>
<STRONG>Author(s):</STRONG> Daniel Cabeza, Manuel Carro.


<P>
<STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST)


<P>
<STRONG>Version of last change:</STRONG> 1.9#365 (2004/7/28, 1:10:31 CEST)


<P>
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 
<A NAME="IDX3308"></A>
path aliases. I.e., generally these predicates will not call 
<A NAME="IDX3309"></A>
<CODE>absolute_file_name/2</CODE> on names of files or directories taken as arguments.



<UL>
<LI><A HREF="ciao_52.html#SEC245">Usage and interface (system)</A>
<LI><A HREF="ciao_52.html#SEC246">Documentation on exports (system)</A>
<LI><A HREF="ciao_52.html#SEC247">Documentation on multifiles (system)</A>
<LI><A HREF="ciao_52.html#SEC248">Known bugs and planned improvements (system)</A>
</UL>



<H2><A NAME="SEC245" HREF="ciao_toc.html#TOC245">Usage and interface (<CODE>system</CODE>)</A></H2>

<div class="cartouche">

<UL>

<LI><STRONG>Library usage:</STRONG>

<CODE>:- use_module(library(system)).</CODE>

<LI><STRONG>Exports:</STRONG>


<UL>

<LI><EM>Predicates:</EM>

<A NAME="IDX3310"></A>
<CODE>pause/1</CODE>, 
<A NAME="IDX3311"></A>
<CODE>time/1</CODE>, 
<A NAME="IDX3312"></A>
<CODE>datime/1</CODE>, 
<A NAME="IDX3313"></A>
<CODE>datime/9</CODE>, 
<A NAME="IDX3314"></A>
<CODE>getenvstr/2</CODE>, 
<A NAME="IDX3315"></A>
<CODE>setenvstr/2</CODE>, 
<A NAME="IDX3316"></A>
<CODE>extract_paths/2</CODE>, 
<A NAME="IDX3317"></A>
<CODE>get_pid/1</CODE>, 
<A NAME="IDX3318"></A>
<CODE>current_host/1</CODE>, 
<A NAME="IDX3319"></A>
<CODE>current_executable/1</CODE>, 
<A NAME="IDX3320"></A>
<CODE>umask/2</CODE>, 
<A NAME="IDX3321"></A>
<CODE>make_directory/2</CODE>, 
<A NAME="IDX3322"></A>
<CODE>make_directory/1</CODE>, 
<A NAME="IDX3323"></A>
<CODE>make_dirpath/2</CODE>, 
<A NAME="IDX3324"></A>
<CODE>make_dirpath/1</CODE>, 
<A NAME="IDX3325"></A>
<CODE>working_directory/2</CODE>, 
<A NAME="IDX3326"></A>
<CODE>cd/1</CODE>, 
<A NAME="IDX3327"></A>
<CODE>shell/0</CODE>, 
<A NAME="IDX3328"></A>
<CODE>shell/1</CODE>, 
<A NAME="IDX3329"></A>
<CODE>shell/2</CODE>, 
<A NAME="IDX3330"></A>
<CODE>system/1</CODE>, 
<A NAME="IDX3331"></A>
<CODE>system/2</CODE>, 
<A NAME="IDX3332"></A>
<CODE>popen/3</CODE>, 
<A NAME="IDX3333"></A>
<CODE>exec/4</CODE>, 
<A NAME="IDX3334"></A>
<CODE>exec/3</CODE>, 
<A NAME="IDX3335"></A>
<CODE>exec/8</CODE>, 
<A NAME="IDX3336"></A>
<CODE>wait/3</CODE>, 
<A NAME="IDX3337"></A>
<CODE>directory_files/2</CODE>, 
<A NAME="IDX3338"></A>
<CODE>mktemp/2</CODE>, 
<A NAME="IDX3339"></A>
<CODE>file_exists/1</CODE>, 
<A NAME="IDX3340"></A>
<CODE>file_exists/2</CODE>, 
<A NAME="IDX3341"></A>
<CODE>file_property/2</CODE>, 
<A NAME="IDX3342"></A>
<CODE>file_properties/6</CODE>, 
<A NAME="IDX3343"></A>
<CODE>modif_time/2</CODE>, 
<A NAME="IDX3344"></A>
<CODE>modif_time0/2</CODE>, 
<A NAME="IDX3345"></A>
<CODE>fmode/2</CODE>, 
<A NAME="IDX3346"></A>
<CODE>chmod/2</CODE>, 
<A NAME="IDX3347"></A>
<CODE>chmod/3</CODE>, 
<A NAME="IDX3348"></A>
<CODE>delete_file/1</CODE>, 
<A NAME="IDX3349"></A>
<CODE>delete_directory/1</CODE>, 
<A NAME="IDX3350"></A>
<CODE>rename_file/2</CODE>, 
<A NAME="IDX3351"></A>
<CODE>cyg2win/3</CODE>.

<LI><EM>Regular Types:</EM>

<A NAME="IDX3352"></A>
<CODE>datime_struct/1</CODE>, 
<A NAME="IDX3353"></A>
<CODE>popen_mode/1</CODE>.

<LI><EM>Multifiles:</EM>

<A NAME="IDX3354"></A>
<CODE>define_flag/3</CODE>.

</UL>

<LI><STRONG>Other modules used:</STRONG>


<UL>

<LI><EM>System library modules:</EM>

<A NAME="IDX3355"></A>
<CODE>lists</CODE>.

</UL>

</UL>

</div class="cartouche">



<H2><A NAME="SEC246" HREF="ciao_toc.html#TOC246">Documentation on exports (<CODE>system</CODE>)</A></H2>
<P>
<A NAME="IDX3356"></A>
<A NAME="IDX3357"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>pause/1:</B>
<DD><A NAME="IDX3358"></A>


<P>
<CODE>pause(Seconds)</CODE>


<P>
Make this thread sleep for some <CODE>Seconds</CODE>.


</DL>

<P>
<A NAME="IDX3359"></A>
<A NAME="IDX3360"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>time/1:</B>
<DD><A NAME="IDX3361"></A>


<P>
<CODE>time(Time)</CODE>


<P>
<CODE>Time</CODE> is unified with the number of seconds elapsed since January, 1, 1970 (UTC).


</DL>

<P>
<A NAME="IDX3362"></A>
<A NAME="IDX3363"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>datime/1:</B>
<DD><A NAME="IDX3364"></A>


<P>
<CODE>datime(Datime)</CODE>


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


</DL>

<P>
<A NAME="IDX3365"></A>
<A NAME="IDX3366"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>datime/9:</B>
<DD><A NAME="IDX3367"></A>


<P>
<CODE>datime(Time, Year, Month, Day, Hour, Min, Sec, WeekDay, YearDay)</CODE>


<P>
<CODE>Time</CODE> is as in 
<A NAME="IDX3368"></A>
<CODE>time/1</CODE>. <CODE>WeekDay</CODE> is the number of days since Sunday, in the range 0 to 6. <CODE>YearDay</CODE> is the number of days since January 1, in the range 0 to 365.


<P>
<STRONG>Usage 1:</STRONG> <CODE>datime(+int, ?int, ?int, ?int, ?int, ?int, ?int, ?int, ?int)</CODE>

<UL>
<LI><EM>Description:</EM> If <CODE>Time</CODE> is given, the rest of the arguments are unified with the date and time to which the <CODE>Time</CODE> argument refers.

</UL>

<P>
<STRONG>Usage 2:</STRONG> <CODE>datime(-int, ?int, ?int, ?int, ?int, ?int, ?int, ?int, ?int)</CODE>

<UL>
<LI><EM>Description:</EM> Bound <CODE>Time</CODE> to current time and the rest of the arguments refer to current time.

</UL>

</DL>

<P>
<A NAME="IDX3369"></A>
<A NAME="IDX3370"></A>
<DL>
<DT><span class="define">REGTYPE:</span> <B>datime_struct/1:</B>
<DD><A NAME="IDX3371"></A>


<P>
A regular type, defined as follows:

<PRE>

<PRE>
datime_struct(datime(Year,Month,Day,Hour,Min,Sec)) :-
        int(Year),
        int(Month),
        int(Day),
        int(Hour),
        int(Min),
        int(Sec).
</PRE>

</PRE>

</DL>

<P>
<A NAME="IDX3372"></A>
<A NAME="IDX3373"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>getenvstr/2:</B>
<DD><A NAME="IDX3374"></A>


<P>
<CODE>getenvstr(Name, Value)</CODE>


<P>
The environment variable <CODE>Name</CODE> has <CODE>Value</CODE>. Fails if variable <CODE>Name</CODE> is not defined.


</DL>

<P>
<A NAME="IDX3375"></A>
<A NAME="IDX3376"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>setenvstr/2:</B>
<DD><A NAME="IDX3377"></A>


<P>
<CODE>setenvstr(Name, Value)</CODE>


<P>
The environment variable <CODE>Name</CODE> is assigned <CODE>Value</CODE>.


</DL>

<P>
<A NAME="IDX3378"></A>
<A NAME="IDX3379"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>extract_paths/2:</B>
<DD><A NAME="IDX3380"></A>


<P>
<CODE>extract_paths(String, Paths)</CODE>


<P>
Interpret <CODE>String</CODE> as the value of a UNIX environment variable holding a list of paths and return in <CODE>Paths</CODE> the list of the paths. Paths in <CODE>String</CODE> 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: 

<PRE>
?- 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
?- 
</PRE>

</DL>

<P>
<A NAME="IDX3381"></A>
<A NAME="IDX3382"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>get_pid/1:</B>
<DD><A NAME="IDX3383"></A>


<P>
<CODE>get_pid(Pid)</CODE>


<P>
Unifies <CODE>Pid</CODE> with the process identificator of the current process or thread.


</DL>

<P>
<A NAME="IDX3384"></A>
<A NAME="IDX3385"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>current_host/1:</B>
<DD><A NAME="IDX3386"></A>


<P>
<CODE>current_host(Hostname)</CODE>


<P>
<CODE>Hostname</CODE> is unified with the fully qualified name of the host.


</DL>

<P>
<A NAME="IDX3387"></A>
<A NAME="IDX3388"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>current_executable/1:</B>
<DD><A NAME="IDX3389"></A>


<P>
<CODE>current_executable(Path)</CODE>


<P>
Unifies <CODE>Path</CODE> with the path to the current executable.


</DL>

<P>
<A NAME="IDX3390"></A>
<A NAME="IDX3391"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>umask/2:</B>
<DD><A NAME="IDX3392"></A>


<P>
<CODE>umask(OldMask, NewMask)</CODE>


<P>
The process file creation mask was <CODE>OldMask</CODE>, and it is changed to <CODE>NewMask</CODE>.


<P>
<STRONG>Usage 2:</STRONG> <CODE>umask(OldMask, NewMask)</CODE>

<UL>
<LI><EM>Description:</EM> Gets the process file creation mask without changing it.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>OldMask</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

<CODE>NewMask</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

The terms <CODE>OldMask</CODE> and <CODE>NewMask</CODE> are strictly identical.
 (<CODE>term_compare:== /2</CODE>)
<LI><EM>The following properties hold upon exit:</EM>

<CODE>OldMask</CODE> is an integer.
 (<CODE>basic_props:int/1</CODE>)

<CODE>NewMask</CODE> is an integer.
 (<CODE>basic_props:int/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX3393"></A>
<A NAME="IDX3394"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>make_directory/2:</B>
<DD><A NAME="IDX3395"></A>


<P>
<CODE>make_directory(DirName, Mode)</CODE>


<P>
Creates the directory <CODE>DirName</CODE> with a given <CODE>Mode</CODE>. This is, as usual, operated against the current umask value.


</DL>

<P>
<A NAME="IDX3396"></A>
<A NAME="IDX3397"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>make_directory/1:</B>
<DD><A NAME="IDX3398"></A>


<P>
<CODE>make_directory(DirName)</CODE>


<P>
Equivalent to <CODE>make_directory(D,0o777)</CODE>.


</DL>

<P>
<A NAME="IDX3399"></A>
<A NAME="IDX3400"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>make_dirpath/2:</B>
<DD><A NAME="IDX3401"></A>


<P>
<CODE>make_dirpath(Path, Mode)</CODE>


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


</DL>

<P>
<A NAME="IDX3402"></A>
<A NAME="IDX3403"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>make_dirpath/1:</B>
<DD><A NAME="IDX3404"></A>


<P>
<CODE>make_dirpath(Path)</CODE>


<P>
Equivalent to <CODE>make_dirpath(D,0o777)</CODE>.


</DL>

<P>
<A NAME="IDX3405"></A>
<A NAME="IDX3406"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>working_directory/2:</B>
<DD><A NAME="IDX3407"></A>


<P>
<CODE>working_directory(OldDir, NewDir)</CODE>


<P>
Unifies current working directory with <CODE>OldDir</CODE>, and then changes the working directory to <CODE>NewDir</CODE>. Calling <CODE>working_directory(Dir,Dir)</CODE> simply unifies <CODE>Dir</CODE> with the current working directory without changing anything else.


<P>
<STRONG>Usage 2:</STRONG> <CODE>working_directory(OldDir, NewDir)</CODE>

<UL>
<LI><EM>Description:</EM> Gets current working directory.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>OldDir</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

<CODE>NewDir</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

The terms <CODE>OldDir</CODE> and <CODE>NewDir</CODE> are strictly identical.
 (<CODE>term_compare:== /2</CODE>)
<LI><EM>The following properties hold upon exit:</EM>

<CODE>OldDir</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)

<CODE>NewDir</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX3408"></A>
<A NAME="IDX3409"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>cd/1:</B>
<DD><A NAME="IDX3410"></A>


<P>
<CODE>cd(Path)</CODE>


<P>
Changes working directory to <CODE>Path</CODE>.


</DL>

<P>
<A NAME="IDX3411"></A>
<A NAME="IDX3412"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>shell/0:</B>
<DD><A NAME="IDX3413"></A>


<P>
<STRONG>Usage:</STRONG> 

<UL>
<LI><EM>Description:</EM> Execs the shell specified by the environment variable <CODE>SHELL</CODE>. When the shell process terminates, control is returned to Prolog.

</UL>

</DL>

<P>
<A NAME="IDX3414"></A>
<A NAME="IDX3415"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>shell/1:</B>
<DD><A NAME="IDX3416"></A>


<P>
<CODE>shell(Command)</CODE>


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


</DL>

<P>
<A NAME="IDX3417"></A>
<A NAME="IDX3418"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>shell/2:</B>
<DD><A NAME="IDX3419"></A>


<P>
<CODE>shell(Command, ReturnCode)</CODE>


<P>
Executes <CODE>Command</CODE> in the shell specified by the environment variable <CODE>SHELL</CODE> and stores the exit code in <CODE>ReturnCode</CODE>.


</DL>

<P>
<A NAME="IDX3420"></A>
<A NAME="IDX3421"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>system/1:</B>
<DD><A NAME="IDX3422"></A>


<P>
<CODE>system(Command)</CODE>


<P>
Executes <CODE>Command</CODE> using the shell 
<A NAME="IDX3423"></A>
<CODE>/bin/sh</CODE>.


</DL>

<P>
<A NAME="IDX3424"></A>
<A NAME="IDX3425"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>system/2:</B>
<DD><A NAME="IDX3426"></A>


<P>
<CODE>system(Command, ReturnCode)</CODE>


<P>
Executes <CODE>Command</CODE> in the 
<A NAME="IDX3427"></A>
<CODE>/bin/sh</CODE> shell and stores the exit code in <CODE>ReturnCode</CODE>.


</DL>

<P>
<A NAME="IDX3428"></A>
<A NAME="IDX3429"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>popen/3:</B>
<DD><A NAME="IDX3430"></A>


<P>
<CODE>popen(Command, Mode, Stream)</CODE>


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


</DL>

<P>
<A NAME="IDX3433"></A>
<A NAME="IDX3434"></A>
<DL>
<DT><span class="define">REGTYPE:</span> <B>popen_mode/1:</B>
<DD><A NAME="IDX3435"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>popen_mode(M)</CODE>

<UL>
<LI><EM>Description:</EM> <CODE>M</CODE> is 'read' or 'write'.

</UL>

</DL>

<P>
<A NAME="IDX3436"></A>
<A NAME="IDX3437"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>exec/4:</B>
<DD><A NAME="IDX3438"></A>


<P>
<CODE>exec(Command, StdIn, StdOut, StdErr)</CODE>


<P>
Starts the process <CODE>Command</CODE> and returns the standart I/O streams of the process in <CODE>StdIn</CODE>, <CODE>StdOut</CODE>, and <CODE>StdErr</CODE>. If <CODE>Command</CODE> 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 
<A NAME="IDX3439"></A>
<CODE>exec('ls -lRa ../sibling_dir', In, Out, Err)</CODE>.


</DL>

<P>
<A NAME="IDX3440"></A>
<A NAME="IDX3441"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>exec/3:</B>
<DD><A NAME="IDX3442"></A>


<P>
<CODE>exec(Command, StdIn, StdOut)</CODE>


<P>
Starts the process <CODE>Command</CODE> and returns the standart I/O streams of the process in <CODE>StdIn</CODE> and <CODE>StdOut</CODE>. <CODE>Standard error</CODE> is connected to whichever the parent process had it connected to. <CODE>Command</CODE> is treated and split in components as in 
<A NAME="IDX3443"></A>
<CODE>exec/4</CODE>.


</DL>

<P>
<A NAME="IDX3444"></A>
<A NAME="IDX3445"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>exec/8:</B>
<DD><A NAME="IDX3446"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>exec(+Command, +Arguments, ?StdIn, ?StdOut, ?StdErr, +Background, -PID, -ErrCode)</CODE>

<UL>
<LI><EM>Description:</EM>

<A NAME="IDX3447"></A>
<CODE>exec/8</CODE> gives a finer control for launching external processes. <CODE>Command</CODE> is the command to be executed and <CODE>Arguments</CODE> is a list of atoms to be passed as arguments to the command. When called with free variables, <CODE>StdIn</CODE>, <CODE>StdOut</CODE>, and <CODE>StdErr</CODE> are instantiated to streams connected to the standard output, input, and error of the created process. <CODE>Background</CODE> controls whether the caller waits for <CODE>Command</CODE> to finish, or if the process executing <CODE>Command</CODE> is completely detached (it can be waited for using 
<A NAME="IDX3448"></A>
<CODE>wait/3</CODE>). <CODE>ErrCode</CODE> is the error code returned by the lower-level <CODE>exec()</CODE> system call (this return code is system-dependent, but a non-zero value usually means that something has gone wrong). If <CODE>Command</CODE> does not start by a slash, 
<A NAME="IDX3449"></A>
<CODE>exec/8</CODE> uses the environment variable <CODE>PATH</CODE> to search for it. If <CODE>PATH</CODE> is not set, <CODE>/bin</CODE> and <CODE>/usr/bin</CODE> are searched. 
<LI><EM>The following properties should hold at call time:</EM>

<CODE>+Command</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)

<CODE>+Arguments</CODE> is a list of <CODE>atm</CODE>s.
 (<CODE>basic_props:list/2</CODE>)

<CODE>?StdIn</CODE> is an open stream.
 (<CODE>streams_basic:stream/1</CODE>)

<CODE>?StdOut</CODE> is an open stream.
 (<CODE>streams_basic:stream/1</CODE>)

<CODE>?StdErr</CODE> is an open stream.
 (<CODE>streams_basic:stream/1</CODE>)

<CODE>+Background</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)

<CODE>-PID</CODE> is an integer.
 (<CODE>basic_props:int/1</CODE>)

<CODE>-ErrCode</CODE> is an integer.
 (<CODE>basic_props:int/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX3450"></A>
<A NAME="IDX3451"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>wait/3:</B>
<DD><A NAME="IDX3452"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>wait(+Pid, -RetCode, -Status)</CODE>

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

<LI><EM>The following properties should hold at call time:</EM>

<CODE>+Pid</CODE> is an integer.
 (<CODE>basic_props:int/1</CODE>)

<CODE>-RetCode</CODE> is an integer.
 (<CODE>basic_props:int/1</CODE>)

<CODE>-Status</CODE> is an integer.
 (<CODE>basic_props:int/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX3453"></A>
<A NAME="IDX3454"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>directory_files/2:</B>
<DD><A NAME="IDX3455"></A>


<P>
<CODE>directory_files(Directory, FileList)</CODE>


<P>
<CODE>FileList</CODE> is the unordered list of entries (files, directories, etc.) in <CODE>Directory</CODE>.


</DL>

<P>
<A NAME="IDX3456"></A>
<A NAME="IDX3457"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>mktemp/2:</B>
<DD><A NAME="IDX3458"></A>


<P>
<CODE>mktemp(Template, Filename)</CODE>


<P>
Returns a unique <CODE>Filename</CODE> based on <CODE>Template</CODE>: <CODE>Template</CODE> must be a valid file name with six trailing X, which are substituted to create a new file name.


</DL>

<P>
<A NAME="IDX3459"></A>
<A NAME="IDX3460"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>file_exists/1:</B>
<DD><A NAME="IDX3461"></A>


<P>
<CODE>file_exists(File)</CODE>


<P>
Succeeds if <CODE>File</CODE> (a file or directory) exists (and is accessible).


</DL>

<P>
<A NAME="IDX3462"></A>
<A NAME="IDX3463"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>file_exists/2:</B>
<DD><A NAME="IDX3464"></A>


<P>
<CODE>file_exists(File, Mode)</CODE>


<P>
<CODE>File</CODE> (a file or directory) exists and it is accessible with <CODE>Mode</CODE>, as in the Unix call <CODE>access(2)</CODE>. Typically, <CODE>Mode</CODE> is 4 for read permission, 2 for write permission and 1 for execute permission.


</DL>

<P>
<A NAME="IDX3465"></A>
<A NAME="IDX3466"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>file_property/2:</B>
<DD><A NAME="IDX3467"></A>


<P>
<CODE>file_property(File, Property)</CODE>


<P>
<CODE>File</CODE> has the property <CODE>Property</CODE>. The possible properties are: 


<DL COMPACT>

<DT>type(<CODE>Type</CODE>)
<DD>
<CODE>Type</CODE> is one of <CODE>regular</CODE>, <CODE>directory</CODE>, <CODE>symlink</CODE>, <CODE>fifo</CODE>, <CODE>socket</CODE> or <CODE>unknown</CODE>. 

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

<DT>mod_time(<CODE>ModTime</CODE>)
<DD>
<CODE>ModTime</CODE> is the time of last modification (seconds since January, 1, 1970). 

<DT>mode(<CODE>Protection</CODE>)
<DD>
<CODE>Protection</CODE> is the protection mode. 

<DT>size(<CODE>Size</CODE>)
<DD>
<CODE>Size</CODE> is the size. 

</DL>

<P>
If <CODE>Property</CODE> is uninstantiated, the predicate will enumerate the properties on backtracking.


</DL>

<P>
<A NAME="IDX3468"></A>
<A NAME="IDX3469"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>file_properties/6:</B>
<DD><A NAME="IDX3470"></A>


<P>
<CODE>file_properties(Path, Type, Linkto, Time, Protection, Size)</CODE>


<P>
The file <CODE>Path</CODE> has the following properties: 



<UL>

<LI>File type <CODE>Type</CODE> (one of <CODE>regular</CODE>, <CODE>directory</CODE>, <CODE>symlink</CODE>, <CODE>fifo</CODE>, <CODE>socket</CODE> or <CODE>unknown</CODE>).

<LI>If <CODE>Path</CODE> is a symbolic link, <CODE>Linkto</CODE> is the file pointed to. All other properties come from the file pointed, not the link. <CODE>Linkto</CODE> is " if <CODE>Path</CODE> is not a symbolic link.

<LI>Time of last modification <CODE>Time</CODE> (seconds since January, 1, 1970).

<LI>Protection mode <CODE>Protection</CODE>.

<LI>Size in bytes <CODE>Size</CODE>.

</UL>

</DL>

<P>
<A NAME="IDX3471"></A>
<A NAME="IDX3472"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>modif_time/2:</B>
<DD><A NAME="IDX3473"></A>


<P>
<CODE>modif_time(File, Time)</CODE>


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


</DL>

<P>
<A NAME="IDX3474"></A>
<A NAME="IDX3475"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>modif_time0/2:</B>
<DD><A NAME="IDX3476"></A>


<P>
<CODE>modif_time0(File, Time)</CODE>


<P>
If <CODE>File</CODE> exists, <CODE>Time</CODE> is its latest modification time, as in 
<A NAME="IDX3477"></A>
<CODE>modif_time/2</CODE>. Otherwise, if <CODE>File</CODE> does not exist, <CODE>Time</CODE> is zero.


</DL>

<P>
<A NAME="IDX3478"></A>
<A NAME="IDX3479"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>fmode/2:</B>
<DD><A NAME="IDX3480"></A>


<P>
<CODE>fmode(File, Mode)</CODE>


<P>
The file <CODE>File</CODE> has protection mode <CODE>Mode</CODE>.


</DL>

<P>
<A NAME="IDX3481"></A>
<A NAME="IDX3482"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>chmod/2:</B>
<DD><A NAME="IDX3483"></A>


<P>
<CODE>chmod(File, NewMode)</CODE>


<P>
Change the protection mode of file <CODE>File</CODE> to <CODE>NewMode</CODE>.


</DL>

<P>
<A NAME="IDX3484"></A>
<A NAME="IDX3485"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>chmod/3:</B>
<DD><A NAME="IDX3486"></A>


<P>
<CODE>chmod(File, OldMode, NewMode)</CODE>


<P>
The file <CODE>File</CODE> has protection mode <CODE>OldMode</CODE> and it is changed to <CODE>NewMode</CODE>.


<P>
<STRONG>Usage 2:</STRONG> <CODE>chmod(File, OldMode, NewMode)</CODE>

<UL>
<LI><EM>Description:</EM> Equivalent to fmode(<CODE>File</CODE>,<CODE>OldMode</CODE>)

<LI><EM>The following properties should hold at call time:</EM>

<CODE>File</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)

<CODE>OldMode</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

<CODE>NewMode</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

The terms <CODE>OldMode</CODE> and <CODE>NewMode</CODE> are strictly identical.
 (<CODE>term_compare:== /2</CODE>)
<LI><EM>The following properties hold upon exit:</EM>

<CODE>File</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)

<CODE>OldMode</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)

<CODE>NewMode</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX3487"></A>
<A NAME="IDX3488"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>delete_file/1:</B>
<DD><A NAME="IDX3489"></A>


<P>
<CODE>delete_file(File)</CODE>


<P>
Delete the file <CODE>File</CODE>.


</DL>

<P>
<A NAME="IDX3490"></A>
<A NAME="IDX3491"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>delete_directory/1:</B>
<DD><A NAME="IDX3492"></A>


<P>
<CODE>delete_directory(File)</CODE>


<P>
Delete the directory <CODE>Directory</CODE>.


</DL>

<P>
<A NAME="IDX3493"></A>
<A NAME="IDX3494"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>rename_file/2:</B>
<DD><A NAME="IDX3495"></A>


<P>
<CODE>rename_file(File1, File2)</CODE>


<P>
Change the name of <CODE>File1</CODE> to <CODE>File2</CODE>.


</DL>

<P>
<A NAME="IDX3496"></A>
<A NAME="IDX3497"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>cyg2win/3:</B>
<DD><A NAME="IDX3498"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>cyg2win(CygWinPath, WindowsPath, SwapSlash)</CODE>

<UL>
<LI><EM>Description:</EM> Converts a path in the CygWin style to a Windows-style path, rewriting the driver part. If <CODE>SwapSlash</CODE> is <CODE>swap</CODE>, slashes are converted in to backslash. If it is <CODE>noswap</CODE>, they are preserved.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>CygWinPath</CODE> is a string (a list of character codes).
 (<CODE>basic_props:string/1</CODE>)

<CODE>WindowsPath</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

<CODE>SwapSlash</CODE> is currently instantiated to an atom.
 (<CODE>term_typing:atom/1</CODE>)
<LI><EM>The following properties should hold upon exit:</EM>

<CODE>CygWinPath</CODE> is a string (a list of character codes).
 (<CODE>basic_props:string/1</CODE>)

<CODE>WindowsPath</CODE> is a string (a list of character codes).
 (<CODE>basic_props:string/1</CODE>)

<CODE>SwapSlash</CODE> is currently instantiated to an atom.
 (<CODE>term_typing:atom/1</CODE>)
</UL>

</DL>



<H2><A NAME="SEC247" HREF="ciao_toc.html#TOC247">Documentation on multifiles (<CODE>system</CODE>)</A></H2>
<P>
<A NAME="IDX3499"></A>
<A NAME="IDX3500"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>define_flag/3:</B>
<DD><A NAME="IDX3501"></A>


<P>
No further documentation available for this predicate.


<P>
The predicate is <EM>multifile</EM>.


</DL>



<H2><A NAME="SEC248" HREF="ciao_toc.html#TOC248">Known bugs and planned improvements (<CODE>system</CODE>)</A></H2>


<UL>

<LI>

<A NAME="IDX3502"></A>
<CODE>shell/n</CODE> 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 <STRONG>might</STRONG> 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 <CODE>sh.exe</CODE> provided with Ciao, which is able to start Windows aplications. Therefore, <CODE>?- shell('command.com').</CODE> just works.

<LI>

If 
<A NAME="IDX3503"></A>
<CODE>exec/4</CODE> 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.

<LI>

If the arguments to cyg2win/3 are not strings, strange results appear, as a very mild type checking is performed.
</UL>

<P><HR><P>
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_51.html">previous</A>, <A HREF="ciao_53.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
</BODY>
</HTML>