Table of Contents

Class Archive

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

Provides static methods for working with archive files (files) in both Godot and system file systems.

public static class Archive
Inheritance
Archive
Inherited Members

Remarks

This class offers a unified interface for file operations that works seamlessly across Godot's virtual file system and the underlying operating system's file system, supporting various file operations including creation, opening, moving, and copying.

Methods

Copy(string?, string?)

Copies a file to a new location.

public static bool Copy(string? path, string? destinationPath)

Parameters

path string

The current path of the file.

destinationPath string

The destination path for the copy.

Returns

bool

true if the file was successfully copied; otherwise, false.

Exceptions

ArgumentNullException

Thrown when either path is null.

Create(string?)

Creates a new empty file at the specified path.

public static bool Create(string? path)

Parameters

path string

The path where the file should be created.

Returns

bool

true if the file was successfully created; otherwise, false.

Remarks

This method will not create files in the Godot resource path when running in release mode. If the file already exists, the operation will return false.

Exceptions

ArgumentNullException

Thrown when path is null.

Exists(string?)

Determines whether the specified file exists.

public static bool Exists(string? path)

Parameters

path string

The path to check for existence.

Returns

bool

true if the file exists; otherwise, false.

Remarks

This method works with both system files and Godot's virtual file system.

Exceptions

ArgumentNullException

Thrown when path is null.

GetArchiveAttributes(IDataInfo?)

Gets the archive attributes for the specified data information.

public static ArchiveAttributes GetArchiveAttributes(IDataInfo? data)

Parameters

data IDataInfo

The data information to get attributes for.

Returns

ArchiveAttributes

The ArchiveAttributes representing the file's attributes.

Remarks

For internal Godot files, returns a combination of Archive, ReadOnly, and Hidden attributes.

Exceptions

ArgumentNullException

Thrown when data is null.

GetArchiveAttributes(string?)

Gets the archive attributes for the specified file path.

public static ArchiveAttributes GetArchiveAttributes(string? path)

Parameters

path string

The path to the file to get attributes for.

Returns

ArchiveAttributes

The ArchiveAttributes representing the file's attributes.

Exceptions

ArgumentNullException

Thrown when path is null.

GetCreationTime(string?)

Gets the creation time of the specified file in local time.

public static DateTime GetCreationTime(string? path)

Parameters

path string

The path to the file.

Returns

DateTime

A DateTime representing the file's creation time in local time.

Exceptions

ArgumentNullException

Thrown when path is null.

GetCreationTimeUtc(string?)

Gets the creation time of the specified file in UTC time.

public static DateTime GetCreationTimeUtc(string? path)

Parameters

path string

The path to the file.

Returns

DateTime

A DateTime representing the file's creation time in UTC.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastAccessTime(string?)

Gets the last access time of the specified file in local time.

public static DateTime GetLastAccessTime(string? path)

Parameters

path string

The path to the file.

Returns

DateTime

A DateTime representing the file's last access time in local time.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastAccessTimeUtc(string?)

Gets the last access time of the specified file in UTC time.

public static DateTime GetLastAccessTimeUtc(string? path)

Parameters

path string

The path to the file.

Returns

DateTime

A DateTime representing the file's last access time in UTC.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastWriteTime(string?)

Gets the last write time of the specified file in local time.

public static DateTime GetLastWriteTime(string? path)

Parameters

path string

The path to the file.

Returns

DateTime

A DateTime representing the file's last write time in local time.

Exceptions

ArgumentNullException

Thrown when path is null.

GetLastWriteTimeUtc(string?)

Gets the last write time of the specified file in UTC time.

public static DateTime GetLastWriteTimeUtc(string? path)

Parameters

path string

The path to the file.

Returns

DateTime

A DateTime representing the file's last write time in UTC.

Exceptions

ArgumentNullException

Thrown when path is null.

GetParent(IArchiveInfo?)

Gets the parent folder of the specified archive information.

public static IDataInfo GetParent(IArchiveInfo? data)

Parameters

data IArchiveInfo

The archive information to get the parent of.

Returns

IDataInfo

An IDataInfo representing the parent folder.

Move(string?, string?)

Moves a file to a new location.

public static bool Move(string? path, string? destinationPath)

Parameters

path string

The current path of the file.

destinationPath string

The new path for the file.

Returns

bool

true if the file was successfully moved; otherwise, false.

Exceptions

ArgumentNullException

Thrown when either path is null.

Open(string?)

Opens a file at the specified path with read-write access using automatic stream type detection.

public static IStream Open(string? path)

Parameters

path string

The path to the file to open.

Returns

IStream

An IStream instance for reading from and writing to the file.

Exceptions

ArgumentNullException

Thrown when path is null.

Open(string?, FileAccess)

Opens a file at the specified path with the given access mode using automatic stream type detection.

public static IStream Open(string? path, FileAccess access)

Parameters

path string

The path to the file to open.

access FileAccess

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

Returns

IStream

An IStream instance for reading from or writing to the file.

Exceptions

ArgumentNullException

Thrown when path is null.

Open(string?, FileAccess, StreamType)

Opens a file at the specified path with the given access mode and stream type.

public static IStream Open(string? path, FileAccess access, StreamType type)

Parameters

path string

The path to the file to open.

access FileAccess

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

type StreamType

The type of stream to use for accessing the file.

Returns

IStream

An IStream instance for reading from or writing to the file.

Exceptions

ArgumentNullException

Thrown when path is null.