mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add basic support for file extensions to word
- when a plain word is used as a directory-local name for file. We don't have a full blown fileName, but still want to check/remove extensions etc.
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,6 +25,45 @@ License
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline std::string::size_type Foam::string::find_ext() const
|
||||
{
|
||||
const size_type i = find_last_of("./");
|
||||
|
||||
if (i == npos || i == 0 || operator[](i) == '/')
|
||||
{
|
||||
return npos;
|
||||
}
|
||||
else
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::string::hasExt() const
|
||||
{
|
||||
return (find_ext() != npos);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::string::removeExt()
|
||||
{
|
||||
const size_type i = find_ext();
|
||||
|
||||
if (i == npos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->resize(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::string::string()
|
||||
|
||||
Reference in New Issue
Block a user