From 39f479025ec6231fb2957f869ba66991c2e05e19 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 9 Jun 2021 23:09:04 -0700 Subject: [PATCH] Io: Correct CreateFullPath() on Linux. Fixes #14519. --- Common/File/Path.cpp | 2 ++ unittest/UnitTest.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index cfbae195d9..a45112599e 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -317,6 +317,8 @@ std::string Path::PathTo(const Path &other) { return std::string(); } diff = a.PathTo(b); + } else if (path_ == "/") { + diff = other.path_.substr(1); } else { diff = other.path_.substr(path_.size() + 1); } diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 36a0bdc332..ccc32b4ac6 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -607,6 +607,7 @@ static bool TestPath() { EXPECT_EQ_STR(Path("C:\\Yo\\Lo").GetFilename(), std::string("Lo")); EXPECT_EQ_STR(Path("/a/b").PathTo(Path("/a/b/c/d/e")), std::string("c/d/e")); + EXPECT_EQ_STR(Path("/").PathTo(Path("/home/foo/bar")), std::string("home/foo/bar")); return true; }