Initial commit, zbrisal narobe ustvarjeno mapo, naredil prvi del simulatorja
This commit is contained in:
parent
f8404698d2
commit
513cb421ec
12 changed files with 329 additions and 1 deletions
23
ass2/fileDevice.cpp
Normal file
23
ass2/fileDevice.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <string>
|
||||
#include <fstream>
|
||||
#include "fileDevice.h"
|
||||
#include <stdexcept>
|
||||
|
||||
fileDevice::fileDevice(std::string& filename): file(filename, std::ios::in | std::ios::out | std::ios::binary) {
|
||||
if (!file.is_open()) {
|
||||
throw std::runtime_error("Datoteke ni mogoče odpreti: " + filename);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t fileDevice::read() {
|
||||
int c = file.get();
|
||||
if (c == EOF) {
|
||||
return 0;
|
||||
}
|
||||
return static_cast<uint8_t>(c);
|
||||
}
|
||||
|
||||
void fileDevice::write(uint8_t val) {
|
||||
file.put(static_cast<char>(val));
|
||||
file.flush();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue