MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / OpenImpl

Method OpenImpl

src/db/hierdatabase.cpp:150–194  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// OpenImpl //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

148// OpenImpl
149///////////////////////////////////////////////////////////////////////////////
150void cHierDatabase::OpenImpl(bool bTruncate) //throw (eArchive, eHierDatabase)
151{
152 // now, we should write the root node at (0,0) if we are creating, and assert that the root node
153 // is there if we are opening an existing one...
154 //
155 if (bTruncate)
156 {
157 //
158 // make the root node that we are creating...
159 //
160 cHierRoot rootNode;
161 rootNode.mChild = cHierAddr(0, 1); // the first array will be placed at (0,1)
162 rootNode.mbCaseSensitive = mbCaseSensitive;
163 rootNode.mDelimitingChar = mDelimitingChar;
164 cHierAddr addr = util_WriteObject(this, &rootNode);
165 //
166 // assert that it was written to (0, 0)
167 //
168 ASSERT((addr.mBlockNum == 0) && (addr.mIndex == 0));
169 //
170 // make an empty array to serve as the root array.
171 //
172 cHierArrayInfo arrayInfo;
173 arrayInfo.mParent = cHierAddr();
174 arrayInfo.mArray = cHierAddr();
175 //
176 // actually write the objects and assert that they were written to the right places.
177 //
178 addr = util_WriteObject(this, &arrayInfo);
179 ASSERT((addr.mBlockNum == 0) && (addr.mIndex == 1));
180
181 mRootArrayAddr = cHierAddr(0, 1);
182 }
183 else
184 {
185 cHierRoot rootNode;
186 util_ReadObject(this, &rootNode, cHierAddr(0, 0));
187 //
188 // set the location of the top-level array and the other root parameters...
189 //
190 mRootArrayAddr = rootNode.mChild;
191 mbCaseSensitive = rootNode.mbCaseSensitive;
192 mDelimitingChar = rootNode.mDelimitingChar;
193 }
194}
195
196//-----------------------------------------------------------------------------
197// cHierDatabaseIter

Callers

nothing calls this directly

Calls 3

cHierAddrClass · 0.85
util_WriteObjectFunction · 0.85
util_ReadObjectFunction · 0.85

Tested by

no test coverage detected