-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSettings.cpp
More file actions
40 lines (33 loc) · 1.37 KB
/
Settings.cpp
File metadata and controls
40 lines (33 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "settings/Settings.h"
#include <boost/filesystem.hpp>
#include <QFile>
#include <QMessageBox>
#include "Exceptions.h"
#include "settings/Messages.h"
Settings::Settings() {
if (!boost::filesystem::is_directory(CONFIGPARAM::BASE_PATH)) {
if (!boost::filesystem::create_directory(CONFIGPARAM::BASE_PATH)) {
throw BioTracker::Core::path_creation_error("Unable to create config dir");
}
}
if (!boost::filesystem::is_directory(CONFIGPARAM::MODULE_PATH)) {
if (!boost::filesystem::create_directory(CONFIGPARAM::MODULE_PATH)) {
throw BioTracker::Core::path_creation_error("Unable to create module dir");
}
}
if (!QFile::exists(QString::fromStdString(CONFIGPARAM::CONFIGURATION_FILE.string()))) {
QMessageBox::warning(nullptr, "No configuration file",
QString::fromStdString(MSGS::SYSTEM::MISSING_CONFIGURATION_FILE));
_ptree = getDefaultParams();
boost::property_tree::write_json(CONFIGPARAM::CONFIGURATION_FILE.string(), _ptree);
} else {
boost::property_tree::ptree pt;
boost::property_tree::read_json(CONFIGPARAM::CONFIGURATION_FILE.string(), pt);
_ptree = pt;
}
}
const boost::property_tree::ptree Settings::getDefaultParams() {
boost::property_tree::ptree pt;
pt.put(TRACKERPARAM::TRACKING_ENABLED, false);
return pt;
}