Go to the documentation of this file.
67 static bool cleanFileName
74 const auto maxLen = str.length();
80 if (maxLen > 2 && str[0] ==
'\\' && str[1] ==
'\\')
86 auto top = std::string::npos;
89 for (
auto src = nChar; src < maxLen; )
111 if (
c ==
'/' && top == std::string::npos)
117 if (doClean && prev ==
'/')
135 const char c1 = str[src];
138 if (
c1 ==
'/' ||
c1 ==
'\\')
151 || str[src+1] ==
'/' || str[src+1] ==
'\\'
163 && top != std::string::npos
164 && (parent = str.rfind(
'/', nChar-2)) != std::string::npos
181 str[nChar++] = prev =
c;
185 if (doClean && nChar > 1 && str[nChar-1] ==
'/')
191 return changed || (nChar != maxLen);
201 return cleanFileName(str,
true,
false);
207 const std::string& str,
212 cleanFileName(out, doClean,
true);
219 const std::string& s1,
220 const std::string& s2,
224 const auto n1 = s1.length();
225 const auto n2 = s2.length();
228 out.reserve(n1 + n2 + 1);
232 if (n1 && n2 && s1.back() != delim && s2.front() != delim)
253 const auto n1 = s1.length();
254 const auto n2 = s2.length();
257 while (i1 < n1 && i2 < n2)
261 if (s1[i1] != s2[i2])
271 while (s1[i1] ==
'/');
277 while (s2[i2] ==
'/');
282 return (i1 == n1 && i2 == n2);
292 else if (
s.back() ==
'~')
298 auto dot = find_ext(
s);
309 !
s.compare(
dot, npos,
"bak") || !
s.compare(
dot, npos,
"BAK")
310 || !
s.compare(
dot, npos,
"old") || !
s.compare(
dot, npos,
"save")
320 for (
const word& item : list)
322 len += 1 + item.length();
326 for (
const word& item : list)
330 if (length())
operator+=(
'/');
340 for (
const word& item : list)
342 len += 1 + item.length();
346 for (
const word& item : list)
350 if (length())
operator+=(
'/');
367 if (checkGzip && (Type::UNDEFINED == t) && size())
379 if (!isAbsolute(*
this))
398 auto beg = str.rfind(
'/');
399 auto dot = str.rfind(
'.');
410 if (
dot != npos &&
dot <= beg)
417 return str.substr(beg);
420 return str.substr(beg,
dot - beg);
430 const auto top = parent.size();
439 top && (
f.size() > (top+1)) &&
f[top] ==
'/'
440 &&
f.starts_with(parent)
445 return "<case>"/
f.substr(top+1);
449 return f.substr(top+1);
452 else if (caseTag &&
f.size() && !
f.isAbsolute())
463 const auto parsed = stringOps::split<string>(*
this, delim);
468 for (
const auto& sub : parsed)
471 words[i] = sub.str();
486 const auto parsed = stringOps::split<string>(*
this, delim);
490 if (cmpt == std::string::npos)
492 return parsed.last().str();
494 else if (cmpt < parsed.size())
496 return parsed[cmpt].str();
516 if (
s.back() !=
'/' && other.front() !=
'/')
524 else if (other.size())
544 if (s1.back() ==
'/' || s2.front() ==
'/')
582 return directory/item;
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
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.
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.
static bool valid(char c)
Is this character valid for a fileName?
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.
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.
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 or empty if out of range.
graph_traits< Graph >::vertices_size_type size_type
static bool equals(const std::string &s1, const std::string &s2)
fileName()=default
Default construct.
static fileName validate(const std::string &, const bool doClean=true)
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.