MCPcopy Create free account
hub / github.com/OpenMW/openmw / save

Method save

components/lua/storage.cpp:281–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279 }
280
281 void LuaStorage::save(lua_State* state, const std::filesystem::path& path) const
282 {
283 sol::table data(state, sol::create);
284 for (const auto& [sectionName, section] : mData)
285 {
286 if (section->mLifeTime == Section::Persistent && !section->mValues.empty())
287 data[sectionName] = section->asTable(state);
288 }
289 std::string serializedData = serialize(data);
290 Log(Debug::Info) << "Saving Lua storage \"" << path << "\" (" << serializedData.size() << " bytes)";
291 std::ofstream fout(path, std::fstream::binary);
292 fout.write(serializedData.data(), serializedData.size());
293 fout.close();
294 }
295
296 const std::shared_ptr<LuaStorage::Section>& LuaStorage::getSection(std::string_view sectionName)
297 {

Callers

nothing calls this directly

Calls 8

LogClass · 0.85
asTableMethod · 0.80
serializeFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
dataMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected