LZ4Stream Class
Namespace: Stride.Core.LZ4Assembly: Stride.Core.Serialization.dll
Block compression stream. Allows to use LZ4 for stream compression.
public class LZ4Stream : NativeStream, IDisposable
Name | Description | |
---|---|---|
Constructors | ||
LZ4Stream(Stream, CompressionMode, Boolean, Int64, Int64, Boolean, Int32) | Initializes a new instance of the LZ4Stream class. |
|
Properties | ||
CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. |
|
CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. |
|
CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. |
|
Length | When overridden in a derived class, gets the length in bytes of the stream. |
|
Position | The position in the uncompressed stream. |
|
Methods | ||
Dispose(Boolean) | Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. |
|
Flush() | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. |
|
Read(Byte[], Int32, Int32) | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. |
|
Read(IntPtr, Int32) | Reads a block of bytes from the stream and writes the data in a given buffer. |
|
ReadByte() | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. |
|
Reset() | Reset the stream to its initial position and state |
|
Seek(Int64, SeekOrigin) | When overridden in a derived class, sets the position within the current stream. |
|
SetLength(Int64) | When overridden in a derived class, sets the length of the current stream. |
|
Write(Byte[], Int32, Int32) | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. |
|
Write(IntPtr, Int32) | Writes a block of bytes to this stream using data from a buffer. |
|
WriteByte(Byte) | Writes a byte to the current position in the stream and advances the position within the stream by one byte. |
Constructors
LZ4Stream(Stream, CompressionMode, Boolean, Int64, Int64, Boolean, Int32)
Initializes a new instance of the LZ4Stream class.
public LZ4Stream(Stream innerStream, CompressionMode compressionMode, bool highCompression = false, long uncompressedSize = -1L, long compressedSize = -1L, bool disposeInnerStream = false, int blockSize = 1048576)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | innerStream | The inner stream. |
System.IO.Compression.CompressionMode | compressionMode | The compression mode. |
System.Boolean | highCompression | if set to |
System.Int64 | uncompressedSize | The size of the stream uncompressed |
System.Int64 | compressedSize | |
System.Boolean | disposeInnerStream | if set to |
System.Int32 | blockSize | Size of the block. |
Properties
CanRead
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the stream supports reading; otherwise, false. |
Overrides
CanSeek
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the stream supports seeking; otherwise, false. |
Overrides
CanWrite
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the stream supports writing; otherwise, false. |
Overrides
Length
When overridden in a derived class, gets the length in bytes of the stream.
public override long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 | A long value representing the length of the stream in bytes. |
Overrides
Position
The position in the uncompressed stream.
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 | The current position within the stream. |
Overrides
Methods
Dispose(Boolean)
Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
Flush()
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
public override void Flush()
Overrides
Read(Byte[], Int32, Int32)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | An array of bytes. When this method returns, the buffer contains the specified byte array with the values between |
System.Int32 | offset | The zero-based byte offset in |
System.Int32 | count | The maximum number of bytes to be read from the current stream. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. |
Overrides
Read(IntPtr, Int32)
Reads a block of bytes from the stream and writes the data in a given buffer.
public override int Read(IntPtr buffer, int count)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | buffer | When this method returns, contains the specified buffer with the values between 0 and (count - 1) replaced by the bytes read from the current source. |
System.Int32 | count | The maximum number of bytes to read. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | array is null. |
ReadByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
public override int ReadByte()
Returns
Type | Description |
---|---|
System.Int32 | The unsigned byte cast to an Int32, or -1 if at the end of the stream. |
Overrides
Reset()
Reset the stream to its initial position and state
public void Reset()
Seek(Int64, SeekOrigin)
When overridden in a derived class, sets the position within the current stream.
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | offset | A byte offset relative to the |
System.IO.SeekOrigin | origin | A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position. |
Returns
Type | Description |
---|---|
System.Int64 | The new position within the current stream. |
Overrides
SetLength(Int64)
When overridden in a derived class, sets the length of the current stream.
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The desired length of the current stream in bytes. |
Overrides
Write(Byte[], Int32, Int32)
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | An array of bytes. This method copies |
System.Int32 | offset | The zero-based byte offset in |
System.Int32 | count | The number of bytes to be written to the current stream. |
Overrides
Write(IntPtr, Int32)
Writes a block of bytes to this stream using data from a buffer.
public override void Write(IntPtr buffer, int count)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | buffer | The buffer containing data to write to the stream. |
System.Int32 | count | The number of bytes to be written to the current stream. |
Overrides
WriteByte(Byte)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
public override void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | The byte to write to the stream. |