67static bool cleanFileName
74 const auto maxLen = str.length();
75 std::string::size_type nChar = 0;
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] ==
'\\'
159 std::string::size_type parent;
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)
250 std::string::size_type i1 = 0;
251 std::string::size_type i2 = 0;
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.length();
444 top && (
f.length() > (top+1)) &&
f[top] ==
'/'
445 &&
f.starts_with(parent)
450 const auto trailing =
f.
find(
'/', top+1);
452 if (npos != trailing)
454 switch (trailing-top-1)
458 if (!compare((top+1), 6,
"system"))
460 return "<system>"/
f.substr(trailing+1);
466 if (!compare((top+1), 8,
"constant"))
468 return "<constant>"/
f.substr(trailing+1);
474 return "<case>"/
f.substr(top+1);
478 return f.substr(top+1);
481 else if (caseTag &&
f.length() && !
f.isAbsolute())
483 const auto trailing =
f.
find(
'/');
485 if (npos != trailing)
491 if (!compare(0, 6,
"system"))
493 return "<system>"/
f.substr(trailing+1);
499 if (!compare(0, 8,
"constant"))
501 return "<constant>"/
f.substr(trailing+1);
516 const auto parsed = stringOps::split<string>(*
this, delim);
521 for (
const auto& sub : parsed)
524 words[i] = sub.str();
539 const auto parsed = stringOps::split<string>(*
this, delim);
543 if (cmpt == std::string::npos)
545 return parsed.last().str();
547 else if (cmpt < parsed.size())
549 return parsed[cmpt].str();
569 if (
s.back() !=
'/' && other.front() !=
'/')
577 else if (other.size())
597 if (s1.back() ==
'/' || s2.front() ==
'/')
635 return directory/item;
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
graph_traits< Graph >::vertices_size_type size_type
Correction limiting method based on the relative particle velocity.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
bool valid() const
True if all internal ids are non-negative.
A class for handling file names.
bool clean()
Cleanup filename (inplace)
Type
Enumerations to handle directory entry types.
fileName()=default
Default construct.
fileName & operator/=(const string &other)
Append a path element with '/' separator.
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
Join two strings with a path separator ('/' by default).
static bool equals(const std::string &s1, const std::string &s2)
static const fileName null
An empty fileName.
fileName & toAbsolute()
Convert from relative to absolute.
static int debug
Debugging.
bool isBackup() const
Return true if file name ends with "~", ".bak", ".old", ".save".
static int allowSpaceInFileName
Allow space character in fileName. To be used with caution.
word nameLessExt() const
Return basename, without extension.
static const char *const typeName
The typeName.
Extracts the components of elements of a field and outputs the result into new fields,...
virtual void validate()
Validate the turbulence fields after construction.
type
Volume classification types.
A class for handling words, derived from Foam::string.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
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))
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
const dimensionedScalar c
Speed of light in a vacuum.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
const fileOperation & fileHandler()
Get current file handler.
fileName cwd()
The physical or logical current working directory path name.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
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.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.