VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
File.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <string>
5#include <string_view>
6
7namespace VoltMod
8{
9
10/**
11 * @brief Read @p path (resolved via ResolvePath) into a string.
12 *
13 * Binary mode: the bytes reach the caller exactly as written, so no text-mode line-ending
14 * translation can alter an offset or split a UTF-8 sequence.
15 *
16 * @return ErrorCode::NotFound when the file cannot be opened.
17 */
18Result<std::string> ReadAllText(std::string_view path);
19
20/**
21 * @brief Write @p text to @p path (resolved via ResolvePath), creating its directory.
22 *
23 * Binary mode, so the file is byte-identical on every platform.
24 */
25Status WriteAllText(std::string_view path, std::string_view text);
26
27} // namespace VoltMod
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
Result< std::string > ReadAllText(std::string_view path)
Read path (resolved via ResolvePath) into a string.
Definition File.cpp:12
std::expected< void, Error > Status
Definition Result.hpp:67
Status WriteAllText(std::string_view path, std::string_view text)
Write text to path (resolved via ResolvePath), creating its directory.
Definition File.cpp:24