| 354 | } |
| 355 | |
| 356 | std::optional<int> ExtensionStateBase::LuaLoadExternalFile(STDString const & path) |
| 357 | { |
| 358 | std::ifstream f(path.c_str(), std::ios::in | std::ios::binary); |
| 359 | if (!f.good()) { |
| 360 | OsiError("File does not exist: " << path); |
| 361 | return {}; |
| 362 | } |
| 363 | |
| 364 | f.seekg(0, std::ios::end); |
| 365 | auto length = f.tellg(); |
| 366 | f.seekg(0, std::ios::beg); |
| 367 | STDString s((uint32_t)length, '\0'); |
| 368 | f.read(s.data(), length); |
| 369 | f.close(); |
| 370 | |
| 371 | LuaVirtualPin lua(*this); |
| 372 | if (!lua) { |
| 373 | OsiErrorS("Called when the Lua VM has not been initialized!"); |
| 374 | return {}; |
| 375 | } |
| 376 | |
| 377 | return lua->LoadScript(s, path); |
| 378 | } |
| 379 | |
| 380 | std::optional<int> ExtensionStateBase::LuaLoadGameFile(FileReaderPin & reader, STDString const & scriptName, int globalsIdx) |
| 381 | { |
nothing calls this directly
no test coverage detected