uploaded current state of stacat

This commit is contained in:
2025-06-14 00:29:53 +02:00
parent e1824fc79c
commit 69bff131db
17 changed files with 643 additions and 0 deletions

36
src/utils/readfile.cpp Normal file
View File

@@ -0,0 +1,36 @@
#include <iostream>
#include <fstream>
#include "readfile.h"
#include "utils.h"
#include "../output.h"
using namespace std;
using namespace debug;
using namespace error;
namespace utils {
string readfile(const char* filename) {
ifstream file(filename);
if (!checkfile(file)) {
exit(EXIT_FAILURE);
}
string data, line;
while (getline(file, line)) {
data += line;
data += '\n';
}
data.pop_back();
file.close();
return data;
}
bool checkfile(ifstream& file) {
if (!file.is_open()) {
throwError(FILE_NOT_FOUND, "File not found", __LINE__, __FILE__);
return false;
}
return true;
}
}