// // BinaryDump.cpp // Clock Signal // // Created by Thomas Harte on 28/08/2016. // Copyright © 2016 Thomas Harte. All rights reserved. // #include "BinaryDump.hpp" #include #include using namespace Storage::Cartridge; BinaryDump::BinaryDump(const char *file_name) { // the file should be exactly 16 kb struct stat file_stats; stat(file_name, &file_stats); // grab contents FILE *file = std::fopen(file_name, "rb"); if(!file) throw ErrorNotAccessible; std::size_t data_length = static_cast(file_stats.st_size); std::vector contents(data_length); contents.resize(std::fread(&contents[0], 1, static_cast(data_length), file)); std::fclose(file); // enshrine segments_.emplace_back( ::Storage::Cartridge::Cartridge::Segment::UnknownAddress, ::Storage::Cartridge::Cartridge::Segment::UnknownAddress, std::move(contents)); }