4.17.2 ISO Input and Output Streams
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Input and output
          • ISO Input and Output Streams
            • open/4
            • open/3
            • open_null_stream/1
            • close/1
            • close/2
            • stream_property/2
            • current_stream/3
            • is_stream/1
            • stream_pair/3
            • set_stream_position/2
            • stream_position_data/3
            • seek/4
            • set_stream/2
            • set_prolog_IO/3
            • set_system_IO/3
    • Packages
Availability:built-in
Source[ISO]stream_property(?Stream, ?StreamProperty)
True when StreamProperty is a property of Stream. If enumeration of streams or properties is demanded because either Stream or StreamProperty are unbound, the implementation enumerates all candidate streams and properties while locking the stream database. Properties are fetched without locking the stream and may be outdated before this predicate returns due to asynchronous activity.
alias(Atom)
If Atom is bound, test if the stream has the specified alias. Otherwise unify Atom with the first alias of the stream.bugBacktracking does not give other aliases.
buffer(Buffering)
SWI-Prolog extension to query the buffering mode of this stream. Buffering is one of full, line or false. See also open/4.
buffer_size(Integer)
SWI-Prolog extension to query the size of the I/O buffer associated to a stream in bytes. Fails if the stream is not buffered.
bom(Bool)
If present and true, a BOM (Byte Order Mark) was detected while opening the file for reading, or a BOM was written while opening the stream. See section 2.18.1.1 for details.
close_on_abort(Bool)
Determine whether or not abort/0 closes the stream. By default streams are closed.
close_on_exec(Bool)
Determine whether or not the stream is closed when executing a new process (exec() in Unix, CreateProcess() in Windows). Default is to close streams. This maps to fcntl() F_SETFD using the flag FD_CLOEXEC on Unix and (negated) HANDLE_FLAG_INHERIT on Windows.
encoding(Encoding)
Query the encoding used for text. See section 2.18.1 for an overview of wide character and encoding issues in SWI-Prolog.
end_of_stream(E)
If Stream is an input stream, unify E with one of the atoms not, at or past. See also at_end_of_stream/[0,1].
eof_action(A)
Unify A with one of eof_code, reset or error. See open/4 for details.
error(Bool)
When true, the stream is in an error state. Applies to both input and output streams.
file_name(Atom)
If Stream is associated to a file, unify Atom to the name of this file.
file_no(Integer)
If the stream is associated with a POSIX file descriptor, unify Integer with the descriptor number. SWI-Prolog extension used primarily for integration with foreign code. See also Sfileno() from SWI-Stream.h.
input
True if Stream has mode read.
locale(Locale)
True when Locale is the current locale associated with the stream. See section 4.23.
mode(IOMode)
Unify IOMode to the mode given to open/4 for opening the stream. Values are: read, write, append and the SWI-Prolog extension update.
newline(NewlineMode)
One of posix or dos. If dos, text streams will emit \r\n for \n and discard \r from input streams. Default depends on the operating system.
nlink(-Count)
Number of hard links to the file. This expresses the number of‘names’the file has. Not supported on all operating systems and the value might be bogus. See the documentation of fstat() for your OS and the value st_nlink.
output
True if Stream has mode write, append or update.
position(Pos)
Unify Pos with the current stream position. A stream position is an opaque term whose fields can be extracted using stream_position_data/3. See also set_stream_position/2.
reposition(Bool)
Unify Bool with true if the position of the stream can be set (see seek/4). It is assumed the position can be set if the stream has a seek-function and is not based on a POSIX file descriptor that is not associated to a regular file.
representation_errors(Mode)
Determines behaviour of character output if the stream cannot represent a character. For example, an ISO Latin-1 stream cannot represent Cyrillic characters. The behaviour is one of error (throw an I/O error exception), prolog (write \x<hex>\), unicode (write \uXXXX or \UXXXXXXXX escape sequences) or xml (write &#...; XML character entity). The initial mode is unicode for the user streams and error for all other streams. See also section 2.18.1 and set_stream/2.
timeout(-Time)
Time is the timeout currently associated with the stream. See set_stream/2 with the same option. If no timeout is specified, Time is unified to the atom infinite.
type(Type)
Unify Type with text or binary.
tty(Bool)
This property is reported with Bool equal to true if the stream is associated with a terminal. See also set_stream/2.
write_errors(Atom)
Atom is one of error (default) or ignore. The latter is intended to deal with service processes for which the standard output handles are not connected to valid streams. In these cases write errors may be ignored on user_error.