From b0d687964ee7b233108e538123c0cef2fa989abf Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 2 Dec 2022 21:01:58 +0400 Subject: [PATCH] Make sure that local path has a trailing slash on Linux and Windows --- components/files/linuxpath.cpp | 5 +++-- components/files/windowspath.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/files/linuxpath.cpp b/components/files/linuxpath.cpp index 7071dd4291..71affb6e06 100644 --- a/components/files/linuxpath.cpp +++ b/components/files/linuxpath.cpp @@ -83,7 +83,8 @@ namespace Files std::filesystem::path LinuxPath::getLocalPath() const { - auto localPath = std::filesystem::current_path(); + auto localPath = std::filesystem::current_path() / ""; + static const std::filesystem::path statusPaths[] = { "/proc/self/exe", "/proc/self/file", "/proc/curproc/exe", "/proc/curproc/file" }; @@ -93,7 +94,7 @@ namespace Files const auto binPath = read_symlink(path, ec); if (ec.value() != -1) { - localPath = binPath.parent_path(); + localPath = binPath.parent_path() / ""; break; } } diff --git a/components/files/windowspath.cpp b/components/files/windowspath.cpp index 8c494e3bce..08ba6b0405 100644 --- a/components/files/windowspath.cpp +++ b/components/files/windowspath.cpp @@ -70,13 +70,13 @@ namespace Files std::filesystem::path WindowsPath::getLocalPath() const { - std::filesystem::path localPath = std::filesystem::current_path(); + std::filesystem::path localPath = std::filesystem::current_path() / ""; WCHAR path[MAX_PATH + 1] = {}; if (GetModuleFileNameW(nullptr, path, MAX_PATH + 1) > 0) { - localPath = std::filesystem::path(path).parent_path(); + localPath = std::filesystem::path(path).parent_path() / ""; } // lookup exe path