From 524997e406b40f7b7548e295e4d2a55a9a20b466 Mon Sep 17 00:00:00 2001 From: SuuperW Date: Tue, 4 Sep 2018 11:23:11 -0500 Subject: [PATCH] clean up Path::IsPathRooted --- desmume/src/path.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/desmume/src/path.cpp b/desmume/src/path.cpp index 2c3151278..b31117539 100644 --- a/desmume/src/path.cpp +++ b/desmume/src/path.cpp @@ -39,23 +39,17 @@ static const char InvalidPathChars[] = { //but it is sort of windows-specific. Does it work in linux? Maybe we'll have to make it smarter static const char VolumeSeparatorChar = ':'; -static const char AltDirectorySeparatorChar = '/'; static bool dirEqualsVolume = (DIRECTORY_DELIMITER_CHAR == VolumeSeparatorChar); - - -bool Path::IsPathRooted (const std::string &path) +bool Path::IsPathRooted(const std::string &path) { - if (path.empty()) { + if (path.empty()) return false; - } - if (path.find_first_of(InvalidPathChars) != std::string::npos) { + if (path.find_first_of(InvalidPathChars) != std::string::npos) return false; - } - char c = path[0]; - return (c == DIRECTORY_DELIMITER_CHAR || - c == AltDirectorySeparatorChar || + std::string delimiters = ALL_DIRECTORY_DELIMITER_STRING; + return (delimiters.find(path[0]) != std::string::npos || (!dirEqualsVolume && path.size() > 1 && path[1] == VolumeSeparatorChar)); }