From efb1016db064234f69f19a17ec98b688e553da71 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 22 Nov 2024 09:29:11 +0900 Subject: [PATCH] test existence of directory before browsing --- .../Helper/src/sofa/helper/system/PluginManager.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp b/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp index ebf75c4548d..3d65ec106b2 100644 --- a/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp @@ -538,13 +538,16 @@ std::string PluginManager::findPlugin(const std::string& pluginName, const std:: for (const auto & path : paths) { - for (auto const& dirEntry : std::filesystem::directory_iterator{path}) + if ( fs::exists(path) ) { - const std::string filename = dirEntry.path().filename().string(); - const std::string downcaseFilename = helper::downcaseString(filename); - if (downcaseFilename == downcaseLibName) + for (auto const& dirEntry : std::filesystem::directory_iterator{path}) { - return FileSystem::cleanPath(dirEntry.path().string()); + const std::string filename = dirEntry.path().filename().string(); + const std::string downcaseFilename = helper::downcaseString(filename); + if (downcaseFilename == downcaseLibName) + { + return FileSystem::cleanPath(dirEntry.path().string()); + } } } }