Table of Contents

Class GodotArchiveStream

Namespace
Cobilas.GodotEngine.Utility.IO
Assembly
com.cobilas.godot.utility.dll

Represents a Godot-specific archive stream implementation that integrates with Godot's file system.

public sealed class GodotArchiveStream : IGodotArchiveStream, IStream, IDisposable
Inheritance
GodotArchiveStream
Implements
Inherited Members

Remarks

This class uses Godot's File API internally while providing a consistent stream interface. It maintains an in-memory buffer that synchronizes with the Godot file system.

Constructors

GodotArchiveStream(string?, FileAccess)

Initializes a new instance of the GodotArchiveStream class with the specified path and access mode.

public GodotArchiveStream(string? path, FileAccess access)

Parameters

path string

The path to the file in the Godot file system.

access FileAccess

The file access mode specifying read and/or write permissions.

Exceptions

ArgumentNullException

Thrown when path is null.

UnauthorizedAccessException

Thrown when the file cannot be opened due to access restrictions.

Properties

AutoFlush

Gets or sets a value indicating whether the stream should automatically flush after each write operation.

public bool AutoFlush { get; set; }

Property Value

bool

true if auto-flush is enabled; otherwise, false.

BufferLength

Gets or sets the length of the buffer.

public long BufferLength { get; set; }

Property Value

long

The current length of the buffer in bytes.

CanRead

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

public bool CanRead { get; }

Property Value

bool

true if the stream supports reading; otherwise, false.

CanWrite

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

public bool CanWrite { get; }

Property Value

bool

true if the stream supports writing; otherwise, false.

IsInternal

Gets a value indicating whether the stream is internal to the Godot engine.

public bool IsInternal { get; }

Property Value

bool

true if the stream is internal to Godot; otherwise, false.

Name

Gets the name of the Godot archive stream.

public string Name { get; }

Property Value

string

The name identifier of the stream.

Position

Gets or sets the current position within the stream.

public long Position { get; set; }

Property Value

long

The current position within the stream.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

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 void Flush()

Exceptions

IOException

An I/O error occurs.

Read()

Reads all bytes from the stream.

public byte[] Read()

Returns

byte[]

A byte array containing the data read from the stream.

Read(out char[])

Reads the stream content as a character array using UTF-8 encoding.

public void Read(out char[] result)

Parameters

result char[]

When this method returns, contains the character array representation of the stream content.

Read(out string)

Reads the stream content as a string using UTF-8 encoding.

public void Read(out string result)

Parameters

result string

When this method returns, contains the string representation of the stream content.

Read(Encoding?, out char[])

Reads the stream content as a character array using the specified encoding.

public void Read(Encoding? encoding, out char[] result)

Parameters

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

result char[]

When this method returns, contains the character array representation of the stream content.

Read(Encoding?, out string)

Reads the stream content as a string using the specified encoding.

public void Read(Encoding? encoding, out string result)

Parameters

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

result string

When this method returns, contains the string representation of the stream content.

Read(Encoding?, out StringBuilder)

Reads the stream content into a StringBuilder using the specified encoding.

public void Read(Encoding? encoding, out StringBuilder result)

Parameters

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

result StringBuilder

When this method returns, contains the StringBuilder with the stream content.

Read(out StringBuilder)

Reads the stream content into a StringBuilder using UTF-8 encoding.

public void Read(out StringBuilder result)

Parameters

result StringBuilder

When this method returns, contains the StringBuilder with the stream content.

RefreshBuffer()

Refreshes the stream buffer, ensuring that any pending changes are applied and the buffer state is updated.

public void RefreshBuffer()

Remarks

This method is particularly useful in Godot environment where buffer synchronization with the underlying resource management system is required.

ReplaceBuffer(byte[]?)

Replaces the entire stream content with the specified byte array.

public void ReplaceBuffer(byte[]? newBuffer)

Parameters

newBuffer byte[]

The new byte array content. If null, the stream will be cleared.

ReplaceBuffer(char[]?)

Replaces the entire stream content with a character array using UTF-8 encoding.

public void ReplaceBuffer(char[]? newBuffer)

Parameters

newBuffer char[]

The new character array content. If null, the stream will be cleared.

ReplaceBuffer(char[]?, Encoding?)

Replaces the entire stream content with a character array using the specified encoding.

public void ReplaceBuffer(char[]? newBuffer, Encoding? encoding)

Parameters

newBuffer char[]

The new character array content. If null, the stream will be cleared.

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

ReplaceBuffer(string?)

Replaces the entire stream content with a string using UTF-8 encoding.

public void ReplaceBuffer(string? newBuffer)

Parameters

newBuffer string

The new string content. If null, the stream will be cleared.

ReplaceBuffer(string?, Encoding?)

Replaces the entire stream content with a string using the specified encoding.

public void ReplaceBuffer(string? newBuffer, Encoding? encoding)

Parameters

newBuffer string

The new string content. If null, the stream will be cleared.

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

ReplaceBuffer(StringBuilder?)

Replaces the entire stream content with a StringBuilder using UTF-8 encoding.

public void ReplaceBuffer(StringBuilder? newBuffer)

Parameters

newBuffer StringBuilder

The new StringBuilder content. If null, the stream will be cleared.

ReplaceBuffer(StringBuilder?, Encoding?)

Replaces the entire stream content with a StringBuilder using the specified encoding.

public void ReplaceBuffer(StringBuilder? newBuffer, Encoding? encoding)

Parameters

newBuffer StringBuilder

The new StringBuilder content. If null, the stream will be cleared.

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

Write(byte[]?)

Writes a sequence of bytes to the stream.

public void Write(byte[]? buffer)

Parameters

buffer byte[]

The byte array to write. If null, no data is written.

Write(char[]?)

Writes a character array to the stream using UTF-8 encoding.

public void Write(char[]? buffer)

Parameters

buffer char[]

The character array to write. If null, no data is written.

Write(char[]?, Encoding?)

Writes a character array to the stream using the specified encoding.

public void Write(char[]? buffer, Encoding? encoding)

Parameters

buffer char[]

The character array to write. If null, no data is written.

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

Write(string?)

Writes a string to the stream using UTF-8 encoding.

public void Write(string? buffer)

Parameters

buffer string

The string to write. If null, no data is written.

Write(string?, Encoding?)

Writes a string to the stream using the specified encoding.

public void Write(string? buffer, Encoding? encoding)

Parameters

buffer string

The string to write. If null, no data is written.

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.

Write(StringBuilder?)

Writes a StringBuilder to the stream using UTF-8 encoding.

public void Write(StringBuilder? buffer)

Parameters

buffer StringBuilder

The StringBuilder to write. If null, no data is written.

Write(StringBuilder?, Encoding?)

Writes a StringBuilder to the stream using the specified encoding.

public void Write(StringBuilder? buffer, Encoding? encoding)

Parameters

buffer StringBuilder

The StringBuilder to write. If null, no data is written.

encoding Encoding

The character encoding to use. If null, UTF-8 will be used.