| 54 | } |
| 55 | |
| 56 | void Shutdown(const fextl::string& ApplicationName) { |
| 57 | if (!Enabled) { |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | auto DataDirectory = Config::GetTelemetryDirectory() + ApplicationName + ".telem"; |
| 62 | |
| 63 | // Retain a single backup if the telemetry already existed. |
| 64 | auto Backup = DataDirectory + ".bck"; |
| 65 | |
| 66 | // Failure on rename is okay. |
| 67 | (void)FHU::Filesystem::RenameFile(DataDirectory, Backup); |
| 68 | |
| 69 | auto File = FEXCore::File::File(DataDirectory.c_str(), |
| 70 | FEXCore::File::FileModes::WRITE | FEXCore::File::FileModes::CREATE | FEXCore::File::FileModes::TRUNCATE); |
| 71 | |
| 72 | if (File.IsValid()) { |
| 73 | for (size_t i = 0; i < TelemetryType::TYPE_LAST; ++i) { |
| 74 | auto& Name = TelemetryNames.at(i); |
| 75 | auto& Data = TelemetryValues.at(i); |
| 76 | fextl::fmt::print(File, "{}: {}\n", Name, Data.load()); |
| 77 | } |
| 78 | File.Flush(); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | #endif |
| 83 | } // namespace FEXCore::Telemetry |