VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Paths.cpp
Go to the documentation of this file.
2#include <format>
3
4namespace VoltMod
5{
6
7static std::filesystem::path g_baseDir;
8
9void SetBaseDir(const std::filesystem::path& baseDir)
10{
12}
13
14std::filesystem::path ResolvePath(std::string_view relativePath)
15{
16 std::filesystem::path p(relativePath);
17 return p.is_absolute() ? p : g_baseDir / p;
18}
19
20std::string PluginDir(std::string_view plugin)
21{
22 return std::format("addons/voltmod/plugins/{}", plugin);
23}
24
25std::string PluginFile(std::string_view plugin, std::string_view relative)
26{
27 return std::format("{}/{}", PluginDir(plugin), relative);
28}
29
30} // namespace VoltMod
std::filesystem::path ResolvePath(std::string_view relativePath)
a relative path against the base directory. If the path is already absolute, returns it as-is.
Definition Paths.cpp:14
void SetBaseDir(const std::filesystem::path &baseDir)
Set the base directory for path resolution (the host's csgo directory). Must be called during initial...
Definition Paths.cpp:9
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::string PluginFile(std::string_view plugin, std::string_view relative)
"addons/voltmod/plugins/<plugin>/<relative>".
Definition Paths.cpp:25
static std::filesystem::path g_baseDir
Definition Paths.cpp:7
std::string PluginDir(std::string_view plugin)
"addons/voltmod/plugins/<plugin>". Pure string building, so safe at static init.
Definition Paths.cpp:20