Do some checks before trying to read json files.

develop
Japa 2018-02-13 20:02:42 +05:30
parent 18cf70a543
commit 74bf06c69e
1 changed files with 6 additions and 3 deletions

@ -386,14 +386,17 @@ bool ServerMain::listen(int port)
Json::Value configJson;
std::ifstream inFile(filename, std::ios_base::in);
bool allow_remote = false;
if (inFile.is_open())
{
inFile >> configJson;
inFile.close();
}
bool allow_remote = configJson.get("allow_remote", "false").asBool();
port = configJson.get("port", port).asInt();
allow_remote = configJson.get("allow_remote", "false").asBool();
port = configJson.get("port", port).asInt();
}
configJson["allow_remote"] = allow_remote;
configJson["port"] = port;