Rewrite asset file loading for new toolchain

Old implementation throws null dereference errors on new toolchain. New implementation has not been fully stress-tested but should be mostly operational.
This commit is contained in:
taylorthemushroom 2023-09-24 23:06:23 -04:00 committed by TheBrokenRail
parent 588eb5feb0
commit 67ef365505

View File

@ -14,10 +14,11 @@
// Read Asset File // Read Asset File
static AppPlatform_readAssetFile_return_value AppPlatform_readAssetFile_injection(__attribute__((unused)) unsigned char *app_platform, std::string const& path) { static AppPlatform_readAssetFile_return_value AppPlatform_readAssetFile_injection(__attribute__((unused)) unsigned char *app_platform, std::string const& path) {
// Read File // Read File
std::string full_path("data/"); std::ifstream stream("data/" + path, std::ios_base::binary | std::ios_base::ate);
full_path.append(path); long len = stream.tellg();
std::ifstream stream(full_path); char *buf = new char[len];
std::string str((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>()); stream.seekg(0, stream.beg);
stream.read(buf, len);
// Return String // Return String
AppPlatform_readAssetFile_return_value ret; AppPlatform_readAssetFile_return_value ret;
ret.length = str.length(); ret.length = str.length();