From 9bc33de652f3ef9e551858725f3446d4ec3c2c4b Mon Sep 17 00:00:00 2001 From: goeiecool9999 <> Date: Wed, 7 Sep 2022 16:28:35 +0200 Subject: [PATCH] Fix crash when permissions are missing up the tree. --- src/Cafe/Filesystem/fscDeviceHostFS.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Cafe/Filesystem/fscDeviceHostFS.cpp b/src/Cafe/Filesystem/fscDeviceHostFS.cpp index 214aa738..437c344c 100644 --- a/src/Cafe/Filesystem/fscDeviceHostFS.cpp +++ b/src/Cafe/Filesystem/fscDeviceHostFS.cpp @@ -248,7 +248,8 @@ class fscDeviceHostFSC : public fscDeviceC { for (auto const &it : relPath) { found = false; - for (auto const& dir_entry : std::filesystem::directory_iterator{correctedPath}) + std::error_code listErr; + for (auto const& dir_entry : std::filesystem::directory_iterator{correctedPath, listErr}) { std::filesystem::path entry_name = dir_entry.path().filename(); if (lowercase_path(entry_name) == lowercase_path(it)) @@ -258,6 +259,14 @@ class fscDeviceHostFSC : public fscDeviceC { break; } } + + // if we can't iterate directory, just copy the original case. + if(listErr) + { + correctedPath /= it; + found = true; + } + if (!found) break; }