Filepath¶
| Spice | |
|---|---|
FilePath struct¶
Represents a path to a file or directory on the local file system
Constructors¶
ctor¶
| Spice | |
|---|---|
Construct an empty file path
ctor¶
| Spice | |
|---|---|
Construct a file path from a raw string
Parameters
| Name | Type | Description |
|---|---|---|
pathStr |
string |
Path string |
ctor¶
| Spice | |
|---|---|
Construct a file path from a String
Parameters
| Name | Type | Description |
|---|---|---|
pathStr |
const String& |
Path string |
Methods¶
replaceSeparator¶
| Spice | |
|---|---|
Replace every path separator in the path with the given one
Parameters
| Name | Type | Description |
|---|---|---|
separator |
char |
Separator to use |
makeGeneric¶
| Spice | |
|---|---|
Convert the path to use the generic (UNIX) path separator
makeNative¶
| Spice | |
|---|---|
Convert the path to use the native path separator of the current platform
isEmpty¶
| Spice | |
|---|---|
Checks if the filepath is empty
Returns: bool — Is the filepath empty
toString¶
| Spice | |
|---|---|
Returns the content of the filepath without modifying.
Returns: string — The content of the filepath
toGenericString¶
| Spice | |
|---|---|
Returns the content of the filepath using the UNIX path separator.
Returns: string — The content of the filepath using the UNIX path separator
toNativeString¶
| Spice | |
|---|---|
Returns the content of the filepath using the native path separator.
Returns: string — The content of the filepath using the native path separator
getFileName¶
| Spice | |
|---|---|
Returns the parent directory of the file or directory.
Example:
In: /home/user/file.txt
Out: file.txt
Returns: String — The parent directory of the file or directory
getParentDir¶
| Spice | |
|---|---|
Returns the parent directory of the file or directory.
Example:
In: /home/user/file.txt
Out: /home/user
Returns: String — The parent directory of the file or directory
getBaseName¶
| Spice | |
|---|---|
Returns the base name of the file.
Example:
In: /home/user/file.txt
Out: file
Returns: String — The base name of the file
getExtension¶
| Spice | |
|---|---|
Returns the extension of the file.
Example:
In: /home/user/file.txt
Out: txt
Returns: String — The extension of the file
replaceExtension¶
| Spice | |
|---|---|
Replaces the current file extension with the given new one
Example:
In: /home/user/file.txt
Out: /home/user/file.spice
Parameters
| Name | Type | Description |
|---|---|---|
newExtension |
string |
New file extension |
exists¶
| Spice | |
|---|---|
Checks if the file or directory exists.
Returns: bool — True if the file or directory exists, false otherwise
Operators¶
operator==¶
| Spice | |
|---|---|
Check if two file paths are equal
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
const FilePath& |
|
rhs |
const FilePath& |
Returns: bool — Equal or not equal
operator!=¶
| Spice | |
|---|---|
Check if two file paths are not equal
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
const FilePath& |
|
rhs |
const FilePath& |
Returns: bool — Not equal or equal
operator/=¶
| Spice | |
|---|---|
Append a path component to the path, inserting a separator if needed
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
FilePath& |
|
rhs |
string |
Path component to append |
operator/=¶
| Spice | |
|---|---|
Append a path component to the path, inserting a separator if needed
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
FilePath& |
|
rhs |
const String& |
Path component to append |
operator/=¶
| Spice | |
|---|---|
Append a path component to the path, inserting a separator if needed
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
FilePath& |
|
rhs |
const FilePath& |
Path component to append |
operator/¶
| Spice | |
|---|---|
Join a path and a path component into a new file path, inserting a separator if needed
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
const FilePath& |
|
rhs |
string |
Returns: FilePath — New joined file path
operator/¶
| Spice | |
|---|---|
Join a path and a path component into a new file path, inserting a separator if needed
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
const FilePath& |
|
rhs |
const String& |
Returns: FilePath — New joined file path
operator/¶
| Spice | |
|---|---|
Join two file paths into a new file path, inserting a separator if needed
Parameters
| Name | Type | Description |
|---|---|---|
lhs |
const FilePath& |
|
rhs |
const FilePath& |
Returns: FilePath — New joined file path