introduce fileName::clean() method

- still needs more fleshing out, but introduce the method for now and
  add more code later (without recompiling everything else).
This commit is contained in:
Mark Olesen
2009-07-23 23:53:32 +02:00
parent 2ec8908377
commit ab918fba9b
3 changed files with 29 additions and 2 deletions

View File

@ -127,8 +127,7 @@ void Foam::argList::getRootCase()
if (iter != options_.end())
{
casePath = iter();
casePath.removeRepeated('/');
casePath.removeTrailing('/');
casePath.clean();
// handle degenerate form and '-case .' like no -case specified
if (casePath.empty() || casePath == ".")

View File

@ -55,6 +55,27 @@ Foam::fileName::Type Foam::fileName::type() const
}
bool Foam::fileName::clean()
{
bool changed = false;
changed = this->removeRepeated('/') || changed;
changed = this->removeTrailing('/') || changed;
return changed;
}
// Return string with repeated characters removed
Foam::fileName Foam::fileName::clean() const
{
fileName fName(*this);
fName.clean();
return fName;
}
// Return file name (part beyond last /)
//
// behaviour compared to /usr/bin/basename:

View File

@ -128,6 +128,13 @@ public:
//- Is this character valid for a fileName?
inline static bool valid(char);
//- Cleanup file name
// eg, remove repeated slashes, etc.
bool clean();
//- Cleanup file name
// eg, remove repeated slashes, etc.
fileName clean() const;
// Interogation