Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<uint8_t> deserializePdb(std::string filename) {
- std::ifstream is(filename, std::ios::binary);
- if (!is.good()) { throw std::runtime_error("Cannot open file for reading"); }
- uint32_t size;
- is.read(reinterpret_cast<char*>(&size), sizeof(size));
- if (!is.good()) { throw std::runtime_error("Error reading size"); }
- std::cout << size << std::endl;
- std::vector<uint8_t> bytes(size);
- is.read(reinterpret_cast<char*>(bytes.data()), size);
- if (!is.good()) { throw std::runtime_error("Error reading bytes"); }
- return bytes;
- }
- void serializePdb(std::vector<uint8_t> const& data, std::string filename) {
- std::ofstream os(filename, std::ios::binary);
- if (!os.good()) { throw std::runtime_error("Cannot open file for writing"); }
- uint32_t size = data.size();
- os.write(reinterpret_cast<const char*>(&size), sizeof(size));
- if (!os.good()) { throw std::runtime_error("Error writing size"); }
- os.write(reinterpret_cast<const char*>(data.data()), size);
- if (!os.good()) { throw std::runtime_error("Error writing bytes"); }
- os.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement