Class FolderInfo
- Namespace
- Cobilas.GodotEngine.Utility.IO
- Assembly
- com.cobilas.godot.utility.dll
Represents information about a folder/directory and provides operations for folder management.
public sealed class FolderInfo : IFolderInfo, IDataInfo, IDisposable, IFormattable, IEnumerable<IDataInfo>, IEnumerable
- Inheritance
-
FolderInfo
- Implements
- Inherited Members
Remarks
This class implements the IFolderInfo interface and provides a unified way to work with folders in both Godot's virtual file system and the system file system. It maintains internal caches of folder contents for efficient enumeration and manipulation.
Constructors
FolderInfo(string?, bool)
Represents information about a folder/directory and provides operations for folder management.
public FolderInfo(string? path, bool skipHidden)
Parameters
pathstringThe path to the folder. If null, an exception will be thrown.
skipHiddenboolWhether to skip hidden files and folders in the enumeration.
Remarks
This class implements the IFolderInfo interface and provides a unified way to work with folders in both Godot's virtual file system and the system file system. It maintains internal caches of folder contents for efficient enumeration and manipulation.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
Properties
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
DataCount
Gets the total number of data items contained within the folder.
public long DataCount { get; }
Property Value
- long
The count of all data items (files and subfolders) in the folder.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
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.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
Parent
Gets the parent data item of the current item.
public IDataInfo Parent { get; }
Property Value
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
Methods
CreateArchive(string?)
Creates a new archive file with the specified name.
public IDataInfo CreateArchive(string? name)
Parameters
namestringThe name of the archive file to create.
Returns
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
CreateFolder(string?)
Creates a new subfolder with the specified name.
public IDataInfo CreateFolder(string? name)
Parameters
namestringThe name of the subfolder to create.
Returns
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
Existe(string?)
Checks whether a data item with the specified name exists in this folder.
public bool Existe(string? name)
Parameters
namestringThe name of the data item to check.
Returns
- bool
trueif a data item with the specified name exists; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
GetArchives()
Gets all archive files contained within this folder.
public IArchiveInfo[] GetArchives()
Returns
- IArchiveInfo[]
An array of IArchiveInfo representing all archive files.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<IDataInfo> GetEnumerator()
Returns
- IEnumerator<IDataInfo>
An enumerator that can be used to iterate through the collection.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
GetFolders()
Gets all subfolders contained within this folder.
public IFolderInfo[] GetFolders()
Returns
- IFolderInfo[]
An array of IFolderInfo representing all subfolders.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
Move(string?)
Moves the entire folder to a new location.
public bool Move(string? destinationPath)
Parameters
destinationPathstringThe destination path where the folder will be moved.
Returns
- bool
trueif the move operation succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
MoveTo(string?, string?)
Moves a data item from this folder to another location.
public bool MoveTo(string? name, string? path)
Parameters
namestringThe name of the data item to move.
pathstringThe destination path where the item will be moved.
Returns
- bool
trueif the move operation succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
Refresh()
Refreshes the folder contents, updating the internal state to reflect any external changes.
public void Refresh()
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
RemoveArchive(string?)
Removes an archive file with the specified name.
public bool RemoveArchive(string? name)
Parameters
namestringThe name of the archive to remove.
Returns
- bool
trueif the removal succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
RemoveFolder(string?)
Removes a subfolder with the specified name.
public bool RemoveFolder(string? name)
Parameters
namestringThe name of the folder to remove.
Returns
- bool
trueif the removal succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
RenameArchive(string?, string?)
Renames an archive file within this folder.
public bool RenameArchive(string? oldName, string? newName)
Parameters
oldNamestringThe current name of the archive to rename.
newNamestringThe new name for the archive.
Returns
- bool
trueif the rename operation succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
RenameFolder(string?, string?)
Renames a subfolder within this folder.
public bool RenameFolder(string? oldName, string? newName)
Parameters
oldNamestringThe current name of the folder to rename.
newNamestringThe new name for the folder.
Returns
- bool
trueif the rename operation succeeded; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
ToString()
Returns a string representation of the folder information using the current culture.
public override string ToString()
Returns
- string
A string containing the folder information.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
ToString(string)
Returns a formatted string representation of the folder information using the current culture.
public string ToString(string format)
Parameters
formatstringThe format string. Use placeholders:
-\%phfor path
-\%npfor name
-\%itlfor internal flag
-\%attfor attributes
-\%dtcfor data count.
Returns
- string
A formatted string containing the folder information.
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.
ToString(string, IFormatProvider)
Returns a formatted string representation of the folder information using the specified format and format provider.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
formatstringThe format string. Use placeholders:
-\%phfor path
-\%npfor name
-\%itlfor internal flag
-\%attfor attributes
-\%dtcfor data count.formatProviderIFormatProviderAn object that supplies culture-specific formatting information.
Returns
- string
A formatted string containing the folder information.
Remarks
The default format when empty is: "path:'{0}'\r\ninternal:'{2}'\r\nattributes:'{3}'\r\ndata count:'{4}'"
Placeholders in the format string are replaced as follows:
- \%ph: Full path
- \%np: Folder name
- \%itl: Internal flag
- \%att: Archive attributes
- \%dtc: Data count (number of items in folder)
Exceptions
- ArgumentNullException
Thrown when path is null.
- DirectoryNotFoundException
Thrown when the folder does not exist.
- IOException
Thrown when an I/O error occurs while opening the folder.