mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: bad names if ensight mask contains NO placeholder (fixes #1747)
- affects ensightSurfaceReader only. If there are no `*` characters, protect against replacement. Otherwise it would attempt to replace a zero-length string with a single `0`, which results in prepending the name. STYLE: ensightSurfaceReader constructor explicit
This commit is contained in:
@ -127,16 +127,24 @@ Foam::fileName Foam::ensightSurfaceReader::replaceMask
|
||||
(
|
||||
const fileName& fName,
|
||||
const label timeIndex
|
||||
) const
|
||||
)
|
||||
{
|
||||
fileName result(fName);
|
||||
std::ostringstream oss;
|
||||
|
||||
label nMask = stringOps::count(fName, '*');
|
||||
const std::string maskStr(nMask, '*');
|
||||
oss << std::setfill('0') << std::setw(nMask) << timeIndex;
|
||||
const word indexStr = oss.str();
|
||||
result.replace(maskStr, indexStr);
|
||||
const auto nMask = stringOps::count(fName, '*');
|
||||
|
||||
// If there are any '*' chars, they are assumed to be contiguous
|
||||
// Eg, data/******/geometry
|
||||
|
||||
if (nMask)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::setfill('0') << std::setw(nMask) << timeIndex;
|
||||
|
||||
const std::string maskStr(nMask, '*');
|
||||
const std::string indexStr = oss.str();
|
||||
result.replace(maskStr, indexStr);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -112,12 +112,12 @@ protected:
|
||||
//- Read and check a section header
|
||||
void debugSection(const word& expected, IFstream& is) const;
|
||||
|
||||
//- Replace the mask with an 0 padded string
|
||||
fileName replaceMask
|
||||
//- Replace the '*' mask chars with a 0 padded string.
|
||||
static fileName replaceMask
|
||||
(
|
||||
const fileName& fName,
|
||||
const label timeIndex
|
||||
) const;
|
||||
);
|
||||
|
||||
//- Read (and discard) geometry file header.
|
||||
// \return information about node/element id handling
|
||||
@ -158,10 +158,11 @@ public:
|
||||
//- Runtime type information
|
||||
TypeName("ensight");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from fileName
|
||||
ensightSurfaceReader(const fileName& fName);
|
||||
explicit ensightSurfaceReader(const fileName& fName);
|
||||
|
||||
|
||||
//- Destructor
|
||||
|
||||
Reference in New Issue
Block a user