VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
GameBuild.cpp
Go to the documentation of this file.
2
5#include <string>
6
7namespace VoltMod
8{
9
10std::string_view GameBuild()
11{
12 static const std::string build = [] {
13 constexpr std::string_view key = "ServerVersion=";
14 auto text = ReadAllText("steam.inf");
15 const size_t at = text ? text->find(key) : std::string::npos;
16 if (at == std::string::npos)
17 {
18 return std::string("unknown");
19 }
20
21 const size_t start = at + key.size();
22 return Strings::Trim(std::string_view(*text).substr(start, text->find_first_of("\r\n", start) - start));
23 }();
24 return build;
25}
26
27} // namespace VoltMod
static std::string Trim(std::string_view str)
Definition Strings.cpp:107
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::string_view GameBuild()
Definition GameBuild.cpp:10
Result< std::string > ReadAllText(std::string_view path)
Read path (resolved via ResolvePath) into a string.
Definition File.cpp:12