1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 12:48:26 +02:00

Remove unnecessary file existence check in GMenu2X::readConfig(string)

A file existence check is already performed, atomically with respect to
the filesystem, by ifstream's constructor. The result of this check is
available using ifstream::is_open().
This commit is contained in:
Nebuleon Fumika 2014-08-10 22:23:57 +00:00 committed by Maarten ter Huurne
parent a741653a13
commit 457fb0a085

View File

@ -448,23 +448,22 @@ void GMenu2X::readConfig() {
} }
void GMenu2X::readConfig(string conffile) { void GMenu2X::readConfig(string conffile) {
if (fileExists(conffile)) { ifstream inf(conffile.c_str(), ios_base::in);
ifstream inf(conffile.c_str(), ios_base::in); if (inf.is_open()) {
if (inf.is_open()) { string line;
string line; while (getline(inf, line, '\n')) {
while (getline(inf, line, '\n')) { string::size_type pos = line.find("=");
string::size_type pos = line.find("="); string name = trim(line.substr(0,pos));
string name = trim(line.substr(0,pos)); string value = trim(line.substr(pos+1,line.length()));
string value = trim(line.substr(pos+1,line.length()));
if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"') if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"')
confStr[name] = value.substr(1,value.length()-2); confStr[name] = value.substr(1,value.length()-2);
else else
confInt[name] = atoi(value.c_str()); confInt[name] = atoi(value.c_str());
}
inf.close();
} }
inf.close();
} }
if (!confStr["lang"].empty()) if (!confStr["lang"].empty())
tr.setLang(confStr["lang"]); tr.setLang(confStr["lang"]);