37 lines
690 B
C++
37 lines
690 B
C++
#include "../../../include/assets/data_parsers"
|
|
|
|
#include <fstream>
|
|
|
|
std::error_code glsl_loader::load(
|
|
const std::filesystem::path& filename,
|
|
std::string& source
|
|
) {
|
|
|
|
auto file = std::ifstream(filename);
|
|
if (not file.is_open())
|
|
{
|
|
return std::make_error_code(std::errc::no_such_file_or_directory);
|
|
}
|
|
|
|
file.seekg(0, std::ios::end);
|
|
const auto size = file.tellg();
|
|
|
|
if (size == 0 or size == std::numeric_limits<std::streamsize>::max())
|
|
{
|
|
return std::make_error_code(std::errc::invalid_seek);
|
|
}
|
|
|
|
source.reserve(size);
|
|
|
|
file.seekg(0, std::ios::beg);
|
|
|
|
source.assign(
|
|
std::istreambuf_iterator<char>(file),
|
|
std::istreambuf_iterator<char>()
|
|
);
|
|
|
|
file.close();
|
|
|
|
return {};
|
|
}
|