Basic platform-specific file system functions.
More...
#include <BasicFileSystem.hpp>
|
| static std::vector< String > | SplitPath (const Char *Path, bool Simplify) |
| |
|
static std::string | BuildPathFromComponents (const std::vector< String > &Components, Char Slash=0) |
| | Builds a path from the given components.
|
| |
| static std::string | SimplifyPath (const Char *Path, Char Slash=0) |
| | Simplifies the path.
|
| |
| template<typename CallbackType> |
| static void | SplitPathList (const Char *PathList, CallbackType Callback, const char Separator=';') |
| |
| static std::string | GetRelativePath (const Char *PathFrom, bool IsFromDirectory, const Char *PathTo, bool IsToDirectory, Char Slash=0) |
| | Returns a relative path from one file or folder to another.
|
| |
| static void | GetCommonPathPrefix (const char *Path1, const char *Path2, size_t &Prefix1Len, size_t &Prefix2Len) |
| |
Basic platform-specific file system functions.
◆ GetCommonPathPrefix()
| static void Diligent::BasicFileSystem::GetCommonPathPrefix |
( |
const char * | Path1, |
|
|
const char * | Path2, |
|
|
size_t & | Prefix1Len, |
|
|
size_t & | Prefix2Len ) |
|
static |
Returns the longest common path-component prefix of two paths.
Components are separated by '/' or '\'. Prefix matching is done component-by-component (no partial component matches). If one path is absolute and the other is relative, the prefix is empty. Repeated separators are ignored for matching, but the returned lengths count characters in the original strings, so Prefix1Len and Prefix2Len may differ.
- Parameters
-
| [in] | Path1 | - First path. Must not be null. |
| [in] | Path2 | - Second path. Must not be null. |
| [out] | Prefix1Len | - Length of the common prefix in Path1. |
| [out] | Prefix2Len | - Length of the common prefix in Path2. |
◆ GetRelativePath()
| static std::string Diligent::BasicFileSystem::GetRelativePath |
( |
const Char * | PathFrom, |
|
|
bool | IsFromDirectory, |
|
|
const Char * | PathTo, |
|
|
bool | IsToDirectory, |
|
|
Char | Slash = 0 ) |
|
static |
Returns a relative path from one file or folder to another.
- Parameters
-
| [in] | PathFrom | - Path that defines the start of the relative path. Must not be null. |
| [in] | IsFromDirectory | - Indicates if PathFrom is a directory. |
| [in] | PathTo | - Path that defines the endpoint of the relative path. Must not be null. |
| [in] | IsToDirectory | - Indicates if PathTo is a directory. |
| [in] | Slash | - Slash symbol to use in the returned path. If 0, platform-specific slash is used. |
- Returns
- Relative path from PathFrom to PathTo. If no relative path exists, PathFrom is returned.
◆ SimplifyPath()
| static std::string Diligent::BasicFileSystem::SimplifyPath |
( |
const Char * | Path, |
|
|
Char | Slash = 0 ) |
|
static |
Simplifies the path.
The function performs the following path simplifications:
- Normalizes slashes using the given slash symbol (
a\b/c -> a/b/c)
- Removes redundant slashes (
a///b -> a/b)
- Removes redundant
. (a/./b-> a/b)
- Collapses
.. (a/b/../c -> a/c)
- Removes trailing slashes (
/a/b/c/ -> /a/b/c)
- When 'Slash' is Windows slash (
\), removes leading slashes (\a\b\c -> a\b\c)
◆ SplitPath()
| static std::vector< String > Diligent::BasicFileSystem::SplitPath |
( |
const Char * | Path, |
|
|
bool | Simplify ) |
|
static |
Splits path into individual components optionally simplifying it.
If Simplify is true:
- Removes redundant slashes (
a///b -> a/b)
- Removes redundant
. (a/./b -> a/b)
- Collapses
.. (a/b/../c -> a/c)
◆ SplitPathList()
template<typename CallbackType>
| static void Diligent::BasicFileSystem::SplitPathList |
( |
const Char * | PathList, |
|
|
CallbackType | Callback, |
|
|
const char | Separator = ';' ) |
|
inlinestatic |
Splits a list of paths separated by a given separator and calls a user callback for every individual path. Empty paths are skipped.