add BOM check to config reads

This commit is contained in:
somewhatlurker
2019-09-03 16:50:20 +10:00
parent 4b649b9dae
commit f58d580b00
2 changed files with 25 additions and 1 deletions
@@ -51,6 +51,13 @@ namespace TLAC::FileSystem
{
std::string line;
// check for BOM
std::getline(fileStream, line);
if (line.size() >= 3 & line.rfind("\xEF\xBB\xBF", 0) == 0)
fileStream.seekg(3);
else
fileStream.seekg(0);
while (std::getline(fileStream, line))
{
if (IsComment(line))
@@ -67,6 +74,6 @@ namespace TLAC::FileSystem
bool ConfigFile::IsComment(const std::string &line)
{
return line.size() <= 0 || line[0] == '#' || line[0] == '[' || line._Starts_with("//");
return line.size() <= 0 || line[0] == '#' || line[0] == '[' || (line.size() >= 2 & line.rfind("//", 0) == 0);
}
}