foamDictionary: improved checking for FoamFile
This commit is contained in:
@ -171,20 +171,28 @@ IOstream::streamFormat readDict(dictionary& dict, const fileName& dictFileName)
|
|||||||
<< exit(FatalError, 1);
|
<< exit(FatalError, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the first entry from the dictionary without expansion
|
// Check if the first character in the file is the first character
|
||||||
entry::disableFunctionEntries = true;
|
// of "FoamFile" to avoid problems if the first entry is a variable
|
||||||
autoPtr<entry> firstEntry(entry::New(dictFile()));
|
// or function
|
||||||
entry::disableFunctionEntries = false;
|
if (dictFile.peek() == IOobject::foamFile[0])
|
||||||
|
|
||||||
// If the first entry is the "FoamFile" header dictionary
|
|
||||||
// read and set the stream format
|
|
||||||
if (firstEntry->isDict() && firstEntry->keyword() == IOobject::foamFile)
|
|
||||||
{
|
{
|
||||||
dictFormat = IOstream::formatEnum
|
// Read the first entry from the dictionary
|
||||||
|
autoPtr<entry> firstEntry(entry::New(dictFile()));
|
||||||
|
|
||||||
|
// If the first entry is the "FoamFile" header
|
||||||
|
// read and set the stream format
|
||||||
|
if
|
||||||
(
|
(
|
||||||
firstEntry->dict().lookup("format")
|
firstEntry->isDict()
|
||||||
);
|
&& firstEntry->keyword() == IOobject::foamFile
|
||||||
dictFile().format(dictFormat);
|
)
|
||||||
|
{
|
||||||
|
dictFormat = IOstream::formatEnum
|
||||||
|
(
|
||||||
|
firstEntry->dict().lookup("format")
|
||||||
|
);
|
||||||
|
dictFile().format(dictFormat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user