MtStream

Namespace: SharpPluginLoader.Core.IO

Represents any kind of stream.

public class MtStream : SharpPluginLoader.Core.MtObject

Inheritance ObjectNativeWrapperMtObjectMtStream

Properties

Flags

The flags of the stream.

public UInt32& Flags { get; }

Property Value

UInt32&

IsReadable

Whether the stream is readable.

public bool IsReadable { get; }

Property Value

Boolean

IsWritable

Whether the stream is writable.

public bool IsWritable { get; }

Property Value

Boolean

IsSeekable

Whether the stream is seekable.

public bool IsSeekable { get; }

Property Value

Boolean

Position

Gets the position of the stream.

public long Position { get; }

Property Value

Int64

Length

Gets or sets the length of the stream.

public long Length { get; set; }

Property Value

Int64

Instance

The native pointer.

public nint Instance { get; set; }

Property Value

IntPtr

Constructors

MtStream(IntPtr)

public MtStream(nint instance)

Parameters

instance IntPtr

MtStream()

public MtStream()

Methods

Close()

Closes the stream.

public void Close()

Flush()

Flushes the stream.

public void Flush()

Read(Int64)

Reads the specified number of bytes from the stream.

public Byte[] Read(long count)

Parameters

count Int64
The number of bytes to read.

Returns

Byte[]
The bytes read.

Exceptions

Exception
Thrown if the number of bytes read does not match the number of bytes requested.

Read(Span<Byte>, Int64)

Reads the specified number of bytes from the stream.

public long Read(Span<byte> buffer, long count)

Parameters

buffer Span<Byte>
The buffer to read into.

count Int64
The number of bytes to read. If -1, it will read bytes equal to the length of the buffer.

Returns

Int64
The number of bytes read.

Write(ReadOnlySpan<Byte>)

Writes the specified bytes to the stream.

public long Write(ReadOnlySpan<byte> buffer)

Parameters

buffer ReadOnlySpan<Byte>
The bytes to write.

Returns

Int64
The number of bytes written.

Seek(Int64, SeekOrigin)

Seeks to the specified position in the stream.

public long Seek(long offset, SeekOrigin origin)

Parameters

offset Int64
The offset to seek to.

origin SeekOrigin
The origin to seek from.

Returns

Int64
The new position in the stream.

Skip(Int64)

Skips the specified number of bytes in the stream.

public void Skip(long count)

Parameters

count Int64
The number of bytes to skip.