wavelength 1.0.0
Loading...
Searching...
No Matches
fileio.h File Reference
#include <cstdint>
#include <expected>
#include <filesystem>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include "error.h"
Include dependency graph for fileio.h:

Go to the source code of this file.

Namespaces

namespace  Tools
namespace  Tools::Common
 Code that the host tools share.

Functions

std::expected< std::vector< std::uint8_t >, Error > Tools::Common::readFile (const std::filesystem::path &path)
 Read a whole file.
std::expected< std::vector< std::string >, Error > Tools::Common::readLines (const std::filesystem::path &path)
 Read the lines of a text file, without their line endings, skipping empty lines.
std::expected< void, Error > Tools::Common::writeLines (const std::filesystem::path &path, const std::vector< std::string > &lines)
 Write lines to a text file, each ending with a line feed.
std::expected< void, Error > Tools::Common::writeFile (const std::filesystem::path &path, std::span< const std::uint8_t > data)
 Replace a file with the given bytes.
std::expected< void, Error > Tools::Common::writeFile (const std::filesystem::path &path, std::string_view text)
 Replace a file with the given text, written as is.