Add ability to check for first-time-run

This commit is contained in:
Andrew nuark G 2020-12-16 00:29:05 +07:00
parent 2293c377eb
commit 6458ebe2a4
2 changed files with 11 additions and 2 deletions

View file

@ -2,16 +2,17 @@
apparatus *apparatus::_instance = nullptr;
const QString apparatus::filename = "data.bin";
void apparatus::open_reading_stream() {
this->_bin_file = new QFile("data.bin");
this->_bin_file = new QFile(apparatus::filename);
this->_bin_file->open(QIODevice::ReadOnly);
stream.setDevice(_bin_file);
}
void apparatus::open_writing_stream() {
this->_bin_file = new QFile("data.bin");
this->_bin_file = new QFile(apparatus::filename);
this->_bin_file->open(QIODevice::WriteOnly);
stream.setDevice(_bin_file);
@ -49,6 +50,10 @@ apparatus& apparatus::instance() {
return *apparatus::_instance;
}
bool apparatus::isFirstRun() {
return QFile(apparatus::filename).exists();
}
void apparatus::init() {
apparatus::_instance = new apparatus();
}