Yerbacon/src/etc/filefuncs.cpp

23 lines
676 B
C++

#include <fstream>
#include <iostream>
using namespace std;
string getFileContent(const string& file)
{
ifstream filetoParse;
string lineinput, fullinput;
filetoParse.open(file, ios::in);
if (filetoParse.is_open()) while (getline(filetoParse, lineinput)) {
fullinput.append(lineinput + "\n");
} else {
cout << "Could not open the file(s), please run as administrator." << endl;
exit(EXIT_FAILURE);
}
filetoParse.close();
return fullinput;
}
void setOutputFileContent(const string& language, const string& file, const string& content) {
static ofstream outputFile (file, ofstream::out);
outputFile << content;
}