EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
Loading...
Searching...
No Matches
FileAssetProvider.cpp
Go to the documentation of this file.
2#include <fstream>
3#include <sstream>
4#include <stdexcept>
5
7
8std::string FileAssetProvider::loadAsset(std::string_view assetName) const {
9 std::ifstream file(std::string(assetName), std::ios::in | std::ios::binary);
10 if (!file) {
11 throw std::runtime_error("FileAssetProvider: Could not open file " + std::string(assetName));
12 }
13
14 std::ostringstream outputStream;
15 outputStream << file.rdbuf();
16 return outputStream.str();
17}
~FileAssetProvider() override
std::string loadAsset(std::string_view assetName) const override
Loads the content of a file from the disk.