[top] [up] [next]

Stream properties


After a stream has been opened it has a set of properties which can be queried, this can be done with the predicate stream_property/2. The supported stream properties are:

file_name(F) If the source/sink is connected to a file then the name of the file is F, if the source/sink is not connected to a file then this property is not available. This property is not defined in the ISO Prolog Standard.
mode(M) M is the I/O mode which was specified when opening the source/sink (read, write or append).
input This means that the stream is connected to a source.
output The stream is connected to a sink.
alias(Name) Name will be an atom used as an alias to denote the stream, only the standard streams have default aliases.
position(P) If the stream has the property 'reposition(true)', P is the current stream position. If the stream has property 'reposition(false)' then this property is not available.
end_of_stream(E) E is one of the values:
  • at: the stream position is end-of-stream
  • past: the stream position is past-end-of-stream
  • not: the stream position is neither end-of-stream nor past-end-of-stream
eof_action(Action) Action has the value which was specified when the source/sink was opened. It can be one of the following three values:
  • error: a permission_error exception is thrown
  • eof_code: the result of input is as if the stream position is end-of-stream
  • reset: the stream position is reset so that it is not past-end-of-stream and another attempt is made to input from it.
reposition(Bool) Bool has the value which was specified when the source/sink was opened.
type(T) T has the value which was used to open the source/sink.

The properties of the standard streams are:

standard input standard output
mode(read) mode(append)
input output
alias(user_input) alias(user_output)
eof_action(reset) eof_action(reset)
reposition(false) reposition(false)
type(text) type(text)

[top] [up] [next]

 

info@trinc-prolog.com