    

 ## On this page

  

 

 # ansys::Project::Path Class Reference

 Last update: 19.05.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 "Path.hpp"`

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

 [Path](classansys_1_1_project_1_1_path.xhtml#a0806ceee18ea0b800857564778f4a0ba) ()  [Path](classansys_1_1_project_1_1_path.xhtml#aed5458d5f0a28f40d0f7e5709690ca96) (const std::string &amp;pPath)  [Path](classansys_1_1_project_1_1_path.xhtml#af255c3ad749bf99349878ebd5387e83f) (const char \*pPath) bool [isNull](classansys_1_1_project_1_1_path.xhtml#ad6c6c48f6fad2de7414b2c03d94d3207) () const Indicates if the path is empty. [More...](classansys_1_1_project_1_1_path.xhtml#ad6c6c48f6fad2de7414b2c03d94d3207)  
 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)  
 bool [isFolderPath](classansys_1_1_project_1_1_path.xhtml#a9b17bbf8223806c71dfc13f3544d2eef) () const Indicates if the path is a folder path (ends with /) [More...](classansys_1_1_project_1_1_path.xhtml#a9b17bbf8223806c71dfc13f3544d2eef)  
 [Path](classansys_1_1_project_1_1_path.xhtml) [getParentPath](classansys_1_1_project_1_1_path.xhtml#a84d47bd152ccc7cc5f2ad2f95686b7f6) () const Return the [Path](classansys_1_1_project_1_1_path.xhtml "Paths used for internal Project filesystem.") for the enclosing folder. [More...](classansys_1_1_project_1_1_path.xhtml#a84d47bd152ccc7cc5f2ad2f95686b7f6)  
 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)  
 std::string [getFolderName](classansys_1_1_project_1_1_path.xhtml#aed66ba6bebb6c4143b8583197e16fed7) () 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. [More...](classansys_1_1_project_1_1_path.xhtml#aed66ba6bebb6c4143b8583197e16fed7)  
 [Path](classansys_1_1_project_1_1_path.xhtml) [getRelativePathTo](classansys_1_1_project_1_1_path.xhtml#a1227cdd9b08011db5b16eff29c84d640) (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. [More...](classansys_1_1_project_1_1_path.xhtml#a1227cdd9b08011db5b16eff29c84d640)  
 const std::string &amp; [str](classansys_1_1_project_1_1_path.xhtml#a23c3a774abe504500c5719c91bffae1d) () const Return as string. [More...](classansys_1_1_project_1_1_path.xhtml#a23c3a774abe504500c5719c91bffae1d)  
 const char \* [c\_str](classansys_1_1_project_1_1_path.xhtml#ae80fd6dba85ddfa063d0b8ddbc6c6dd9) () const bool [operator==](classansys_1_1_project_1_1_path.xhtml#ad44756757c1fa43673870937d9f1189a) (const [Path](classansys_1_1_project_1_1_path.xhtml) &amp;pPath) const bool [operator==](classansys_1_1_project_1_1_path.xhtml#a39f5522970569d709a9f57becb5b7803) (const std::string &amp;pPathStr) const bool [operator==](classansys_1_1_project_1_1_path.xhtml#a8753fda33c053857d1fa7fa54ef4d3cd) (const char \*pPathStr) const bool [operator!=](classansys_1_1_project_1_1_path.xhtml#af56c56146f51281ff99cc92cfbf5a7ec) (const [Path](classansys_1_1_project_1_1_path.xhtml) &amp;pPath) const bool [operator!=](classansys_1_1_project_1_1_path.xhtml#a71c506fb0c39d42d33855aba0b95b59d) (const std::string &amp;pPathStr) const void [operator+=](classansys_1_1_project_1_1_path.xhtml#af5c375bd62d14889370b1447b3dca543) (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."). [More...](classansys_1_1_project_1_1_path.xhtml#af5c375bd62d14889370b1447b3dca543)  
 ## <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)  
 static bool [isValidPath](classansys_1_1_project_1_1_path.xhtml#a48e0ca51a81dc1f815fbeebd3738db80) (const std::string &amp;pStr) Check if the specified path is correct. [More...](classansys_1_1_project_1_1_path.xhtml#a48e0ca51a81dc1f815fbeebd3738db80)  
 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, \_ - . + @



## Constructor &amp; Destructor Documentation

<a id="a0806ceee18ea0b800857564778f4a0ba" name="a0806ceee18ea0b800857564778f4a0ba"></a>## [◆ ](#a0806ceee18ea0b800857564778f4a0ba)Path() \[1/3\]

 ansys::Project::Path::Path  ( ) 





<a id="aed5458d5f0a28f40d0f7e5709690ca96" name="aed5458d5f0a28f40d0f7e5709690ca96"></a>## [◆ ](#aed5458d5f0a28f40d0f7e5709690ca96)Path() \[2/3\]

 ansys::Project::Path::Path  ( const std::string &amp;  *pPath*) 





<a id="af255c3ad749bf99349878ebd5387e83f" name="af255c3ad749bf99349878ebd5387e83f"></a>## [◆ ](#af255c3ad749bf99349878ebd5387e83f)Path() \[3/3\]

 ansys::Project::Path::Path  ( const char \*  *pPath*) 





## Member Function Documentation

<a id="ae80fd6dba85ddfa063d0b8ddbc6c6dd9" name="ae80fd6dba85ddfa063d0b8ddbc6c6dd9"></a>## [◆ ](#ae80fd6dba85ddfa063d0b8ddbc6c6dd9)c\_str()

 const char \* ansys::Project::Path::c\_str  ( )  const  inline 





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

 std::string ansys::Project::Path::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="a84d47bd152ccc7cc5f2ad2f95686b7f6" name="a84d47bd152ccc7cc5f2ad2f95686b7f6"></a>## [◆ ](#a84d47bd152ccc7cc5f2ad2f95686b7f6)getParentPath()

 [Path](classansys_1_1_project_1_1_path.xhtml) ansys::Project::Path::getParentPath  ( )  const

Return the [Path](classansys_1_1_project_1_1_path.xhtml "Paths used for internal Project filesystem.") for the enclosing folder.





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

 [Path](classansys_1_1_project_1_1_path.xhtml) ansys::Project::Path::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="a9b17bbf8223806c71dfc13f3544d2eef" name="a9b17bbf8223806c71dfc13f3544d2eef"></a>## [◆ ](#a9b17bbf8223806c71dfc13f3544d2eef)isFolderPath()

 bool ansys::Project::Path::isFolderPath  ( )  const

Indicates if the path is a folder path (ends with /)





<a id="ad6c6c48f6fad2de7414b2c03d94d3207" name="ad6c6c48f6fad2de7414b2c03d94d3207"></a>## [◆ ](#ad6c6c48f6fad2de7414b2c03d94d3207)isNull()

 bool ansys::Project::Path::isNull  ( )  const

Indicates if the path is empty.





<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 



<a id="a48e0ca51a81dc1f815fbeebd3738db80" name="a48e0ca51a81dc1f815fbeebd3738db80"></a>## [◆ ](#a48e0ca51a81dc1f815fbeebd3738db80)isValidPath()

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

Check if the specified path is correct.





<a id="af56c56146f51281ff99cc92cfbf5a7ec" name="af56c56146f51281ff99cc92cfbf5a7ec"></a>## [◆ ](#af56c56146f51281ff99cc92cfbf5a7ec)operator!=() \[1/2\]

 bool ansys::Project::Path::operator!=  ( const [Path](classansys_1_1_project_1_1_path.xhtml) &amp;  *pPath*)  const  inline 





<a id="a71c506fb0c39d42d33855aba0b95b59d" name="a71c506fb0c39d42d33855aba0b95b59d"></a>## [◆ ](#a71c506fb0c39d42d33855aba0b95b59d)operator!=() \[2/2\]

 bool ansys::Project::Path::operator!=  ( const std::string &amp;  *pPathStr*)  const  inline 





<a id="af5c375bd62d14889370b1447b3dca543" name="af5c375bd62d14889370b1447b3dca543"></a>## [◆ ](#af5c375bd62d14889370b1447b3dca543)operator+=()

 void ansys::Project::Path::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="a8753fda33c053857d1fa7fa54ef4d3cd" name="a8753fda33c053857d1fa7fa54ef4d3cd"></a>## [◆ ](#a8753fda33c053857d1fa7fa54ef4d3cd)operator==() \[1/3\]

 bool ansys::Project::Path::operator==  ( const char \*  *pPathStr*)  const  inline 





<a id="ad44756757c1fa43673870937d9f1189a" name="ad44756757c1fa43673870937d9f1189a"></a>## [◆ ](#ad44756757c1fa43673870937d9f1189a)operator==() \[2/3\]

 bool ansys::Project::Path::operator==  ( const [Path](classansys_1_1_project_1_1_path.xhtml) &amp;  *pPath*)  const





<a id="a39f5522970569d709a9f57becb5b7803" name="a39f5522970569d709a9f57becb5b7803"></a>## [◆ ](#a39f5522970569d709a9f57becb5b7803)operator==() \[3/3\]

 bool ansys::Project::Path::operator==  ( const std::string &amp;  *pPathStr*)  const





<a id="a23c3a774abe504500c5719c91bffae1d" name="a23c3a774abe504500c5719c91bffae1d"></a>## [◆ ](#a23c3a774abe504500c5719c91bffae1d)str()

 const std::string &amp; ansys::Project::Path::str  ( )  const

Return as string.