diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f60472bb13e0d617c286165fcf1f939a2304a32a..d94ee91f06754727b48bd427ad7df07d5a0c7a40 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -74,3 +74,4 @@ trigger dependents: <<: *base_ubuntu_18_04 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/3464/trigger/pipeline diff --git a/SrcBehaviorLoader/PluginLoader.cpp b/SrcBehaviorLoader/PluginLoader.cpp index 0c75aad742c0bc7192e2d895d11c74ad8bde7bd7..7af1339ebda2d6c258fece89a9efbb591283a609 100644 --- a/SrcBehaviorLoader/PluginLoader.cpp +++ b/SrcBehaviorLoader/PluginLoader.cpp @@ -172,6 +172,10 @@ bool endsWith(std::string value, std::string ending) 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){ //Search directories std::vector<std::string> filesFromFolders; @@ -182,12 +186,12 @@ std::vector<std::string> PluginLoader::searchDirectoriesForPlugins(std::vector<s if (!file.empty() && file[file.size() - 1] == '/') { for (auto& p : std::filesystem::directory_iterator(file)) { std::string s = p.path().string(); - if(endsWith(s,suffix+".dll") || endsWith(s,suffix+".so")) + if(validSuffix(s, suffix)) filesFromFolders.push_back(s); } } else { - if(endsWith(f,suffix+".dll") || endsWith(f,suffix+".so")) + if(validSuffix(f, suffix)) filesFromFolders.push_back(f); } } @@ -247,7 +251,9 @@ bool PluginLoader::loadPluginFromName(QString name) { 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); @@ -264,8 +270,10 @@ void PluginLoader::addToPluginList(QString filename) { m_PluginMap.insert(std::pair<QString, QString>(mstring, filename)); } else { + return 2; qWarning() << "Error reading plugin: " << filename; } + return 0; } QStringListModel* PluginLoader::getPluginList() { diff --git a/SrcBehaviorLoader/PluginLoader.h b/SrcBehaviorLoader/PluginLoader.h index f0184fea63c3d8aa4ff03cceca593fc873138ff0..dc313ce85cbc10ec4f348ad39c8f88056ceed0cd 100644 --- a/SrcBehaviorLoader/PluginLoader.h +++ b/SrcBehaviorLoader/PluginLoader.h @@ -20,7 +20,7 @@ public: * It will then be added to the stringlist and is selectable via "loadPluginFromName". * 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.