FEDEM Solver  R8.0
Source code of the dynamics solver
Functions
FFaFilePath Namespace Reference

Utilities for file path handling. More...

Functions

size_t checkName (char *thePath, size_t length)
 Converts file pathnames from UNIX to Windows syntax and vice versa. More...
 
std::string & checkName (std::string &thePath)
 C++ wrapper for FFaFilePath::checkName(char*,size_t). More...
 
std::string & unixStyle (std::string &thePath)
 Modify the given path to using UNIX-style path separators. More...
 
std::string unixStyle (const std::string &thePath)
 Return a copy of the given path with UNIX-style path separators. More...
 
bool hasPath (const std::string &fileName)
 Checks if the provided fileName has a path. More...
 
bool isRelativePath (const std::string &pathName)
 Determines if path is relative or absolute. More...
 
bool isExtension (const std::string &fileName, const std::string &ext)
 Checks if ext is the extension of fName. More...
 
std::string getPath (const std::string &fullPath, bool keepSlash=true)
 Returns the path part of fullPath. More...
 
std::string getFileName (const std::string &fullPath)
 Returns the file name part of fullPath. More...
 
std::string getExtension (const std::string &fileName)
 Returns the extension of fName. More...
 
std::string getBaseName (const std::string &fileName, bool removePath=false)
 Returns the file name without extension. More...
 
std::string appendFileNameToPath (const std::string &path, const std::string &fName)
 Appends fileName to path. More...
 
std::string & appendToPath (std::string &path, const std::string &fName)
 Appends fileName to path. More...
 
std::string & makeItAbsolute (std::string &fName, const std::string &path)
 Makes fileName an absolute pathname by prefixing it with absPath. More...
 
std::string & makeItRelative (std::string &fName, const std::string &path)
 Makes fileName a relative pathname with respect to absPath. More...
 
std::string & setPath (std::string &fName, const std::string &path)
 Replaces the current path in fileName with path. More...
 
char getPathSeparator ()
 Returns the path separator for this system. More...
 
std::string & addExtension (std::string &fileName, const std::string &ext)
 Adds ext to fileName, if not already present. More...
 
std::string & addExtension (std::string &fileName, const std::vector< std::string > &exts)
 Checks fName for existing extension in exts. More...
 
std::string getRelativeFilename (const std::string &currentDirectory, const std::string &absoluteFilename)
 Returns the relative path name with respect to an absolute path. More...
 
std::string distillName (const std::string &filePath, bool removePath=false)
 Checks for illegal characters in file names. More...
 

Detailed Description

Utilities for file path handling.

Function Documentation

◆ addExtension() [1/2]

std::string & FFaFilePath::addExtension ( std::string &  fName,
const std::string &  ext 
)

Adds ext to fileName, if not already present.

If fileName has another extension, that extension is replaced by ext.

◆ addExtension() [2/2]

std::string & FFaFilePath::addExtension ( std::string &  fName,
const std::vector< std::string > &  exts 
)

Checks fName for existing extension in exts.

If not found, adds the first.

◆ appendFileNameToPath()

std::string FFaFilePath::appendFileNameToPath ( const std::string &  path,
const std::string &  fileName 
)

Appends fileName to path.

If fileName begins with one or more "../" and there are a corresponding number of directory levels in path, the resulting pathname is modified such that, e.g.,

/a/bb/../ccc
real(sp), dimension(:,:,:), pointer a
Definition: diffractionModule.f90:21

is reduced to

/a/ccc

◆ appendToPath()

std::string & FFaFilePath::appendToPath ( std::string &  path,
const std::string &  fName 
)

Appends fileName to path.

◆ checkName() [1/2]

size_t FFaFilePath::checkName ( char *  thePath,
size_t  length 
)

Converts file pathnames from UNIX to Windows syntax and vice versa.

◆ checkName() [2/2]

std::string & FFaFilePath::checkName ( std::string &  thePath)

◆ distillName()

std::string FFaFilePath::distillName ( const std::string &  filePath,
bool  removePath = false 
)

Checks for illegal characters in file names.

Utility method to get rid of characters we don't want to have in a file name. If removePath is true, all characters up to and including the last '/' or '\' character are removed, assuming they are the directory path.

◆ getBaseName()

std::string FFaFilePath::getBaseName ( const std::string &  fName,
bool  removePath = false 
)

Returns the file name without extension.

Beware that if fName has a path, that will be included as well, unless removePath is true.

◆ getExtension()

std::string FFaFilePath::getExtension ( const std::string &  fileName)

Returns the extension of fName.

◆ getFileName()

std::string FFaFilePath::getFileName ( const std::string &  fullPath)

Returns the file name part of fullPath.

◆ getPath()

std::string FFaFilePath::getPath ( const std::string &  fullPath,
bool  keepTrailingSlash = true 
)

Returns the path part of fullPath.

It is equivalent to the UNIX command "dirname", except that the trailing '/', after removing the file name part, is retained when keepTrailingSlash is true.

◆ getPathSeparator()

char FFaFilePath::getPathSeparator ( )

Returns the path separator for this system.

◆ getRelativeFilename()

std::string FFaFilePath::getRelativeFilename ( const std::string &  currentDirectory,
const std::string &  absoluteFilename 
)

Returns the relative path name with respect to an absolute path.

Given the absolute current directory and an absolute file name, the relative file name is returned. For example, if the current directory is

C:\foo\bar

and we provide the filename

C:\foo\whee\text.txt

then this method will return

..\whee\text.txt
Author
Rob Fisher, rfish.nosp@m.er@i.nosp@m.ee.or.nosp@m.g http://come.to/robfisher

◆ hasPath()

bool FFaFilePath::hasPath ( const std::string &  fileName)

Checks if the provided fileName has a path.

◆ isExtension()

bool FFaFilePath::isExtension ( const std::string &  fileName,
const std::string &  ext 
)

Checks if ext is the extension of fName.

◆ isRelativePath()

bool FFaFilePath::isRelativePath ( const std::string &  pathName)

Determines if path is relative or absolute.

◆ makeItAbsolute()

std::string & FFaFilePath::makeItAbsolute ( std::string &  fileName,
const std::string &  absPath 
)

Makes fileName an absolute pathname by prefixing it with absPath.

If fileName already is an absolute path, that name is returned.

◆ makeItRelative()

std::string & FFaFilePath::makeItRelative ( std::string &  fName,
const std::string &  path 
)

Makes fileName a relative pathname with respect to absPath.

◆ setPath()

std::string & FFaFilePath::setPath ( std::string &  fName,
const std::string &  path 
)

Replaces the current path in fileName with path.

◆ unixStyle() [1/2]

std::string FFaFilePath::unixStyle ( const std::string &  thePath)

Return a copy of the given path with UNIX-style path separators.

◆ unixStyle() [2/2]

std::string & FFaFilePath::unixStyle ( std::string &  thePath)

Modify the given path to using UNIX-style path separators.