included libscerror header for throw macros; now honours extension

This commit is contained in:
Bob Polis 2020-12-16 13:43:19 +01:00
parent 7ef068fc5b
commit 77c69b721f

View File

@ -14,9 +14,9 @@
#include <map> #include <map>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <dlfcn.h> #include <dlfcn.h>
#include <dirent.h> #include <dirent.h>
#include <libscerror.hpp>
namespace sc { namespace sc {
@ -32,10 +32,9 @@ namespace sc {
std::string plugname {info->d_name}; std::string plugname {info->d_name};
std::string::size_type lastdot = plugname.rfind("."); std::string::size_type lastdot = plugname.rfind(".");
if (plugname.substr(lastdot + 1) == ext) { if (plugname.substr(lastdot + 1) == ext) {
plugin plugin {dir + '/' + plugname};
plugins.emplace(plugname.substr(0, lastdot), std::move(plugin));
} }
plugin plugin {dir + '/' + plugname};
plugins.emplace(plugname.substr(0, lastdot), std::move(plugin));
} }
} }
throw_if_min1(::closedir(plugins_dir)); throw_if_min1(::closedir(plugins_dir));
@ -62,6 +61,7 @@ namespace sc {
plugin(const std::string& path) : _path {path} { plugin(const std::string& path) : _path {path} {
_plugin = ::dlopen(path.c_str(), RTLD_LAZY); _plugin = ::dlopen(path.c_str(), RTLD_LAZY);
//std::cerr << path << (_plugin ? "" : " not") << " opened\n"; //std::cerr << path << (_plugin ? "" : " not") << " opened\n";
const char* err {::dlerror()}; const char* err {::dlerror()};
if (err) std::cerr << err << '\n'; if (err) std::cerr << err << '\n';