Elevate Engine 1
Loading...
Searching...
No Matches
FileUtility.cpp
Go to the documentation of this file.
1#include "eepch.h"
2#include "FileUtility.h"
3
4#include <fstream>
7
8std::string Elevate::File::GetFileContent(std::string path)
9{
10 std::string resolvedPath = PathResolver::Resolve(path);
11
12 std::string content;
13 std::ifstream s(resolvedPath, std::ios::in);
14
15 // If file does not exists
16 if (!s.is_open())
17 {
18 EE_CORE_ERROR("Could not open file : {0}, file does not exist", resolvedPath);
19 return std::string();
20 }
21
22 // Get all of the lines from the file
23 std::string line = "";
24 while (!s.eof())
25 {
26 std::getline(s, line);
27 content.append(line + "\n");
28 }
29
30 // Close the file (good practice)
31 s.close();
32
33 return content;
34}
std::string GetFileContent(std::string path)