diff --git a/src/Common/unix/FileStream_unix.cpp b/src/Common/unix/FileStream_unix.cpp index 8eef914b..4c8c1d16 100644 --- a/src/Common/unix/FileStream_unix.cpp +++ b/src/Common/unix/FileStream_unix.cpp @@ -13,19 +13,20 @@ std::optional findPathCI(const fs::path& path) else return {}; } + std::string fName = path.filename().string(); - if (fs::exists(parentPath)) + + if (fs::exists(parentPath / fName)) + return parentPath / fName; + + std::error_code listErr; + for (auto&& dirEntry: fs::directory_iterator(parentPath, listErr)) { - std::error_code listErr; - for (auto&& dirEntry: fs::directory_iterator(parentPath, listErr)) + std::string dirFName = dirEntry.path().filename().string(); + if (boost::iequals(dirFName, fName)) { - std::string dirFName = dirEntry.path().filename().string(); - if (boost::iequals(dirFName, fName)) - { - return dirEntry; - } + return dirEntry; } - return fName; } return parentPath / fName; }