Files
FS/include/fs/AbsPath.inl
T
2024-07-10 13:31:12 +02:00

52 lines
1.7 KiB
C++

#pragma once
#include <locale>
namespace fs
{
namespace detail
{
TL_DECLARE_STRING_LITERAL(EmptyRootTag, "");
}
// windows path system
template<typename parse_separators, typename format_separator>
template<typename T>
T WindowsSystemCustom<parse_separators, format_separator>::format_abs(tl::span<const tl::string> members)
{
return tl::simple_path_system<detail::EmptyRootTag, parse_separators, format_separator>::template format_abs<T>(members);
}
template<typename parse_separators, typename format_separator>
void WindowsSystemCustom<parse_separators, format_separator>::parse_abs(tl::vector<tl::string>& o_elements, const char* path, size_t size)
{
// On windows, the drive letter case is undefined. To avoid issues (hashing, etc), we always convert the drive letter to uppercase
tl::simple_path_system<detail::EmptyRootTag, parse_separators, format_separator>::parse_abs(o_elements, path, size);
if (!o_elements.empty())
{
tl::string& str = o_elements.front();
if (str.length() == 2 && str[1] == ':')
{
char strUp[2];
strUp[0] = tl::ascii::toupper(str[0]);
strUp[1] = ':';
str = tl::string(strUp, 2);
}
}
}
template<typename parse_separators, typename format_separator>
bool WindowsSystemCustom<parse_separators, format_separator>::match(const char* path, size_t size)
{
return size >= 2 && std::isalpha(path[0], std::locale()) && path[1] == ':';
}
template<typename parse_separators, typename format_separator>
bool WindowsSystemCustom<parse_separators, format_separator>::validate_abs_path(tl::span<const tl::string> members)
{
return !members.empty() && match(members[0].c_str(), members[0].size());
}
//////////////////////////////////////////////////////////////////////////
}