#include "file.h" #include namespace fs = std::filesystem; using namespace std::string_literals; std::string unicode::File::getFile(const fs::path& filename) { std::ifstream file(filename.string(), std::ios::in | std::ios::binary | std::ios::ate); if (file.is_open()) { std::ifstream::pos_type fileSize { file.tellg() }; file.seekg(0, std::ios::beg); std::string bytes(fileSize, '\0'); file.read(reinterpret_cast(bytes.data()), fileSize); return bytes; } else { throw std::runtime_error("Opening "s + filename.string() + " for reading"); } } void unicode::File::setFile(const fs::path& filename, const std::string& s) { std::ofstream file(filename.string(), std::ios::out | std::ios::binary); if (file.is_open()) { file.write(s.data(), s.size()); } else { throw std::runtime_error("Opening "s + filename.string() + " for writing"); } }