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()); + } } } }