Refactoring

This commit is contained in:
Daniel Marjamäki 2016-08-13 15:23:46 +02:00
parent 2d4f0980cb
commit 2ed50fbf5a
1 changed files with 3 additions and 9 deletions

View File

@ -60,17 +60,11 @@ std::string Path::fromNativeSeparators(std::string path)
std::string Path::simplifyPath(std::string originalPath) std::string Path::simplifyPath(std::string originalPath)
{ {
const bool isUnc = originalPath.size() > 2 && originalPath[0] == '/' && originalPath[1] == '/'; const bool isUnc = originalPath.compare(0,2,"//") == 0;
// Remove ./, .//, ./// etc. at the beginning // Remove ./, .//, ./// etc. at the beginning
while (originalPath.size() > 2 && originalPath[0] == '.' && originalPath[1] == '/') { // remove "./././" while (originalPath.compare(0,2,"./") == 0) { // remove "./././"
size_t toErase = 2; size_t toErase = originalPath.find_first_not_of("/",2);
for (std::size_t i = 2; i < originalPath.size(); i++) {
if (originalPath[i] == '/')
toErase++;
else
break;
}
originalPath = originalPath.erase(0, toErase); originalPath = originalPath.erase(0, toErase);
} }