#include <sicstus/sicstus.h> spio_t_error_code SP_fopen( char const *pathname, void *reserved, spio_t_bits options, SP_stream **pstream);
Opens a file and creates a SICStus stream reading and/or writing to it.
The path to the file as an encoded string.
It is expanded by
SP_expand_file_name() unless the option
SP_FOPEN_OPTION_NOEXPAND is specified, in which case the
path must already have been expanded by
Reserved, should be
The following bits can be set:
Open the file for reading. The file must exist.
Open the file for writing. The file is overwritten if it exists. The file is created if it does not exist.
Open the file for writing but start writing at the end of the file if it exists. The file is created if it does not exist.
Open the file as a binary (byte) stream.
Open the file as a text stream. The default character encoding is Latin 1 (i.e. the 8 bit subset of Unicode). The default end of line convention is OS specific.
After writing to this stream, Prolog predicates will do a
flush_output/1. In essence this ensures that the stream behaves
as if it were unbuffered.
Treat this stream as an interactive stream. Implies SP_CREATE_STREAM_OPTION_AUTOFLUSH.
If this is set, flush and close of the stream will not wait for data
to reach the disk. See the
SP_FCLOSE_OPTION_NO_FSYNC for more information.
pathname has already been expanded with
SP_expand_file_name() or something similar. This implies that
pathname is an absolute path. If this option is not
pathname is expanded with
SP_expand_file_name() before use.
On successful return,
*pstream will be set to the created
*pstream will be set to the created stream and
SPIO_S_NOERR or some other success code returned.
On failure, some SPIO failure code will be returned. Error codes with
special meaning for
The file does not exist.
Insufficient permissions to open or create the file.
Generic error during open.
Other error codes may also be returned.