fixes
This commit is contained in:
36
source/assets/data_loaders/glsl_loader.cpp
Normal file
36
source/assets/data_loaders/glsl_loader.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "assets/data_loaders/glsl_loader.hpp"
|
||||
|
||||
#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 {};
|
||||
}
|
||||
Reference in New Issue
Block a user