Class GDFile
- Namespace
- Cobilas.GodotEngine.Utility
- Assembly
- com.cobilas.godot.utility.dll
This class is a representation of a file.
[Obsolete("Use Archive class")]
public class GDFile : GDFileBase, IDisposable- Inheritance
- 
      
      
      GDFile
- Implements
- Inherited Members
Properties
Attribute
The type of the item.
public override ArchiveAttributes Attribute { get; protected set; }Property Value
- ArchiveAttributes
- Returns the type of attribute the item has. - Null: Indicates that the item is a representation of a null file.- File: Indicates that the item is a representation of a file.- Directory: Indicates that the item is a representation of a directory file.
Name
Item name.
public override string Name { get; }Property Value
- string
- Returns the name of the item. 
NameWithoutExtension
The name of the item without extension.
public override string NameWithoutExtension { get; }Property Value
- string
- Returns the item name without its extension. 
Parent
The item's parent GDFileBase.
public override GDFileBase Parent { get; protected set; }Property Value
- GDFileBase
- Returns the parent GDFileBase that the item is affiliated with. 
Path
The path of the item.
public override string Path { get; protected set; }Property Value
- string
- Returns the full or relative path of the item. 
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public override void Dispose()Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
protected virtual void Dispose(bool disposing)Parameters
- disposingbool
- When the value is true the object discards the manageable resources. 
~GDFile()
The finalizer allows the disposal of unmanageable code.
protected ~GDFile()Load()
Loads a resource at the given path, caching the result for further access.
public Resource Load()Returns
- Resource
- Returns an empty resource if no Godot.ResourceFormatLoader could handle the file. 
Remarks
The registered Godot.ResourceFormatLoader are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
Load(string, bool)
Loads a resource at the given path, caching the result for further access.
public Resource Load(string typeHint = "", bool noCache = false)Parameters
- typeHintstring
- An optional - type_hintcan be used to further specify the Godot.Resource type that should be handled by the Godot.ResourceFormatLoader. Anything that inherits from Godot.Resource can be used as a type hint, for example Godot.Image.
- noCachebool
- If - no_cacheis- true, the resource cache will be bypassed and the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists.
Returns
- Resource
- Returns an empty resource if no Godot.ResourceFormatLoader could handle the file. 
Remarks
The registered Godot.ResourceFormatLoader are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
Load<T>()
Loads a resource at the given path, caching the result for further access.
public T Load<T>() where T : classReturns
- T
- Returns an empty resource if no Godot.ResourceFormatLoader could handle the file. 
Type Parameters
- T
- The type to cast to. Should be a descendant of Godot.Resource. 
Remarks
The registered Godot.ResourceFormatLoader are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
Exceptions
- InvalidCastException
- Thrown when the given the loaded resource can't be casted to the given type T. 
Load<T>(string, bool)
Loads a resource at the given path, caching the result for further access.
public T Load<T>(string typeHint = "", bool noCache = false) where T : classParameters
- typeHintstring
- An optional - type_hintcan be used to further specify the Godot.Resource type that should be handled by the Godot.ResourceFormatLoader. Anything that inherits from Godot.Resource can be used as a type hint, for example Godot.Image.
- noCachebool
- If - no_cacheis- true, the resource cache will be bypassed and the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists.
Returns
- T
- Returns an empty resource if no Godot.ResourceFormatLoader could handle the file. 
Type Parameters
- T
- The type to cast to. Should be a descendant of Godot.Resource. 
Remarks
The registered Godot.ResourceFormatLoader are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
Exceptions
- InvalidCastException
- Thrown when the given the loaded resource can't be casted to the given type T. 
Read()
Allows reading of the file.
public string Read()Returns
- string
- Returns the list of bytes read from the file converted to a string using the UTF-8 decoder. 
Write(byte[]?)
Allows you to write data into the file.
public void Write(byte[]? buffer)Parameters
- bufferbyte[]
- The list of bytes that will be written into the file.