Skip to content
Snippets Groups Projects
Commit e231c66f authored by Moritz Maxeiner's avatar Moritz Maxeiner
Browse files

Do not ignore manually specified plugins, use generic std::filesystem functionality

parent 333bdb20
No related branches found
No related tags found
No related merge requests found
...@@ -134,6 +134,12 @@ bool WinSetEnv(const char* name, const char* toWhat){ ...@@ -134,6 +134,12 @@ bool WinSetEnv(const char* name, const char* toWhat){
} }
#endif #endif
bool is_shared_library(std::filesystem::path const& p)
{
auto extension = p.extension();
return extension == ".so" || extension == ".dylib" || extension == ".dll";
}
const char* PluginLoader::addDllPath(std::string f) const char* PluginLoader::addDllPath(std::string f)
{ {
//Get the directory of the DLL/*.so and add it to the PATH env variable. //Get the directory of the DLL/*.so and add it to the PATH env variable.
...@@ -180,26 +186,41 @@ std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<s ...@@ -180,26 +186,41 @@ std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<s
//Search directories //Search directories
std::vector<std::string> filesFromFolders; std::vector<std::string> filesFromFolders;
for (auto f: list) { for (auto f: list)
std::string file = f; {
try { auto path = std::filesystem::path(f);
if (!file.empty() && file[file.size() - 1] == '/') { if (path.empty())
for (auto& p : std::filesystem::directory_iterator(file)) { {
std::string s = p.path().string(); continue;
if(validSuffix(s, suffix)) }
filesFromFolders.push_back(s); if (std::filesystem::is_directory(path))
} {
} try
else { {
if(validSuffix(f, suffix)) for (auto& e : std::filesystem::directory_iterator(path))
filesFromFolders.push_back(f); {
} auto p = e.path();
} if (is_shared_library(p) && p.replace_extension().extension() == ".robo_tracker")
catch (...){ {
qWarning() << "Could not read file/directory: " << file.c_str(); filesFromFolders.push_back(p.string());
} }
} }
}
catch (std::filesystem::filesystem_error const& e)
{
qWarning() << e.what();
}
}
else if (is_shared_library(path))
{
filesFromFolders.push_back(f);
}
else
{
qWarning() << "Neither a directory, nor a shared library:" << f.data();
}
}
return filesFromFolders; return filesFromFolders;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment