/
ColdC/Functions/
ColdC/Structure/
<head><title>ColdC: Files</title></head>

<body>
<h1 align=center><a href="/ColdC/">ColdC</a>: Files</h1>
<hr>

<p>ColdC gives the ability to handle files with the following functions: 

<blockquote>
<pre>
<a href="Functions/execute.html">execute()</a>
<a href="Functions/fchmod.html">fchmod()</a>
<a href="Functions/fclose.html">fclose()</a>
<a href="Functions/feof.html">feof()</a>
<a href="Functions/fflush.html">fflush()</a>
<a href="Functions/file.html">file()</a>
<a href="Functions/files.html">files()</a>
<a href="Functions/fmkdir.html">fmkdir()</a>
<a href="Functions/fopen.html">fopen()</a>
<a href="Functions/frmdir.html">frmdir()</a>
<a href="Functions/fstat.html">fstat()</a>
<a href="Functions/fread.html">fread()</a>
<a href="Functions/fremove.html">fremove()</a>
<a href="Functions/frename.html">frename()</a>
<a href="Functions/fseek.html">fseek()</a>
<a href="Functions/fwrite.html">fwrite()</a>
</pre>
</blockquote>

<p>When a file is opened it is associated (i.e. bound) with the current object.
Therefore, most file functions assume there is a file associated with the
current object when you use them (such as <code>fwrite()</code>).  If there
is not a file, the error <code>~file</code> is thrown.

<p>If the driver was compiled with <code>RESTRICTIVE_FILES</code>, the
driver will restrict where on the filesystem files can be manipulated
(usually the <code>./root</code> directory, with the exception of the
function <code>execute()</code>, which will use the directory
<code>./dbbin</code>.  More information on where the directories are
given in the <a href="/Genesis/">Genesis Manual</a>).

<p>A file is opened using the function <code>fopen()</code>, and is closed
using the function <code>fclose()</code>.  Reaching the end of a file will
not close it.  Destroying the object for a file will close the file.

<p>Example of opening, writing to and closing a simple text logfile:

<blockquote>
<pre>
<a href="Functions/fopen.html">fopen</a>("log");
<a href="Functions/fwrite.html">fwrite</a>("[" + $time.format("%d %h %y %H:%M") + "] " + message);
<a href="Functions/fclose.html">fclose</a>();
</pre>
</blockquote>

<p>Example of reading an image file:
<blockquote>
<pre>
stat = <a href="Functions/fopen.html">fopen</a>("image.gif", "-");
buffer = <a href="Functions/fread.html">fread</a>(stat[2]);
fclose();
</pre>
</blockquote>

<hr size=4><p align=center><i>Last Modified on 23 March 1996</i>
<br><i>Copyright &copy; 1995, 1996, Brandon Gillespie</i>
</body>