IDataStream
Description
- Derived from
-
IDisposableGeneric<IDataStream>
IDataStreamOps
IBinaryReader
IBinaryWriter
IPathInfo
ICanReadWrite
ITransferable<IDataStream> - Extended by
-
DataStreamBase abstract
A IDataStream object provides access to a stream of bytes.
All non-abstract implementations of IDataStream are required to call Finish when they are about to get disposed (e.g. first statement of Disposable.DisposeResources). If an error happens during that call, it will be logged, instead of being thrown as an exception. As best practice, code that writes to a data stream should call the Finish method before disposing the stream.
Public / Methods
Finish
Flushes the data stream and tells it that no more data will be written to it.
After calling this method, ICanWrite.CanWrite will return false
. Aggregated data streams will not be finished, so data may still be written to them.
- IOException
-
If an I/O error has occurred.
PopPosition
Pops the topmost position from the stack and sets the current file cursor position to that value.
The PushPosition and PopPosition are convenience methods that can be used jump back and forth in the file for reading/writing disjoint blocks of data.
- IOException
-
If an I/O error has occurred.
PushPosition
Pushes the current file cursor position onto the stack.
The PushPosition and PopPosition are convenience methods that can be used jump back and forth in the file for reading/writing disjoint blocks of data.
- IOException
-
If an I/O error has occurred.
Public / Attributes
Endianness
The byte-order to use for reading and writing multibyte values.
The default byte-order is ByteOrder.LittleEndian.
Position
The current position of the file cursor.
Settings this property to its current value will never throw a IOException because of CanSeek returning false
.
- IOException
-
If an I/O error has occurred.
Extensions
Codec
Encodes resp. decodes data using the given block codec before writing it to resp. after reading it from this stream.
For encoding (i.e. IBlockCodec.Mode is CodecMode.Encode), the returned data stream will be write-only: Data that is written to it will be divided into blocks which then get processed by this codec. Block padding will be performed with random data, if necessary. Processed blocks are chained with XOR
before being written to the this data stream.
For decoding (i.e. IBlockCodec.Mode is CodecMode.Decode), the returned data stream will be read-only: Data will be read from this data stream in blocks, which then get processed by this codec.
Deflate
Compresses data using RFC 1950/1951 before writing it to this stream.
- IOException
-
If this stream does not support writing.
Inflate
Decompresses data using RFC 1950/1951 after reading it from this stream.
- IOException
-
If this stream does not support reading.
ReadBom
Creates a ITextStream from the data of this object, consuming resp. byte order marks (BOM) at the current stream position.
The method tries to identify the following byte order marks (BOM) at the current stream position, in order to automatically determine the character encoding:
-
0xEF 0xBB 0xBF
: CharacterEncoding.UTF_8 -
0xFE 0xFF
: CharacterEncoding.UTF_16_BE -
0xFF 0xFE
: CharacterEncoding.UTF_16_LE
If no BOM is found, the given default encoding opt is used.
- IOException
-
If an I/O error has occurred.
Unzip
Interprets the given data stream as a ZIP/GZ archive and extracts the given entry.
- IOException
-
If this stream does not support reading, if the data format is invalid or if some other I/O error has occurred.
UnzipNames
Interprets the given data stream as a ZIP/GZ archive and extracts the names of all entries.
The stream position will be modified by this method.
- IOException
-
If this stream does not support reading, if the data format is invalid or if some other I/O error has occurred.
WriteBom
Creates a ITextStream from the data of this object, emitting byte order marks (BOM) at the current stream position.
The method will output the byte order marks according to the specified encoding opt:
-
0xEF 0xBB 0xBF
: CharacterEncoding.UTF_8 -
0xFE 0xFF
: CharacterEncoding.UTF_16_BE -
0xFF 0xFE
: CharacterEncoding.UTF_16_LE
- IOException
-
If an I/O error has occurred.