Call exit() when the file(s) passed as argument(s) can't be opened.

This commit is contained in:
Username404-59 2021-03-26 13:23:13 +01:00
parent c087d8b2f0
commit ad7075db7e
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1

View File

@ -1,4 +1,5 @@
#include <fstream>
#include <iostream>
using namespace std;
string getFileContent(const string& file)
@ -8,6 +9,9 @@ string getFileContent(const string& file)
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;