-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFile.cpp
More file actions
39 lines (31 loc) · 778 Bytes
/
Copy pathFile.cpp
File metadata and controls
39 lines (31 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "File.hpp"
BEGIN_XE_NAMESPACE
std::string File::readAll(std::string filePath)
{
std::string content;
std::ifstream fileStream(filePath.c_str(), std::ios::in);
if (!fileStream.is_open())
{
std::cerr << "Could not read file " << filePath << ". File does not exist." << std::endl;
return "";
}
std::string line = "";
while (!fileStream.eof())
{
std::getline(fileStream, line);
content.append(line + "\n");
}
fileStream.close();
return content;
}
std::string File::readVertShaderText(std::string name)
{
auto path = std::string("assets/") + name + "-vert.glsl";
return readAll(path);
}
std::string File::readFragShaderText(std::string name)
{
auto path = std::string("assets/") + name + "-frag.glsl";
return readAll(path);
}
END_XE_NAMESPACE