> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ansys::Project::Path Class Reference

Paths used for internal [Project](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_project) filesystem.

`#include "Path.hpp"`

## Public Member Functions

| Type | Name |
| - | - |
| | [Path](#a0806ceee18ea0b800857564778f4a0ba) () |
| | [Path](#aed5458d5f0a28f40d0f7e5709690ca96) (const std::string \&pPath) |
| | [Path](#af255c3ad749bf99349878ebd5387e83f) (const char \*pPath) |
| bool | [isNull](#ad6c6c48f6fad2de7414b2c03d94d3207) () const Indicates if the path is empty. |
| std::vector\< std::string > | [getPathComponents](#a9c0f0c9c4467b5d13a45124a24624b59) () const Return the path components as a vector of string. |
| bool | [isFolderPath](#a9b17bbf8223806c71dfc13f3544d2eef) () const Indicates if the path is a folder path (ends with /) |
| [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) | [getParentPath](#a84d47bd152ccc7cc5f2ad2f95686b7f6) () const Return the [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) for the enclosing folder. |
| std::string | [getFilename](#a5bf681569409af8416dea17233728dd3) () const Return the filename part of the path. |
| std::string | [getFolderName](#aed66ba6bebb6c4143b8583197e16fed7) () const Return the folder name - only if [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) is a folder path. |
| [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) | [getRelativePathTo](#a1227cdd9b08011db5b16eff29c84d640) (const [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) \&pTarget) const Convert a global path and a global target to a relative path to the target. |
| const std::string & | [str](#a23c3a774abe504500c5719c91bffae1d) () const Return as string. |
| const char \* | [c\_str](#ae80fd6dba85ddfa063d0b8ddbc6c6dd9) () const |
| bool | [operator==](#ad44756757c1fa43673870937d9f1189a) (const [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) \&pPath) const |
| bool | [operator==](#a39f5522970569d709a9f57becb5b7803) (const std::string \&pPathStr) const |
| bool | [operator==](#a8753fda33c053857d1fa7fa54ef4d3cd) (const char \*pPathStr) const |
| bool | [operator!=](#af56c56146f51281ff99cc92cfbf5a7ec) (const [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) \&pPath) const |
| bool | [operator!=](#a71c506fb0c39d42d33855aba0b95b59d) (const std::string \&pPathStr) const |
| void | [operator+=](#af5c375bd62d14889370b1447b3dca543) (const std::string \&pPathStr) Appends the string to the [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md). |

## Static Public Member Functions

| Type | Name |
| - | - |
| static bool | [isValidFilename](#a8c99e9d72982bf6b74a16d30785c15b9) (const std::string \&pStr) Check if the specified name is valid for a file. |
| static bool | [isValidPath](#a48e0ca51a81dc1f815fbeebd3738db80) (const std::string \&pStr) Check if the specified path is correct. |
| static std::string | [formatPath](#a80cfa1aaec54cf2497057f99250922ff) (const std::string \&pPath, bool pFilenameOnly=false) Converts a string to a valid path string. |
| static std::string | [getPathFromEnvironment](#a17cd8bc19bf458d0235250c69f61b969) (const std::string \&envVar) Retrieves the value of an environment variable as a path string. |

## Detailed Description

Paths used for internal [Project](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_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, \_ - . + @

## Constructor & Destructor Documentation

### Path() \[1/3]

```cpp theme={null}
ansys::Project::Path::Path()
```

### Path() \[2/3]

```cpp theme={null}
ansys::Project::Path::Path(const std::string & pPath)
```

### Path() \[3/3]

```cpp theme={null}
ansys::Project::Path::Path(const char * pPath)
```

## Member Function Documentation

### c\_str()

```cpp theme={null}
const char * ansys::Project::Path::c_str() const
```

`inline`

### formatPath()

```cpp theme={null}
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**

| Name | Description |
| - | - |
| pFilenameOnly | : to check if the path is for a filename (not a folder) |

### getFilename()

```cpp theme={null}
std::string ansys::Project::Path::getFilename() const
```

Return the filename part of the path.

If the path is a folder path, filename is empty

### getFolderName()

```cpp theme={null}
std::string ansys::Project::Path::getFolderName() const
```

Return the folder name - only if [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) is a folder path.

### getParentPath()

```cpp theme={null}
Path ansys::Project::Path::getParentPath() const
```

Return the [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md) for the enclosing folder.

### getPathComponents()

```cpp theme={null}
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 /

```cpp theme={null}
 /path/folder/filename
 will lead to:
 [ /, path/, folder/, filename ]
```

### getPathFromEnvironment()

```cpp theme={null}
std::string ansys::Project::Path::getPathFromEnvironment(const std::string & envVar)
```

`static`

Retrieves the value of an environment variable as a path string.

**Parameters**

| Name | Description |
| - | - |
| envVar | The name of the environment variable to retrieve |

**Returns**

A `std::string` containing the value of the environment variable if it exists. Returns an empty string if the environment variable is not set or if the input is empty.

### getRelativePathTo()

```cpp theme={null}
Path ansys::Project::Path::getRelativePathTo(const Path & pTarget) const
```

Convert a global path and a global target to a relative path to the target.

### isFolderPath()

```cpp theme={null}
bool ansys::Project::Path::isFolderPath() const
```

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

### isNull()

```cpp theme={null}
bool ansys::Project::Path::isNull() const
```

Indicates if the path is empty.

### isValidFilename()

```cpp theme={null}
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

### isValidPath()

```cpp theme={null}
bool ansys::Project::Path::isValidPath(const std::string & pStr)
```

`static`

Check if the specified path is correct.

### operator!=() \[1/2]

```cpp theme={null}
bool ansys::Project::Path::operator!=(const Path & pPath) const
```

`inline`

### operator!=() \[2/2]

```cpp theme={null}
bool ansys::Project::Path::operator!=(const std::string & pPathStr) const
```

`inline`

### operator+=()

```cpp theme={null}
void ansys::Project::Path::operator+=(const std::string & pPathStr)
```

Appends the string to the [Path](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_project_1_1_path.md).

### operator==() \[1/3]

```cpp theme={null}
bool ansys::Project::Path::operator==(const char * pPathStr) const
```

`inline`

### operator==() \[2/3]

```cpp theme={null}
bool ansys::Project::Path::operator==(const Path & pPath) const
```

### operator==() \[3/3]

```cpp theme={null}
bool ansys::Project::Path::operator==(const std::string & pPathStr) const
```

### str()

```cpp theme={null}
const std::string & ansys::Project::Path::str() const
```

Return as string.
