Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::basic_ifstream<uint8_t> f;
- std::ios_base::iostate exceptionMask = f.exceptions() | std::ios::failbit;
- f.exceptions(exceptionMask);
- try {
- f.open(file_name, std::ios::binary);
- f.seekg(std::ios::end);
- this->buffer.reserve(f.tellg());
- f.seekg(std::ios::beg);
- this->buffer.assign(
- std::istreambuf_iterator<uint8_t>(f),
- std::istreambuf_iterator<uint8_t>()
- );
- }
- catch (std::ios_base::failure& e) {
- std::cerr << e.what() << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement