VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
GameBuild.cpp
Go to the documentation of this file.
1
#include "
Core/Files/GameBuild.hpp
"
2
3
#include <
VoltMod/Core/Files/File.hpp
>
4
#include <
VoltMod/Core/Text/Strings.hpp
>
5
#include <string>
6
7
namespace
VoltMod
8
{
9
10
std::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
File.hpp
GameBuild.hpp
Strings.hpp
VoltMod::Strings::Trim
static std::string Trim(std::string_view str)
Definition
Strings.cpp:107
VoltMod
Definition
Options.hpp:13
VoltMod::ReadFile
static std::string ReadFile(const std::filesystem::path &path)
Definition
Loader.cpp:56
VoltMod::GameBuild
std::string_view GameBuild()
Definition
GameBuild.cpp:10
VoltMod::ReadAllText
Result< std::string > ReadAllText(std::string_view path)
Read path (resolved via ResolvePath) into a string.
Definition
File.cpp:12
src
Core
Files
GameBuild.cpp
Generated by
1.9.8