implement get_firmware_version

add firmware version to the first line in the log
This commit is contained in:
Megamouse 2019-02-16 14:05:13 +01:00
parent 092cfef060
commit b929c13c45
4 changed files with 34 additions and 4 deletions

View file

@ -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 "";
}