From dcadfe1c38df63c817d1fbd5d7318764baa24833 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Sat, 9 Jun 2018 16:15:26 +0200 Subject: [PATCH] Open config.json file with SDL functions It's not possible to use the usual c++ functions because it's not supported by android assets directory. --- src/blupi.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/blupi.cxx b/src/blupi.cxx index 8c294ad..9ec9fb9 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -115,12 +115,16 @@ ReadConfig () { const auto config = GetBaseDir () + "data/config.json"; - std::ifstream file (config, std::ifstream::in); + SDL_RWops * file = SDL_RWFromFile (config.c_str (), "rb"); if (!file) return false; - nlohmann::json j; - file >> j; + Sint64 size = SDL_RWsize (file); + char * buffer = (char *) calloc (sizeof (char), size + 1); + SDL_RWread (file, buffer, size, 1); + nlohmann::json j = buffer; + SDL_RWclose (file); + free (buffer); if ( !(g_settingsOverload & SETTING_SPEEDRATE) &&