From b929c13c4546b17b1ec6391a6bada6ebc8548c8b Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 16 Feb 2019 14:05:13 +0100 Subject: [PATCH] implement get_firmware_version add firmware version to the first line in the log --- Utilities/Log.cpp | 5 ++++- Utilities/sysinfo.cpp | 27 ++++++++++++++++++++++++++- Utilities/sysinfo.h | 4 +++- rpcs3/Emu/RSX/Overlays/overlays.h | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 77237e45a1..1d60e1b3fb 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -589,12 +589,15 @@ logs::file_listener::file_listener(const std::string& name) // Write UTF-8 BOM file_writer::log(logs::level::always, "\xEF\xBB\xBF", 3); + const std::string firmware_version = utils::get_firmware_version(); + const std::string firmware_string = firmware_version.empty() ? "" : (" | Firmware version: " + firmware_version); + // Write initial message stored_message ver; ver.m.ch = nullptr; ver.m.sev = level::always; ver.stamp = 0; - ver.text = fmt::format("RPCS3 v%s | %s\n%s", rpcs3::version.to_string(), rpcs3::get_branch(), utils::get_system_info()); + ver.text = fmt::format("RPCS3 v%s | %s%s\n%s", rpcs3::version.to_string(), rpcs3::get_branch(), firmware_string, utils::get_system_info()); file_writer::log(logs::level::always, ver.text.data(), ver.text.size()); file_writer::log(logs::level::always, "\n", 1); diff --git a/Utilities/sysinfo.cpp b/Utilities/sysinfo.cpp index b651704bb8..96226362dd 100644 --- a/Utilities/sysinfo.cpp +++ b/Utilities/sysinfo.cpp @@ -1,5 +1,7 @@ -#include "sysinfo.h" +#include "sysinfo.h" #include "StrFmt.h" +#include "File.h" +#include "Emu/System.h" #ifdef _WIN32 #include "windows.h" @@ -128,3 +130,26 @@ std::string utils::get_system_info() return result; } + +std::string utils::get_firmware_version() +{ + const std::string file_path = g_cfg.vfs.get_dev_flash() + "vsh/etc/version.txt"; + if (fs::is_file(file_path)) + { + const fs::file version_file = fs::file(file_path); + std::string version = version_file.to_string(); + + // Extract version + const size_t start = version.find_first_of(':') + 1; + const size_t end = version.find_first_of(':', start); + version = version.substr(start, end - start); + + // Trim version + const size_t trim_start = version.find_first_not_of('0'); + const size_t trim_end = version.find_last_not_of('0'); + version = version.substr(trim_start, trim_end); + + return version; + } + return ""; +} diff --git a/Utilities/sysinfo.h b/Utilities/sysinfo.h index 88ca019964..5f2bc1f3ed 100644 --- a/Utilities/sysinfo.h +++ b/Utilities/sysinfo.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "types.h" #include @@ -44,4 +44,6 @@ namespace utils bool has_xop(); std::string get_system_info(); + + std::string get_firmware_version(); } diff --git a/rpcs3/Emu/RSX/Overlays/overlays.h b/rpcs3/Emu/RSX/Overlays/overlays.h index 7c9f3378d6..d72196ab33 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.h +++ b/rpcs3/Emu/RSX/Overlays/overlays.h @@ -925,7 +925,7 @@ namespace rsx close(); } - error_code show(const std::string text, const MsgDialogType &type, std::function on_close) + error_code show(const std::string& text, const MsgDialogType &type, std::function on_close) { num_progress_bars = type.progress_bar_count; if (num_progress_bars)