MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / writeRoot

Method writeRoot

source/core/StarBTreeDatabase.cpp:1043–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1041}
1042
1043void BTreeDatabase::writeRoot() {
1044 DataStreamIODevice ds(m_device);
1045 // First write the root info to whichever section we are not currently using
1046 ds.seek(BTreeRootInfoStart + (m_usingAltRoot ? 0 : BTreeRootInfoSize));
1047 ds.write<BlockIndex>(m_headFreeIndexBlock);
1048 ds.write<StreamOffset>(m_deviceSize);
1049 ds.write<BlockIndex>(m_root);
1050 ds.write<bool>(m_rootIsLeaf);
1051
1052 // Then flush all the pending changes.
1053 m_device->sync();
1054
1055 // Then switch headers by writing the single bit that switches them
1056 m_usingAltRoot = !m_usingAltRoot;
1057 ds.seek(BTreeRootSelectorBit);
1058 ds.write(m_usingAltRoot);
1059
1060 // Then flush this single bit write to make sure it happens before anything
1061 // else.
1062 m_device->sync();
1063}
1064
1065void BTreeDatabase::readRoot() {
1066 DataStreamIODevice ds(m_device);

Callers

nothing calls this directly

Calls 3

seekMethod · 0.45
syncMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected