Go to the documentation of this file.
67 out.resize(
s.length());
71 auto iter =
s.cbegin();
75 if (
s.length() > 2 &&
s[0] ==
'\\' &&
s[1] ==
'\\')
84 for (; iter !=
s.cend(); ++iter)
100 if (fileName::valid(
c))
102 if (doClean && prev ==
'/' &&
c ==
'/')
109 out[len++] = prev =
c;
113 if (doClean && prev ==
'/' && len > 1)
127 const std::string& s1,
128 const std::string& s2,
132 const auto n1 = s1.length();
133 const auto n2 = s2.length();
136 out.reserve(n1 + n2 + 1);
140 if (n1 && n2 && s1.back() != delim && s2.front() != delim)
161 const auto n1 = s1.length();
162 const auto n2 = s2.length();
165 while (i1 < n1 && i2 < n2)
169 if (s1[i1] != s2[i2])
179 while (s1[i1] ==
'/');
185 while (s2[i2] ==
'/');
190 return (i1 == n1 && i2 == n2);
200 else if (
s.back() ==
'~')
206 auto dot = find_ext(
s);
217 !
s.compare(
dot, npos,
"bak") || !
s.compare(
dot, npos,
"BAK")
218 || !
s.compare(
dot, npos,
"old") || !
s.compare(
dot, npos,
"save")
228 for (
const word& item : list)
230 len += 1 + item.length();
234 for (
const word& item : list)
238 if (length())
operator+=(
'/');
248 for (
const word& item : list)
250 len += 1 + item.length();
254 for (
const word& item : list)
258 if (length())
operator+=(
'/');
275 if (checkGzip && (Type::UNDEFINED == t) && size())
287 if (!isAbsolute(*
this))
302 auto top = str.find(prev);
305 if (top == std::string::npos)
313 const auto maxLen = str.length();
315 for (
auto src = nChar; src < maxLen; )
317 const char c = str[src++];
337 const char c1 = str[src];
347 if (
c1 ==
'.' && (src+1 >= maxLen || str[src+1] ==
'/'))
357 && (parent = str.rfind(
'/', nChar-2)) != string::npos
373 str[nChar++] = prev =
c;
377 if (nChar > 1 && str[nChar-1] ==
'/')
384 return (nChar != maxLen);
404 auto beg = str.rfind(
'/');
405 auto dot = str.rfind(
'.');
416 if (
dot != npos &&
dot <= beg)
423 return str.substr(beg);
426 return str.substr(beg,
dot - beg);
436 const auto top = parent.size();
445 top && (
f.size() > (top+1)) &&
f[top] ==
'/'
446 &&
f.starts_with(parent)
451 return "<case>"/
f.substr(top+1);
455 return f.substr(top+1);
458 else if (caseTag &&
f.size() && !
f.isAbsolute())
475 const auto parsed = stringOps::split<string>(*
this, delim);
480 for (
const auto& sub : parsed)
483 words[i] = sub.str();
498 const auto parsed = stringOps::split<string>(*
this, delim);
500 if (cmpt < parsed.size())
502 return parsed[cmpt].str();
521 if (
s.back() !=
'/' && other.front() !=
'/')
529 else if (other.size())
549 if (s1.back() ==
'/' || s2.front() ==
'/')
587 return directory/item;
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool hasExt() const
Return true if it has an extension or simply ends with a '.'.
wordList components(const char delim='/') const
Return path components as wordList.
A class for handling words, derived from Foam::string.
A class for handling file names.
static fileName validate(const std::string &s, const bool doClean=true)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
static int debug
Debugging.
Type
Enumerations to handle directory entry types.
word nameLessExt() const
Return basename, without extension.
static int allowSpaceInFileName
Allow space character in fileName. To be used with caution.
const fileOperation & fileHandler()
Get current file handler.
fileName & toAbsolute()
Convert from relative to absolute.
fileName relative(const fileName &parent, const bool caseTag=false) const
bool isBackup() const
Return true if file name ends with "~", ".bak", ".old", ".save".
fileName & operator/=(const string &other)
Append a path element with '/' separator.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
static const char *const typeName
The typeName.
bool hasExt() const
Return true if it has an extension or simply ends with a '.'.
Type type(bool followLink=true, bool checkGzip=false) const
word component(const size_type cmpt, const char delim='/') const
Return a single component of the path.
graph_traits< Graph >::vertices_size_type size_type
static bool equals(const std::string &s1, const std::string &s2)
fileName()=default
Construct null.
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
static const fileName null
An empty fileName.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
Join two strings with a path separator ('/' by default).
const dimensionedScalar c
Speed of light in a vacuum.
fileName cwd()
The physical or logical current working directory path name.
bool clean()
Cleanup filename inplace.
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.