MtFileStream

Namespace: SharpPluginLoader.Core.IO

Represents a file stream.

public class MtFileStream : MtStream, System.IDisposable

Inheritance ObjectNativeWrapperMtObjectMtStreamMtFileStream
Implements IDisposable

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

MtFileStream(IntPtr)

public MtFileStream(nint instance)

Parameters

instance IntPtr

MtFileStream()

public MtFileStream()

Methods

FromFile(MtFile)

Creates a new file stream from the specified file.

public static MtFileStream FromFile(MtFile file)

Parameters

file MtFile
The file to create the stream from.

Returns

MtFileStream
The created file stream, or null if the file stream could not be created.

FromPath(String, OpenMode, Boolean)

Opens a file stream from the specified path.

public static MtFileStream FromPath(string path, OpenMode mode, bool createPath)

Parameters

path String
The path of the file.

mode OpenMode
The mode to open the file in.

createPath Boolean
Whether to create the path if it does not exist.

Returns

MtFileStream
The opened file stream, or null if the file stream could not be opened.

Write(String, Encoding)

Writes the given string to the stream.

public long Write(string str, Encoding encoding)

Parameters

str String
The string to write.

encoding Encoding
The encoding to use. If null, UTF8 will be used.

Returns

Int64
The number of bytes written.

Dispose()

public void Dispose()

Finalize()

protected void Finalize()