Merge branch 'fix_7210' into 'master'

Fix #7210

Closes #7210

See merge request OpenMW/openmw!2737
pull/3229/head
jvoisin 2 years ago
commit 8a6a3c7121

@ -5,6 +5,7 @@
#endif // NO_LUAJIT #endif // NO_LUAJIT
#include <filesystem> #include <filesystem>
#include <fstream>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/files/conversion.hpp> #include <components/files/conversion.hpp>
@ -385,7 +386,9 @@ namespace LuaUtil
sol::function LuaState::loadInternalLib(std::string_view libName) sol::function LuaState::loadInternalLib(std::string_view libName)
{ {
const auto path = packageNameToPath(libName, mLibSearchPaths); 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()) if (!res.valid())
throw std::runtime_error("Lua error: " + res.get<std::string>()); throw std::runtime_error("Lua error: " + res.get<std::string>());
return res; return res;

Loading…
Cancel
Save