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
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
pathstringThe 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
pathstringThe 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
dataIDataInfoThe 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
pathstringThe 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
pathstringThe path to the file.
Returns
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
pathstringThe path to the file.
Returns
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
pathstringThe path to the file.
Returns
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
pathstringThe path to the file.
Returns
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
pathstringThe path to the file.
Returns
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
pathstringThe path to the file.
Returns
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
dataIArchiveInfoThe archive information to get the parent of.
Returns
Move(string?, string?)
Moves a file to a new location.
public static bool Move(string? path, string? destinationPath)
Parameters
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
pathstringThe path to the file to open.
Returns
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
pathstringThe path to the file to open.
accessFileAccessThe file access mode specifying read and/or write permissions.
Returns
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
pathstringThe path to the file to open.
accessFileAccessThe file access mode specifying read and/or write permissions.
typeStreamTypeThe type of stream to use for accessing the file.
Returns
Exceptions
- ArgumentNullException
Thrown when path is null.