2020-12-05 13:08:24 +01:00
|
|
|
#include "stdafx.h"
|
2020-02-15 23:36:20 +01:00
|
|
|
#include "system_config.h"
|
|
|
|
|
#include "Utilities/StrUtil.h"
|
2021-04-10 07:06:40 +02:00
|
|
|
#include "Utilities/StrFmt.h"
|
2020-12-18 10:55:54 +01:00
|
|
|
|
|
|
|
|
#include "util/sysinfo.hpp"
|
2020-02-15 23:36:20 +01:00
|
|
|
|
2021-04-03 18:38:02 +02:00
|
|
|
cfg_root g_cfg{};
|
2020-02-15 23:36:20 +01:00
|
|
|
|
2020-05-18 15:02:44 +02:00
|
|
|
bool cfg_root::node_core::has_rtm() const
|
|
|
|
|
{
|
|
|
|
|
return utils::has_rtm();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-10 07:06:40 +02:00
|
|
|
std::string cfg_root::node_vfs::get(const cfg::string& _cfg, std::string_view emu_dir) const
|
2020-02-15 23:36:20 +01:00
|
|
|
{
|
2021-04-10 07:06:40 +02:00
|
|
|
std::string _emu_dir; // Storage only
|
2020-02-15 23:36:20 +01:00
|
|
|
|
2021-04-10 07:06:40 +02:00
|
|
|
if (emu_dir.empty())
|
2020-02-15 23:36:20 +01:00
|
|
|
{
|
2021-04-10 07:06:40 +02:00
|
|
|
// Optimization if provided arg
|
|
|
|
|
_emu_dir = emulator_dir;
|
|
|
|
|
|
|
|
|
|
if (_emu_dir.empty())
|
|
|
|
|
{
|
|
|
|
|
_emu_dir = fs::get_config_dir() + '/';
|
|
|
|
|
}
|
|
|
|
|
// Check if path does not end with a delimiter
|
|
|
|
|
else if (_emu_dir.back() != fs::delim[0] && _emu_dir.back() != fs::delim[1])
|
|
|
|
|
{
|
|
|
|
|
_emu_dir += '/';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emu_dir = _emu_dir;
|
2020-02-15 23:36:20 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-10 07:06:40 +02:00
|
|
|
std::string path = _cfg.to_string();
|
|
|
|
|
|
|
|
|
|
if (path.empty())
|
|
|
|
|
{
|
|
|
|
|
// Fallback
|
|
|
|
|
path = _cfg.def;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path = fmt::replace_all(path, "$(EmulatorDir)", emu_dir);
|
|
|
|
|
|
|
|
|
|
// Check if path does not end with a delimiter
|
|
|
|
|
if (path.back() != fs::delim[0] && path.back() != fs::delim[1])
|
|
|
|
|
{
|
|
|
|
|
path += '/';
|
|
|
|
|
}
|
2020-02-15 23:36:20 +01:00
|
|
|
|
2021-04-10 07:06:40 +02:00
|
|
|
return path;
|
2020-02-15 23:36:20 +01:00
|
|
|
}
|