1 /** 2 A directory for the resource filesystem. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.editorfilesystemdirectory; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 /** 24 A directory for the resource filesystem. 25 26 A more generalized, low-level variation of the directory concept. 27 */ 28 @GodotBaseClass struct EditorFileSystemDirectory 29 { 30 package(godot) enum string _GODOT_internal_name = "EditorFileSystemDirectory"; 31 public: 32 @nogc nothrow: 33 union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; } 34 alias _GODOT_base this; 35 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 36 package(godot) __gshared bool _classBindingInitialized = false; 37 package(godot) static struct GDNativeClassBinding 38 { 39 __gshared: 40 @GodotName("find_dir_index") GodotMethod!(long, String) findDirIndex; 41 @GodotName("find_file_index") GodotMethod!(long, String) findFileIndex; 42 @GodotName("get_file") GodotMethod!(String, long) getFile; 43 @GodotName("get_file_count") GodotMethod!(long) getFileCount; 44 @GodotName("get_file_import_is_valid") GodotMethod!(bool, long) getFileImportIsValid; 45 @GodotName("get_file_path") GodotMethod!(String, long) getFilePath; 46 @GodotName("get_file_script_class_extends") GodotMethod!(String, long) getFileScriptClassExtends; 47 @GodotName("get_file_script_class_name") GodotMethod!(String, long) getFileScriptClassName; 48 @GodotName("get_file_type") GodotMethod!(String, long) getFileType; 49 @GodotName("get_name") GodotMethod!(String) getName; 50 @GodotName("get_parent") GodotMethod!(EditorFileSystemDirectory) getParent; 51 @GodotName("get_path") GodotMethod!(String) getPath; 52 @GodotName("get_subdir") GodotMethod!(EditorFileSystemDirectory, long) getSubdir; 53 @GodotName("get_subdir_count") GodotMethod!(long) getSubdirCount; 54 } 55 /// 56 pragma(inline, true) bool opEquals(in EditorFileSystemDirectory other) const 57 { return _godot_object.ptr is other._godot_object.ptr; } 58 /// 59 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 60 { _godot_object.ptr = n; return null; } 61 /// 62 pragma(inline, true) bool opEquals(typeof(null) n) const 63 { return _godot_object.ptr is n; } 64 /// 65 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 66 mixin baseCasts; 67 /// Construct a new instance of EditorFileSystemDirectory. 68 /// Note: use `memnew!EditorFileSystemDirectory` instead. 69 static EditorFileSystemDirectory _new() 70 { 71 static godot_class_constructor constructor; 72 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorFileSystemDirectory"); 73 if(constructor is null) return typeof(this).init; 74 return cast(EditorFileSystemDirectory)(constructor()); 75 } 76 @disable new(size_t s); 77 /** 78 Returns the index of the directory with name `name` or `-1` if not found. 79 */ 80 long findDirIndex(in String name) const 81 { 82 checkClassBinding!(typeof(this))(); 83 return ptrcall!(long)(GDNativeClassBinding.findDirIndex, _godot_object, name); 84 } 85 /** 86 Returns the index of the file with name `name` or `-1` if not found. 87 */ 88 long findFileIndex(in String name) const 89 { 90 checkClassBinding!(typeof(this))(); 91 return ptrcall!(long)(GDNativeClassBinding.findFileIndex, _godot_object, name); 92 } 93 /** 94 Returns the name of the file at index `idx`. 95 */ 96 String getFile(in long idx) const 97 { 98 checkClassBinding!(typeof(this))(); 99 return ptrcall!(String)(GDNativeClassBinding.getFile, _godot_object, idx); 100 } 101 /** 102 Returns the number of files in this directory. 103 */ 104 long getFileCount() const 105 { 106 checkClassBinding!(typeof(this))(); 107 return ptrcall!(long)(GDNativeClassBinding.getFileCount, _godot_object); 108 } 109 /** 110 Returns `true` if the file at index `idx` imported properly. 111 */ 112 bool getFileImportIsValid(in long idx) const 113 { 114 checkClassBinding!(typeof(this))(); 115 return ptrcall!(bool)(GDNativeClassBinding.getFileImportIsValid, _godot_object, idx); 116 } 117 /** 118 Returns the path to the file at index `idx`. 119 */ 120 String getFilePath(in long idx) const 121 { 122 checkClassBinding!(typeof(this))(); 123 return ptrcall!(String)(GDNativeClassBinding.getFilePath, _godot_object, idx); 124 } 125 /** 126 Returns the base class of the script class defined in the file at index `idx`. If the file doesn't define a script class using the `class_name` syntax, this will return an empty string. 127 */ 128 String getFileScriptClassExtends(in long idx) const 129 { 130 checkClassBinding!(typeof(this))(); 131 return ptrcall!(String)(GDNativeClassBinding.getFileScriptClassExtends, _godot_object, idx); 132 } 133 /** 134 Returns the name of the script class defined in the file at index `idx`. If the file doesn't define a script class using the `class_name` syntax, this will return an empty string. 135 */ 136 String getFileScriptClassName(in long idx) const 137 { 138 checkClassBinding!(typeof(this))(); 139 return ptrcall!(String)(GDNativeClassBinding.getFileScriptClassName, _godot_object, idx); 140 } 141 /** 142 Returns the resource type of the file at index `idx`. This returns a string such as `"Resource"` or `"GDScript"`, $(I not) a file extension such as `".gd"`. 143 */ 144 String getFileType(in long idx) const 145 { 146 checkClassBinding!(typeof(this))(); 147 return ptrcall!(String)(GDNativeClassBinding.getFileType, _godot_object, idx); 148 } 149 /** 150 Returns the name of this directory. 151 */ 152 String getName() 153 { 154 checkClassBinding!(typeof(this))(); 155 return ptrcall!(String)(GDNativeClassBinding.getName, _godot_object); 156 } 157 /** 158 Returns the parent directory for this directory or `null` if called on a directory at `res://` or `user://`. 159 */ 160 EditorFileSystemDirectory getParent() 161 { 162 checkClassBinding!(typeof(this))(); 163 return ptrcall!(EditorFileSystemDirectory)(GDNativeClassBinding.getParent, _godot_object); 164 } 165 /** 166 Returns the path to this directory. 167 */ 168 String getPath() const 169 { 170 checkClassBinding!(typeof(this))(); 171 return ptrcall!(String)(GDNativeClassBinding.getPath, _godot_object); 172 } 173 /** 174 Returns the subdirectory at index `idx`. 175 */ 176 EditorFileSystemDirectory getSubdir(in long idx) 177 { 178 checkClassBinding!(typeof(this))(); 179 return ptrcall!(EditorFileSystemDirectory)(GDNativeClassBinding.getSubdir, _godot_object, idx); 180 } 181 /** 182 Returns the number of subdirectories in this directory. 183 */ 184 long getSubdirCount() const 185 { 186 checkClassBinding!(typeof(this))(); 187 return ptrcall!(long)(GDNativeClassBinding.getSubdirCount, _godot_object); 188 } 189 }