mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use fileName::nameLessExt() instead of fileName::name(bool)
- the purpose is more explicit, without needing to check documentation about what the bool parameter means. STYLE: improve formatting of fileName documentation
This commit is contained in:
@ -288,7 +288,7 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
|
||||
vtkSurfaceWriter().write
|
||||
(
|
||||
surface_.searchableSurface::time().constant()/"triSurface",
|
||||
surfaceName_.lessExt().name(),
|
||||
surfaceName_.nameLessExt(),
|
||||
meshedSurfRef
|
||||
(
|
||||
surface_.points(),
|
||||
|
||||
@ -1657,9 +1657,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
const fileName sFeatFileName
|
||||
(
|
||||
fileName(surf1Name).lessExt().name()
|
||||
fileName(surf1Name).nameLessExt()
|
||||
+ "_"
|
||||
+ fileName(surf2Name).lessExt().name()
|
||||
+ fileName(surf2Name).nameLessExt()
|
||||
+ "_"
|
||||
+ action
|
||||
);
|
||||
|
||||
@ -92,7 +92,7 @@ void Foam::dynamicCode::checkSecurity
|
||||
|
||||
Foam::word Foam::dynamicCode::libraryBaseName(const fileName& libPath)
|
||||
{
|
||||
word libName(libPath.name(true));
|
||||
word libName(libPath.nameLessExt());
|
||||
libName.removeStart("lib"); // Remove leading 'lib' from name
|
||||
return libName;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -215,7 +215,7 @@ Foam::fileName Foam::fileName::clean() const
|
||||
|
||||
Foam::word Foam::fileName::name() const
|
||||
{
|
||||
size_type i = rfind('/');
|
||||
const size_type i = rfind('/');
|
||||
|
||||
if (i == npos)
|
||||
{
|
||||
@ -223,50 +223,44 @@ Foam::word Foam::fileName::name() const
|
||||
}
|
||||
else
|
||||
{
|
||||
return substr(i+1, npos);
|
||||
return substr(i+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::fileName::name(const bool noExt) const
|
||||
Foam::word Foam::fileName::nameLessExt() const
|
||||
{
|
||||
if (noExt)
|
||||
size_type beg = rfind('/');
|
||||
|
||||
if (beg == npos)
|
||||
{
|
||||
size_type beg = rfind('/');
|
||||
if (beg == npos)
|
||||
{
|
||||
beg = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++beg;
|
||||
}
|
||||
|
||||
size_type dot = rfind('.');
|
||||
if (dot != npos && dot <= beg)
|
||||
{
|
||||
dot = npos;
|
||||
}
|
||||
|
||||
if (dot == npos)
|
||||
{
|
||||
return substr(beg, npos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return substr(beg, dot - beg);
|
||||
}
|
||||
beg = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->name();
|
||||
++beg;
|
||||
}
|
||||
|
||||
size_type dot = rfind('.');
|
||||
if (dot != npos && dot <= beg)
|
||||
{
|
||||
dot = npos;
|
||||
}
|
||||
|
||||
if (dot == npos)
|
||||
{
|
||||
return substr(beg, npos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return substr(beg, dot - beg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::fileName::path() const
|
||||
{
|
||||
size_type i = rfind('/');
|
||||
const size_type i = rfind('/');
|
||||
|
||||
if (i == npos)
|
||||
{
|
||||
@ -285,7 +279,7 @@ Foam::fileName Foam::fileName::path() const
|
||||
|
||||
Foam::fileName Foam::fileName::lessExt() const
|
||||
{
|
||||
size_type i = find_ext();
|
||||
const size_type i = find_ext();
|
||||
|
||||
if (i == npos)
|
||||
{
|
||||
@ -300,7 +294,7 @@ Foam::fileName Foam::fileName::lessExt() const
|
||||
|
||||
Foam::word Foam::fileName::ext() const
|
||||
{
|
||||
size_type i = find_ext();
|
||||
const size_type i = find_ext();
|
||||
|
||||
if (i == npos)
|
||||
{
|
||||
@ -351,7 +345,7 @@ bool Foam::fileName::hasExt(const word& ending) const
|
||||
|
||||
bool Foam::fileName::hasExt(const wordRe& ending) const
|
||||
{
|
||||
size_type i = find_ext();
|
||||
const size_type i = find_ext();
|
||||
if (i == npos)
|
||||
{
|
||||
return false;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -161,92 +161,104 @@ public:
|
||||
fileName clean() const;
|
||||
|
||||
|
||||
// Interrogation
|
||||
// Interrogation
|
||||
|
||||
//- Return the file type: FILE, DIRECTORY, UNDEFINED or
|
||||
// LINK (only if followLink=false)
|
||||
Type type(const bool followLink = true) const;
|
||||
//- Return the file type: FILE, DIRECTORY, UNDEFINED or
|
||||
// LINK (only if followLink=false)
|
||||
Type type(const bool followLink = true) const;
|
||||
|
||||
//- Return true if file name is absolute
|
||||
bool isAbsolute() const;
|
||||
//- Return true if file name is absolute
|
||||
bool isAbsolute() const;
|
||||
|
||||
//- Convert from relative to absolute
|
||||
fileName& toAbsolute();
|
||||
//- Convert from relative to absolute
|
||||
fileName& toAbsolute();
|
||||
|
||||
|
||||
// Decomposition
|
||||
// Decomposition
|
||||
|
||||
//- Return file name (part beyond last /)
|
||||
//
|
||||
// Behaviour compared to /usr/bin/basename:
|
||||
// Input name() basename
|
||||
// ----- ------ --------
|
||||
// "foo" "foo" "foo"
|
||||
// "/foo" "foo" "foo"
|
||||
// "foo/bar" "bar" "bar"
|
||||
// "/foo/bar" "bar" "bar"
|
||||
// "/foo/bar/" "" "bar"
|
||||
//
|
||||
word name() const;
|
||||
//- Return basename (part beyond last /), including its extension
|
||||
//
|
||||
// Behaviour compared to /usr/bin/basename:
|
||||
// \verbatim
|
||||
// input name() basename
|
||||
// ----- ------ --------
|
||||
// "foo" "foo" "foo"
|
||||
// "/foo" "foo" "foo"
|
||||
// "foo/bar" "bar" "bar"
|
||||
// "/foo/bar" "bar" "bar"
|
||||
// "/foo/bar/" "" "bar"
|
||||
// \endverbatim
|
||||
word name() const;
|
||||
|
||||
//- Return file name, optionally without extension
|
||||
word name(const bool noExt) const;
|
||||
//- Return basename, without extension
|
||||
word nameLessExt() const;
|
||||
|
||||
//- Return directory path name (part before last /)
|
||||
//
|
||||
// Behaviour compared to /usr/bin/dirname:
|
||||
// input path() dirname
|
||||
// ----- ------ -------
|
||||
// "foo" "." "."
|
||||
// "/foo" "/" "foo"
|
||||
// "foo/bar" "foo" "foo"
|
||||
// "/foo/bar" "/foo" "/foo"
|
||||
// "/foo/bar/" "/foo/bar/" "/foo"
|
||||
//
|
||||
fileName path() const;
|
||||
//- Return basename, optionally without extension
|
||||
// \deprecated in favour of name() or nameLessExt() which more
|
||||
// explicitly describe their behaviour (MAR-2017).
|
||||
word name(const bool noExt) const
|
||||
{
|
||||
return noExt ? this->nameLessExt() : this->name();
|
||||
}
|
||||
|
||||
//- Return file name without extension (part before last .)
|
||||
fileName lessExt() const;
|
||||
//- Return directory path name (part before last /)
|
||||
//
|
||||
// Behaviour compared to /usr/bin/dirname:
|
||||
// \verbatim
|
||||
// input path() dirname
|
||||
// ----- ------ -------
|
||||
// "foo" "." "."
|
||||
// "/foo" "/" "foo"
|
||||
// "foo/bar" "foo" "foo"
|
||||
// "/foo/bar" "/foo" "/foo"
|
||||
// "/foo/bar/" "/foo/bar/" "/foo"
|
||||
// \endverbatim
|
||||
fileName path() const;
|
||||
|
||||
//- Return file name extension (part after last .)
|
||||
word ext() const;
|
||||
//- Return file name without extension (part before last .)
|
||||
fileName lessExt() const;
|
||||
|
||||
//- Append a '.' and the ending, and return the object.
|
||||
// The '.' and ending will not be added when the ending is empty,
|
||||
// or when the file name is empty or ended with a '/'.
|
||||
fileName& ext(const word& ending);
|
||||
//- Return file name extension (part after last .)
|
||||
word ext() const;
|
||||
|
||||
//- Return true if it has an extension or simply ends with a '.'
|
||||
bool hasExt() const;
|
||||
//- Append a '.' and the ending, and return the object.
|
||||
// The '.' and ending will not be added when the ending is empty,
|
||||
// or when the file name is empty or ended with a '/'.
|
||||
fileName& ext(const word& ending);
|
||||
|
||||
//- Return true if the extension is the same as the given ending.
|
||||
bool hasExt(const word& ending) const;
|
||||
//- Return true if it has an extension or simply ends with a '.'
|
||||
bool hasExt() const;
|
||||
|
||||
//- Return true if the extension matches the given ending.
|
||||
bool hasExt(const wordRe& ending) const;
|
||||
//- Return true if the extension is the same as the given ending.
|
||||
bool hasExt(const word& ending) const;
|
||||
|
||||
//- Remove extension, returning true if string changed.
|
||||
bool removeExt();
|
||||
//- Return true if the extension matches the given ending.
|
||||
bool hasExt(const wordRe& ending) const;
|
||||
|
||||
//- Remove extension, returning true if string changed.
|
||||
bool removeExt();
|
||||
|
||||
|
||||
//- Return path components as wordList
|
||||
//
|
||||
// Behaviour:
|
||||
// Input components()
|
||||
// ----- ------
|
||||
// "foo" 1("foo")
|
||||
// "/foo" 1("foo")
|
||||
// "foo/bar" 2("foo", "bar")
|
||||
// "/foo/bar" 2("foo", "bar")
|
||||
// "/foo/bar/" 2("foo", "bar")
|
||||
wordList components(const char delimiter = '/') const;
|
||||
//- Return path components as wordList
|
||||
//
|
||||
// Behaviour:
|
||||
// \verbatim
|
||||
// Input components()
|
||||
// ----- ------
|
||||
// "foo" 1("foo")
|
||||
// "/foo" 1("foo")
|
||||
// "foo/bar" 2("foo", "bar")
|
||||
// "/foo/bar" 2("foo", "bar")
|
||||
// "/foo/bar/" 2("foo", "bar")
|
||||
// \endverbatim
|
||||
wordList components(const char delimiter = '/') const;
|
||||
|
||||
//- Return a single component of the path
|
||||
word component
|
||||
(
|
||||
const size_type cmpt,
|
||||
const char delimiter = '/'
|
||||
) const;
|
||||
//- Return a single component of the path
|
||||
word component
|
||||
(
|
||||
const size_type cmpt,
|
||||
const char delimiter = '/'
|
||||
) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
@ -245,7 +245,7 @@ void Foam::fileFormats::OBJedgeFormat::write
|
||||
|
||||
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< "o " << os.name().nameLessExt() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# lines : " << edgeLst.size() << nl;
|
||||
|
||||
@ -65,7 +65,7 @@ void Foam::fileFormats::STARCDedgeFormat::writeCase
|
||||
const label nEdges
|
||||
)
|
||||
{
|
||||
word caseName = os.name().lessExt().name();
|
||||
const word caseName = os.name().nameLessExt();
|
||||
|
||||
os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
|
||||
<< "! " << pointLst.size() << " points, " << nEdges << " lines" << nl
|
||||
|
||||
@ -70,7 +70,7 @@ void pointNoise::processData(const Function1Types::CSV<scalar>& data)
|
||||
{
|
||||
Info<< "Reading data file " << data.fName() << endl;
|
||||
|
||||
const fileName fNameBase = data.fName().name(true);
|
||||
const word fNameBase = data.fName().nameLessExt();
|
||||
|
||||
// Time and pressure history data
|
||||
scalarField t, p;
|
||||
|
||||
@ -572,7 +572,7 @@ void surfaceNoise::calculate()
|
||||
}
|
||||
}
|
||||
|
||||
const word& fNameBase = fName.name(true);
|
||||
const word fNameBase = fName.nameLessExt();
|
||||
|
||||
// Output directory for graphs
|
||||
fileName outDir
|
||||
|
||||
@ -237,7 +237,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
|
||||
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
<< "o " << os.name().lessExt().name() << nl
|
||||
<< "o " << os.name().nameLessExt() << nl
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << faceLst.size() << nl
|
||||
|
||||
@ -87,7 +87,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
||||
const UList<surfZone>& zoneLst
|
||||
)
|
||||
{
|
||||
word caseName = os.name().lessExt().name();
|
||||
const word caseName = os.name().nameLessExt();
|
||||
|
||||
os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
|
||||
<< "! " << pointLst.size() << " points, " << nFaces << " faces" << nl
|
||||
|
||||
Reference in New Issue
Block a user