RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
File.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <optional>
5#include <string>
6#include <string_view>
7
8namespace RST::System {
9
13
15 [[nodiscard]] std::optional<std::string> readFile(const std::filesystem::path& path);
16
18 bool writeFile(const std::filesystem::path& path, std::string_view content);
19
21 bool appendFile(const std::filesystem::path& path, std::string_view content);
23}
Portable access to system information, environment variables, files and paths.
Definition Environment.hpp:7
std::optional< std::string > readFile(const std::filesystem::path &path)
Content of the file, or std::nullopt if it cannot be read.
bool writeFile(const std::filesystem::path &path, std::string_view content)
Creates or replaces the file with content; returns false on failure.
bool appendFile(const std::filesystem::path &path, std::string_view content)
Appends content to the file, creating it if needed; returns false on failure.