From 0599f4e6a5f0ccd5a767a7ea1ce4e846e107c6bb Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:38:42 +0300 Subject: [PATCH] fs: Fix case of getting the mount itself --- src/core/file_sys/fs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/file_sys/fs.cpp b/src/core/file_sys/fs.cpp index f009dc2d..ee900a9f 100644 --- a/src/core/file_sys/fs.cpp +++ b/src/core/file_sys/fs.cpp @@ -31,11 +31,16 @@ std::filesystem::path MntPoints::GetHostPath(const std::string& guest_directory) return guest_directory; } + // Nothing to do if getting the mount itself. + if (guest_directory == mount->mount) { + return mount->host_path; + } + // Remove device (e.g /app0) from path to retrieve relative path. const u32 pos = mount->mount.size() + 1; const auto rel_path = std::string_view(guest_directory).substr(pos); const auto host_path = mount->host_path / rel_path; - if (!NeedsCaseInsensiveSearch || std::filesystem::exists(host_path)) { + if (!NeedsCaseInsensiveSearch) { return host_path; } @@ -87,7 +92,7 @@ std::filesystem::path MntPoints::GetHostPath(const std::string& guest_directory) if (!found_match) { // Opening the guest path will surely fail but at least gives // a better error message than the empty path. - return guest_directory; + return host_path; } }