Class ArchiveInfo
- Namespace
- Cobilas.GodotEngine.Utility.IO
- Assembly
- com.cobilas.godot.utility.dll
Represents information about an archive file and provides operations for working with archive contents.
public sealed class ArchiveInfo : IArchiveInfo, IDataInfo, IDisposable, IFormattable
- Inheritance
-
ArchiveInfo
- Implements
- Inherited Members
Remarks
This class implements the IArchiveInfo interface and provides a unified way to work with files in both Godot's virtual file system and the system file system.
Constructors
ArchiveInfo(string?)
Represents information about an archive file and provides operations for working with archive contents.
public ArchiveInfo(string? path)
Parameters
pathstringThe path to the archive file. If null, an exception will be thrown.
Remarks
This class implements the IArchiveInfo interface and provides a unified way to work with files in both Godot's virtual file system and the system file system.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
Properties
ArchiveExtension
Gets the file extension of the archive.
public string ArchiveExtension { get; }
Property Value
- string
The archive file extension including the dot (e.g., ".zip", ".rar").
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
Attributes
Gets the attributes associated with the data item.
public ArchiveAttributes Attributes { get; }
Property Value
- ArchiveAttributes
The archive attributes defining the item's properties and permissions.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
FullName
Gets the full path and name of the data item.
public string FullName { get; }
Property Value
- string
The complete path including the item name.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
GetCreationTime
Gets the creation time of the data item in local time.
public DateTime GetCreationTime { get; }
Property Value
- DateTime
The creation date and time in local time.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
GetCreationTimeUtc
Gets the creation time of the data item in Coordinated Universal Time (UTC).
public DateTime GetCreationTimeUtc { get; }
Property Value
- DateTime
The creation date and time in UTC.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
GetLastAccessTime
Gets the last access time of the data item in local time.
public DateTime GetLastAccessTime { get; }
Property Value
- DateTime
The last access date and time in local time.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
GetLastAccessTimeUtc
Gets the last access time of the data item in Coordinated Universal Time (UTC).
public DateTime GetLastAccessTimeUtc { get; }
Property Value
- DateTime
The last access date and time in UTC.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
GetLastWriteTime
Gets the last write time of the data item in local time.
public DateTime GetLastWriteTime { get; }
Property Value
- DateTime
The last write date and time in local time.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
GetLastWriteTimeUtc
Gets the last write time of the data item in Coordinated Universal Time (UTC).
public DateTime GetLastWriteTimeUtc { get; }
Property Value
- DateTime
The last write date and time in UTC.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
IsGodotRoot
Gets a value indicating whether the data item is located at the Godot engine root.
public bool IsGodotRoot { get; }
Property Value
- bool
true if the item is at the Godot root; otherwise, false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
IsInternal
Gets a value indicating whether the data item is internal to the application or archive.
public bool IsInternal { get; }
Property Value
- bool
true if the item is internal; otherwise, false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
Name
Gets the name of the data item without the path.
public string Name { get; }
Property Value
- string
The name of the data item.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
NameWithoutExtension
Gets the name of the archive without the file extension.
public string NameWithoutExtension { get; }
Property Value
- string
The archive name excluding the extension.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
Parent
Gets the parent data item of the current item.
public IDataInfo Parent { get; }
Property Value
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
Methods
CopyTo(string?)
Copies the archive to the specified destination path without overwriting existing files.
public bool CopyTo(string? destinationPath)
Parameters
destinationPathstringThe destination path where the archive will be copied.
Returns
- bool
trueif the copy operation succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
CopyTo(string?, bool)
Copies the archive to the specified destination path.
public bool CopyTo(string? destinationPath, bool overwrite)
Parameters
destinationPathstringThe destination path where the archive will be copied.
overwriteboolWhether to overwrite an existing file at the destination path.
Returns
- bool
trueif the copy operation succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
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.
- IOException
Thrown when an I/O error occurs while opening the file.
Move(string?)
Moves the archive to the specified destination path.
public bool Move(string? destinationPath)
Parameters
destinationPathstringThe destination path where the archive will be moved.
Returns
- bool
trueif the move operation succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
Open(FileAccess)
Opens the archive with the specified access mode using the default StreamType.
public IStream Open(FileAccess access)
Parameters
accessFileAccessThe file access mode specifying read and/or write permissions.
Returns
- IStream
A stream object for reading from or writing to the archive.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
Open(FileAccess, StreamType)
Opens the archive with the specified access mode and StreamType.
public IStream Open(FileAccess access, StreamType type)
Parameters
accessFileAccessThe file access mode specifying read and/or write permissions.
typeStreamTypeThe type of stream to use for accessing the archive contents.
Returns
- IStream
A stream object for reading from or writing to the archive.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
ToString()
Returns a string representation of the archive information using the current culture.
public override string ToString()
Returns
- string
A string containing the archive information.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
ToString(string)
Returns a formatted string representation of the archive information using the current culture.
public string ToString(string format)
Parameters
formatstringThe format string. Use placeholders: \%ph for path, \%np for name, \%itl for internal flag, \%att for attributes.
Returns
- string
A formatted string containing the archive information.
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.
ToString(string, IFormatProvider)
Returns a formatted string representation of the archive information using the specified format and format provider.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
formatstringThe format string. Use placeholders: \%ph for path, \%np for name, \%itl for internal flag, \%att for attributes.
formatProviderIFormatProviderAn object that supplies culture-specific formatting information.
Returns
- string
A formatted string containing the archive information.
Remarks
The default format when empty is: "path:'{0}'\r\ninternal:'{2}'\r\nattributes:'{3}'"
Placeholders in the format string are replaced as follows:
- \%ph: Full path
- \%np: File name
- \%itl: Internal flag
- \%att: Archive attributes
Exceptions
- ArgumentNullException
Thrown when path is null.
- FileNotFoundException
Thrown when the file does not exist.
- IOException
Thrown when an I/O error occurs while opening the file.