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:
Mark Olesen
2008-12-12 19:16:32 +01:00
parent 089e5e3b00
commit 0571f5393e
9 changed files with 30 additions and 10 deletions

View File

@ -32,6 +32,7 @@ Description
#include "fileName.H"
#include "IOstreams.H"
#include "OSspecific.H"
using namespace Foam;
@ -57,7 +58,16 @@ int main()
Info<< "pathName.components() = " << pathName.components() << endl;
Info<< "pathName.component(2) = " << pathName.component(2) << endl;
Info<< "end" << endl;
// test findEtcFile
Info<< "\n\nfindEtcFile tests:" << nl
<< " controlDict => " << findEtcFile("controlDict") << nl
<< " badName => " << findEtcFile("badName") << endl;
Info<< "This should emit a fatal error:" << endl;
Info<< " badName(die) => " << findEtcFile("badName", true) << nl
<< endl;
Info<< "\nEnd" << endl;
return 0;
}

View File

@ -78,7 +78,7 @@ int main(int argc, char *argv[])
Info<< nl << "Reading Burcat data dictionary" << endl;
fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData"));
fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
// Construct control dictionary
IFstream BurcatCpDataFile(BurcatCpDataFileName);

View File

@ -79,7 +79,7 @@ int main(int argc, char *argv[])
Info<< nl << "Reading Burcat data dictionary" << endl;
fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData"));
fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
// Construct control dictionary
IFstream BurcatCpDataFile(BurcatCpDataFileName);

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
Info<< nl << "Reading Burcat data dictionary" << endl;
fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData"));
fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
// Construct control dictionary
IFstream BurcatCpDataFile(BurcatCpDataFileName);