ENH: improve consistency of fileName handling windows/non-windows (#2057)

- wrap command-line retrieval of fileName with an implicit validate.

  Instead of this:
      fileName input(args[1]);
      fileName other(args["someopt"]);

  Now use this:
      auto input = args.get<fileName>(1);
      auto other = args.get<fileName>("someopt");

  which adds a fileName::validate on the inputs

  Because of how it is implemented, it will automatically also apply
  to argList getOrDefault<fileName>, readIfPresent<fileName> etc.

- adjust fileName::validate and clean to handle backslash conversion.
  This makes it easier to ensure that path names arising from MS-Windows
  are consistently handled internally.

- dictionarySearch: now check for initial '/' directly instead of
  relying on fileName isAbsolute(), which now does more things

BREAKING: remove fileName::clean() const method

- relying on const/non-const to control the behaviour (inplace change
  or return a copy) is too fragile and the const version was
  almost never used.

  Replace:
      fileName sanitized = constPath.clean();

  With:
      fileName sanitized(constPath);
      sanitized.clean());

STYLE: test empty() instead of comparing with fileName::null
This commit is contained in:
Mark Olesen
2021-04-12 22:56:20 +02:00
committed by Andrew Heather
parent 96a1b86fb9
commit b060378dca
109 changed files with 483 additions and 456 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -101,7 +101,7 @@ int main(int argc, char *argv[])
{ {
if (true) if (true)
{ {
IFstream is(args[argi]); IFstream is(args.get<fileName>(argi));
Info<< nl << nl Info<< nl << nl
<< "read from " << is.name() << nl << endl; << "read from " << is.name() << nl << endl;
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
if (true) if (true)
{ {
IFstream is(args[argi]); IFstream is(args.get<fileName>(argi));
Info<< nl << nl Info<< nl << nl
<< "read from " << is.name() << nl << endl; << "read from " << is.name() << nl << endl;

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -125,9 +126,9 @@ int main(int argc, char *argv[])
} }
for (label argI=1; argI < args.size(); ++argI) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& srcFile = args[argI]; const auto srcFile = args.get<fileName>(argi);
Info<< nl << "reading " << srcFile << nl; Info<< nl << "reading " << srcFile << nl;
IFstream ifs(srcFile); IFstream ifs(srcFile);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -74,8 +74,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const fileName decompFile = args[1]; const auto decompFile = args.get<fileName>(1);
const bool region = args.found("region"); const bool region = args.found("region");
const bool allRegions = args.found("allRegions"); const bool allRegions = args.found("allRegions");
const bool verbose = args.found("verbose"); const bool verbose = args.found("verbose");

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,9 +60,9 @@ int main(int argc, char *argv[])
else else
{ {
IOobject::writeDivider(Info); IOobject::writeDivider(Info);
for (label argI=1; argI < args.size(); ++argI) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& dictFile = args[argI]; const auto dictFile = args.get<fileName>(argi);
IFstream is(dictFile); IFstream is(dictFile);
dictionary dict(is); dictionary dict(is);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -179,7 +179,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& dictFile = args[argi]; const auto dictFile = args.get<fileName>(argi);
IFstream is(dictFile); IFstream is(dictFile);
dictionary inputDict(is); dictionary inputDict(is);
@ -201,7 +201,7 @@ int main(int argc, char *argv[])
{ {
for (label argi=1; argi < args.size(); ++argi) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& dictFile = args[argi]; const auto dictFile = args.get<fileName>(argi);
IFstream is(dictFile); IFstream is(dictFile);
dictionary inputDict(is); dictionary inputDict(is);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -135,8 +135,8 @@ int main(int argc, char *argv[])
args.readIfPresent("maxPath", maxPath); args.readIfPresent("maxPath", maxPath);
#endif #endif
const fileName srcFile(fileName::validate(args[1])); const auto srcFile = args.get<fileName>(1);
const fileName dstFile(fileName::validate(args[2])); const auto dstFile = args.get<fileName>(2);
const fileName tmpFile(dstFile + Foam::name(pid())); const fileName tmpFile(dstFile + Foam::name(pid()));
Info<< "src : " << srcFile << nl Info<< "src : " << srcFile << nl

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,7 +55,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
const fileName file(args[1]); const auto file = args.get<fileName>(1);
Info<< "Reading " << file << nl << endl; Info<< "Reading " << file << nl << endl;
decomposedBlockData data decomposedBlockData data

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -123,9 +124,9 @@ int main(int argc, char *argv[])
else else
{ {
IOobject::writeDivider(Info); IOobject::writeDivider(Info);
for (label argI=1; argI < args.size(); ++argI) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& dictFile = args[argI]; const auto dictFile = args.get<fileName>(argi);
IFstream is(dictFile); IFstream is(dictFile);
dictionary dict(is); dictionary dict(is);

View File

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& dictFile = args[argi]; const auto dictFile = args.get<fileName>(argi);
IFstream is(dictFile); IFstream is(dictFile);
dictionary input(is); dictionary input(is);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -61,7 +61,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi) for (label argi=1; argi < args.size(); ++argi)
{ {
IFstream is(args[argi]); IFstream is(args.get<fileName>(argi));
dictionary dict(is); dictionary dict(is);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -70,7 +70,7 @@ int main(int argc, char *argv[])
for (int argi = 1; argi < args.size(); ++argi) for (int argi = 1; argi < args.size(); ++argi)
{ {
const fileName libName(fileName::validate(args[argi])); const auto libName = args.get<fileName>(argi);
if (libName.empty()) if (libName.empty())
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -79,7 +79,7 @@ int main(int argc, char *argv[])
{ {
IOobject::writeDivider(Info); IOobject::writeDivider(Info);
IFstream is(args[argi]); IFstream is(args.get<fileName>(argi));
const dictionary dict(is); const dictionary dict(is);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -60,7 +60,7 @@ unsigned testClean(std::initializer_list<Pair<std::string>> tests)
const std::string& expected = test.second(); const std::string& expected = test.second();
fileName cleaned(test.first()); fileName cleaned(test.first());
cleaned.clean(); cleaned.clean(); // Remove unneeded ".."
if (cleaned == expected) if (cleaned == expected)
{ {

View File

@ -5,7 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,11 +25,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application Application
fileNameCleanTest Test-fileNameClean
Description Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
@ -51,7 +51,7 @@ void printCleaning(fileName& pathName)
Info<< "components = " << flatOutput(pathName.components()) << nl; Info<< "components = " << flatOutput(pathName.components()) << nl;
Info<< "component 2 = " << pathName.component(2) << nl; Info<< "component 2 = " << pathName.component(2) << nl;
pathName.clean(); pathName.clean(); // Remove unneeded ".."
Info<< "cleaned = " << pathName << nl Info<< "cleaned = " << pathName << nl
<< " path() = " << pathName.path() << nl << " path() = " << pathName.path() << nl
@ -94,9 +94,15 @@ int main(int argc, char *argv[])
printCleaning(pathName); printCleaning(pathName);
} }
for (label argI=1; argI < args.size(); ++argI) for (label argi=1; argi < args.size(); ++argi)
{ {
pathName = args[argI]; fileName fn(args[argi], false); // no strip
Info<< "Input = " << fn << nl;
fn.clean(); // Remove unneeded ".."
Info<< "cleaned = " << fn << nl;
Info<< "get = " << args.get<fileName>(argi) << nl;
pathName = fileName::validate(args[argi]);
printCleaning(pathName); printCleaning(pathName);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
for (label argi = 1; argi < args.size(); ++argi) for (label argi = 1; argi < args.size(); ++argi)
{ {
const fileName inputName(args[argi]); const auto inputName = args.get<fileName>(argi);
InfoErr<< "input: " << inputName; InfoErr<< "input: " << inputName;

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,9 +54,9 @@ int main(int argc, char *argv[])
label ok = 0; label ok = 0;
for (label argI=1; argI < args.size(); ++argI) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& srcFile = args[argI]; const auto srcFile = args.get<fileName>(argi);
if (args.found("ext")) if (args.found("ext"))
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi) for (label argi=1; argi < args.size(); ++argi)
{ {
IFstream is(args[argi]); IFstream is(args.get<fileName>(argi));
dictionary dict(is); dictionary dict(is);

View File

@ -375,7 +375,7 @@ int main(int argc, char *argv[])
for (label argi = 1; argi < args.size(); ++argi) for (label argi = 1; argi < args.size(); ++argi)
{ {
IFstream is(args[argi]); IFstream is(args.get<fileName>(argi));
List<regexTest> tests(is); List<regexTest> tests(is);
Info<< "Test expressions:" << tests << endl; Info<< "Test expressions:" << tests << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -76,9 +76,9 @@ int main(int argc, char *argv[])
useCatmullRom = true; useCatmullRom = true;
} }
for (label argI=1; argI < args.size(); ++argI) for (label argi=1; argi < args.size(); ++argi)
{ {
const string& srcFile = args[argI]; const auto srcFile = args.get<fileName>(argi);
Info<< nl << "reading " << srcFile << nl; Info<< nl << "reading " << srcFile << nl;
IFstream ifs(srcFile); IFstream ifs(srcFile);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -139,13 +139,13 @@ int main(int argc, char *argv[])
const word outputFile(args.executable() + ".obj"); const word outputFile(args.executable() + ".obj");
const fileName surf1Name(args[1]); const auto surf1Name = args.get<fileName>(1);
triSurface surf1 = loadSurface(runTime, surf1Name, scaleFactor)(); triSurface surf1 = loadSurface(runTime, surf1Name, scaleFactor)();
Info<< surf1Name << " statistics:" << endl; Info<< surf1Name << " statistics:" << endl;
surf1.writeStats(Info); surf1.writeStats(Info);
Info<< endl; Info<< endl;
const fileName surf2Name(args[2]); const auto surf2Name = args.get<fileName>(2);
triSurface surf2 = loadSurface(runTime, surf2Name, scaleFactor)(); triSurface surf2 = loadSurface(runTime, surf2Name, scaleFactor)();
Info<< surf2Name << " statistics:" << endl; Info<< surf2Name << " statistics:" << endl;
surf2.writeStats(Info); surf2.writeStats(Info);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const fileName importName = args[1]; const auto importName = args.get<fileName>(1);
word ext; word ext;
if (!args.readIfPresent("ext", ext)) if (!args.readIfPresent("ext", ext))

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -68,8 +68,8 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const fileName importName = args[1]; const auto importName = args.get<fileName>(1);
const fileName exportName = args[2]; const auto exportName = args.get<fileName>(2);
if (importName == exportName) if (importName == exportName)
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi) for (label argi=1; argi < args.size(); ++argi)
{ {
const auto& input = args[argi]; const auto input = args.get<fileName>(argi);
Info << "load from " << input << nl; Info << "load from " << input << nl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -327,7 +327,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
const fileName ansysFile(args[1]); const auto ansysFile = args.get<fileName>(1);
std::ifstream ansysStream(ansysFile); std::ifstream ansysStream(ansysFile);
if (!ansysStream) if (!ansysStream)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -225,7 +225,7 @@ int main(int argc, char *argv[])
} }
// CCM reader for reading geometry/solution // CCM reader for reading geometry/solution
ccm::reader reader(args[1], rOpts); ccm::reader reader(args.get<fileName>(1), rOpts);
// list the geometry information // list the geometry information
if (optList) if (optList)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
IFstream cfxFile(args[1]); IFstream cfxFile(args.get<fileName>(1));
// Read the cfx information using a fixed format reader. // Read the cfx information using a fixed format reader.
// Comments in the file are in C++ style, so the stream parser will remove // Comments in the file are in C++ style, so the stream parser will remove

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
std::ifstream plot3dFile(args[1]); std::ifstream plot3dFile(args.get<fileName>(1));
string line; string line;
std::getline(plot3dFile, line); std::getline(plot3dFile, line);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
fileFormats::FIREMeshReader reader fileFormats::FIREMeshReader reader
( (
args[1], args.get<fileName>(1),
// Default no scaling // Default no scaling
args.getOrDefault<scalar>("scale", 1) args.getOrDefault<scalar>("scale", 1)
); );

View File

@ -835,7 +835,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
const fileName fluentFile = args[1]; const auto fluentFile = args.get<fileName>(1);
IFstream fluentStream(fluentFile); IFstream fluentStream(fluentFile);
if (!fluentStream) if (!fluentStream)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -912,7 +912,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
const fileName fluentFile = args[1]; const auto fluentFile = args.get<fileName>(1);
std::ifstream fluentStream(fluentFile); std::ifstream fluentStream(fluentFile);
if (!fluentStream) if (!fluentStream)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -82,7 +82,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
fileName exportName = args[1]; auto exportName = args.get<fileName>(1);
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 0); const scalar scaleFactor = args.getOrDefault<scalar>("scale", 0);
const bool doTriangulate = args.found("tri"); const bool doTriangulate = args.found("tri");

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -653,7 +653,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
const fileName gambitFile = args[1]; const auto gambitFile = args.get<fileName>(1);
std::ifstream gambitStream(gambitFile); std::ifstream gambitStream(gambitFile);
if (!gambitStream) if (!gambitStream)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1325,7 +1325,7 @@ int main(int argc, char *argv[])
} }
const bool keepOrientation = args.found("keepOrientation"); const bool keepOrientation = args.found("keepOrientation");
IFstream inFile(args[1]); IFstream inFile(args.get<fileName>(1));
// Storage for points // Storage for points
pointField points; pointField points;

View File

@ -666,7 +666,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const fileName ideasName = args[1]; const auto ideasName = args.get<fileName>(1);
IFstream inFile(ideasName); IFstream inFile(ideasName);
if (!inFile.good()) if (!inFile.good())

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -77,7 +78,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
const bool readHex = args.found("hex"); const bool readHex = args.found("hex");
IFstream mshStream(args[1]); IFstream mshStream(args.get<fileName>(1));
label nCells; label nCells;
mshStream >> nCells; mshStream >> nCells;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -104,7 +104,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
IFstream str(args[1]); IFstream str(args.get<fileName>(1));
// //
// Read nodes. // Read nodes.

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
IFstream plot3dFile(args[1]); IFstream plot3dFile(args.get<fileName>(1));
// Read the plot3d information using a fixed format reader. // Read the plot3d information using a fixed format reader.
// Comments in the file are in C++ style, so the stream parser will remove // Comments in the file are in C++ style, so the stream parser will remove

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -108,7 +108,7 @@ int main(int argc, char *argv[])
// Remove extensions and/or trailing '.' // Remove extensions and/or trailing '.'
const fileName prefix = fileName(args[1]).lessExt(); const auto prefix = args.get<fileName>(1).lessExt();
fileFormats::STARCDMeshReader reader fileFormats::STARCDMeshReader reader

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const fileName prefix = args[1]; const auto prefix = args.get<fileName>(1);
const bool readFaceFile = !args.found("noFaceFile"); const bool readFaceFile = !args.found("noFaceFile");
const fileName nodeFile(prefix + ".node"); const fileName nodeFile(prefix + ".node");

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,7 +66,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
IFstream mshStream(args[1]); IFstream mshStream(args.get<fileName>(1));
vtkUnstructuredReader reader(runTime, mshStream); vtkUnstructuredReader reader(runTime, mshStream);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -289,7 +289,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
} }
} }
if (foamyHexMeshControls().objOutput() && fName != fileName::null) if (foamyHexMeshControls().objOutput() && !fName.empty())
{ {
DelaunayMeshTools::writeOBJ(time().path()/fName, pts); DelaunayMeshTools::writeOBJ(time().path()/fName, pts);
} }
@ -324,7 +324,7 @@ void Foam::conformalVoronoiMesh::insertEdgePointGroups
} }
} }
if (foamyHexMeshControls().objOutput() && fName != fileName::null) if (foamyHexMeshControls().objOutput() && !fName.empty())
{ {
DelaunayMeshTools::writeOBJ(time().path()/fName, pts); DelaunayMeshTools::writeOBJ(time().path()/fName, pts);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -378,7 +378,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const fileName exportName = args[1]; const auto exportName = args.get<fileName>(1);
Info<< "Reading surfaces as specified in the foamyHexMeshDict and" Info<< "Reading surfaces as specified in the foamyHexMeshDict and"
<< " writing a re-sampled surface to " << exportName << " writing a re-sampled surface to " << exportName

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -64,8 +64,8 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const labelVector n(args.get<labelVector>(1)); const auto n = args.get<labelVector>(1);
const fileName exportName = args[2]; const auto exportName = args.get<fileName>(2);
Info<< "Reading surfaces as specified in the foamyHexMeshDict and" Info<< "Reading surfaces as specified in the foamyHexMeshDict and"
<< " writing re-sampled " << n << " to " << exportName << " writing re-sampled " << n << " to " << exportName

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -97,7 +98,7 @@ int main(int argc, char *argv[])
if (args.found("pointsFile")) if (args.found("pointsFile"))
{ {
mesh.insertPoints(args["pointsFile"]); mesh.insertPoints(args.get<fileName>("pointsFile"));
} }
else else
{ {

View File

@ -541,7 +541,7 @@ void extractSurface
? runTime.globalPath()/outFileName ? runTime.globalPath()/outFileName
: runTime.path()/outFileName : runTime.path()/outFileName
); );
globalCasePath.clean(); globalCasePath.clean(); // Remove unneeded ".."
Info<< "Writing merged surface to " << globalCasePath << endl; Info<< "Writing merged surface to " << globalCasePath << endl;

View File

@ -306,7 +306,7 @@ void Foam::mergeAndWrite
/ mesh.pointsInstance() / mesh.pointsInstance()
/ set.name() / set.name()
); );
outputDir.clean(); outputDir.clean(); // Remove unneeded ".."
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir); mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
} }
@ -399,7 +399,7 @@ void Foam::mergeAndWrite
/ mesh.pointsInstance() / mesh.pointsInstance()
/ set.name() / set.name()
); );
outputDir.clean(); outputDir.clean(); // Remove unneeded ".."
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir); mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
} }
@ -498,7 +498,7 @@ void Foam::mergeAndWrite
/ mesh.pointsInstance() / mesh.pointsInstance()
// set.name() // set.name()
); );
outputDir.clean(); outputDir.clean(); // Remove unneeded ".."
mkDir(outputDir); mkDir(outputDir);
fileName outputFile(outputDir/writer.getFileName(points, wordList())); fileName outputFile(outputDir/writer.getFileName(points, wordList()));

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -66,8 +66,8 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
#include "createPolyMesh.H" #include "createPolyMesh.H"
const fileName surfName = args[1]; const auto surfName = args.get<fileName>(1);
const fileName setName = args[2]; const auto setName = args.get<fileName>(2);
// Read surface // Read surface
Info<< "Reading surface from " << surfName << endl; Info<< "Reading surface from " << surfName << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,7 +45,7 @@ using namespace Foam;
void getRootCase(fileName& casePath) void getRootCase(fileName& casePath)
{ {
casePath.clean(); casePath.clean(); // Remove unneeded ".."
if (casePath.empty() || casePath == ".") if (casePath.empty() || casePath == ".")
{ {
@ -56,7 +56,7 @@ void getRootCase(fileName& casePath)
{ {
// avoid relative cases ending in '..' - makes for very ugly names // avoid relative cases ending in '..' - makes for very ugly names
casePath = cwd()/casePath; casePath = cwd()/casePath;
casePath.clean(); casePath.clean(); // Remove unneeded ".."
} }
} }
@ -102,8 +102,8 @@ int main(int argc, char *argv[])
const bool overwrite = args.found("overwrite"); const bool overwrite = args.found("overwrite");
fileName masterCase = args[1]; auto masterCase = args.get<fileName>(1);
fileName addCase = args[2]; auto addCase = args.get<fileName>(2);
const word masterRegion = const word masterRegion =
args.getOrDefault<word>("masterRegion", polyMesh::defaultRegion); args.getOrDefault<word>("masterRegion", polyMesh::defaultRegion);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -123,8 +123,8 @@ int main(int argc, char *argv[])
argList::addArgument("vtk-file", "The output vtk file"); argList::addArgument("vtk-file", "The output vtk file");
argList args(argc, argv); argList args(argc, argv);
const fileName objName = args[1]; const auto objName = args.get<fileName>(1);
const fileName outName = args[2]; const auto outName = args.get<fileName>(2);
std::ifstream OBJfile(objName); std::ifstream OBJfile(objName);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -793,7 +793,7 @@ int main(int argc, char *argv[])
if (batch) if (batch)
{ {
const fileName batchFile = args["batch"]; const auto batchFile = args.get<fileName>("batch");
Info<< "Reading commands from file " << batchFile << endl; Info<< "Reading commands from file " << batchFile << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -373,7 +373,7 @@ int main(int argc, char *argv[])
} }
} }
const fileName dictFileName(args[1]); const auto dictFileName = args.get<fileName>(1);
autoPtr<IFstream> dictFile(new IFstream(dictFileName)); autoPtr<IFstream> dictFile(new IFstream(dictFileName));
if (!dictFile().good()) if (!dictFile().good())

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -105,7 +105,7 @@ int main(int argc, char *argv[])
for (int argi = 1; argi < args.size(); ++argi) for (int argi = 1; argi < args.size(); ++argi)
{ {
const fileName libName(fileName::validate(args[argi])); const auto libName = args.get<fileName>(argi); // with validate
if (libName.empty()) if (libName.empty())
{ {

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
#include "createNamedMesh.H" #include "createNamedMesh.H"
IFstream smapFile(args[1]); IFstream smapFile(args.get<fileName>(1));
if (!smapFile.good()) if (!smapFile.good())
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
args.readIfPresent("visual-length", lumpedPointState::visLength); args.readIfPresent("visual-length", lumpedPointState::visLength);
const fileName responseFile(args[1]); const auto responseFile = args.get<fileName>(1);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Slave mode // Slave mode

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -286,7 +286,7 @@ int main(int argc, char *argv[])
fileName rootDirTarget(args.rootPath()); fileName rootDirTarget(args.rootPath());
fileName caseDirTarget(args.globalCaseName()); fileName caseDirTarget(args.globalCaseName());
fileName casePath = args[1]; const auto casePath = args.get<fileName>(1);
const fileName rootDirSource = casePath.path().toAbsolute(); const fileName rootDirSource = casePath.path().toAbsolute();
const fileName caseDirSource = casePath.name(); const fileName caseDirSource = casePath.name();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -214,7 +214,7 @@ int main(int argc, char *argv[])
fileName rootDirTarget(args.rootPath()); fileName rootDirTarget(args.rootPath());
fileName caseDirTarget(args.globalCaseName()); fileName caseDirTarget(args.globalCaseName());
const fileName casePath = args[1]; const auto casePath = args.get<fileName>(1);
const fileName rootDirSource = casePath.path(); const fileName rootDirSource = casePath.path();
const fileName caseDirSource = casePath.name(); const fileName caseDirSource = casePath.name();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -83,9 +83,9 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName inFileName1 = args[1]; const auto inFileName1 = args.get<fileName>(1);
const fileName inFileName2 = args[2]; const auto inFileName2 = args.get<fileName>(2);
const fileName outFileName = args[3]; const auto outFileName = args.get<fileName>(3);
const bool addPoint = args.found("points"); const bool addPoint = args.found("points");
const bool mergeRegions = args.found("mergeRegions"); const bool mergeRegions = args.found("mergeRegions");
@ -99,7 +99,7 @@ int main(int argc, char *argv[])
<< nl << endl; << nl << endl;
Info<< "Surface : " << inFileName1<< nl Info<< "Surface : " << inFileName1<< nl
<< "Points : " << args["points"] << nl << "Points : " << args.get<fileName>("points") << nl
<< "Writing : " << outFileName << nl << endl; << "Writing : " << outFileName << nl << endl;
} }
else else
@ -145,7 +145,7 @@ int main(int argc, char *argv[])
if (addPoint) if (addPoint)
{ {
IFstream pointsFile(args["points"]); IFstream pointsFile(args.get<fileName>("points"));
const pointField extraPoints(pointsFile); const pointField extraPoints(pointsFile);
Info<< "Additional Points:" << extraPoints.size() << endl; Info<< "Additional Points:" << extraPoints.size() << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -335,7 +335,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName surfFileName = args[1]; const auto surfFileName = args.get<fileName>(1);
const bool checkSelfIntersect = args.found("checkSelfIntersection"); const bool checkSelfIntersect = args.found("checkSelfIntersection");
const bool splitNonManifold = args.found("splitNonManifold"); const bool splitNonManifold = args.found("splitNonManifold");
const label outputThreshold = const label outputThreshold =

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -82,10 +82,10 @@ int main(int argc, char *argv[])
); );
argList args(argc, argv); argList args(argc, argv);
const fileName inFileName = args[1]; const auto inFileName = args.get<fileName>(1);
const scalar minLen = args.get<scalar>(2); const auto minLen = args.get<scalar>(2);
const scalar minQuality = args.get<scalar>(3); const auto minQuality = args.get<scalar>(3);
const fileName outFileName = args[4]; const auto outFileName = args.get<fileName>(4);
Info<< "Reading surface " << inFileName << nl Info<< "Reading surface " << inFileName << nl
<< "Collapsing all triangles with" << nl << "Collapsing all triangles with" << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -92,9 +92,9 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName inFileName = args[1]; const auto inFileName = args.get<fileName>(1);
const scalar reduction = args.get<scalar>(2); const auto reduction = args.get<scalar>(2);
const fileName outFileName = args[3]; const auto outFileName = args.get<fileName>(3);
if (reduction <= 0 || reduction > 1) if (reduction <= 0 || reduction > 1)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -159,8 +159,8 @@ int main(int argc, char *argv[])
} }
} }
const fileName importName(args[1]); const auto importName = args.get<fileName>(1);
const fileName exportName(args[2]); const auto exportName = args.get<fileName>(2);
if (importName == exportName) if (importName == exportName)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -106,8 +106,8 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
const fileName importName(args[1]); const auto importName = args.get<fileName>(1);
const fileName exportName(args[2]); const auto exportName = args.get<fileName>(2);
// Disable inplace editing // Disable inplace editing
if (importName == exportName) if (importName == exportName)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,7 +72,7 @@ int main(int argc, char *argv[])
Info<< "Reading surf ..." << endl; Info<< "Reading surf ..." << endl;
meshedSurface surf1(args[1]); meshedSurface surf1(args.get<fileName>(1));
// //
// Nearest vertex // Nearest vertex

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -88,7 +88,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName surfFileName = args[1]; const auto surfFileName = args.get<fileName>(1);
const scalar density = args.getOrDefault<scalar>("density", 1); const scalar density = args.getOrDefault<scalar>("density", 1);
vector refPt = Zero; vector refPt = Zero;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -609,12 +609,12 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const word inputName(args[1]); const auto inputName = args.get<word>(1);
const scalar distance(args.get<scalar>(2)); const auto distance = args.get<scalar>(2);
const scalar extendFactor(args.get<scalar>(3)); const auto extendFactor = args.get<scalar>(3);
const bool checkSelfIntersect = args.found("checkSelfIntersection"); const bool checkSelfIntersect = args.found("checkSelfIntersection");
const label nSmooth = args.getOrDefault<label>("nSmooth", 10); const auto nSmooth = args.getOrDefault<label>("nSmooth", 10);
const scalar featureAngle = args.getOrDefault<scalar>("featureAngle", 180); const auto featureAngle = args.getOrDefault<scalar>("featureAngle", 180);
const bool debug = args.found("debug"); const bool debug = args.found("debug");

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -156,11 +156,11 @@ int main(int argc, char *argv[])
); );
argList args(argc, argv); argList args(argc, argv);
const fileName surfFileName = args[1]; const auto surfFileName = args.get<fileName>(1);
const scalar lambda = args.get<scalar>(2); const auto lambda = args.get<scalar>(2);
const scalar mu = args.get<scalar>(3); const auto mu = args.get<scalar>(3);
const label iters = args.get<label>(4); const auto iters = args.get<label>(4);
const fileName outFileName = args[5]; const auto outFileName = args.get<fileName>(5);
if (lambda < 0 || lambda > 1) if (lambda < 0 || lambda > 1)
{ {
@ -192,7 +192,7 @@ int main(int argc, char *argv[])
if (args.found("featureFile")) if (args.found("featureFile"))
{ {
const fileName featureFileName(args["featureFile"]); const auto featureFileName = args.get<fileName>("featureFile");
Info<< "Reading features from " << featureFileName << " ..." << endl; Info<< "Reading features from " << featureFileName << " ..." << endl;
edgeMesh feMesh(featureFileName); edgeMesh feMesh(featureFileName);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -181,8 +181,8 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
const fileName importName(args[1]); const auto importName = args.get<fileName>(1);
const fileName exportName(args[2]); const auto exportName = args.get<fileName>(2);
if (importName == exportName) if (importName == exportName)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -155,8 +155,8 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
const fileName exportName(args[1]); const auto exportName = args.get<fileName>(1);
const word importName(args.getOrDefault<word>("name", "default")); const auto importName = args.getOrDefault<word>("name", "default");
const word writeFileType const word writeFileType
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -156,7 +156,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const fileName userOutFileName(args[1]); const auto userOutFileName = args.get<fileName>(1);
if (!userOutFileName.hasExt()) if (!userOutFileName.hasExt())
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -167,8 +167,8 @@ int main(int argc, char *argv[])
} }
const fileName importName(args[1]); const auto importName = args.get<fileName>(1);
const word exportName(args.getOrDefault<word>("name", "default")); const auto exportName = args.getOrDefault<word>("name", "default");
const word readFileType const word readFileType
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
const fileName importName = args[1]; const auto importName = args.get<fileName>(1);
// check that reading is supported // check that reading is supported
if (!UnsortedMeshedSurface<face>::canRead(importName, true)) if (!UnsortedMeshedSurface<face>::canRead(importName, true))

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -76,9 +76,9 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName surfFileName = args[1]; const auto surfFileName = args.get<fileName>(1);
const point visiblePoint = args.get<point>(2); const auto visiblePoint = args.get<point>(2);
const fileName outFileName = args[3]; const auto outFileName = args.get<fileName>(3);
const bool orientInside = args.found("inside"); const bool orientInside = args.found("inside");
const bool usePierceTest = args.found("usePierceTest"); const bool usePierceTest = args.found("usePierceTest");

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,9 +67,9 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName surfFileName = args[1]; const auto surfFileName = args.get<fileName>(1);
const scalar mergeTol = args.get<scalar>(2); const auto mergeTol = args.get<scalar>(2);
const fileName outFileName = args[3]; const auto outFileName = args.get<fileName>(3);
const scalar scaling = args.getOrDefault<scalar>("scale", -1); const scalar scaling = args.getOrDefault<scalar>("scale", -1);

View File

@ -124,8 +124,8 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
runTime.functionObjects().off(); runTime.functionObjects().off();
const fileName surfFileName = args[1]; const auto surfFileName = args.get<fileName>(1);
const word distTypeName = args[2]; const auto distTypeName = args.get<word>(2);
const label distType = const label distType =
distributedTriSurfaceMesh::distributionTypeNames_[distTypeName]; distributedTriSurfaceMesh::distributionTypeNames_[distTypeName];

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,8 +72,8 @@ int main(int argc, char *argv[])
); );
argList args(argc, argv); argList args(argc, argv);
const fileName surfFileName(args[1]); const auto surfFileName = args.get<fileName>(1);
const fileName outFileName(args[2]); const auto outFileName = args.get<fileName>(2);
Info<< "Reading surface from " << surfFileName << " ..." << endl; Info<< "Reading surface from " << surfFileName << " ..." << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName surfName = args[1]; const auto surfName = args.get<fileName>(1);
const fileName surfBase(surfName.lessExt()); const fileName surfBase(surfName.lessExt());

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,12 +60,12 @@ int main(int argc, char *argv[])
argList::addArgument("output", "The output surface file"); argList::addArgument("output", "The output surface file");
argList args(argc, argv); argList args(argc, argv);
fileName surfFileName(args[1]); const auto surfFileName = args.get<fileName>(1);
Info<< "Reading surface from " << surfFileName << endl; Info<< "Reading surface from " << surfFileName << endl;
fileName outFileName(args[2]); const auto outFileName = args.get<fileName>(2);
fileName outFileBaseName = outFileName.lessExt(); const fileName outFileBaseName = outFileName.lessExt();
word outExtension = outFileName.ext(); const word outExtension = outFileName.ext();
// Load surface // Load surface
triSurface surf(surfFileName); triSurface surf(surfFileName);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -691,8 +691,8 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName inSurfName = args[1]; const auto inSurfName = args.get<fileName>(1);
const fileName outSurfName = args[2]; const auto outSurfName = args.get<fileName>(2);
const bool debug = args.found("debug"); const bool debug = args.found("debug");
Info<< "Reading surface from " << inSurfName << endl; Info<< "Reading surface from " << inSurfName << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,15 +67,13 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
Info<< "Reading dictionary " << args[1] << " ..." << endl; Info<< "Reading dictionary " << args[1] << " ..." << endl;
IFstream dictFile(args[1]); IFstream dictFile(args.get<fileName>(1));
dictionary meshSubsetDict(dictFile); dictionary meshSubsetDict(dictFile);
Info<< "Reading surface " << args[2] << " ..." << endl; Info<< "Reading surface " << args[2] << " ..." << endl;
meshedSurface surf1(args.get<fileName>(2));
meshedSurface surf1(args[2]); const auto outFileName(args.get<fileName>(3));
const fileName outFileName(args[3]);
Info<< "Original:" << endl; Info<< "Original:" << endl;
surf1.writeStats(Info); surf1.writeStats(Info);
@ -217,7 +215,7 @@ int main(int argc, char *argv[])
{ {
const dictionary& surfDict = meshSubsetDict.subDict("surface"); const dictionary& surfDict = meshSubsetDict.subDict("surface");
const fileName surfName(surfDict.get<fileName>("name")); const auto surfName(surfDict.get<fileName>("name"));
const volumeType::type volType = const volumeType::type volType =
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
#include "createTime.H" #include "createTime.H"
#include "createPolyMesh.H" #include "createPolyMesh.H"
const fileName surfName = args[1]; const auto surfName = args.get<fileName>(1);
Info<< "Reading surface from " << surfName << " ..." << endl; Info<< "Reading surface from " << surfName << " ..." << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -283,8 +283,8 @@ int main(int argc, char *argv[])
} }
} }
const fileName importName(args[1]); const auto importName = args.get<fileName>(1);
const fileName exportName(args[2]); const auto exportName = args.get<fileName>(2);
const word readFileType const word readFileType
( (

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -70,7 +71,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName controlFileName = args[1]; const auto controlFileName = args.get<fileName>(1);
// Construct control dictionary // Construct control dictionary
IFstream controlFile(controlFileName); IFstream controlFile(controlFileName);

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -76,11 +77,18 @@ int main(int argc, char *argv[])
speciesTable species; speciesTable species;
chemkinReader cr(species, args[1], args[3], args[2], newFormat); chemkinReader cr
(
species,
args.get<fileName>(1), // chemkin fileName
args.get<fileName>(3), // thermo fileName
args.get<fileName>(2), // transport fileName
newFormat
);
{ {
// output: reactions file // output: reactions file
OFstream reactionsFile(args[4]); OFstream reactionsFile(args.get<fileName>(4));
reactionsFile.writeEntry("elements", cr.elementNames()) << nl; reactionsFile.writeEntry("elements", cr.elementNames()) << nl;
reactionsFile.writeEntry("species", cr.species()) << nl; reactionsFile.writeEntry("species", cr.species()) << nl;
@ -113,7 +121,7 @@ int main(int argc, char *argv[])
// output: thermo file // output: thermo file
thermoDict.write(OFstream(args[5])(), false); thermoDict.write(OFstream(args.get<fileName>(5))(), false);
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -73,7 +74,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName controlFileName = args[1]; const auto controlFileName = args.get<fileName>(1);
// Construct control dictionary // Construct control dictionary
IFstream controlFile(controlFileName); IFstream controlFile(controlFileName);

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,7 +70,7 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
const fileName controlFileName(args[1]); const auto controlFileName = args.get<fileName>(1);
// Construct control dictionary // Construct control dictionary
IFstream controlFile(controlFileName); IFstream controlFile(controlFileName);

View File

@ -154,8 +154,8 @@ bool Foam::IOobject::fileNameComponents
// Convert explicit relative file-system path to absolute file-system path. // Convert explicit relative file-system path to absolute file-system path.
if (path.starts_with("./") || path.starts_with("../")) if (path.starts_with("./") || path.starts_with("../"))
{ {
fileName absPath = cwd()/path; fileName absPath(cwd()/path);
absPath.clean(); absPath.clean(); // Remove unneeded ".."
return fileNameComponents(absPath, instance, local, name); return fileNameComponents(absPath, instance, local, name);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -184,7 +184,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
} }
else if (slash == 0) else if (slash == 0)
{ {
// (isAbsolute) // isAbsolute:
// Ascend to top-level // Ascend to top-level
while (&dictPtr->parent_ != &dictionary::null) while (&dictPtr->parent_ != &dictionary::null)
{ {
@ -385,8 +385,9 @@ const Foam::dictionary* Foam::dictionary::cfindScopedDict
} }
const dictionary* dictPtr = this; const dictionary* dictPtr = this;
if (fileName::isAbsolute(dictPath)) if (dictPath[0] == '/')
{ {
// isAbsolute:
// Ascend to top-level // Ascend to top-level
while (&dictPtr->parent_ != &dictionary::null) while (&dictPtr->parent_ != &dictionary::null)
{ {
@ -394,10 +395,11 @@ const Foam::dictionary* Foam::dictionary::cfindScopedDict
} }
} }
fileName path = dictPath.clean(); fileName path(dictPath); // Work on copy
const wordList cmpts = path.components(); path.clean(); // Remove unneeded ".."
const wordList dictCmpts(path.components()); // Split on '/'
for (const word& cmpt : cmpts) for (const word& cmpt : dictCmpts)
{ {
if (cmpt == ".") if (cmpt == ".")
{ {
@ -486,8 +488,9 @@ Foam::dictionary* Foam::dictionary::makeScopedDict(const fileName& dictPath)
} }
dictionary* dictPtr = this; dictionary* dictPtr = this;
if (fileName::isAbsolute(dictPath)) if (dictPath[0] == '/')
{ {
// isAbsolute:
// Ascend to top-level // Ascend to top-level
while (&dictPtr->parent_ != &dictionary::null) while (&dictPtr->parent_ != &dictionary::null)
{ {
@ -495,14 +498,11 @@ Foam::dictionary* Foam::dictionary::makeScopedDict(const fileName& dictPath)
} }
} }
// Work on a copy, without any assumptions std::string path(dictPath); // Work on a copy
std::string path = dictPath; fileName::clean(path); // Remove unneeded ".."
fileName::clean(path); auto dictCmpts = stringOps::split(path, '/'); // Split on '/'
// Split on '/' for (const auto& cmpt : dictCmpts)
auto cmpts = stringOps::split(path, '/');
for (const auto& cmpt : cmpts)
{ {
if (cmpt == ".") if (cmpt == ".")
{ {

View File

@ -52,7 +52,7 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
// Put in undecomposed case // Put in undecomposed case
// (Note: gives problems for distributed data running) // (Note: gives problems for distributed data running)
fileName baseDir = fileName baseDir
( (
fileObr_.time().globalPath() fileObr_.time().globalPath()
/ functionObject::outputPrefix / functionObject::outputPrefix
@ -67,7 +67,6 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
baseDir /= mesh.name(); baseDir /= mesh.name();
} }
} }
baseDir.clean(); // Remove unneeded ".." baseDir.clean(); // Remove unneeded ".."
return baseDir; return baseDir;

View File

@ -715,8 +715,7 @@ void Foam::argList::setCasePaths()
if (optIter.found()) if (optIter.found())
{ {
caseDir = fileName::validate(optIter.val()); caseDir = fileName::validate(optIter.val()); // includes 'clean'
caseDir.clean();
if (caseDir.empty() || caseDir == ".") if (caseDir.empty() || caseDir == ".")
{ {
@ -1193,7 +1192,7 @@ void Foam::argList::parse
// Could also check for absolute path, but shouldn't be needed // Could also check for absolute path, but shouldn't be needed
if (adjustOpt) if (adjustOpt)
{ {
source.clean(); source.clean(); // Remove unneeded ".."
options_.set("decomposeParDict", source); options_.set("decomposeParDict", source);
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -378,6 +378,7 @@ public:
//- Get a value from the argument at index. //- Get a value from the argument at index.
// Index 1 is the first (non-option) argument. // Index 1 is the first (non-option) argument.
// For fileName type, invokes fileName::validate()
template<class T> template<class T>
inline T get(const label index) const; inline T get(const label index) const;
@ -388,6 +389,7 @@ public:
//- Get a value from the named option //- Get a value from the named option
// The default template parameter is string (ie, no conversion). // The default template parameter is string (ie, no conversion).
// For fileName type, invokes fileName::validate()
template<class T=string> template<class T=string>
inline T get(const word& optName) const; inline T get(const word& optName) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -221,7 +221,7 @@ namespace Foam
template<> template<>
inline fileName argList::get<Foam::fileName>(const label index) const inline fileName argList::get<Foam::fileName>(const label index) const
{ {
return args_[index]; return fileName::validate(args_[index]);
} }
@ -240,7 +240,7 @@ namespace Foam
template<> template<>
inline fileName argList::get<Foam::fileName>(const word& optName) const inline fileName argList::get<Foam::fileName>(const word& optName) const
{ {
return options_[optName]; return fileName::validate(options_[optName]);
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -52,72 +52,164 @@ int Foam::fileName::allowSpaceInFileName
const Foam::fileName Foam::fileName::null; const Foam::fileName Foam::fileName::null;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
Foam::fileName Foam::fileName::validate namespace
{
// doClean:
// - remove duplicate slashes, "/./" and "/../" components.
//
// checkValid:
// - similar to stripInvalid (but silent)
//
// return True if the content changed
static bool cleanFileName
( (
const std::string& s, std::string& str,
const bool doClean const bool doClean,
const bool checkValid
) )
{ {
// The logic is very similar to stripInvalid, const auto maxLen = str.length();
// but silently removes bad characters std::string::size_type nChar = 0;
fileName out; // Preserve UNC \\server\path (windows)
out.resize(s.length()); // - MS-windows only, but handle for other systems
// since there is no collision with this pattern
std::string::size_type len = 0; if (maxLen > 2 && str[0] == '\\' && str[1] == '\\')
auto iter = s.cbegin();
#ifdef _WIN32
// Preserve UNC \\server-name\...
if (s.length() > 2 && s[0] == '\\' && s[1] == '\\')
{ {
len += 2; nChar += 2;
++iter;
++iter;
} }
#endif
char prev = 0; char prev = 0;
for (/*nil*/; iter != s.cend(); ++iter) auto top = std::string::npos; // Not yet found
bool changed = false;
for (auto src = nChar; src < maxLen; /*nil*/)
{ {
char c = *iter; char c = str[src++];
// Treat raw backslash like a path separator. There is no "normal"
// way for these to be there (except for an OS that uses them), but
// could also cause issues when writing strings, shell commands etc.
// Treat raw backslash like a path separator.
// There is no "normal" way for these to be there
// (except for an OS that uses them), but can cause issues
// when writing strings, shell commands etc.
if (c == '\\') if (c == '\\')
{ {
c = '/'; c = '/';
str[nChar] = c;
changed = true;
} }
else if (checkValid && !Foam::fileName::valid(c))
{
// Ignore invalid chars
// Could explicitly allow space character or rely on // Could explicitly allow space character or rely on
// allowSpaceInFileName via fileName::valid() // allowSpaceInFileName via fileName::valid()
if (fileName::valid(c))
{
if (doClean && prev == '/' && c == '/')
{
// Avoid repeated '/';
continue; continue;
} }
// Only track valid chars if (c == '/' && top == std::string::npos)
out[len++] = prev = c;
}
}
if (doClean && prev == '/' && len > 1)
{ {
// Avoid trailing '/' // Top-level slash not previously determined
--len; top = (src-1);
} }
out.resize(len); if (doClean && prev == '/')
{
// Repeated '/' - skip it
if (c == '/')
{
continue;
}
// Could be "/./", "/../" or a trailing "/."
if (c == '.')
{
// Trailing "/." - skip it
if (src >= maxLen)
{
break;
}
// Peek at the next character
const char c1 = str[src];
// Found "/./" - skip over it
if (c1 == '/' || c1 == '\\')
{
++src;
continue;
}
// Trailing "/.." or intermediate "/../"
if
(
c1 == '.'
&&
(
src+1 >= maxLen
|| str[src+1] == '/' || str[src+1] == '\\'
)
)
{
// Backtrack to find the parent directory
// Minimum of 3 characters: '/x/../'
// Strip it, provided it is above the top point
std::string::size_type parent;
if
(
nChar > 2
&& top != std::string::npos
&& (parent = str.rfind('/', nChar-2)) != std::string::npos
&& parent >= top
)
{
nChar = parent + 1; // Retain '/' from the parent
src += 2;
continue;
}
// Bad resolution, eg 'abc/../../'
// Retain the sequence, but move the top to avoid it being
// considered a valid parent later
top = nChar + 2;
}
}
}
str[nChar++] = prev = c;
}
// Remove trailing '/'
if (doClean && nChar > 1 && str[nChar-1] == '/')
{
--nChar;
}
str.erase(nChar);
return changed || (nChar != maxLen);
}
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
bool Foam::fileName::clean(std::string& str)
{
return cleanFileName(str, true, false); // clean, checkValid = false
}
Foam::fileName Foam::fileName::validate
(
const std::string& str,
const bool doClean
)
{
fileName out(str, false); // copy, no stripping
cleanFileName(out, doClean, true); // checkValid = true
return out; return out;
} }
@ -288,117 +380,19 @@ Foam::fileName& Foam::fileName::toAbsolute()
{ {
fileName& f = *this; fileName& f = *this;
f = cwd()/f; f = cwd()/f;
f.clean(); f.clean(); // Remove unneeded ".."
} }
return *this; return *this;
} }
bool Foam::fileName::clean(std::string& str)
{
// Start with the top slash found - we are never allowed to go above it
char prev = '/';
auto top = str.find(prev);
// No slashes - nothing to do
if (top == std::string::npos)
{
return false;
}
// Number of output characters
auto nChar = top+1;
const auto maxLen = str.length();
for (auto src = nChar; src < maxLen; /*nil*/)
{
const char c = str[src++];
if (prev == '/')
{
// Repeated '/' - skip it
if (c == '/')
{
continue;
}
// Could be "/./", "/../" or a trailing "/."
if (c == '.')
{
// Trailing "/." - skip it
if (src >= maxLen)
{
break;
}
// Peek at the next character
const char c1 = str[src];
// Found "/./" - skip it
if (c1 == '/')
{
++src;
continue;
}
// Trailing "/.." or intermediate "/../"
if (c1 == '.' && (src+1 >= maxLen || str[src+1] == '/'))
{
string::size_type parent;
// Backtrack to find the parent directory
// Minimum of 3 characters: '/x/../'
// Strip it, provided it is above the top point
if
(
nChar > 2
&& (parent = str.rfind('/', nChar-2)) != string::npos
&& parent >= top
)
{
nChar = parent + 1; // Retain '/' from the parent
src += 2;
continue;
}
// Bad resolution, eg 'abc/../../'
// Retain the sequence, but move the top to avoid it being
// considered a valid parent later
top = nChar + 2;
}
}
}
str[nChar++] = prev = c;
}
// Remove trailing slash
if (nChar > 1 && str[nChar-1] == '/')
{
nChar--;
}
str.resize(nChar);
return (nChar != maxLen);
}
bool Foam::fileName::clean() bool Foam::fileName::clean()
{ {
return fileName::clean(*this); return fileName::clean(*this);
} }
Foam::fileName Foam::fileName::clean() const
{
fileName cleaned(*this);
fileName::clean(cleaned);
return cleaned;
}
std::string Foam::fileName::nameLessExt(const std::string& str) std::string Foam::fileName::nameLessExt(const std::string& str)
{ {
auto beg = str.rfind('/'); auto beg = str.rfind('/');

View File

@ -151,10 +151,10 @@ public:
//- Is this character valid for a fileName? //- Is this character valid for a fileName?
inline static bool valid(char c); inline static bool valid(char c);
//- Construct fileName with no invalid characters, possibly applying //- Construct fileName without invalid characters, possibly applying
//- other transformations such as changing the path separator, //- other transformations such as changing the path separator,
//- removing duplicate or trailing slashes, etc. //- removing duplicate or trailing slashes, etc.
static fileName validate(const std::string& s, const bool doClean=true); static fileName validate(const std::string&, const bool doClean=true);
//- Join two strings with a path separator ('/' by default). //- Join two strings with a path separator ('/' by default).
// No separator is added if either argument is an empty string or // No separator is added if either argument is an empty string or
@ -174,44 +174,48 @@ public:
//- Strip invalid characters //- Strip invalid characters
inline void stripInvalid(); inline void stripInvalid();
//- Cleanup filename //- Cleanup filename string, possibly applies other transformations
//- such as changing the path separator etc.
// //
// Removes trailing \c / // Changes back-slash to forward-slash path separator,
// while preserving windows UNC:
// \verbatim
// \\server\abc\def --> \\server/abc/def
// \endverbatim
//
// Removes trailing slash:
// \verbatim // \verbatim
// / --> / // / --> /
// /abc/ --> /abc // /abc/ --> /abc
// \endverbatim // \endverbatim
// //
// Removes repeated slashes // Removes repeated slashes, but preserves UNC:
// \verbatim // \verbatim
// /abc////def --> /abc/def // /abc////def --> /abc/def
// \\server\abc////def --> \\server/abc/def
// \endverbatim // \endverbatim
// //
// Removes \c /./ (current directory) // Removes \c "/./" (current directory), except for leading one:
// \verbatim // \verbatim
// /abc/def/./ghi/. --> /abc/def/ghi // /abc/def/./ghi/. --> /abc/def/ghi
// abc/def/./ --> abc/def // abc/def/./ --> abc/def
// ./abc/ --> ./abc // ./abc/ --> ./abc
// \endverbatim // \endverbatim
// //
// Removes \c /../ (parent directory) // Removes \c "/../" (parent directory), except for leading one:
// \verbatim // \verbatim
// /abc/def/../ghi/jkl/nmo/.. --> /abc/ghi/jkl // /abc/def/../ghi/jkl/nmo/.. --> /abc/ghi/jkl
// abc/../def/ghi/../jkl --> abc/../def/jkl // abc/../def/ghi/../jkl --> abc/../def/jkl
// \endverbatim // \endverbatim
// .
// //
// \return True if the content changed // \return True if the content changed
static bool clean(std::string& str); static bool clean(std::string& str);
//- Cleanup filename (inplace)
//- Cleanup filename inplace // \return True if the content changed
// \return True if any contents changed
bool clean(); bool clean();
//- Cleanup filename
// \return cleaned copy of fileName
fileName clean() const;
// Interrogation // Interrogation
@ -223,10 +227,13 @@ public:
// \param checkGzip add an additional test for a gzip FILE // \param checkGzip add an additional test for a gzip FILE
Type type(bool followLink=true, bool checkGzip=false) const; Type type(bool followLink=true, bool checkGzip=false) const;
//- Return true if string starts with a '/' //- Return true if filename starts with a '/' or '\\'
//- or (windows-only) with a filesystem-root
inline static bool isAbsolute(const std::string& str); inline static bool isAbsolute(const std::string& str);
//- Return true if file name is absolute (starts with a '/') //- Return true if filename is absolute,
//- which means it starts with a '/' or '\\'
//- or (windows-only) with a filesystem-root
inline bool isAbsolute() const; inline bool isAbsolute() const;
//- Convert from relative to absolute //- Convert from relative to absolute

View File

@ -135,20 +135,22 @@ inline void Foam::fileName::stripInvalid()
inline bool Foam::fileName::isAbsolute(const std::string& str) inline bool Foam::fileName::isAbsolute(const std::string& str)
{ {
return return !str.empty() &&
( (
(!str.empty() && str.front() == '/') // ie, str.starts_with('/') // Starts with '/', but also accept '\\' since it will be
#ifdef _WIN32 // converted to a generic '/' or it is part of a (windows)
|| // UNC '\\server-name\path'
( // - accept even on non-windows systems
// Eg, d:/path or \\machine/path
(str.length() > 2) && (str[0] == '/' || str[0] == '\\')
(
(str[1] == ':' && str[2] == '/') #ifdef _WIN32
|| (str[0] == '\\' && str[1] == '\\') // Filesytem root - eg, d:/path or d:\path
|| (
(str.length() > 2 && str[1] == ':')
&& (str[2] == '/' || str[2] == '\\')
) )
) #endif
#endif
); );
} }

View File

@ -699,13 +699,13 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
// Write current non-ortho // Write current non-ortho
fileName outputDir = fileName outputDir
( (
mesh_.time().globalPath() mesh_.time().globalPath()
/ functionObject::outputPrefix / functionObject::outputPrefix
/ mesh_.pointsInstance() / mesh_.pointsInstance()
); );
outputDir.clean(); outputDir.clean(); // Remove unneeded ".."
writerPtr = surfaceWriter::New writerPtr = surfaceWriter::New
( (
"ensight" //"vtk" "ensight" //"vtk"

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -90,10 +90,10 @@ Foam::fileName Foam::functionObjects::externalCoupled::groupDir
fileName result fileName result
( (
commsDir commsDir
/regionGroupName / regionGroupName
/string::validate<fileName>(groupName) / word::validate(groupName)
); );
result.clean(); result.clean(); // Remove unneeded ".."
return result; return result;
} }

View File

@ -195,7 +195,7 @@ bool Foam::functionObjects::dataCloud::read(const dictionary& dict)
// Standard postProcessing/ naming // Standard postProcessing/ naming
directory_ = time_.globalPath()/functionObject::outputPrefix/name(); directory_ = time_.globalPath()/functionObject::outputPrefix/name();
} }
directory_.clean(); directory_.clean(); // Remove unneeded ".."
return true; return true;
} }

View File

@ -449,7 +449,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
// Standard postProcessing/ naming // Standard postProcessing/ naming
directory_ = time_.globalPath()/functionObject::outputPrefix/name(); directory_ = time_.globalPath()/functionObject::outputPrefix/name();
} }
directory_.clean(); directory_.clean(); // Remove unneeded ".."
return true; return true;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -167,11 +167,10 @@ bool Foam::functionObjects::abort::read(const dictionary& dict)
if (dict.readIfPresent("file", file_)) if (dict.readIfPresent("file", file_))
{ {
file_.expand(); file_.expand();
if (!file_.empty() && !file_.isAbsolute())
if (!file_.isAbsolute() && file_.size())
{ {
file_ = time_.globalPath()/file_; file_ = time_.globalPath()/file_;
file_.clean(); file_.clean(); // Remove unneeded ".."
} }
} }
@ -179,7 +178,7 @@ bool Foam::functionObjects::abort::read(const dictionary& dict)
if (file_.empty()) if (file_.empty())
{ {
file_ = time_.globalPath()/name(); file_ = time_.globalPath()/name();
file_.clean(); file_.clean(); // Remove unneeded ".."
} }
triggered_ = false; triggered_ = false;

View File

@ -175,7 +175,7 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
// Standard postProcessing/ naming // Standard postProcessing/ naming
outputDir_ = time_.globalPath()/functionObject::outputPrefix/name(); outputDir_ = time_.globalPath()/functionObject::outputPrefix/name();
} }
outputDir_.clean(); outputDir_.clean(); // Remove unneeded ".."
return true; return true;
} }

Some files were not shown because too many files have changed in this diff Show More