diff --git a/source/Graphics/Shader.cpp b/source/Graphics/Shader.cpp index 47f1016..e24eb1f 100644 --- a/source/Graphics/Shader.cpp +++ b/source/Graphics/Shader.cpp @@ -1,6 +1,6 @@ -#include #include +#include #include #include @@ -30,26 +30,26 @@ const std::string& Shader::getName() const return m_name; } -bool Shader::loadFromFile(const std::string& file) +bool Shader::loadFromFile(const std::string& filename) { std::string src; - std::ifstream strm; + File file; // If this shader does not have a name, pick the filename. if (m_name.length() < 1) { - m_name = Path::getBasename(file); + m_name = Path::getBasename(filename); } - // Load file into memory. - strm.open(file.c_str(), std::fstream::in); - if (!strm.is_open()) { - m_error = "Can't open file: " + file; + if (!file.open(filename)) { + m_error = "Can't open file: " + filename; return false; } - src.assign(std::istreambuf_iterator(strm), std::istreambuf_iterator()); - - strm.close(); + // Load file into memory. + if (!file.read(src)) { + m_error = "Could not read file: " + filename; + return false; + } return loadFromMemory(src); }