22 lines
397 B
C++
22 lines
397 B
C++
#include "file.h"
|
|
|
|
string read_entire_file(const char *path) {
|
|
string content;
|
|
std::ifstream file_stream(path, std::ios::in);
|
|
|
|
if (!file_stream.is_open()) {
|
|
printf("Failed to read %s! File doesn't exist.", path);
|
|
return "";
|
|
}
|
|
|
|
string line = "";
|
|
while (!file_stream.eof())
|
|
{
|
|
std::getline(file_stream, line);
|
|
content.append(line + "\n");
|
|
}
|
|
|
|
file_stream.close();
|
|
return content;
|
|
}
|