mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Simplified getPathFromConfigOrDefault
This commit is contained in:
@ -145,16 +145,14 @@ std::wstring VCMIDirsWIN32::utf8ToWstring(const std::string& str) const
|
||||
|
||||
bfs::path VCMIDirsWIN32::getPathFromConfigOrDefault(const std::string& key, const std::function<bfs::path()>& fallbackFunc) const
|
||||
{
|
||||
|
||||
if (!dirsConfig || !dirsConfig->isStruct())
|
||||
return fallbackFunc();
|
||||
|
||||
const auto& structMap = dirsConfig->Struct();
|
||||
auto it = structMap.find(key);
|
||||
if (it == structMap.end() || !it->second.isString())
|
||||
const JsonNode& node = (*dirsConfig)[key];
|
||||
if (!node.isString())
|
||||
return fallbackFunc();
|
||||
|
||||
std::wstring raw = utf8ToWstring(it->second.String());
|
||||
std::wstring raw = utf8ToWstring(node.String());
|
||||
wchar_t expanded[MAX_PATH];
|
||||
if (ExpandEnvironmentStringsW(raw.c_str(), expanded, MAX_PATH))
|
||||
return bfs::path(expanded);
|
||||
|
Reference in New Issue
Block a user