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

Function WriteObject

src/tw/twutil.cpp:156–186  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// WriteObject -- template class that writes an object to disk (ie -- report, db, etc) either encrypted or unencrypted. The only requrement on the object is that it is typed serializable. errorMsg is a number that can be passed to iUserString to indicate an appropriate error message if the object fails to load 10/30 -- this f

Source from the content-addressed store, hash-verified

154// none is desired.
155///////////////////////////////////////////////////////////////////////////////
156static void WriteObject(const TCHAR* filename,
157 const iTypedSerializable* pObjHeader,
158 const iTypedSerializable& obj,
159 cFileHeader& fileHeader,
160 bool bEncrypt,
161 const cElGamalSigPrivateKey* pPrivateKey)
162{
163 cDebug d("WriteObject");
164 d.TraceDebug(_T("Writing %s to file %s\n"), obj.GetType().AsString(), filename);
165
166 ASSERT(pPrivateKey || (!bEncrypt));
167
168 cFileArchive arch;
169
170 if (!cFileUtil::IsRegularFile(filename) && cFileUtil::FileExists(filename))
171 throw eArchiveNotRegularFile(filename);
172
173 try
174 {
175 arch.OpenReadWrite(filename);
176 }
177 catch (eArchive&)
178 {
179 // probably better to rethrow this as a write failed exception
180 throw eArchiveWrite(filename, iFSServices::GetInstance()->GetErrString());
181 }
182
183 WriteObjectToArchive(arch, filename, pObjHeader, obj, fileHeader, bEncrypt, pPrivateKey);
184
185 arch.Close();
186}
187
188
189///////////////////////////////////////////////////////////////////////////////

Callers 4

WriteDatabaseMethod · 0.85
WriteReportMethod · 0.85
WriteConfigTextMethod · 0.85
WritePolicyTextMethod · 0.85

Calls 6

WriteObjectToArchiveFunction · 0.85
OpenReadWriteMethod · 0.80
GetErrStringMethod · 0.80
TraceDebugMethod · 0.60
AsStringMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected