TIO: Methods  


To create your own stream types, you should extend TStream and implement at least these methods.

You should also make sure your stream can handle multiple calls to the Close method.

Methods

EofGet stream end of file status
PosGet position of seekable stream
SizeGet size of seekable stream
SeekSeek to position in seekable stream
FlushFlush stream
CloseClose stream
ReadRead at least 1 byte from a stream
WriteWrite at least 1 byte to a stream

Method reference

Method Eof()
ReturnsTrue for end of file reached, otherwise False
DescriptionGet stream end of file status
Information For seekable streams such as file streams, Eof generally returns True if the file position equals the file size. This means that no more bytes can be read from the stream. However, it may still be possible to write bytes, in which case the file will 'grow'.

For communication type streams such as socket streams, Eof returns True if the stream has been shut down for some reason - either locally or by the remote host. In this case, no more bytes can be read from or written to the stream.

Method Pos()
ReturnsStream position as a byte offset, or -1 if stream is not seekable
DescriptionGet position of seekable stream

Method Size()
ReturnsSize, in bytes, of seekable stream, or 0 if stream is not seekable
DescriptionGet size of seekable stream

Method Seek( pos )
ReturnsNew stream position, or -1 if stream is not seekable
DescriptionSeek to position in seekable stream

Method Flush()
DescriptionFlush stream
Information Flushes any internal stream buffers.

Method Close()
DescriptionClose stream
Information Closes the stream after flushing any internal stream buffers.

Method Read( buf:Byte Ptr,count )
ReturnsNumber of bytes successfully read
DescriptionRead at least 1 byte from a stream
Information This method may 'block' if it is not possible to read at least one byte due to IO buffering.

If this method returns 0, the stream has reached end of file.

Method Write( buf:Byte Ptr,count )
ReturnsNumber of bytes successfully written
DescriptionWrite at least 1 byte to a stream
Information This method may 'block' if it is not possible to write at least one byte due to IO buffering.

If this method returns 0, the stream has reached end of file.