| 14 | } |
| 15 | |
| 16 | SConfig::SConfig() |
| 17 | { |
| 18 | assert(!g_instance && "Only a single SConfig instance is allowed"); |
| 19 | g_instance = this; |
| 20 | |
| 21 | const QString exeDir = QCoreApplication::applicationDirPath(); |
| 22 | const QString portableFilePath = exeDir + "/portable.txt"; |
| 23 | QFile file(portableFilePath); |
| 24 | if (file.exists()) |
| 25 | { |
| 26 | m_settings = new QSettings(exeDir + "/settings.ini", QSettings::IniFormat); |
| 27 | } |
| 28 | else |
| 29 | { |
| 30 | const QString organization{"dolphin-memory-engine"}; |
| 31 | const QString application{"dolphin-memory-engine"}; |
| 32 | m_settings = |
| 33 | new QSettings(QSettings::IniFormat, QSettings::UserScope, organization, application); |
| 34 | } |
| 35 | |
| 36 | const QString lockFilepath{m_settings->fileName() + "_lock"}; |
| 37 | QDir().mkpath(QFileInfo{lockFilepath}.absolutePath()); |
| 38 | m_lockFile = std::make_unique<QLockFile>(lockFilepath); |
| 39 | if (!m_lockFile->tryLock()) |
| 40 | { |
| 41 | std::cerr << "ERROR: Unable to lock \"" + lockFilepath.toStdString() + |
| 42 | "\". Is another instance running?\n"; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | SConfig::~SConfig() |
| 47 | { |
nothing calls this directly
no outgoing calls
no test coverage detected