RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
File.hpp File Reference
#include <filesystem>
#include <optional>
#include <string>
#include <string_view>

Go to the source code of this file.

Namespaces

namespace  RST
 Root namespace of RSTools.
 
namespace  RST::System
 Portable access to system information, environment variables, files and paths.
 

Functions

Files

Files are read and written in binary mode, so the content is kept unchanged.

std::optional< std::string > RST::System::readFile (const std::filesystem::path &path)
 Content of the file, or std::nullopt if it cannot be read.
 
bool RST::System::writeFile (const std::filesystem::path &path, std::string_view content)
 Creates or replaces the file with content; returns false on failure.
 
bool RST::System::appendFile (const std::filesystem::path &path, std::string_view content)
 Appends content to the file, creating it if needed; returns false on failure.