Skip to content

Commit

Permalink
[SofaKernel] Replace boost by std filesystem in PluginManager
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed Sep 7, 2020
1 parent 5997b93 commit 4f8c145
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ using sofa::helper::system::FileSystem;
#include <sofa/helper/Utils.h>
#include <sofa/helper/logging/Messaging.h>

#include <boost/filesystem.hpp>
#include <fstream>

#include <filesystem>


using sofa::helper::Utils;

namespace sofa
Expand Down Expand Up @@ -316,16 +318,16 @@ std::string PluginManager::findPlugin(const std::string& pluginName, const std::
{
const std::string& dir = *i;

boost::filesystem::recursive_directory_iterator iter(dir);
boost::filesystem::recursive_directory_iterator end;
std::filesystem::recursive_directory_iterator iter(dir);
std::filesystem::recursive_directory_iterator end;

while (iter != end)
{
if ( iter.level() > maxRecursiveDepth )
if ( iter.depth() > maxRecursiveDepth )
{
iter.no_push(); // skip
iter.disable_recursion_pending(); // skip
}
else if ( !boost::filesystem::is_directory(iter->path()) )
else if ( !std::filesystem::is_directory(iter->path()) )
{
const std::string path = iter->path().string();
const std::string filename = iter->path().filename().string();
Expand All @@ -337,12 +339,7 @@ std::string PluginManager::findPlugin(const std::string& pluginName, const std::
}
}

boost::system::error_code ec;
iter.increment(ec);
if (ec)
{
msg_error("PluginManager") << "Error while accessing " << iter->path().string() << ": " << ec.message();
}
iter++;
}
}
}
Expand All @@ -351,10 +348,13 @@ std::string PluginManager::findPlugin(const std::string& pluginName, const std::

bool PluginManager::pluginIsLoaded(const std::string& plugin)
{
// check if path valid
std::string pluginPath = plugin;

if (!FileSystem::isFile(plugin)) {
pluginPath = findPlugin(plugin);
std::filesystem::path sysPath(pluginPath);
if (!std::filesystem::exists(sysPath))
{
// Plugin is not a file, try to find the plugin real path
pluginPath = findPlugin(pluginPath);
}

return m_pluginMap.find(pluginPath) != m_pluginMap.end();
Expand Down

0 comments on commit 4f8c145

Please sign in to comment.