MolSim
Loading...
Searching...
No Matches
Functions
PathUtils Namespace Reference

Namespace defining utility functions for working with file paths. More...

Functions

static bool isXmlFile (const std::string &filename)
 Checks if a file is an XML file by verifying its extension in a case-insensitive way.
 
static std::string getTargetPath (const std::string &fullPath, const std::string &targetDir)
 Helper method to get the absolute path of a file or directory contained within a given path.
 
static bool setupFileTests (std::string &targetPath, std::string &skipReason)
 Checks if the test file directory can be found.
 

Detailed Description

Namespace defining utility functions for working with file paths.

Function Documentation

◆ getTargetPath()

static std::string PathUtils::getTargetPath ( const std::string &  fullPath,
const std::string &  targetDir 
)
inlinestatic

Helper method to get the absolute path of a file or directory contained within a given path.

This is used to get the full directory of the project root in order to properly find and address input files, assuming the project directory name is "MolSim".

Parameters
fullPathThe full path which contains the subpath to be found (haystack).
targetDirThe file or directory name to get the absolute path from (needle).
Returns
The absolute path of the subpath if it can be extracted, or an empty string otherwise.

◆ isXmlFile()

static bool PathUtils::isXmlFile ( const std::string &  filename)
inlinestatic

Checks if a file is an XML file by verifying its extension in a case-insensitive way.

Parameters
filenameThe name of (path to) the file to be checked.
Returns
true if the file has a .xml extension.
false if the file does not have a .xml extension.

◆ setupFileTests()

static bool PathUtils::setupFileTests ( std::string &  targetPath,
std::string &  skipReason 
)
inlinestatic

Checks if the test file directory can be found.

Parameters
targetPathOut parameter. Here, the absolute path to the test file directory may be stored if the files are found.
skipReasonOut parameter. If something fails, the reason will be logged here.
Returns
true if the test file directory could be found.
false if the test file directory could not be found.