Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

freopen64_guardian(3) OSS Library Calls Reference Manual
r Opens a text file for reading.
w Creates a new text file for writing, or opens and truncates a text file to zero
length.
a Appends (opens a text file for writing at the end of the file, or creates a text file
for writing).
r+ Opens a text file for update (reading and writing).
w+ Truncates or creates a text file for update.
a+ Appends (opens a text file for update, writing at the end of the file, or creates a
text file for writing).
rb Opens a C binary file for reading.
wb Creates a new C binary file for writing, or opens and truncates a C binary file to
zero length.
ab Appends (opens a C binary file for writing at the end of the file, or creates a C
binary file for writing).
rb+ Opens a C binary file for update (reading and writing).
wb+ Truncates or creates a C binary file for update.
ab+ Appends (opens a C binary file for update, writing at the end of the file, or
creates a C binary file for writing).
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 fush( ) function call or a file-positioning operation (such as the fseeko64( ), fset-
pos64( ),orrewind( ) functions). Also, an output operation cannot directly follow an input opera-
tion without an intervening 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 fseeko64( ) function to
reposition 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
repositioned to the end of the output.
If two separate processes open the same file for append, each process can write freely to the file
without destroying the output being written by the other. The output from the two processes 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.
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 freopen64( ) distinguishes between text and binary files. If
the mode parameter does not contain a b, the file is created or opened as a text le. The OSS ver-
sion of freopen64( ) 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.
2154 Hewlett-Packard Company 527187-017