Table of Contents

Class ArchiveStream

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

Represents a file-based archive stream implementation that provides read and write operations.

public sealed class ArchiveStream : IArchiveStream, IStream, IDisposable
Inheritance
ArchiveStream
Implements
Inherited Members

Remarks

This class wraps a FileStream to provide archive stream functionality with various data type support including bytes, strings, and character arrays.

Constructors

ArchiveStream(string?, FileAccess)

Represents a file-based archive stream implementation that provides read and write operations.

public ArchiveStream(string? path, FileAccess access)

Parameters

path string

The path to the file. If null, may throw an exception.

access FileAccess

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

Remarks

This class wraps a FileStream to provide archive stream functionality with various data type support including bytes, strings, and character arrays.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

Name

Gets the name of the archive stream.

public string Name { get; }

Property Value

string

The name identifier of the stream.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

Position

Gets or sets the current position within the stream.

public long Position { get; set; }

Property Value

long

The current position within the stream.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

Methods

Dispose()

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

public void Dispose()

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.

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.

Exceptions

ArgumentNullException

Thrown when path is null.

FileNotFoundException

Thrown when the file does not exist.

UnauthorizedAccessException

Thrown when access is denied.