1 /// Convenience wrapper for file paths 2 module godot.api.path; 3 4 import godot, godot.projectsettings; 5 6 /++ 7 A file path inside the Godot filesystem represented as a local Godot String and 8 a global D string. 9 10 Useful for paths that need to be worked on by functions from both Godot and D. 11 The conversion is done only once in the constructor and both strings are saved. 12 +/ 13 deprecated struct Path { 14 private: 15 String _godot; 16 CharString _d; 17 public: 18 /// 19 String godot() const { 20 return _godot; 21 } 22 /// 23 string d() const { 24 return cast(string) _d.data[0 .. _d.length]; 25 } 26 27 @disable this(this); 28 /// 29 void godot(String value) { 30 // TODO: fix singleton 31 _godot = value; 32 //_d = ProjectSettings.globalizePath(value).utf8; 33 } 34 /// 35 void d(string value) { 36 // TODO: fix singleton 37 // inefficient back-and-forth; need to construct CharString directly 38 String tmp = String(value); 39 _d = tmp.utf8; 40 //_godot = ProjectSettings.localizePath(tmp); 41 } 42 43 /// 44 alias local = godot; 45 /// 46 alias global = d; 47 48 /// 49 this(String projectLocalPath) { 50 godot = projectLocalPath; 51 } 52 /// 53 this(string globalPath) { 54 d = globalPath; 55 } 56 }