Sophie

Sophie

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

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               - Basic file/stream handling</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_23.html">previous</A>, <A HREF="ciao_25.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="SEC153" HREF="ciao_toc.html#TOC153">Basic file/stream handling</A></H1>
<P>
<A NAME="IDX1606"></A>


<P>
<STRONG>Author(s):</STRONG> Daniel Cabeza, Mats Carlsson.


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


<P>
<STRONG>Version of last change:</STRONG> 1.9#247 (2003/12/29, 18:50:42 CET)


<P>
This module provides basic predicates for handling files and streams, in order to make input/output on them.



<UL>
<LI><A HREF="ciao_24.html#SEC154">Usage and interface (streams_basic)</A>
<LI><A HREF="ciao_24.html#SEC155">Documentation on exports (streams_basic)</A>
<LI><A HREF="ciao_24.html#SEC156">Documentation on multifiles (streams_basic)</A>
</UL>



<H2><A NAME="SEC154" HREF="ciao_toc.html#TOC154">Usage and interface (<CODE>streams_basic</CODE>)</A></H2>

<div class="cartouche">

<UL>

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

These predicates are builtin in Ciao, so nothing special has to be done to use them.

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


<UL>

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

<A NAME="IDX1607"></A>
<CODE>open/3</CODE>, 
<A NAME="IDX1608"></A>
<CODE>open/4</CODE>, 
<A NAME="IDX1609"></A>
<CODE>close/1</CODE>, 
<A NAME="IDX1610"></A>
<CODE>set_input/1</CODE>, 
<A NAME="IDX1611"></A>
<CODE>current_input/1</CODE>, 
<A NAME="IDX1612"></A>
<CODE>set_output/1</CODE>, 
<A NAME="IDX1613"></A>
<CODE>current_output/1</CODE>, 
<A NAME="IDX1614"></A>
<CODE>character_count/2</CODE>, 
<A NAME="IDX1615"></A>
<CODE>line_count/2</CODE>, 
<A NAME="IDX1616"></A>
<CODE>line_position/2</CODE>, 
<A NAME="IDX1617"></A>
<CODE>flush_output/1</CODE>, 
<A NAME="IDX1618"></A>
<CODE>flush_output/0</CODE>, 
<A NAME="IDX1619"></A>
<CODE>clearerr/1</CODE>, 
<A NAME="IDX1620"></A>
<CODE>current_stream/3</CODE>, 
<A NAME="IDX1621"></A>
<CODE>stream_code/2</CODE>, 
<A NAME="IDX1622"></A>
<CODE>absolute_file_name/2</CODE>, 
<A NAME="IDX1623"></A>
<CODE>absolute_file_name/7</CODE>.

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

<A NAME="IDX1624"></A>
<CODE>open_option_list/1</CODE>, 
<A NAME="IDX1625"></A>
<CODE>sourcename/1</CODE>, 
<A NAME="IDX1626"></A>
<CODE>stream/1</CODE>, 
<A NAME="IDX1627"></A>
<CODE>stream_alias/1</CODE>, 
<A NAME="IDX1628"></A>
<CODE>io_mode/1</CODE>.

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

<A NAME="IDX1629"></A>
<CODE>file_search_path/2</CODE>, 
<A NAME="IDX1630"></A>
<CODE>library_directory/1</CODE>.

</UL>

</UL>

</div class="cartouche">



<H2><A NAME="SEC155" HREF="ciao_toc.html#TOC155">Documentation on exports (<CODE>streams_basic</CODE>)</A></H2>
<P>
<A NAME="IDX1631"></A>
<A NAME="IDX1632"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>open/3:</B>
<DD><A NAME="IDX1633"></A>


<P>
<CODE>open(File, Mode, Stream)</CODE>


<P>
Open <CODE>File</CODE> with mode <CODE>Mode</CODE> and return in <CODE>Stream</CODE> the stream associated with the file. No extension is implicit in <CODE>File</CODE>.


<P>
<STRONG>Usage 1:</STRONG> <CODE>open(+sourcename, +io_mode, ?stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>Description:</EM> Normal use.

<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

<P>
<STRONG>Usage 2:</STRONG> <CODE>open(+int, +io_mode, ?stream)</CODE>

<UL>
<LI><EM>Description:</EM> In the special case that <CODE>File</CODE> is an integer, it is assumed to be a file descriptor passed to Prolog from a foreign function call. The file descriptor is connected to a Prolog stream (invoking the UNIX function <CODE>fdopen</CODE>) which is unified with <CODE>Stream</CODE>.

<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1634"></A>
<A NAME="IDX1635"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>open/4:</B>
<DD><A NAME="IDX1636"></A>


<P>
<CODE>open(File, Mode, Stream, Options)</CODE>


<P>
Same as <CODE>open(<CODE>File</CODE>, <CODE>Mode</CODE>, <CODE>Stream</CODE>)</CODE> with options <CODE>Options</CODE>. See the definition of 
<A NAME="IDX1637"></A>
<CODE>open_option_list/1</CODE> for details.


<P>
<STRONG>Usage:</STRONG> <CODE>open(+sourcename, +io_mode, ?stream, +open_option_list)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1638"></A>
<A NAME="IDX1639"></A>
<DL>
<DT><span class="define">REGTYPE:</span> <B>open_option_list/1:</B>
<DD><A NAME="IDX1640"></A>


<P>
A list of options for 
<A NAME="IDX1641"></A>
<CODE>open/4</CODE>, currently the meaningful options are: 


<DL COMPACT>

<DT><CODE>lock</CODE>
<DD>
Try to set an advisory lock for the file. If the open mode is <CODE>read</CODE>, the lock is a read (shared) lock, else it is a write (exclusive) lock. If the lock cannot be acquired, the call waits until it is released (but can fail in exceptional cases). 

<DT><CODE>lock_nb</CODE>
<DD>
Same as <CODE>lock</CODE>, but the call immediately fails if the lock cannot be acquired. 

<DT><CODE>lock(Lock_Mode)</CODE>
<DD>
Same as <CODE>lock</CODE>, but specifying in <CODE>Lock_Mode</CODE> whether the lock is <CODE>read</CODE> (also <CODE>shared</CODE>) or <CODE>write</CODE> (also <CODE>exclusive</CODE>). This option has be included for compatibility with the SWI-Prolog locking options, because in general the type of lock should match the open mode as in the <CODE>lock</CODE> option. 

<DT><CODE>lock_nb(Lock_Mode)</CODE>
<DD>
Same as the previous option but with the <CODE>lock_nb</CODE> behavior. 

</DL>

<P>
All file locking is implemented via the POSIX function fcntl(). Please refer to its manual page for details.


<P>
<STRONG>Usage:</STRONG> <CODE>open_option_list(L)</CODE>

<UL>
<LI><EM>Description:</EM> <CODE>L</CODE> is a list of options for

<A NAME="IDX1642"></A>
<CODE>open/4</CODE>. 
</UL>

</DL>

<P>
<A NAME="IDX1643"></A>
<A NAME="IDX1644"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>close/1:</B>
<DD><A NAME="IDX1645"></A>


<P>
<CODE>close(Stream)</CODE>


<P>
Close the stream <CODE>Stream</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>close(+stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1646"></A>
<A NAME="IDX1647"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>set_input/1:</B>
<DD><A NAME="IDX1648"></A>


<P>
<CODE>set_input(Stream)</CODE>


<P>
Set the current input stream to <CODE>Stream</CODE>. A notion of 
<A NAME="IDX1649"></A>
<A NAME="IDX1650"></A>
<EM>current input stream</EM> is maintained by the system, so that input predicates with no explicit stream operate on the current input stream. Initially it is set to <CODE>user_input</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>set_input(+stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1651"></A>
<A NAME="IDX1652"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>current_input/1:</B>
<DD><A NAME="IDX1653"></A>


<P>
<CODE>current_input(Stream)</CODE>


<P>
Unify <CODE>Stream</CODE> with the 
<A NAME="IDX1654"></A>
current input stream.


<P>
<STRONG>Usage:</STRONG> <CODE>current_input(?stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1655"></A>
<A NAME="IDX1656"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>set_output/1:</B>
<DD><A NAME="IDX1657"></A>


<P>
<CODE>set_output(Stream)</CODE>


<P>
Set the current output stream to <CODE>Stream</CODE>. A notion of 
<A NAME="IDX1658"></A>
<A NAME="IDX1659"></A>
<EM>current output stream</EM> is maintained by the system, so that output predicates with no explicit stream operate on the current output stream. Initially it is set to <CODE>user_output</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>set_output(+stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1660"></A>
<A NAME="IDX1661"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>current_output/1:</B>
<DD><A NAME="IDX1662"></A>


<P>
<CODE>current_output(Stream)</CODE>


<P>
Unify <CODE>Stream</CODE> with the 
<A NAME="IDX1663"></A>
current output stream.


<P>
<STRONG>Usage:</STRONG> <CODE>current_output(?stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1664"></A>
<A NAME="IDX1665"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>character_count/2:</B>
<DD><A NAME="IDX1666"></A>


<P>
<CODE>character_count(Stream, Count)</CODE>


<P>
<CODE>Count</CODE> characters have been read from or written to <CODE>Stream</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>character_count(+stream, ?int)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1667"></A>
<A NAME="IDX1668"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>line_count/2:</B>
<DD><A NAME="IDX1669"></A>


<P>
<CODE>line_count(Stream, Count)</CODE>


<P>
<CODE>Count</CODE> lines have been read from or written to <CODE>Stream</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>line_count(+stream, ?int)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1670"></A>
<A NAME="IDX1671"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>line_position/2:</B>
<DD><A NAME="IDX1672"></A>


<P>
<CODE>line_position(Stream, Count)</CODE>


<P>
<CODE>Count</CODE> characters have been read from or written to the current line of <CODE>Stream</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>line_position(+stream, ?int)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1673"></A>
<A NAME="IDX1674"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>flush_output/1:</B>
<DD><A NAME="IDX1675"></A>


<P>
<CODE>flush_output(Stream)</CODE>


<P>
Flush any buffered data to output stream <CODE>Stream</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>flush_output(+stream)</CODE>
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1676"></A>
<A NAME="IDX1677"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>flush_output/0:</B>
<DD><A NAME="IDX1678"></A>


<P>
<CODE>flush_output(flush_output</CODE>


<P>
Behaves like <CODE>current_output(S), flush_output(S)</CODE>


<P>
<STRONG>Usage:</STRONG> 
<KBD> * ISO * </KBD>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1679"></A>
<A NAME="IDX1680"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>clearerr/1:</B>
<DD><A NAME="IDX1681"></A>


<P>
<CODE>clearerr(Stream)</CODE>


<P>
Clear the end-of-file and error indicators for input stream <CODE>Stream</CODE>.


</DL>

<P>
<A NAME="IDX1682"></A>
<A NAME="IDX1683"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>current_stream/3:</B>
<DD><A NAME="IDX1684"></A>


<P>
<CODE>current_stream(Filename, Mode, Stream)</CODE>


<P>
<CODE>Stream</CODE> is a stream which was opened in mode <CODE>Mode</CODE> and which is connected to the absolute file name <CODE>Filename</CODE> (an atom) or to the file descriptor <CODE>Filename</CODE> (an integer). This predicate can be used for enumerating all currently open streams through backtracking.


<P>
<STRONG>General properties:</STRONG> 

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1685"></A>
<A NAME="IDX1686"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>stream_code/2:</B>
<DD><A NAME="IDX1687"></A>


<P>
<CODE>stream_code(Stream, StreamCode)</CODE>


<P>
<CODE>StreamCode</CODE> is the file descriptor (an integer) corresponding to the Prolog stream <CODE>Stream</CODE>.


</DL>

<P>
<A NAME="IDX1688"></A>
<A NAME="IDX1689"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>absolute_file_name/2:</B>
<DD><A NAME="IDX1690"></A>


<P>
<CODE>absolute_file_name(RelFileSpec, AbsFileSpec)</CODE>


<P>
If <CODE>RelFileSpec</CODE> is an absolute pathname then do an absolute lookup. If <CODE>RelFileSpec</CODE> is a relative pathname then prefix the name with the name of the current directory and do an absolute lookup. If <CODE>RelFileSpec</CODE> is a path alias, perform the lookup following the path alias rules (see 
<A NAME="IDX1691"></A>
<CODE>sourcename/1</CODE>). In all cases: if a matching file with suffix <CODE>.pl</CODE> exists, then <CODE>AbsFileSpec</CODE> will be unified with this file. Failure to open a file normally causes an exception. The behaviour can be controlled by the <CODE>fileerrors</CODE> 
<A NAME="IDX1692"></A>
prolog flag.


<P>
<STRONG>Usage:</STRONG> <CODE>absolute_file_name(+RelFileSpec, -AbsFileSpec)</CODE>

<UL>
<LI><EM>Description:</EM> <CODE>AbsFileSpec</CODE> is the absolute name (with full path) of <CODE>RelFileSpec</CODE>.

<LI><EM>Calls should, and exit will be compatible with:</EM>

<CODE>+RelFileSpec</CODE> is a source name.
 (<CODE>streams_basic:sourcename/1</CODE>)

<CODE>-AbsFileSpec</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1693"></A>
<A NAME="IDX1694"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>absolute_file_name/7:</B>
<DD><A NAME="IDX1695"></A>


<P>
<CODE>absolute_file_name(Spec, Opt, Suffix, CurrDir, AbsFile, AbsBase, AbsDir)</CODE>


<P>
<CODE>AbsFile</CODE> is the absolute name (with full path) of <CODE>Spec</CODE>, which has an optional first suffix <CODE>Opt</CODE> and an optional second suffix <CODE>Suffix</CODE>, when the current directory is <CODE>CurrDir</CODE>. <CODE>AbsBase</CODE> is the same as <CODE>AbsFile</CODE>, but without the second suffix, and <CODE>AbsDir</CODE> is the absolute path of the directory where <CODE>AbsFile</CODE> is. The Ciao compiler invokes this predicate with <CODE>Opt</CODE>=<CODE>'_opt'</CODE> and <CODE>Suffix</CODE>=<CODE>'.pl'</CODE> when searching source files.


<P>
<STRONG>Usage:</STRONG> <CODE>absolute_file_name(+sourcename, +atm, +atm, +atm, -atm, -atm, -atm)</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1696"></A>
<A NAME="IDX1697"></A>
<DL>
<DT><span class="define">REGTYPE:</span> <B>sourcename/1:</B>
<DD><A NAME="IDX1698"></A>


<P>
A source name is a flexible way of referring to a concrete file. A source name is either a relative or absolute filename given as: 



<UL>

<LI>an atom, or

<LI>a unary functor (which represents a

<A NAME="IDX1699"></A>
<A NAME="IDX1700"></A>
<EM>path alias</EM>, see below) applied to a <EM>relative</EM> path, the latter being given as an atom. 

</UL>

<P>
In all cases certain filename extensions (e.g., <CODE>.pl</CODE>) can be implicit. In the first form above, file names can be relative to the current directory. Also, file names beginning with <CODE>~</CODE> or <CODE>$</CODE> are treated specially. For example, 


<DL COMPACT>

<DT><CODE>'~/ciao/sample.pl'</CODE>
<DD>
is equivalent to <CODE>'/home/staff/herme/ciao/sample.pl'</CODE>, if <CODE>/home/staff/herme</CODE> is the user's home directory. (This is also equivalent to <CODE>'$HOME/ciao/sample.pl'</CODE> as explained below.) 

<DT><CODE>'~bardo/prolog/sample.pl'</CODE>
<DD>
is equivalent to <CODE>'/home/bardo/prolog/sample.pl'</CODE>, if <CODE>/home/bardo</CODE> is bardo's home directory. 

<DT><CODE>'$UTIL/sample.pl'</CODE>
<DD>
is equivalent to <CODE>'/usr/local/src/utilities/sample.pl'</CODE>, if <CODE>/usr/local/src/utilities</CODE> is the value of the environment variable <CODE>UTIL</CODE>. 

</DL>

<P>
The second form allows using path aliases. Such aliases allow refering to files not with absolute file system paths but with paths which are relative to predefined (or user-defined) abstract names. For example, given the path alias <CODE>myutils</CODE> which has been defined to refer to path <CODE>'/home/bardo/utilities'</CODE>, if that directory contains the file <CODE>stuff.pl</CODE> then the term <CODE>myutils(stuff)</CODE> in a 
<A NAME="IDX1701"></A>
<CODE>use_module/1</CODE> declaration would refer to the file <CODE>'/home/bardo/utilities/stuff.pl'</CODE> (the <CODE>.pl</CODE> extension is implicit in the 
<A NAME="IDX1702"></A>
<CODE>use_module/1</CODE> declaration). As a special case, if that directory contains a subdirectory named <CODE>stuff</CODE> which in turn contains the file <CODE>stuff.pl</CODE>, the same term would refer to the file <CODE>'/home/bardo/utilities/stuff/stuff.pl'</CODE>. If a path alias is related to several paths, all paths are scanned in sequence until a match is found. For information on predefined path aliases or how to define new path aliases, see 
<A NAME="IDX1703"></A>
<CODE>file_search_path/2</CODE>. 


<P>
<STRONG>Usage:</STRONG> <CODE>sourcename(F)</CODE>

<UL>
<LI><EM>Description:</EM> <CODE>F</CODE> is a source name.

</UL>

</DL>

<P>
<A NAME="IDX1704"></A>
<A NAME="IDX1705"></A>
<DL>
<DT><span class="define">REGTYPE:</span> <B>stream/1:</B>
<DD><A NAME="IDX1706"></A>


<P>
Streams correspond to the file pointers used at the operating system level, and usually represent opened files. There are four special streams which correspond with the operating system standard streams: 
<DL COMPACT>

<DT><CODE>user_input</CODE>
<DD>
The standard input stream, i.e. the terminal, usually. 

<DT><CODE>user_output</CODE>
<DD>
The standard output stream, i.e. the terminal, usually. 

<DT><CODE>user_error</CODE>
<DD>
The standard error stream. 

<DT><CODE>user</CODE>
<DD>
The standard input or output stream, depending on context. 

</DL>

<P>
<STRONG>Usage:</STRONG> <CODE>stream(S)</CODE>

<UL>
<LI><EM>Description:</EM> <CODE>S</CODE> is an open stream.

</UL>

</DL>

<P>
<A NAME="IDX1707"></A>
<A NAME="IDX1708"></A>
<DL>
<DT><span class="define">REGTYPE:</span> <B>stream_alias/1:</B>
<DD><A NAME="IDX1709"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>stream_alias(S)</CODE>

<UL>
<LI><EM>Description:</EM> <CODE>S</CODE> is the alias of an open stream, i.e., an atom which represents a stream at Prolog level.

</UL>

</DL>

<P>
<A NAME="IDX1710"></A>
<A NAME="IDX1711"></A>
<DL>
<DT><span class="define">REGTYPE:</span> <B>io_mode/1:</B>
<DD><A NAME="IDX1712"></A>


<P>
Can have the following values: 
<DL COMPACT>

<DT><CODE>read</CODE>
<DD>
Open the file for input. 

<DT><CODE>write</CODE>
<DD>
Open the file for output. The file is created if it does not already exist, the file will otherwise be truncated. 

<DT><CODE>append</CODE>
<DD>
Open the file for output. The file is created if it does not already exist, the file will otherwise be appended to. 

</DL>

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

<UL>
<LI><EM>Description:</EM> <CODE>M</CODE> is an opening mode ('read', 'write' or 'append').

</UL>

</DL>



<H2><A NAME="SEC156" HREF="ciao_toc.html#TOC156">Documentation on multifiles (<CODE>streams_basic</CODE>)</A></H2>
<P>
<A NAME="IDX1713"></A>
<A NAME="IDX1714"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>file_search_path/2:</B>
<DD><A NAME="IDX1715"></A>


<P>
<CODE>file_search_path(Alias, Path)</CODE>


<P>
The 
<A NAME="IDX1716"></A>
path alias <CODE>Alias</CODE> is linked to path <CODE>Path</CODE>. Both arguments must be atoms. New facts (or clauses) of this predicate can be asserted to define new path aliases. Predefined path aliases in Ciao are: 


<DL COMPACT>

<DT><CODE>library</CODE>
<DD>
Initially points to all Ciao library paths. See 
<A NAME="IDX1717"></A>
<CODE>library_directory/1</CODE>. 

<DT><CODE>engine</CODE>
<DD>
The path of the 
<A NAME="IDX1718"></A>
Ciao engine builtins. 

<DT><CODE>.</CODE>
<DD>
The current path (<CODE>'.'</CODE>). 

</DL>

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


<P>
The predicate is of type <EM>dynamic</EM>.


</DL>

<P>
<A NAME="IDX1719"></A>
<A NAME="IDX1720"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>library_directory/1:</B>
<DD><A NAME="IDX1721"></A>


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


<P>
<CODE>Path</CODE> is a library path (a path represented by the 
<A NAME="IDX1722"></A>
path alias <CODE>library</CODE>). Predefined library paths in Ciao are <CODE>'$CIAOLIB/lib'</CODE>, <CODE>'$CIAOLIB/library'</CODE>, and <CODE>'$CIAOLIB/contrib'</CODE>, given that <CODE>$CIAOLIB</CODE> is the path of the root ciao library directory. More library paths can be defined by asserting new facts (or clauses) of this predicate.


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


<P>
The predicate is of type <EM>dynamic</EM>.


</DL>

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