MCPcopy Create free account
hub / github.com/Kitware/CMake / TryWrite

Method TryWrite

Source/cmSarifLog.cxx:325–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325cmSarif::LogFileWriter::WriteResult cmSarif::LogFileWriter::TryWrite()
326{
327 // Check that SARIF logging is enabled
328 if (!this->WriteCondition || !this->WriteCondition()) {
329 return WriteResult::SKIPPED;
330 }
331
332 // Open the file
333 if (!this->EnsureFileValid()) {
334 return WriteResult::FAILURE;
335 }
336 cmsys::ofstream outputFile(this->FilePath.c_str());
337
338 // The file is available, so proceed to write the log
339
340 // Assemble the SARIF JSON from the results in the log
341 Json::Value root(Json::objectValue);
342 this->Log.WriteJson(root);
343
344 // Serialize the JSON to the file
345 Json::StreamWriterBuilder builder;
346 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
347
348 writer->write(root, &outputFile);
349 outputFile.close();
350
351 this->FileWritten = true;
352 return WriteResult::SUCCESS;
353}
354
355bool cmSarif::LogFileWriter::ConfigureForCMakeRun(cmake& cm)
356{

Callers 1

~LogFileWriterMethod · 0.95

Calls 6

EnsureFileValidMethod · 0.95
c_strMethod · 0.80
WriteJsonMethod · 0.80
newStreamWriterMethod · 0.80
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected