MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / getRootCase

Function getRootCase

src/OpenFOAM/global/argList/argList.C:330–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328
329
330void Foam::argList::getRootCase()
331{
332 fileName casePath;
333
334 // [-case dir] specified
335 HashTable<string>::const_iterator iter = options_.find("case");
336
337 if (iter != options_.end())
338 {
339 casePath = iter();
340 casePath.clean();
341
342 if (casePath.empty() || casePath == ".")
343 {
344 // Handle degenerate form and '-case .' like no -case specified
345 casePath = cwd();
346 options_.erase("case");
347 }
348 else if (!casePath.isAbsolute() && casePath.name() == "..")
349 {
350 // Avoid relative cases ending in '..' - makes for very ugly names
351 casePath = cwd()/casePath;
352 casePath.clean();
353 }
354 }
355 else
356 {
357 // Nothing specified, use the current dir
358 casePath = cwd();
359 }
360
361 rootPath_ = casePath.path();
362 globalCase_ = casePath.name();
363 case_ = globalCase_;
364
365
366 // Set the case and case-name as an environment variable
367 if (rootPath_.isAbsolute())
368 {
369 // Absolute path - use as-is
370 setEnv("FOAM_CASE", rootPath_/globalCase_, true);
371 setEnv("FOAM_CASENAME", globalCase_, true);
372 }
373 else
374 {
375 // Qualify relative path
376 casePath = cwd()/rootPath_/globalCase_;
377 casePath.clean();
378
379 setEnv("FOAM_CASE", casePath, true);
380 setEnv("FOAM_CASENAME", casePath.name(), true);
381 }
382}
383
384
385// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Callers 1

parseFunction · 0.70

Calls 6

setEnvFunction · 0.85
eraseMethod · 0.80
endMethod · 0.45
emptyMethod · 0.45
nameMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected