Cold Help System: Programming: ColdC Reference Manual: Implementation: Files

ColdC gives the ability to handle files with the following functions:

execute() fchmod() fclose() feof()
fflush() file() files() fmkdir()
fopen() frmdir() fstat() fread()
fremove() frename() fseek() fwrite()

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 used (such as fwrite()). If there is not a file, the error ~file is thrown.

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

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

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

fwrite("[" + $time.format("%d %h %y %H:%M") + "] " + message);

Example of reading an image file:

stat = fopen("image.gif", "-");
buffer = fread(stat[2]);

Methods | Tasks and Frames | Errors | Security | Networking | Regexps | Files

the Cold Dark