1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 09:45:36 +00:00
This commit is contained in:
Petr Mikheev 2023-02-15 10:31:10 +01:00
parent a0cea6569b
commit b71eac3e76

View file

@ -5,6 +5,7 @@
#endif // NO_LUAJIT
#include <filesystem>
#include <fstream>
#include <components/debug/debuglog.hpp>
#include <components/files/conversion.hpp>
@ -385,7 +386,9 @@ namespace LuaUtil
sol::function LuaState::loadInternalLib(std::string_view libName)
{
const auto path = packageNameToPath(libName, mLibSearchPaths);
sol::load_result res = mSol.load_file(Files::pathToUnicodeString(path), sol::load_mode::text);
std::ifstream stream(path);
std::string fileContent(std::istreambuf_iterator<char>(stream), {});
sol::load_result res = mSol.load(fileContent, Files::pathToUnicodeString(path), sol::load_mode::text);
if (!res.valid())
throw std::runtime_error("Lua error: " + res.get<std::string>());
return res;