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
pathstringThe path to the file. If null, may throw an exception.
accessFileAccessThe 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
trueif 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
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
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
resultchar[]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
resultstringWhen 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
encodingEncodingThe character encoding to use. If null, UTF-8 will be used.
resultchar[]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
encodingEncodingThe character encoding to use. If null, UTF-8 will be used.
resultstringWhen 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
encodingEncodingThe character encoding to use. If null, UTF-8 will be used.
resultStringBuilderWhen 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
resultStringBuilderWhen 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
newBufferbyte[]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
newBufferchar[]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
newBufferchar[]The new character array content. If null, the stream will be cleared.
encodingEncodingThe 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
newBufferstringThe 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
newBufferstringThe new string content. If null, the stream will be cleared.
encodingEncodingThe 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
newBufferStringBuilderThe 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
newBufferStringBuilderThe new StringBuilder content. If null, the stream will be cleared.
encodingEncodingThe 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
bufferbyte[]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
bufferchar[]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
bufferchar[]The character array to write. If null, no data is written.
encodingEncodingThe 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
bufferstringThe 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
bufferstringThe string to write. If null, no data is written.
encodingEncodingThe 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
bufferStringBuilderThe 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
bufferStringBuilderThe StringBuilder to write. If null, no data is written.
encodingEncodingThe 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.