Guardian C Library Calls Reference Manual

Reference to Library Calls
Guardian TNS C Library Calls Reference Manual128833 3-49
fopen
Usage Guidelines
The possible values of the string *access_mode are:
If you attempt to open a file in read mode and the file does not exist or cannot be
read, fopen fails, returning the pointer value NULL.
When you open a file in append mode, the file-position indicator is set to the end of
the file before each write operation, regardless of previous positioning.
When you include a system name in the file name, you must precede the system
name with two backslashes instead of one because backslash is an escape character
in C. For example, to open the file \sys.$vol.svol.file, you would use the C string:
"\\sys.$vol.svol.file"
Unless you include b in the access string, the file is opened as a text file.
If the file does not already exist, fopen creates a C binary file if you include b in the
access string; otherwise, it creates an Edit file.
The default number of secondary extents for files created by fopen is 16.
The default number of maxextents for files created by fopen is 500.
"r"
Open an existing text file for read-only access.
"w"
Create a text file (or truncate an existing text file to length zero) and
open it for write-only access.
"a"
Create a text file (or open an existing text file) and open it for append
(write at the end of the file) access.
"r+"
Open an existing text file for update access (reading and writing).
"w+"
Create a text file (or truncate an existing text file to length zero) and
open it for update access.
"a+"
Create a text file (or open an existing text file) and open it for update
access with writing at the end of the file.
"rb"
Open an existing binary file for read-only access.
"wb"
Create a binary file (or truncate an existing binary file to length zero) and
open it for write-only access.
"ab"
Create a binary file (or open an existing binary file) and open it for
append (write at the end of the file) access.
"rb+"
Open an existing binary file for update access (reading and writing).
"wb+"
Create a binary file (or truncate an existing binary file to length zero) and
open it for update access.
"ab+"
Create a binary file (or open an existing binary file) and open it for
update access with writing at the end of the file.