open/[3,4]open(+FileSpec, +Mode, -Stream)
open(+FileSpec, +Mode, +Options, -Stream)
Creates a Prolog stream by opening the file FileSpec in mode Mode with options Options.
[read,write,append]
read
write
append
text
binary
variable, and turns off trimming.
record(Size)
end_of_line(EolCode)
end_of_file(EofCode)
eof_action(Action)
error
eof_code
end_of_file option for reading past end of file.
reset
overflow(OvAction)
error
truncate
flush
seek(SeekOption)
error
previous
stream_position/3 is the only
predicate that can be used to seek on the stream. This is the default
for both text and binary streams.
byte
seek(previous).
Both stream_position/3 and seek/4 work on the stream.
record
flush(FlushType)
error
flush
trim
format below.
system(SysAttrs)
QU_open() function, which can be
redefined by the user. The default version of QU_open() will report an
error, causing a permission_error to be raised, if system(SysAttrs)
is specified.
format(Format)
format(delimited(lf))
for text stream, format(variable) for binary stream, and
format(delimited(tty)) for tty file. Users will not
normally need to use the format(Format) options directly.
Format is one of:
variable
trim option is set.
delimited(lf)
delimited(tty)
QP_DELIM_LF as far
as record termination is concerned.
end_of_line option) is returned
instead as the character code at the end of the record. Prolog system
also puts delimiter characters at the end of record when a record is
written out.
format(variable) is used; otherwise format(delimited(lf)) is
used.
open/3 is equivalent to open/4 with Options=[].
open/4 is designed to work on various file systems under
different operating systems.
Stream is used as an argument to Prolog input and output predicates.
Stream can also be converted to the corresponding foreign
representation through stream_code/2 and used in foreign code to
perform input/output operations.
domain_error
read, write or append.
Options has an undefined option or an element in Options
is out of the domain of the option.
instantiation_error
type_error
existence_error
permission_error
resource_error
If an option is specified more than once the rightmost option takes precedence.
Prolog streams are in general classified as tty streams, text streams,
or binary streams. A Prolog stream is a tty stream if the format of
the stream is set to format(delimited(tty)), or if no format is
specified and FileSpec refers to a terminal (decided by the function
isatty(3)). Prolog provides a special service to print prompts for a
tty input stream. A text stream corresponds to a text file. The
Prolog system removes the control characters of the text stream. A
binary stream is a stream of bytes; the Prolog system returns the
actual characters stored in the file. Specifying binary or
text along with trim and end_of_line options will
result in a hybrid of binary and text streams.
Defaults are provided for Options in QU_stream_param()
function. This description is based on those input/output defaults.
Format is seldom set by the user. It is only
useful in case the user has redefined QU_open().
open(FileSpec, Mode, [binary, seek(byte),
eof_action(eof_code)], Stream).
open(FileSpec, Mode, [record(0)], Stream).
/dev/tty, it means that the file is the default tty for the Prolog system. Terminal is used interactively.
open_null_stream/1, close/1,
QP_prepare_stream/[3,4] QP_fopen(), QP_fdopen(),
QU_open()
fli-emb-how-iou