11.3.217 stream_property/2 [ISO]

Synopsis

stream_property(?Stream, ?Property))

Stream Stream has stream property Property.

Arguments

Stream
stream_object
Property
term

A stream property, one of the following:

file_name(F)
F is the file name associated with the Stream.
mode(M)
Stream has been opened in mode M.
input
Stream is an input stream. Note that both input and output stream properties are set for bidirectional streams.
output
Stream is an output stream. Note that both input and output stream properties are set for bidirectional streams.
alias(A)
Stream has an alias A.
position(P)
P is a term representing the current stream position of Stream. Only guaranteed to be available if the stream has been opened with the open/4 option reposition(true).

Same as stream_position(Stream, P) except that the latter can be called on any stream, regardless of the value of the reposition/1 open/4 option.

end_of_stream(E)
E describes the position of the input stream Stream, with respect to the end of stream. If not all characters have been read, or if peeking ahead to determine this fact would block, then E is unified with not; otherwise, (all characters read) but no end of stream indicator (-1 or end_of_file) was reported yet, then E is unified with at; otherwise, E is unified with past.
eof_action(A)
A is the end-of-file action applicable to Stream, cf. the eof_action option of open/4.
type(T)
Stream is of type T, one of text, binary, cf. the type option of open/4.
encoding(CS)
Stream is a text stream with encoding CS, cf. the encoding option of open/4. Note that the encoding used may be different from the encoding option passed to open/4 if a byte order mark or other information was used to determine the real encoding of the file, cf. the encoding_signature option of open/4.
eol(EOL)
Stream is a text stream with end of line convention EOL, cf. the eol option of open/4.
encoding_signature(ES)
If Stream is a text stream then ES is determined as follows:

If the file contents was used to determine the character encoding then ES will be true. Typically this is the result of opening, in mode read, a text file that contains a byte order mark or some other information that lets open/[3,4] determine a suitable encoding, cf. the encoding_signature option of open/4.

Otherwise if the stream is open in direction output then ES will be as specified when the file was opened.

reposition(REPOSITION)
REPOSITION is true if it is possible to set the position of the stream with set_stream_position/2, cf. the reposition option of open/4.
interactive
Stream is an interactive stream.

Most streams have only a subset of these properties set.

More properties may be added in the future.

Backtracking

Can be used to backtrack over all currently open streams, including the standard input/output/error streams, and all their properties. See ref-iou-sfh-bos.

Exceptions

domain_error
Stream is not a valid stream object, or Property is not a valid stream property.

See Also

ref-iou-sfh.


Send feedback on this subject.