mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
Check if settings file is open before parsing JSON content from it (#1616)
This commit is contained in:
parent
f0f044b766
commit
ff0c021162
@ -10,8 +10,12 @@ namespace json
|
||||
try
|
||||
{
|
||||
std::wifstream file(file_name.data(), std::ios::binary);
|
||||
using isbi = std::istreambuf_iterator<wchar_t>;
|
||||
return JsonValue::Parse(std::wstring{ isbi{ file }, isbi{} }).GetObjectW();
|
||||
if (file.is_open())
|
||||
{
|
||||
using isbi = std::istreambuf_iterator<wchar_t>;
|
||||
return JsonValue::Parse(std::wstring{ isbi{ file }, isbi{} }).GetObjectW();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user