VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Paths.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <string>
5#include <string_view>
6
7namespace VoltMod
8{
9
10/**
11 * @brief Set the base directory for path resolution (the host's `csgo` directory).
12 * Must be called during initialization before any file loading.
13 *
14 * @param baseDir The base directory path to use for resolving relative paths.
15 */
16void SetBaseDir(const std::filesystem::path& baseDir);
17
18/**
19 * @brief a relative path against the base directory.
20 * If the path is already absolute, returns it as-is.
21 * @param relativePath The relative path to resolve.
22 * @return The resolved absolute path.
23 */
24std::filesystem::path ResolvePath(std::string_view relativePath);
25
26/** @brief "addons/voltmod/plugins/<plugin>". Pure string building, so safe at static init. */
27std::string PluginDir(std::string_view plugin);
28
29/** @brief "addons/voltmod/plugins/<plugin>/<relative>". */
30std::string PluginFile(std::string_view plugin, std::string_view relative);
31
32} // 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
std::string PluginDir(std::string_view plugin)
"addons/voltmod/plugins/<plugin>". Pure string building, so safe at static init.
Definition Paths.cpp:20