mirror of
https://github.com/PixlOne/logiops.git
synced 2025-09-14 13:56:50 +08:00
Do not throw error if config file does not exist
This commit is contained in:
parent
c5a9c1d0a4
commit
44e319d770
@ -19,6 +19,7 @@
|
|||||||
#include <Configuration.h>
|
#include <Configuration.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <filesystem>
|
||||||
#include <ipc_defs.h>
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
@ -27,6 +28,7 @@ using namespace logid::config;
|
|||||||
|
|
||||||
Configuration::Configuration(std::string config_file) :
|
Configuration::Configuration(std::string config_file) :
|
||||||
_config_file(std::move(config_file)) {
|
_config_file(std::move(config_file)) {
|
||||||
|
if (std::filesystem::exists(_config_file)) {
|
||||||
try {
|
try {
|
||||||
_config.readFile(_config_file);
|
_config.readFile(_config_file);
|
||||||
} catch (const FileIOException& e) {
|
} catch (const FileIOException& e) {
|
||||||
@ -40,6 +42,9 @@ Configuration::Configuration(std::string config_file) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
Config::operator=(get<Config>(_config.getRoot()));
|
Config::operator=(get<Config>(_config.getRoot()));
|
||||||
|
} else {
|
||||||
|
logPrintf(INFO, "Config file does not exist, using empty config.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!devices.has_value())
|
if (!devices.has_value())
|
||||||
devices.emplace();
|
devices.emplace();
|
||||||
|
Loading…
Reference in New Issue
Block a user