7std::vector<std::byte>
fs::readFileBuffer(
const std::filesystem::path& filepath, std::size_t startOffset) {
8 FileStream stream{filepath};
12 stream.seek_in_u(startOffset);
13 return stream.read_bytes(std::filesystem::file_size(filepath) - startOffset);
16std::vector<std::byte>
fs::readFileBuffer(
const std::filesystem::path& filepath,
bool& exists, std::size_t startOffset) {
18 exists = !buffer.empty() || std::filesystem::exists(filepath);
22std::string
fs::readFileText(
const std::filesystem::path& filepath, std::size_t startOffset) {
23 FileStream stream{filepath};
27 stream.seek_in_u(startOffset);
28 return stream.read_string();
31std::string
fs::readFileText(
const std::filesystem::path& filepath,
bool& exists, std::size_t startOffset) {
33 exists = !text.empty() || std::filesystem::exists(filepath);
38 FileStream stream{filepath, FileStream::OPT_TRUNCATE | FileStream::OPT_CREATE_IF_NONEXISTENT};
42 stream.seek_out(0).write(buffer);
47 FileStream stream{filepath, FileStream::OPT_TRUNCATE | FileStream::OPT_CREATE_IF_NONEXISTENT};
51 stream.seek_out(0).write(text,
false);
std::string readFileText(const std::filesystem::path &filepath, std::size_t startOffset=0)
bool writeFileText(const std::filesystem::path &filepath, std::string_view text)
bool writeFileBuffer(const std::filesystem::path &filepath, std::span< const std::byte > buffer)
std::vector< std::byte > readFileBuffer(const std::filesystem::path &filepath, std::size_t startOffset=0)