error if settings.json exists, but is unreadable

This commit is contained in:
Tyler Chambers 2021-07-30 14:26:37 -04:00
parent da1c0c64fd
commit 2b071265c3

View File

@ -60,9 +60,15 @@ bool ReadSettings(const fs::path& path, std::map<std::string, SettingsValue>& va
values.clear();
errors.clear();
// Ok for file to not exist
if (!fs::exists(path)) return true;
fsbridge::ifstream file;
file.open(path);
if (!file.is_open()) return true; // Ok for file not to exist.
if (!file.is_open()) {
errors.emplace_back(strprintf("%s. Please check permissions.", path.string()));
return false;
}
SettingsValue in;
if (!in.read(std::string{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()})) {