Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<std::byte> utils::read_log_file()
- {
- std::ifstream ifs(path, std::ios::binary | std::ios::ate);
- if (!ifs)
- throw std::runtime_error("Could not load file.");
- const auto end = ifs.tellg();
- ifs.seekg(0, std::ios::beg);
- const auto size = static_cast<std::size_t>(end - ifs.tellg());
- if (size == 0)
- return {};
- std::vector<std::byte> buffer(size);
- if (!ifs.read(reinterpret_cast<char*>(buffer.data()), buffer.size()))
- throw std::runtime_error("Could not read file.");
- return buffer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement