mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
rename Foam::dotFoam() -> Foam::findEtcFile() with an optional 'mandatory' argument
- if mandatory is true, findEtcFile() will abort with a message (via cerr). This allows a non-existent file to be caught at the lowest level and avoid error handling in IFstream, which might not be initialized at that stage.
This commit is contained in:
@ -211,7 +211,7 @@ bool Foam::chDir(const fileName& dir)
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::dotFoam(const fileName& name)
|
||||
Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
|
||||
{
|
||||
// Search user files:
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
@ -268,6 +268,15 @@ Foam::fileName Foam::dotFoam(const fileName& name)
|
||||
}
|
||||
|
||||
// Not found
|
||||
// abort if the file is mandatory, otherwise return null
|
||||
if (mandatory)
|
||||
{
|
||||
cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
|
||||
" could not find mandatory file\n '"
|
||||
<< name.c_str() << "'\n\n" << std::endl;
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user