qualify exported FOAM_CASE

- avoid ambiguities caused by relative paths
This commit is contained in:
Mark Olesen
2009-07-23 09:43:05 +02:00
parent dacc93a568
commit 0b7832e37c
3 changed files with 37 additions and 5 deletions

View File

@ -29,6 +29,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "IOobject.H" #include "IOobject.H"
#include "IFstream.H" #include "IFstream.H"
@ -41,6 +42,15 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel();
argList args(argc, argv);
Info<< nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
<< endl;
{ {
dictionary dict1(IFstream("testDict")()); dictionary dict1(IFstream("testDict")());
Info<< "dict1: " << dict1 << nl Info<< "dict1: " << dict1 << nl

View File

@ -14,6 +14,9 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#inputMode merge #inputMode merge
#includeIfPresent "someUnknownFile"
#includeIfPresent "$FOAM_CASE/someUnknownFile"
#includeIfPresent "$FOAM_CASE/someUnknownFile-$FOAM_CASENAME"
internalField uniform 1; internalField uniform 1;
@ -78,7 +81,6 @@ boundaryField
// NB: the inputMode has a global scope // NB: the inputMode has a global scope
#inputMode merge #inputMode merge
#include "testDict2" #include "testDict2"
#includeIfPresent "SomeUnknownFile"
foo foo
{ {

View File

@ -129,14 +129,18 @@ void Foam::argList::getRootCase()
casePath = iter(); casePath = iter();
casePath.removeRepeated('/'); casePath.removeRepeated('/');
casePath.removeTrailing('/'); casePath.removeTrailing('/');
// handle degenerate form and '-case .' like no -case specified
if (casePath.empty() || casePath == ".")
{
casePath = cwd();
options_.erase("case");
}
} }
else else
{ {
// nothing specified, use the current dir // nothing specified, use the current dir
casePath = cwd(); casePath = cwd();
// we could add this back in as '-case'?
// options_.set("case", casePath);
} }
rootPath_ = casePath.path(); rootPath_ = casePath.path();
@ -522,10 +526,26 @@ Foam::argList::argList
} }
jobInfo.write(); jobInfo.write();
// Set the case and case-name as an environment variable // Set the case and case-name as an environment variable
setEnv("FOAM_CASE", rootPath_/globalCase_, true); if (rootPath_[0] == '/')
{
// absolute path
setEnv("FOAM_CASE", rootPath_/globalCase_, true);
}
else if (rootPath_ == ".")
{
// relative to the current working directory
setEnv("FOAM_CASE", cwd()/globalCase_, true);
}
else
{
// qualify relative path
setEnv("FOAM_CASE", cwd()/rootPath_/globalCase_, true);
}
setEnv("FOAM_CASENAME", globalCase_, true); setEnv("FOAM_CASENAME", globalCase_, true);
// Switch on signal trapping. We have to wait until after Pstream::init // Switch on signal trapping. We have to wait until after Pstream::init
// since this sets up its own ones. // since this sets up its own ones.
sigFpe_.set(bannerEnabled); sigFpe_.set(bannerEnabled);