Do the seekg thing

This commit is contained in:
Michał Janiszewski 2023-05-07 20:46:05 +02:00
parent 01f32a660f
commit 6f2bf26ce1
1 changed files with 3 additions and 1 deletions

View File

@ -73,7 +73,9 @@ public:
{
throw std::runtime_error("Unable to open " + path);
}
auto length = fs.end - fs.beg;
fs.seekg(0, fs.end);
auto length = fs.tellg();
fs.seekg(0, fs.beg);
std::unique_ptr<char[]> buffer = std::make_unique<char[]>(length);
fs.read(buffer.get(), length);
auto result = std::string(buffer.get(), buffer.get() + length);