MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / WriteCrashLog

Method WriteCrashLog

src/crashlog.cpp:191–204  ·  view source on GitHub ↗

* Write the crash log to a file. * @note The filename will be written to \c crashlog_filename. * @return true when the crash log was successfully written. */

Source from the content-addressed store, hash-verified

189 * @return true when the crash log was successfully written.
190 */
191bool CrashLog::WriteCrashLog()
192{
193 this->crashlog_filename = this->CreateFileName(".json.log");
194
195 auto file = FioFOpenFile(this->crashlog_filename, "w", NO_DIRECTORY);
196 if (!file.has_value()) return false;
197
198 std::string survey_json = this->survey.dump(4);
199
200 size_t len = survey_json.size();
201 size_t written = fwrite(survey_json.data(), 1, len, *file);
202
203 return len == written;
204}
205
206/**
207 * Write the (crash) dump to a file.

Callers 1

MakeCrashLogMethod · 0.95

Calls 5

CreateFileNameMethod · 0.95
FioFOpenFileFunction · 0.85
dumpMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected