Table of Contents

Class ClrToSdlStream

Namespace
Sdl3Sharp.IO
Assembly
Sdl3Sharp.dll

Represents an SDL Stream that wraps a .NET (CLR) Stream

public sealed class ClrToSdlStream : Stream, IDisposable
Inheritance
ClrToSdlStream
Implements
Inherited Members
Extension Methods

Remarks

Please note that operations on this stream are potentially throwing. They won't throw inevitably, but exceptions from the underlying CLR stream will propagate through this wrapper.

Constructors

ClrToSdlStream(Stream, bool)

Creates a new ClrToSdlStream instance wrapping the provided CLR Stream

public ClrToSdlStream(Stream clrStream, bool leaveOpen = false)

Parameters

clrStream Stream

The CLR Stream to wrap

leaveOpen bool

A value indicating whether to leave the underlying CLR stream open when this stream is disposed

Exceptions

ArgumentNullException

clrStream is null

Properties

ClrStream

Gets the underlying CLR Stream

public Stream? ClrStream { get; }

Property Value

Stream

The underlying CLR Stream

LengthCore

Gets the total length, in bytes, of the stream

protected override long LengthCore { get; }

Property Value

long

The total length, in bytes, of the stream, or -1 on failure

See Also

Methods

CloseCore()

Closes the stream and release associated resources

protected override bool CloseCore()

Returns

bool

true if the stream was closed successfully; otherwise, false

See Also

Dispose(bool, bool)

Disposes the stream

protected override void Dispose(bool disposing, bool close)

Parameters

disposing bool

A value indicating whether the call came from a call to Dispose() or from the finalizer

close bool

A value indicating whether the stream should be closed

Remarks

This method is not threadsafe.

See Also

FlushCore(ref StreamStatus)

Flushes any buffered data in the stream

protected override bool FlushCore(ref StreamStatus status)

Parameters

status StreamStatus

The StreamStatus of the stream. The value of the referenced StreamStatus could change on failure and should not necessarily change on success.

Returns

bool

true if the flush was successful; otherwise, false

See Also

ReadCore(NativeMemory, ref StreamStatus)

Reads into specified data from the stream

protected override nuint ReadCore(NativeMemory data, ref StreamStatus status)

Parameters

data NativeMemory

The memory buffer to read data into

status StreamStatus

The StreamStatus of the stream. The value of the referenced StreamStatus could change on failure and should not necessarily change on success.

Returns

nuint

The number of bytes read from the stream

See Also

SeekCore(long, StreamWhence)

Seeks within the stream

protected override long SeekCore(long offset, StreamWhence whence)

Parameters

offset long

The offset to seek to

whence StreamWhence

The reference point for the seek operation

Returns

long

The absolute offset from the start of the stream after seeking, or -1 on failure

See Also

WriteCore(ReadOnlyNativeMemory, ref StreamStatus)

Writes all specified data into the stream

protected override nuint WriteCore(ReadOnlyNativeMemory data, ref StreamStatus status)

Parameters

data ReadOnlyNativeMemory

The memory buffer containing all the data to be written into the stream

status StreamStatus

The StreamStatus of the stream. The value of the referenced StreamStatus could change on failure and should not necessarily change on success.

Returns

nuint

The number of bytes read from the stream

See Also