mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-03 14:14:11 +00:00
find_plugin_by_name() now relies on the new SearchPaths class.
This commit is contained in:
parent
5f5b2b5770
commit
baddd228fa
2 changed files with 11 additions and 19 deletions
|
@ -24,6 +24,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE ${YAMLCPP_LIBRARY}
|
PRIVATE ${YAMLCPP_LIBRARY}
|
||||||
PRIVATE ${Readline_LIBRARY}
|
PRIVATE ${Readline_LIBRARY}
|
||||||
${bare_name}-backend
|
${bare_name}-backend
|
||||||
|
${bare_name}-core
|
||||||
)
|
)
|
||||||
|
|
||||||
#install(TARGETS ${PROJECT_NAME}
|
#install(TARGETS ${PROJECT_NAME}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "dindexer-common/settings.hpp"
|
#include "dindexer-common/settings.hpp"
|
||||||
#include "dindexer-common/split_tags.hpp"
|
#include "dindexer-common/split_tags.hpp"
|
||||||
|
#include "dindexer-core/searchpaths.hpp"
|
||||||
#include "dindexerConfig.h"
|
#include "dindexerConfig.h"
|
||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
namespace dinlib {
|
namespace dinlib {
|
||||||
namespace {
|
namespace {
|
||||||
std::string expand ( const char* parString );
|
std::string expand ( const char* parString );
|
||||||
std::string find_plugin_by_name ( const std::vector<boost::string_ref>& parSearchPaths, const std::string& parName );
|
std::string find_plugin_by_name ( std::vector<boost::string_ref>&& parSearchPaths, const std::string& parName );
|
||||||
void throw_if_plugin_failed ( const dindb::BackendPlugin& parPlugin, const std::string& parPluginPath, const std::string& parIntendedName );
|
void throw_if_plugin_failed ( const dindb::BackendPlugin& parPlugin, const std::string& parPluginPath, const std::string& parIntendedName );
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
|
|
||||||
|
@ -68,24 +69,14 @@ namespace dinlib {
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string find_plugin_by_name (const std::vector<boost::string_ref>& parSearchPaths, const std::string& parName) {
|
std::string find_plugin_by_name (std::vector<boost::string_ref>&& parSearchPaths, const std::string& parName) {
|
||||||
using boost::filesystem::path;
|
dincore::ShallowSearchPaths search_paths(std::move(parSearchPaths));
|
||||||
using boost::filesystem::is_directory;
|
return search_paths.first_hit(
|
||||||
using boost::filesystem::directory_iterator;
|
[&parName](boost::string_ref, const std::string& parPath) {
|
||||||
using boost::filesystem::directory_entry;
|
return dindb::backend_name(parPath) == parName;
|
||||||
using boost::make_iterator_range;
|
},
|
||||||
|
dincore::SearchPaths::File
|
||||||
for (auto search_path : parSearchPaths) {
|
);
|
||||||
const std::string search_path_cpy(search_path.begin(), search_path.end());
|
|
||||||
path curr_path(search_path_cpy);
|
|
||||||
auto listing = make_iterator_range(directory_iterator(curr_path), directory_iterator());
|
|
||||||
for (const directory_entry& entry : listing) {
|
|
||||||
auto current_full_path = entry.path().string();
|
|
||||||
if (not is_directory(entry) and dindb::backend_name(current_full_path) == parName)
|
|
||||||
return current_full_path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return std::string();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void throw_if_plugin_failed (const dindb::BackendPlugin& parPlugin, const std::string& parPluginPath, const std::string& parIntendedName) {
|
void throw_if_plugin_failed (const dindb::BackendPlugin& parPlugin, const std::string& parPluginPath, const std::string& parIntendedName) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue