Merge branch 'feature-robuster-ioobjectlist-construction' into 'develop'

Feature robuster IOobjectList construction

See merge request !134
This commit is contained in:
Mark Olesen
2017-08-09 10:58:19 +01:00

View File

@ -154,14 +154,14 @@ Foam::IOobjectList::IOobjectList
} }
// Create a list of file names in this directory // Create a list of file names in this directory
fileNameList objNames = const auto objNames =
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE); readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
forAll(objNames, i) for (const auto& objName : objNames)
{ {
IOobject* objectPtr = new IOobject IOobject* objectPtr = new IOobject
( (
objNames[i], objName,
newInstance, newInstance,
local, local,
db, db,
@ -170,8 +170,23 @@ Foam::IOobjectList::IOobjectList
registerObject registerObject
); );
// Use object with local scope bool ok = false;
if (objectPtr->typeHeaderOk<IOList<label>>(false)) const bool throwingIOerr = FatalIOError.throwExceptions();
try
{
// Use object with local scope and current instance (no searching)
ok = objectPtr->typeHeaderOk<IOList<label>>(false, false);
}
catch (Foam::IOerror& err)
{
Warning
<< err << nl << endl;
}
FatalIOError.throwExceptions(throwingIOerr);
if (ok)
{ {
insert(objectPtr->name(), objectPtr); insert(objectPtr->name(), objectPtr);
} }