String manipulation and test functions. More...
Enumerations | |
enum | Murl::Util::MatchOptions { Murl::Util::MATCH_DEFAULT , Murl::Util::MATCH_NOESCAPE , Murl::Util::MATCH_PATHNAME , Murl::Util::MATCH_PERIOD , Murl::Util::MATCH_CASEFOLD , Murl::Util::MATCH_LEADING_DIR } |
Match option flags, can be combined using bitwise OR. More... | |
Functions | |
String | Murl::Util::GetFilePath (const String &filePathAndName) |
Get the file path substring of a file path and name. More... | |
String | Murl::Util::GetFileName (const String &filePathAndName) |
Get the file name substring of a file path and name. More... | |
String | Murl::Util::GetFileExtension (const String &fileName) |
Get the file extension substring of a file name. More... | |
String | Murl::Util::StripExtension (const String &fileName) |
Strip the file extension from a file name. More... | |
String | Murl::Util::StripPathAndExtension (const String &filePathAndName) |
Strip the file path and extension from a file path and name. More... | |
String | Murl::Util::JoinPaths (const String &leftPath, const String &rightPath) |
Join two path strings. More... | |
String | Murl::Util::GetUnixPath (const String &windowsPath) |
Exchange all '\' with '/' characters. More... | |
String | Murl::Util::GetWindowsPath (const String &unixPath) |
Exchange all '/' with '\' characters. More... | |
String | Murl::Util::GetNormalizedPath (const String &path) |
Get a normalized path. More... | |
String | Murl::Util::GetRelativePath (const String &absolutePath, const String &absoluteBasePath) |
Get a relative path from an absolute one. More... | |
String | Murl::Util::GetAbsolutePath (const String &relativePath, const String &absoluteBasePath) |
Get an absolute path from a relative one. More... | |
Bool | Murl::Util::HasMatchPattern (const String &name, UInt32 matchOption=MATCH_DEFAULT) |
Check if a name contains pattern matching statements. More... | |
Bool | Murl::Util::IsNameMatching (const String &pattern, const String &name, UInt32 matchOptions=MATCH_DEFAULT) |
Check if a name matches a specified pattern. More... | |
Detailed Description
String manipulation and test functions.
Enumeration Type Documentation
◆ MatchOptions
Match option flags, can be combined using bitwise OR.
Function Documentation
◆ GetFilePath()
Get the file path substring of a file path and name.
Returns the substring before the last '/' character.
- Parameters
-
filePathAndName The file path and name.
- Returns
- The file path substring of the file name. If the '/' character is not found an empty string is returned.
◆ GetFileName()
Get the file name substring of a file path and name.
Returns the substring behind the last '/' character.
- Parameters
-
filePathAndName The file path and name.
- Returns
- The file name substring of the file name. If the '/' character is not found the input string is returned.
◆ GetFileExtension()
Get the file extension substring of a file name.
Returns the substring behind the last '.' character.
- Parameters
-
fileName The file name.
- Returns
- The file extension substring of the file name. If the '.' character is not found an empty string is returned.
◆ StripExtension()
Strip the file extension from a file name.
Returns the substring before the last '.' character.
- Parameters
-
fileName The file name.
- Returns
- The file name substring excluding the file extension. If the '.' character is not found the input string is returned.
◆ StripPathAndExtension()
Strip the file path and extension from a file path and name.
Returns the substring from the last '/' to the last '.' character.
- Parameters
-
filePathAndName The file path and name.
- Returns
- The file name substring excluding the file path and extension. If the '.' and '/' character is not found the input string is returned.
◆ JoinPaths()
Join two path strings.
Ensures exactly one '/' character between the left and the right part.
- Parameters
-
leftPath The left path string. rightPath The right path string.
- Returns
- The left plus the right path string.
◆ GetUnixPath()
Exchange all '\' with '/' characters.
- Parameters
-
windowsPath The path string to convert.
- Returns
- The Unix path string.
◆ GetWindowsPath()
Exchange all '/' with '\' characters.
- Parameters
-
unixPath The path string to convert.
- Returns
- The Windows path string.
◆ GetNormalizedPath()
Get a normalized path.
Returns the given path, with all occurrences of "." removed, and any occurrences of ".." recursively joined with the previous sub-path.
- Parameters
-
path The path to normalize.
- Returns
- The normalized Unix-style path.
◆ GetRelativePath()
Get a relative path from an absolute one.
When the relative path cannot be resolved, the given absolute path is returned. This may happen e.g. when both given paths are located on different volumes.
- Parameters
-
absolutePath The absolute path to convert. absoluteBasePath The absolute base path relative to which the path is converted.
- Returns
- The relative path if it can be resolved, or absolutePath if not.
◆ GetAbsolutePath()
Get an absolute path from a relative one.
When the given relative path is actually representing an absolute location (i.e. starting with "/"), it is directly returned. Otherwise, the base path and relative path are concatenated and normalized.
- Parameters
-
relativePath The relative path to convert. absoluteBasePath The absolute base path relative to which the path is converted.
- Returns
- The absolute path if it can be resolved, or relativePath if not.
◆ HasMatchPattern()
Bool Murl::Util::HasMatchPattern | ( | const String & | name, |
UInt32 | matchOption = MATCH_DEFAULT |
||
) |
Check if a name contains pattern matching statements.
Pattern matching is supported by IsNameMatching().
- Parameters
-
name The name string to check. matchOption The option for checking, either MATCH_DEFAULT or MATCH_NOESCAPE.
- Returns
- true if the name contains pattern matching statements, otherwise false.
◆ IsNameMatching()
Bool Murl::Util::IsNameMatching | ( | const String & | pattern, |
const String & | name, | ||
UInt32 | matchOptions = MATCH_DEFAULT |
||
) |
Check if a name matches a specified pattern.
Matches patterns according to the Unix-like globbing rules * ? [0-z]
. See HasMatchPattern() to check a name for patterns.
- Parameters
-
pattern The pattern string. name The name string to check. matchOptions The options for checking, any MatchOptions can be combined using bitwise OR.
- Returns
- true if the name matches the pattern, otherwise false.