skein/src/io.cpp

24 lines
468 B
C++
Raw Normal View History

2023-07-28 00:23:51 +02:00
#include "io.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
std::string readFile(const std::string& filePath)
{
std::ifstream fileStream(filePath, std::ios::in);
if (!fileStream.is_open())
{
std::cerr << "Could not read file " << filePath <<
". File does not exist." << std::endl;
return "";
}
std::stringstream sstr;
sstr << fileStream.rdbuf();
fileStream.close();
return sstr.str();
}