Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)
fopen64_guardian(3) Guardian Native C Library Calls Ref
erence Manual
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.
When you open a file for update, you can perform both input and output operations on the result-
ing stream. However, an input operation cannot directly follow an output operation without an
intervening fflush( ) function call or a file-positioning operation (fseek(), fsetpos( ),orrewind()
function). Also, an output operation cannot directly follow an input operation without an inter-
vening flush or file-positioning operation, unless the input operation encounters the end of the
file.
When you open a file for append (that is, when the mode parameter is a, ab, a+,orab+), it is
impossible to overwrite information already in the file. You can use the fseek() function to repo-
sition the file pointer to any position in the file, but when output is written to the file, the current
file pointer is ignored. All output is written at the end of the file and the file pointer is reposi-
tioned to the end of the output.
If two separate processes open the same terminal or process for append (or, if the same process
has more than one concurrent open of a terminal or process for an append operation), you can use
each open to write freely to the file without destroying the output being written using the other
open. The output from the two opens is intermixed in the order in which it is written to the file.
If the data is buffered, it is not actually written until it is flushed.
Note: Guardian disk files cannot have more than one open at a time using fopen64_guardian()
unless all of the opens are only for reading (r or rb). To have more than one concurrent open of a
Guardian disk file for modification (any mode value except r or rb), you must use the Guardian
FILE_OPEN_ procedure to open the file with an exclusion mode of 0 (zero) for shared access.
When opened, a stream is fully buffered if and only if it does not refer to an interactive device.
The error and End-of-File indicators for the stream are cleared.
The ANSISTREAMS pragma determines whether a text file is type 180 (C binary file) or type 101
(edit file). The Guardian version of fopen64( ) distinguishes between text and binary files. If the
mode parameter does not contain a b, the file is created or opened as a text file. The OSS version
of fopen64( ) does not distinguish between text and binary files. Text and binary files in the OSS
environment are type 180. For information on the ANSISTREAMS pragma, see the C/C++
Programmer’s Guide.
2−32 Hewlett-Packard Company 527192-007