    

 ## On this page

  

 

 # ansys::Project::Path Class Reference

 Last update: 16.07.2025 

Paths used for internal [Project](classansys_1_1_project_1_1_project.xhtml "Base class for Project API, also see SimProject.") filesystem. [More...](classansys_1_1_project_1_1_path.xhtml#details)

`#include "<a class="el" href="_path_8hpp_source.xhtml">Path.hpp</a>"`

## <a id="pub-methods" name="pub-methods"></a>Public Member Functions

<a id="ad6c6c48f6fad2de7414b2c03d94d3207" name="ad6c6c48f6fad2de7414b2c03d94d3207"></a>bool **isNull** () const Indicates if the path is empty.   
 std::vector&lt; std::string &gt; [getPathComponents](classansys_1_1_project_1_1_path.xhtml#a9c0f0c9c4467b5d13a45124a24624b59) () const Return the path components as a vector of string. [More...](classansys_1_1_project_1_1_path.xhtml#a9c0f0c9c4467b5d13a45124a24624b59)  
 <a id="a9b17bbf8223806c71dfc13f3544d2eef" name="a9b17bbf8223806c71dfc13f3544d2eef"></a>bool **isFolderPath** () const Indicates if the path is a folder path (ends with /)   
 <a id="a84d47bd152ccc7cc5f2ad2f95686b7f6" name="a84d47bd152ccc7cc5f2ad2f95686b7f6"></a>[Path](classansys_1_1_project_1_1_path.xhtml) **getParentPath** () const Return the [Path](classansys_1_1_project_1_1_path.xhtml "Paths used for internal Project filesystem.") for the enclosing folder.   
 std::string [getFilename](classansys_1_1_project_1_1_path.xhtml#a5bf681569409af8416dea17233728dd3) () const Return the filename part of the path. [More...](classansys_1_1_project_1_1_path.xhtml#a5bf681569409af8416dea17233728dd3)  
 <a id="aed66ba6bebb6c4143b8583197e16fed7" name="aed66ba6bebb6c4143b8583197e16fed7"></a>std::string **getFolderName** () const Return the folder name - only if [Path](classansys_1_1_project_1_1_path.xhtml "Paths used for internal Project filesystem.") is a folder path.   
 <a id="a1227cdd9b08011db5b16eff29c84d640" name="a1227cdd9b08011db5b16eff29c84d640"></a>[Path](classansys_1_1_project_1_1_path.xhtml) **getRelativePathTo** (const [Path](classansys_1_1_project_1_1_path.xhtml) &amp;pTarget) const Convert a global path and a global target to a relative path to the target.   
 <a id="a23c3a774abe504500c5719c91bffae1d" name="a23c3a774abe504500c5719c91bffae1d"></a>const std::string &amp; **str** () const Return as string.   
 <a id="af5c375bd62d14889370b1447b3dca543" name="af5c375bd62d14889370b1447b3dca543"></a>void **operator+=** (const std::string &amp;pPathStr) Appends the string to the [Path](classansys_1_1_project_1_1_path.xhtml "Paths used for internal Project filesystem.").   
 ## <a id="pub-static-methods" name="pub-static-methods"></a>Static Public Member Functions

static bool [isValidFilename](classansys_1_1_project_1_1_path.xhtml#a8c99e9d72982bf6b74a16d30785c15b9) (const std::string &amp;pStr) Check if the specified name is valid for a file. [More...](classansys_1_1_project_1_1_path.xhtml#a8c99e9d72982bf6b74a16d30785c15b9)  
 <a id="a48e0ca51a81dc1f815fbeebd3738db80" name="a48e0ca51a81dc1f815fbeebd3738db80"></a>static bool **isValidPath** (const std::string &amp;pStr) Check if the specified path is correct.   
 static std::string [formatPath](classansys_1_1_project_1_1_path.xhtml#a80cfa1aaec54cf2497057f99250922ff) (const std::string &amp;pPath, bool pFilenameOnly=false) Converts a string to a valid path string. [More...](classansys_1_1_project_1_1_path.xhtml#a80cfa1aaec54cf2497057f99250922ff)  
 <a id="details" name="details"></a>## Detailed Description

Paths used for internal [Project](classansys_1_1_project_1_1_project.xhtml "Base class for Project API, also see SimProject.") 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

<a id="a80cfa1aaec54cf2497057f99250922ff" name="a80cfa1aaec54cf2497057f99250922ff"></a>## [◆ ](#a80cfa1aaec54cf2497057f99250922ff)formatPath()

 std::string ansys::Project::Path::formatPath  ( const std::string &amp;  *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) 



<a id="a5bf681569409af8416dea17233728dd3" name="a5bf681569409af8416dea17233728dd3"></a>## [◆ ](#a5bf681569409af8416dea17233728dd3)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





<a id="a9c0f0c9c4467b5d13a45124a24624b59" name="a9c0f0c9c4467b5d13a45124a24624b59"></a>## [◆ ](#a9c0f0c9c4467b5d13a45124a24624b59)getPathComponents()

 std::vector&lt; std::string &gt; 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 ]
```

 



<a id="a8c99e9d72982bf6b74a16d30785c15b9" name="a8c99e9d72982bf6b74a16d30785c15b9"></a>## [◆ ](#a8c99e9d72982bf6b74a16d30785c15b9)isValidFilename()

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

Check if the specified name is valid for a file.

Returnsfalse if the filename contains any invalid characters