Next: cpg-ref-SP_foreign_stash, Previous: cpg-ref-SP_flush_output, Up: cpg-bif [Contents][Index]
SP_fopen()
#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 SP_expand_file_name()
.
Reserved, should be NULL
.
The following bits can be set:
SP_FOPEN_OPTION_READ
Open the file for reading. The file must exist.
SP_FOPEN_OPTION_WRITE
Open the file for writing. The file is overwritten if it exists. The file is created if it does not exist.
SP_FOPEN_OPTION_APPEND
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.
SP_FOPEN_OPTION_BINARY
Open the file as a binary (byte) stream.
SP_FOPEN_OPTION_TEXT
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.
SP_FOPEN_OPTION_AUTOFLUSH
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.
SP_FOPEN_OPTION_INTERACTIVE
Treat this stream as an interactive stream. Implies SP_CREATE_STREAM_OPTION_AUTOFLUSH.
SP_FOPEN_OPTION_NO_FSYNC
If this is set, flush and close of the stream will not wait for data
to reach the disk. See the SP_fclose()
option
SP_FCLOSE_OPTION_NO_FSYNC
for more information.
SP_FOPEN_OPTION_NOEXPAND
The 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
specified, pathname
is expanded with
SP_expand_file_name()
before use.
On successful return, *pstream
will be set to the created
stream.
On success, *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 SP_fopen()
:
SPIO_E_FILE_NOT_FOUND
The file does not exist.
SPIO_E_FILE_ACCESS
Insufficient permissions to open or create the file.
SPIO_E_OPEN_ERROR
Generic error during open.
Other error codes may also be returned.