diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index cedfa1cdee3b75a7118abd9940b5d49d750d05d6..458474d7aebf8c7328b4d048201b56ca0254ab98 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -124,7 +124,8 @@ Foam::fileName Foam::fileName::validate Foam::fileName Foam::fileName::concat ( const std::string& s1, - const std::string& s2 + const std::string& s2, + const char delim ) { const auto n1 = s1.length(); @@ -135,10 +136,10 @@ Foam::fileName Foam::fileName::concat out += s1; - if (n1 && n2 && s1.back() != '/' && s2.front() != '/') + if (n1 && n2 && s1.back() != delim && s2.front() != delim) { - // Add separator - out += '/'; + // Add delimiter + out += delim; } out += s2; @@ -473,9 +474,9 @@ bool Foam::fileName::hasExt(const wordRe& ending) const } -Foam::wordList Foam::fileName::components(const char delimiter) const +Foam::wordList Foam::fileName::components(const char delim) const { - const auto parsed = stringOps::split<string>(*this, delimiter); + const auto parsed = stringOps::split<string>(*this, delim); wordList words(parsed.size()); @@ -495,10 +496,10 @@ Foam::wordList Foam::fileName::components(const char delimiter) const Foam::word Foam::fileName::component ( const size_type cmpt, - const char delimiter + const char delim ) const { - const auto parsed = stringOps::split<string>(*this, delimiter); + const auto parsed = stringOps::split<string>(*this, delim); if (cmpt < parsed.size()) { diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index b7c500e892d2b91d3262f5d0ece0f0aa583e12ea..0600dc99d5880d9af4a46c935837493c634d891e 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -149,11 +149,16 @@ public: //- removing duplicate or trailing slashes, etc. static fileName validate(const std::string& s, const bool doClean=true); - //- Join two strings with '/' as a path separator. - // No '/' separator is added if either argument is an empty string or + //- Join two strings with a path separator ('/' by default). + // No separator is added if either argument is an empty string or // if the arguments already had the path separator at the junction. // Invalid characters are \em not stripped (ie, retained). - static fileName concat(const std::string& s1, const std::string& s2); + static fileName concat + ( + const std::string& s1, + const std::string& s2, + const char delim = '/' + ); //- This is a specialized (possibly slower) version of compare() //- that ignores duplicate or trailing slashes. @@ -343,14 +348,10 @@ public: // "/abc/def" ("abc", "def") // "/abc/def/" ("abc", "def") // \endverbatim - wordList components(const char delimiter = '/') const; + wordList components(const char delim = '/') const; //- Return a single component of the path - word component - ( - const size_type cmpt, - const char delimiter = '/' - ) const; + word component(const size_type cmpt, const char delim = '/') const; // Member Operators