file

File: samarium/util/file.hpp

Read and write files

namespace file

Typedefs

using Path = std::filesystem::path

Functions

auto read([[maybe_unused]] Text tag, const Path &file_path) -> Result<std::string>
auto read(const Path &file_path) -> Result<std::string>
auto read_image(const Path &file_path) -> Result<Image>
void write([[maybe_unused]] Targa tag, const Image &image, const Path &file_path = date_time_str() + ".tga")
void write([[maybe_unused]] Pam tag, const Image &image, const Path &file_path = date_time_str() + ".pam")

Write image to file_path in the NetBPM PAM format.

See https://wikipedia.org/wiki/Netpbm#PAM_graphics_format

Parameters:
  • tag – Use the PAM format (tag dispatch)

  • image

  • file_path

inline void write(Png, const Image &image, const Path &file_path = date_time_str() + ".png")
void write([[maybe_unused]] Bmp tag, const Image &image, const Path &file_path = date_time_str() + ".bmp")
auto find(const std::string &file_name, const Path &directory = std::filesystem::current_path()) -> Result<Path>
auto find(const std::string &file_name, std::span<Path> search_paths) -> Result<Path>
auto find(const std::string &file_name, std::initializer_list<Path> search_paths) -> Result<Path>

Variables

static constexpr auto text = Text{}
static constexpr auto targa = Targa{}
static constexpr auto pam = Pam{}
static constexpr auto png = Png{}
static constexpr auto bmp = Bmp{}
struct Text
struct Targa
struct Pam
struct Png
struct Bmp