STYLE: update fileName docs and minor code cleanup

This commit is contained in:
Mark Olesen
2018-10-16 23:03:38 +02:00
parent 01737e14e7
commit 0a0fee88a0
6 changed files with 177 additions and 53 deletions

View File

@ -46,21 +46,30 @@ Foam::word Foam::string::ext() const
return word::null;
}
return substr(i+1, npos);
return substr(i+1);
}
bool Foam::string::ext(const Foam::word& ending)
bool Foam::string::ext(const word& ending)
{
if (!ending.empty() && !empty() && operator[](size()-1) != '/')
if (ending.empty() || empty() || back() == '/')
{
return false;
}
else if (ending[0] == '.')
{
if (ending.size() == 1)
{
return false;
}
}
else
{
append(1u, '.');
append(ending);
return true;
}
append(ending);
return false;
return true;
}
@ -90,7 +99,7 @@ bool Foam::string::hasExt(const wordRe& ending) const
return false;
}
const std::string end = substr(i+1, npos); // Compare *after* the dot
const std::string end = substr(i+1); // Compare *after* the dot
return ending.match(end);
}