From d4ecda40ff8553bc583eb52b140c06f685f10ec9 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Sat, 3 Nov 2018 10:37:52 +0100 Subject: [PATCH] Use the correct separator when computing relativePath. --- src/common/pathTools.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/common/pathTools.cpp b/src/common/pathTools.cpp index cb76475e1..198dd3272 100644 --- a/src/common/pathTools.cpp +++ b/src/common/pathTools.cpp @@ -35,9 +35,9 @@ #endif #ifdef _WIN32 -#define SEPARATOR "\\" +const std::string SEPARATOR("\\"); #else -#define SEPARATOR "/" +const std::string SEPARATOR("/"); #include #endif @@ -66,9 +66,7 @@ string computeRelativePath(const string path, const string absolutePath) while (commonCount < pathParts.size() && commonCount < absolutePathParts.size() && pathParts[commonCount] == absolutePathParts[commonCount]) { - if (!pathParts[commonCount].empty()) { commonCount++; - } } string relativePath; @@ -76,18 +74,17 @@ string computeRelativePath(const string path, const string absolutePath) /* On Windows you have a token more because the root is represented by a letter */ if (commonCount == 0) { - relativePath = "../"; + relativePath = ".." + SEPARATOR; } #endif for (unsigned int i = commonCount; i < pathParts.size(); i++) { - relativePath += "../"; + relativePath += ".." + SEPARATOR; } for (unsigned int i = commonCount; i < absolutePathParts.size(); i++) { relativePath += absolutePathParts[i]; - relativePath += i + 1 < absolutePathParts.size() ? "/" : ""; + relativePath += i + 1 < absolutePathParts.size() ? SEPARATOR : ""; } - return relativePath; }