Geo::PathUtils
Functions to handle file path creation and modification.
Functions
Name | Description |
---|---|
AppendFileSeparator(GeoFileString &) | This will append a \ (or /) to the end of the string if one isn't already there. |
Canonicalize(const char *) | This will standardise a filename to the appropriate platform. |
Canonicalize(const Geo::GeoFileString &) | This will standardise a filename to the appropriate platform. |
CropAfterFileExtension(GeoFileString &) | This will remove the string beyond and including the last . |
CropAfterLastFileSeparator(GeoFileString &) | This will remove the string beyond and including the last file separator if there is one. |
CropBeforeFileExtension(GeoFileString &) | This will remove the string upto and including the last . |
CropBeforeLastFileSeparator(GeoFileString &) | This will remove the string up to and including the last file separator if there is one. |
ExtractArguments(GeoFileString, GeoArray< GeoFileString >) | This function breaks arguments up into tokens and handles filenames with spaces by using quotes. |
ExtractDirectories(const GeoFileString &, GeoFileString) | Splits a given path into an array of directory names. |
GetApplicationPath() | Returns the path to the application being executed. May not be available outside Windows platform. |
GetCurrentPath() | Returns the current working folder. May not be available outside Windows platform. |
GetDirectoryName(const GeoFileString &) | This will remove the string beyond and including the last file separator if there is one. |
GetDriveName(const GeoFileString &) | Extracts the drive letter of a given path. Valid only on platforms with multiple filesystem roots. |
GetEnvString(const char *) | Retrieves the value of an Environment variable. May not be available outside Windows platform. |
GetFileName(const GeoFileString &) | This will remove the string before and including the last file separator if there is one. |
GetFileNameWithoutExtension(const GeoFileString &) | This will remove the string before and including the last file separator if there is one. |
GetSandboxDataPath() | Returns the path to the application's data path, for platforms that provide application sandboxes. |
GetTemporaryPath() | Returns the temporary folder (e.g. C:\Windows\Temp). May not be available outside Windows platform. |
GetWindowsPath() | Returns the path to the Windows folder. Not available outside Windows platform. |
IsAbsoluteFilePath(const char *) | Returns the true if file string is an absolute path to a file, and false if it is relative. |
MakePathRelative(GeoFileString &, const GeoFileString &) | Make path relative wrt. |
NormalizeFileSeparators(GeoFileString &, char) | This will normalize file separators to the system default, or the given slash character if provided. |
RemoveTrailingFileSeparators(GeoFileString &) | This will remove \ (or /) characters from the end of the string if present. |
SetSandboxDataPath(const char *) | Sets the path to the application's data path, for platforms that provide application sandboxes. |
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::AppendFileSeparator
...
public: bool AppendFileSeparator
(
GeoFileString & path
)
...
This will append a \ (or /) to the end of the string if one isn't already there.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::Canonicalize
...
public: GeoFileString Canonicalize
(
const char * in
)
...
This will standardise a filename to the appropriate platform.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::Canonicalize
...
public: GeoFileString Canonicalize
(
const Geo::GeoFileString & in
)
...
This will standardise a filename to the appropriate platform.
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::CropAfterFileExtension
...
public: bool CropAfterFileExtension
(
GeoFileString & path
)
...
This will remove the string beyond and including the last .
if there is one. If there isn't one it won't do anything.
Returns
True if the string was cropped.
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::CropAfterLastFileSeparator
...
public: bool CropAfterLastFileSeparator
(
GeoFileString & path
)
...
This will remove the string beyond and including the last file separator if there is one.
If there isn't one it won't do anything.
Returns
True if the string was cropped.
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::CropBeforeFileExtension
...
public: bool CropBeforeFileExtension
(
GeoFileString & path
)
...
This will remove the string upto and including the last .
if there is one. If there isn't one it won't do anything.
Returns
True if the string was cropped.
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::CropBeforeLastFileSeparator
...
public: bool CropBeforeLastFileSeparator
(
GeoFileString & path
)
...
This will remove the string up to and including the last file separator if there is one.
If there isn't one it won't do anything.
Returns
True if the string was cropped.
Anchor | ||||
---|---|---|---|---|
|
GeoArray<GeoFileString> Geo::PathUtils::ExtractArguments
...
public: GeoArray< GeoFileString > ExtractArguments
(
GeoFileString commandlineParams,
GeoArray< GeoFileString > argArray
)
...
This function breaks arguments up into tokens and handles filenames with spaces by using quotes.
Anchor | ||||
---|---|---|---|---|
|
Geo::s32 Geo::PathUtils::ExtractDirectories
...
public: Geo::s32 ExtractDirectories
(
const GeoFileString & path,
GeoFileString dirs
)
...
Splits a given path into an array of directory names.
Parameters
[in] | path | The path to split. |
[inout] | dirs | The resulting directory names. The final filename section is discarded. |
Returns
The number of entries in the dirs array.
Note | ||
---|---|---|
| ||
This function is extremely dangerous as it makes no attempt to range check before adding to the dirs array. As a consequence, if the dirs array is too short, it will trash memory. The function should be modified to add a maxDirs parameter. |
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetApplicationPath
...
public: GeoFileString GetApplicationPath()
...
Returns the path to the application being executed. May not be available outside Windows platform.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetCurrentPath
...
public: GeoFileString GetCurrentPath()
...
Returns the current working folder. May not be available outside Windows platform.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetDirectoryName
...
public: GeoFileString GetDirectoryName
(
const GeoFileString & path
)
...
This will remove the string beyond and including the last file separator if there is one.
If there isn't one it won't do anything.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetDriveName
...
public: GeoFileString GetDriveName
(
const GeoFileString & path
)
...
Extracts the drive letter of a given path. Valid only on platforms with multiple filesystem roots.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetEnvString
...
public: GeoFileString GetEnvString
(
const char * envName
)
...
Retrieves the value of an Environment variable. May not be available outside Windows platform.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetFileName
...
public: GeoFileString GetFileName
(
const GeoFileString & path
)
...
This will remove the string before and including the last file separator if there is one.
If there isn't one it won't do anything.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetFileNameWithoutExtension
...
public: GeoFileString GetFileNameWithoutExtension
(
const GeoFileString & path
)
...
This will remove the string before and including the last file separator if there is one.
This will remove the string beyond and including the last . if there is one. If there isn't one it won't do anything.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetSandboxDataPath
...
public: GeoFileString GetSandboxDataPath()
...
Returns the path to the application's data path, for platforms that provide application sandboxes.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetTemporaryPath
...
public: GeoFileString GetTemporaryPath()
...
Returns the temporary folder (e.g. C:\Windows\Temp). May not be available outside Windows platform.
Anchor | ||||
---|---|---|---|---|
|
GeoFileString Geo::PathUtils::GetWindowsPath
...
public: GeoFileString GetWindowsPath()
...
Returns the path to the Windows folder. Not available outside Windows platform.
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::IsAbsoluteFilePath
...
public: bool IsAbsoluteFilePath
(
const char * path
)
...
Returns the true if file string is an absolute path to a file, and false if it is relative.
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::MakePathRelative
...
public: bool MakePathRelative
(
GeoFileString & path,
const GeoFileString & relativeTo
)
...
Make path relative wrt.
relativeTo.
Note | ||
---|---|---|
| ||
relativeTo must be an absolute path. |
Anchor | ||||
---|---|---|---|---|
|
void Geo::PathUtils::NormalizeFileSeparators
...
public: void NormalizeFileSeparators
(
GeoFileString & path,
char slash
)
...
This will normalize file separators to the system default, or the given slash character if provided.
Anchor | ||||
---|---|---|---|---|
|
bool Geo::PathUtils::RemoveTrailingFileSeparators
...
public: bool RemoveTrailingFileSeparators
(
GeoFileString & path
)
...
This will remove \ (or /) characters from the end of the string if present.
Anchor | ||||
---|---|---|---|---|
|
void Geo::PathUtils::SetSandboxDataPath
...
public: void SetSandboxDataPath
(
const char * appDataPath
)
...
Sets the path to the application's data path, for platforms that provide application sandboxes.
Should be called at application start, before client code queries it.