Codechange: Use std::string in FIO search path handling.

This commit is contained in:
Michael Lutz
2020-12-06 21:11:44 +01:00
parent 0c6e8a8123
commit f3326d34e7
12 changed files with 180 additions and 216 deletions

View File

@@ -116,17 +116,16 @@ bool ScriptInstance::LoadCompatibilityScripts(const char *api_version, Subdirect
{
char script_name[32];
seprintf(script_name, lastof(script_name), "compat_%s.nut", api_version);
char buf[MAX_PATH];
Searchpath sp;
FOR_ALL_SEARCHPATHS(sp) {
FioAppendDirectory(buf, lastof(buf), sp, dir);
strecat(buf, script_name, lastof(buf));
if (!FileExists(buf)) continue;
std::string buf = FioGetDirectory(sp, dir);
buf += script_name;
if (!FileExists(buf.c_str())) continue;
if (this->engine->LoadScript(buf)) return true;
if (this->engine->LoadScript(buf.c_str())) return true;
ScriptLog::Error("Failed to load API compatibility script");
DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf);
DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf.c_str());
return false;
}