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.
Eof | Get stream end of file status |
Pos | Get position of seekable stream |
Size | Get size of seekable stream |
Seek | Seek to position in seekable stream |
Flush | Flush stream |
Close | Close stream |
Read | Read at least 1 byte from a stream |
Write | Write at least 1 byte to a stream |
Method Eof() | |
Returns | True for end of file reached, otherwise False |
Description | Get 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() | |
Returns | Stream position as a byte offset, or -1 if stream is not seekable |
Description | Get position of seekable stream |
Method Size() | |
Returns | Size, in bytes, of seekable stream, or 0 if stream is not seekable |
Description | Get size of seekable stream |
Method Seek( pos ) | |
Returns | New stream position, or -1 if stream is not seekable |
Description | Seek to position in seekable stream |
Method Flush() | |
Description | Flush stream |
Information | Flushes any internal stream buffers. |
Method Close() | |
Description | Close stream |
Information | Closes the stream after flushing any internal stream buffers. |
Method Read( buf:Byte Ptr,count ) | |
Returns | Number of bytes successfully read |
Description | Read 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 ) | |
Returns | Number of bytes successfully written |
Description | Write 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. |