Skip to main content

Common Fluids Format 2024 R2

ansys::Project::Path Class Reference

Last update: 16.07.2025

Paths used for internal Project filesystem. More...

#include "Path.hpp"

Public Member Functions

bool isNull () const
 Indicates if the path is empty.
 
std::vector< std::string > getPathComponents () const
 Return the path components as a vector of string. More...
 
bool isFolderPath () const
 Indicates if the path is a folder path (ends with /)
 
Path getParentPath () const
 Return the Path for the enclosing folder.
 
std::string getFilename () const
 Return the filename part of the path. More...
 
std::string getFolderName () const
 Return the folder name - only if Path is a folder path.
 
Path getRelativePathTo (const Path &pTarget) const
 Convert a global path and a global target to a relative path to the target.
 
const std::string & str () const
 Return as string.
 
void operator+= (const std::string &pPathStr)
 Appends the string to the Path.
 

Static Public Member Functions

static bool isValidFilename (const std::string &pStr)
 Check if the specified name is valid for a file. More...
 
static bool isValidPath (const std::string &pStr)
 Check if the specified path is correct.
 
static std::string formatPath (const std::string &pPath, bool pFilenameOnly=false)
 Converts a string to a valid path string. More...
 

Detailed Description

Paths used for internal Project filesystem.

The paths used for project filenames might differ from the actual disk storage, as the project might have different file/folder names or even virtual folders.

  • A global path starts with /
  • A relative path starts with ./
  • Folder paths end with /
  • Acceptable characters: Alphanumeric, _ - . + @

Member Function Documentation

◆ formatPath()

std::string ansys::Project::Path::formatPath ( const std::string &  pPath,
bool  pFilenameOnly = false 
)
static

Converts a string to a valid path string.

Whitespace is strippped and invalid characters are replaced by _ Can also be used to check if a path is valid as-is.

Parameters
pFilenameOnly: to check if the path is for a filename (not a folder)

◆ getFilename()

std::string ansys::Project::Path::getFilename ( ) const

Return the filename part of the path.

If the path is a folder path, filename is empty

◆ getPathComponents()

std::vector< std::string > ansys::Project::Path::getPathComponents ( ) const

Return the path components as a vector of string.

Each folder component is returned with trailing /

 /path/folder/filename
 will lead to:
 [ /, path/, folder/, filename ]

◆ isValidFilename()

bool ansys::Project::Path::isValidFilename ( const std::string &  pStr)
static

Check if the specified name is valid for a file.

Returns
false if the filename contains any invalid characters

Connect with Ansys