Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Geo::PathUtils

Functions to handle file path creation and modification.

Functions

NameDescription
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
a164406c07d666877b23017d2008794ab
a164406c07d666877b23017d2008794ab

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
a9570e7b96cc5c414c141322022ec9697
a9570e7b96cc5c414c141322022ec9697

GeoFileString Geo::PathUtils::Canonicalize

...

public: GeoFileString Canonicalize
(
    const char * in
)

...

This will standardise a filename to the appropriate platform.


Anchor
aaceaf13cc513c90aa1895c66c08263ad
aaceaf13cc513c90aa1895c66c08263ad

GeoFileString Geo::PathUtils::Canonicalize

...

public: GeoFileString Canonicalize
(
    const Geo::GeoFileString & in
)

...

This will standardise a filename to the appropriate platform.


Anchor
a0f6c5b2c7dae6c84dfebb42394b0f3a4
a0f6c5b2c7dae6c84dfebb42394b0f3a4

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
ae2cea4187ad52fedf7d7aa0837b02681
ae2cea4187ad52fedf7d7aa0837b02681

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
a62f70d9bd4ce1e06e1fd8af464710acc
a62f70d9bd4ce1e06e1fd8af464710acc

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
ad8258e1e5926dcca47a95f6470bc603b
ad8258e1e5926dcca47a95f6470bc603b

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
adf59b79f3bd4255eb249a2c505807e91
adf59b79f3bd4255eb249a2c505807e91

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
a675dc82523507ed5a5efa370e8ccdbb2
a675dc82523507ed5a5efa370e8ccdbb2

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
titleNote

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
a96f55bd83f11c0d2643196933eedaaf5
a96f55bd83f11c0d2643196933eedaaf5

GeoFileString Geo::PathUtils::GetApplicationPath

...

public: GeoFileString GetApplicationPath()

...

Returns the path to the application being executed. May not be available outside Windows platform.


Anchor
a8ae91b6758650e760a0929cfd85636e3
a8ae91b6758650e760a0929cfd85636e3

GeoFileString Geo::PathUtils::GetCurrentPath

...

public: GeoFileString GetCurrentPath()

...

Returns the current working folder. May not be available outside Windows platform.


Anchor
a556ee3bc4d1ffa77de18a8e9ce692e3e
a556ee3bc4d1ffa77de18a8e9ce692e3e

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
a567dfc6102105b4c84b19cc27f38671b
a567dfc6102105b4c84b19cc27f38671b

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
a9c71f8399c3cf493dda3043aa0b5323f
a9c71f8399c3cf493dda3043aa0b5323f

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
a93e352ff3bae77d7db514a6450529650
a93e352ff3bae77d7db514a6450529650

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
a7eac111429c512d12fd9bd54b7a8a945
a7eac111429c512d12fd9bd54b7a8a945

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
a7e085169df68ed213155f2715e4798f1
a7e085169df68ed213155f2715e4798f1

GeoFileString Geo::PathUtils::GetSandboxDataPath

...

public: GeoFileString GetSandboxDataPath()

...

Returns the path to the application's data path, for platforms that provide application sandboxes.


Anchor
ac5ca74db21a8d419742e1a5493a617c7
ac5ca74db21a8d419742e1a5493a617c7

GeoFileString Geo::PathUtils::GetTemporaryPath

...

public: GeoFileString GetTemporaryPath()

...

Returns the temporary folder (e.g. C:\Windows\Temp). May not be available outside Windows platform.


Anchor
acbc92e965e4464ea89570a5e94541a73
acbc92e965e4464ea89570a5e94541a73

GeoFileString Geo::PathUtils::GetWindowsPath

...

public: GeoFileString GetWindowsPath()

...

Returns the path to the Windows folder. Not available outside Windows platform.


Anchor
a2e6dda342426cc6c1d60d7a4bb430608
a2e6dda342426cc6c1d60d7a4bb430608

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
ae685cbeafc981b1f8219f0566964216e
ae685cbeafc981b1f8219f0566964216e

bool Geo::PathUtils::MakePathRelative

...

public: bool MakePathRelative
(
    GeoFileString & path,
    const GeoFileString & relativeTo
)

...

Make path relative wrt.

relativeTo.

Note
titleNote

relativeTo must be an absolute path.


Anchor
a3b25007552d3c810471d3618340cb8ad
a3b25007552d3c810471d3618340cb8ad

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
aeb383384a68289db20a20b6665d59655
aeb383384a68289db20a20b6665d59655

bool Geo::PathUtils::RemoveTrailingFileSeparators

...

public: bool RemoveTrailingFileSeparators
(
    GeoFileString & path
)

...

This will remove \ (or /) characters from the end of the string if present.


Anchor
a86883ff223d97b1183858920fe8767da
a86883ff223d97b1183858920fe8767da

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.