// asset_io — the one portable asset-read point. // // The standalone libs (libgr2, formats, mtproto, mtpack) keep their raw // fopen/ifstream `*_path()` entry points for the non-Godot CTests. Every read // from the *running extension* goes through here instead, so it works for: // - res:// (loose files in dev, PCK on iOS/Android read-only bundles) // - user:// (extracted cache) // - absolute OS paths (dev: AssetRoot points at mtgodot-poc/assets/) // godot::FileAccess handles all three transparently. #pragma once #include #include #include #include #include "dxt.h" namespace mtgodot { // Whole-file read. Empty PackedByteArray on failure (path missing / unreadable). godot::PackedByteArray read_file(const godot::String &path); bool file_exists(const godot::String &path); // FileAccess::file_exists wrapper // .dds -> RGBA8 level 0 via read_file. !ok() on failure. Image dds_from_file(const godot::String &path); // .gr2 parse via read_file. nullopt on read or parse failure. std::optional gr2_from_file(const godot::String &path, gr2::LoadError *err = nullptr); } // namespace mtgodot