mirror of https://github.com/axmolengine/axmol.git
Fix isAbsolutePathInternal for string_view
This commit is contained in:
parent
deddc5542e
commit
85f1f0b424
|
@ -1053,16 +1053,17 @@ bool FileUtils::isAbsolutePath(std::string_view path) const
|
|||
|
||||
bool FileUtils::isAbsolutePathInternal(std::string_view path)
|
||||
{
|
||||
const char* raw = path.data();
|
||||
#if defined(_WIN32)
|
||||
// see also: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN
|
||||
return ((path.length() > 2 && ((path[0] >= 'a' && path[0] <= 'z') || (path[0] >= 'A' && path[0] <= 'Z')) &&
|
||||
path[1] == ':') // Normal absolute path
|
||||
return ((path.length() > 2 && ((raw[0] >= 'a' && raw[0] <= 'z') || (raw[0] >= 'A' && raw[0] <= 'Z')) &&
|
||||
raw[1] == ':') // Normal absolute path
|
||||
|| cxx20::starts_with(path, R"(\\?\)") // Win32 File Namespaces for Long Path
|
||||
|| cxx20::starts_with(path, R"(\\.\)") // Win32 Device Namespaces for device
|
||||
|| (path[0] == '/' || path[0] == '\\') // Current disk drive
|
||||
|| (raw[0] == '/' || raw[0] == '\\') // Current disk drive
|
||||
);
|
||||
#else
|
||||
return (path[0] == '/');
|
||||
return (raw[0] == '/');
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue