skein/io.cpp

24 lines
468 B
C++

#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();
}