22 lines
663 B
C++
22 lines
663 B
C++
#include <fstream>
|
|
#include <iostream>
|
|
#include <system_error>
|
|
using namespace std;
|
|
|
|
string getFileContent(const string& file)
|
|
{
|
|
ifstream fileStream(file, ios::in);
|
|
if (not fileStream.fail()) {
|
|
string lineinput, fullinput;
|
|
while (getline(fileStream, lineinput)) {
|
|
fullinput.append(lineinput += '\n');
|
|
}
|
|
fileStream.close();
|
|
return fullinput;
|
|
} else throw Yerbacon::Exception("Could not open \"" + file + "\" : " + generic_category().message(errno));
|
|
}
|
|
|
|
void outputFileContent(const string& file, const string_view content) {
|
|
ofstream outputFile (file, ofstream::out);
|
|
outputFile << content;
|
|
} |