Fixes Windows not reading files properly.
This commit is contained in:
parent
fd24ce63c1
commit
0b4806b354
|
@ -95,7 +95,17 @@ BattleLibrary* BuildLibrary::Build(const std::string& pathString,
|
||||||
continue;
|
continue;
|
||||||
std::ifstream in(dirEntry.path());
|
std::ifstream in(dirEntry.path());
|
||||||
std::string contents((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
|
std::string contents((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
|
||||||
asScriptResolver->CreateScript((const char*)dirEntry.path().c_str(), contents.c_str());
|
const auto* p = dirEntry.path().c_str();
|
||||||
|
// Windows defines paths as widechars, so we need to convert it to a normal human const char*
|
||||||
|
#if WINDOWS
|
||||||
|
std::mbstate_t state = std::mbstate_t();
|
||||||
|
int textLen = 1 + std::wcsrtombs(NULL, &p, 0, &state);
|
||||||
|
std::vector<char> storeTextBuffer(textLen);
|
||||||
|
std::wcsrtombs(&storeTextBuffer[0], &p, textLen, &state);
|
||||||
|
asScriptResolver->CreateScript(&storeTextBuffer[0], contents.c_str());
|
||||||
|
#else
|
||||||
|
asScriptResolver->CreateScript(p, contents.c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
asScriptResolver->FinalizeModule();
|
asScriptResolver->FinalizeModule();
|
||||||
ScriptsTimeMs =
|
ScriptsTimeMs =
|
||||||
|
|
Loading…
Reference in New Issue