MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / write

Method write

framework/serialization/serialize.cpp:231–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231bool XMLSerializationArchive::write(const UString &path, bool pack, bool pretty)
232{
233 // warning! data provider must be freed when this method ends,
234 // so code calling this method may override archive
235 auto dataProvider = getProvider(pack);
236 if (!dataProvider->openArchive(path, true))
237 {
238 LogWarning("Failed to open archive at \"%s\"", path);
239 return false;
240 }
241
242 for (auto &root : this->docRoots)
243 {
244 std::stringstream ss;
245 unsigned int flags = pugi::format_default;
246 const char *indent = " ";
247 if (pretty == false)
248 {
249 flags = pugi::format_raw;
250 indent = "";
251 }
252 root.second.save(ss, indent, flags);
253 if (!dataProvider->saveDocument(root.first, ss.str()))
254 {
255 return false;
256 }
257 }
258
259 return dataProvider->finalizeSave();
260}
261
262SerializationNode *XMLSerializationNode::addNode(const char *name, const UString &value)
263{

Callers 8

writeArchiveWithBackupFunction · 0.80
saveGameMethod · 0.80
saveGameDeltaMethod · 0.80
saveTilesetMethod · 0.80
saveImagePackMethod · 0.80
saveAnimationPackMethod · 0.80
saveSectorMethod · 0.80
writeImageMethod · 0.80

Calls 5

getProviderFunction · 0.85
openArchiveMethod · 0.45
saveMethod · 0.45
saveDocumentMethod · 0.45
finalizeSaveMethod · 0.45

Tested by

no test coverage detected