mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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 == ".")
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user