mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 06:32:48 +00:00
Optimise 'path_is_absolute()'
This commit is contained in:
parent
e1e6f2db51
commit
f522cfcce8
@ -621,19 +621,29 @@ const char *path_basename(const char *path)
|
||||
**/
|
||||
bool path_is_absolute(const char *path)
|
||||
{
|
||||
#if defined(__wiiu__) || defined(VITA)
|
||||
const char *seperator = NULL;
|
||||
#endif
|
||||
|
||||
if (string_is_empty(path))
|
||||
return false;
|
||||
|
||||
if (path[0] == '/')
|
||||
return true;
|
||||
#ifdef _WIN32
|
||||
/* Many roads lead to Rome ... */
|
||||
if (( strstr(path, "\\\\") == path)
|
||||
|| strstr(path, ":/")
|
||||
|| strstr(path, ":\\")
|
||||
|| strstr(path, ":\\\\"))
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* Many roads lead to Rome...
|
||||
* Note: Drive letter can only be 1 character long */
|
||||
if (string_starts_with(path, "\\\\") ||
|
||||
string_starts_with(path + 1, ":/") ||
|
||||
string_starts_with(path + 1, ":\\"))
|
||||
return true;
|
||||
#elif defined(__wiiu__) || defined(VITA)
|
||||
if (strstr(path, ":/"))
|
||||
seperator = strchr(path, ':');
|
||||
if (seperator && (seperator[1] == '/'))
|
||||
return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user