Cold Help System: Programming: ColdC Reference Manual: Functions: File: fopen()


LIST fopen(STRING filename[, STRING mode])

This function is used to open a file on the current object. It is called with one or two arguments. The first argument is the name of the file to open. If the driver was compiled with the RESTRICTIVE_FILES option, the filename will have restrictions (see the section on Files for more information). If RESTRICTIVE_FILES was compiled, all files will have the root directory prepended to them (this directory is defined by a command line argument to Genesis). If it was not compiled, but the file does not begin with a slash ("/"), the root directory will still be prepended.

The second argument is the mode for the file. If the mode begins with "<" or nothing, the file is opened for reading. If the mode begins with ">", the file is truncated to zero length or created for writing. If the mode begins with ">>", the file is opend for appending. If the second argument is not specified, the mode of file defaults to "<".

A "+" may be placed before ">" or "<" to specify both read and write access to the file. Ending a mode with a "-" sets it as a binary file, meaning that input and output to the file is through buffers, rather than ColdC strings.

If successful, the return value of fopen() is stat information in the format returned by fstat().

Examples:

stat = fopen("log", ">>")
stat = fopen("/usr/home/test.info", "+>-")


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


the Cold Dark