Skip to content
Snippets Groups Projects
Commit 98a99c3f authored by moenck's avatar moenck
Browse files

Added suffix filter to addToPluginList

Also added Biotracker to the downstream
parent 5061dee7
No related branches found
No related tags found
No related merge requests found
Pipeline #12532 passed
...@@ -74,3 +74,4 @@ trigger dependents: ...@@ -74,3 +74,4 @@ trigger dependents:
<<: *base_ubuntu_18_04 <<: *base_ubuntu_18_04
script: script:
- curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master https://git.imp.fu-berlin.de/api/v4/projects/3654/trigger/pipeline - curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master https://git.imp.fu-berlin.de/api/v4/projects/3654/trigger/pipeline
- curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master https://git.imp.fu-berlin.de/api/v4/projects/3464/trigger/pipeline
...@@ -172,6 +172,10 @@ bool endsWith(std::string value, std::string ending) ...@@ -172,6 +172,10 @@ bool endsWith(std::string value, std::string ending)
return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
} }
bool validSuffix(std::string f, std::string suffix){
return (endsWith(f,suffix+".dll") || endsWith(f,suffix+".so"));
}
std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<std::string> list, std::string suffix){ std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<std::string> list, std::string suffix){
//Search directories //Search directories
std::vector<std::string> filesFromFolders; std::vector<std::string> filesFromFolders;
...@@ -182,12 +186,12 @@ std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<s ...@@ -182,12 +186,12 @@ std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<s
if (!file.empty() && file[file.size() - 1] == '/') { if (!file.empty() && file[file.size() - 1] == '/') {
for (auto& p : std::filesystem::directory_iterator(file)) { for (auto& p : std::filesystem::directory_iterator(file)) {
std::string s = p.path().string(); std::string s = p.path().string();
if(endsWith(s,suffix+".dll") || endsWith(s,suffix+".so")) if(validSuffix(s, suffix))
filesFromFolders.push_back(s); filesFromFolders.push_back(s);
} }
} }
else { else {
if(endsWith(f,suffix+".dll") || endsWith(f,suffix+".so")) if(validSuffix(f, suffix))
filesFromFolders.push_back(f); filesFromFolders.push_back(f);
} }
} }
...@@ -247,7 +251,9 @@ bool PluginLoader::loadPluginFromName(QString name) { ...@@ -247,7 +251,9 @@ bool PluginLoader::loadPluginFromName(QString name) {
return loadPluginFromFilename(filename); return loadPluginFromFilename(filename);
} }
void PluginLoader::addToPluginList(QString filename) { int PluginLoader::addToPluginList(QString filename, QString suffix) {
if (!validSuffix(filename.toStdString(), suffix.toStdString()))
return 1;
bool isLib = QLibrary::isLibrary(filename); bool isLib = QLibrary::isLibrary(filename);
...@@ -264,8 +270,10 @@ void PluginLoader::addToPluginList(QString filename) { ...@@ -264,8 +270,10 @@ void PluginLoader::addToPluginList(QString filename) {
m_PluginMap.insert(std::pair<QString, QString>(mstring, filename)); m_PluginMap.insert(std::pair<QString, QString>(mstring, filename));
} }
else { else {
return 2;
qWarning() << "Error reading plugin: " << filename; qWarning() << "Error reading plugin: " << filename;
} }
return 0;
} }
QStringListModel* PluginLoader::getPluginList() { QStringListModel* PluginLoader::getPluginList() {
......
...@@ -20,7 +20,7 @@ public: ...@@ -20,7 +20,7 @@ public:
* It will then be added to the stringlist and is selectable via "loadPluginFromName". * It will then be added to the stringlist and is selectable via "loadPluginFromName".
* This function does not actually set the plugin instance. * This function does not actually set the plugin instance.
*/ */
void addToPluginList(QString p); int addToPluginList(QString filename, QString suffix);
/** /**
* Returns a QStrinListModel with the names of all seen Plugins. * Returns a QStrinListModel with the names of all seen Plugins.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment