next up previous contents index
Next: 6.1.2.1 Other Predicates using Up: 6.1 Input and Output Previous: 6.1.1 I/O Stream Implementation   Contents   Index

6.1.2 ISO Streams

open(+SourceSink,+Mode,-Stream)
ISO
open/1 creates a stream for the source or sink designated in SourceSink, and binds Stream to a structure representing that stream.

ISO Compatability Note: This predicate extends the ISO definition of open/3 to include strings and pipes as well as the file modes write_binary and append_binary.

Error Cases

open(+File,+Mode,-Stream,+Options)
ISO
open/4 behaves as does open/3, but allows a list of options to be given. The option alias(A) allows the stream to be aliased to an atom A. The ISO option type(T) has no effect on file streams in UNIX, which are always textual, but in Windows if T is binary a binary file is opened. The ISO option reposition(Boolean) currently has no effect on streams, because whether or not the stream is repositionable or not depends on the stream class. And finally, the ISO option eof_action(Action) currently has no effect on file streams. Appropriate warnings are given if an option list includes these option types.

Error Cases Error cases are the same as open/3 but with the addition:

close(+Stream_or_alias,+OptionsList)
ISO
close/2 closes the stream or alias Stream_or_alias. OptionsList allows the user to declare whether a permission error will be raised in XSB upon a resource or system error from the closing function (e.g. fclose() or other system function). If OptionsList is non-empty and contains only terms unifying with force(true) then such an error will be ignored (possibly leading to unacknowledged loss of data). Otherwise, a permission error is thrown if fclose() or other system function returns an error condition. If the stream class of Stream_or_alias is an atom, then the only action taken is to close the stream itself - the interned atom itself is not affected.

Error Cases

close(+Stream_or_alias)
ISO
close/1 closes the stream or alias Stream_or_alias.
Behaves as close(Stream_or_alias,[force(false)]).

set_input(+Stream_or_alias)
ISO
Makes file Stream_or_alias the current input stream.

Error Cases

set_output(+Stream_or_alias)
ISO
Makes file Stream_or_alias the current output stream.

Error Cases

stream_property(?Stream,?Property)
ISO
This predicate backtracks through the various stream properties that unify with Property for the stream Stream. Currently, the following properties are defined.

flush_output(+Stream_or_alias)
ISO
Any buffered data in Stream_or_alias gets flushed. If Stream is not buffered (i.e. if it is of class atom), no action is taken.

Error Cases

flush_output
ISO
Any buffered data in the current output stream gets flushed.

set_stream_position(+Stream_or_alias,+Position)
ISO
If the stream associated with Stream_or_alias is repositionable (i.e. is a file or atom), sets the stream position indicator for the next input or output operation. Position is a positive integer, taken to be the number of bytes the stream is to be placed from the origin.

Error Cases

at_end_of_stream(+Stream_or_alias)
ISO
Succeeds if Stream_or_alias has position at or past the end of stream.

Error Cases

at_end_of_stream
ISO
Acts as at_end_of_stream/1 but using the current input stream.



Subsections
next up previous contents index
Next: 6.1.2.1 Other Predicates using Up: 6.1 Input and Output Previous: 6.1.1 I/O Stream Implementation   Contents   Index
Terrance Swift 2007-10-05