ReXGlue SDK
Loading...
Searching...
No Matches
path.h File Reference
#include <initializer_list>
#include <string>
#include <string_view>
#include <vector>
#include <rex/platform.h>
#include <rex/types.h>

Go to the source code of this file.

Namespaces

namespace  rex

Functions

std::vector< std::string_view > rex::string::utf8_split_path (const std::string_view path)
std::string_view rex::string::utf8_strip_leading_slashes (const std::string_view path)
std::string rex::string::utf8_join_paths (const std::string_view left_path, const std::string_view right_path, char32_t separator=kUTF8PathSeparator)
std::string rex::string::utf8_join_paths (const std::vector< std::string > &paths, char32_t separator=kUTF8PathSeparator)
std::string rex::string::utf8_join_paths (const std::vector< std::string_view > &paths, char32_t separator=kUTF8PathSeparator)
std::string rex::string::utf8_join_paths (std::initializer_list< const std::string_view > paths, char32_t separator=kUTF8PathSeparator)
std::string rex::string::utf8_join_guest_paths (const std::string_view left_path, const std::string_view right_path)
std::string rex::string::utf8_join_guest_paths (const std::vector< std::string > &paths)
std::string rex::string::utf8_join_guest_paths (const std::vector< std::string_view > &paths)
std::string rex::string::utf8_join_guest_paths (std::initializer_list< const std::string_view > paths)
std::string rex::string::utf8_fix_path_separators (const std::string_view path, char32_t new_separator=kUTF8PathSeparator)
std::string rex::string::utf8_find_name_from_path (const std::string_view path, char32_t separator=kUTF8PathSeparator)
std::string rex::string::utf8_find_name_from_guest_path (const std::string_view path)
std::string rex::string::utf8_find_base_name_from_path (const std::string_view path, char32_t separator=kUTF8PathSeparator)
std::string rex::string::utf8_find_base_name_from_guest_path (const std::string_view path)
std::string rex::string::utf8_find_base_path (const std::string_view path, char32_t separator=kUTF8PathSeparator)
std::string rex::string::utf8_find_base_guest_path (const std::string_view path)
std::string rex::string::utf8_canonicalize_path (const std::string_view path, char32_t separator=kUTF8PathSeparator)
std::string rex::string::NormalizeGuestPath (std::string_view path)
std::string rex::string::utf8_canonicalize_guest_path (const std::string_view path)

Variables

constexpr char32_t rex::string::kUTF8PathSeparator = static_cast<char32_t>(rex::platform::kPathSeparator)
constexpr char32_t rex::string::kUTF8GuestPathSeparator = U'\\'

Detailed Description

License
BSD 3-Clause License See LICENSE file in the project root for full license text.
Remarks
Derived from Xenia's xenia/base/utf8.h (Ben Vanik, 2020).

Function Documentation

◆ NormalizeGuestPath()

std::string rex::string::NormalizeGuestPath ( std::string_view path)

Normalizes a guest path to the lowercase key form with forward slashes and no device prefix.

◆ utf8_canonicalize_path()

std::string rex::string::utf8_canonicalize_path ( const std::string_view path,
char32_t separator = kUTF8PathSeparator )

Removes . and .. components from a path. A .. never removes a component that ends in a colon.

Parameters
pathPath to canonicalize, split on / and .

◆ utf8_find_base_name_from_path()

std::string rex::string::utf8_find_base_name_from_path ( const std::string_view path,
char32_t separator = kUTF8PathSeparator )

Returns the last component of a path without its last extension. A name whose only dot is its first character is kept whole.

◆ utf8_find_base_path()

std::string rex::string::utf8_find_base_path ( const std::string_view path,
char32_t separator = kUTF8PathSeparator )

Returns the parent of a path, or an empty string when the path has no separator. A parent that ends in a colon keeps its trailing separator.

◆ utf8_find_name_from_path()

std::string rex::string::utf8_find_name_from_path ( const std::string_view path,
char32_t separator = kUTF8PathSeparator )

Returns the last component of a path, ignoring trailing separators, or an empty string for an empty path or only separators.

◆ utf8_fix_path_separators()

std::string rex::string::utf8_fix_path_separators ( const std::string_view path,
char32_t new_separator = kUTF8PathSeparator )

Replaces every / and \ with one separator and collapses repeated separators.

◆ utf8_join_paths()

std::string rex::string::utf8_join_paths ( const std::string_view left_path,
const std::string_view right_path,
char32_t separator = kUTF8PathSeparator )

Joins two path segments, adding a separator unless the left segment ends with one.

Parameters
left_pathFirst segment. When empty the result is right_path.
right_pathSecond segment. When empty the result is left_path.

◆ utf8_split_path()

std::vector< std::string_view > rex::string::utf8_split_path ( const std::string_view path)

Splits a path on both / and \ and omits empty parts.

Returns
Views of the path components, in order.