libpdal_plugin_{stagetype}_{name}.{extension} For example, libpdal_plugin_writer_text.so or libpdal_plugin_filter_color.dylib
| 71 | // For example, libpdal_plugin_writer_text.so or |
| 72 | // libpdal_plugin_filter_color.dylib |
| 73 | std::string validPlugin(const std::string& path, const StringList& types) |
| 74 | { |
| 75 | auto typeValid = [&types](std::string& type) |
| 76 | { |
| 77 | for (auto t: types) |
| 78 | if (type == t) |
| 79 | return true; |
| 80 | return false; |
| 81 | }; |
| 82 | |
| 83 | // Strip off the leader. |
| 84 | std::string file = FileUtils::getFilename(path); |
| 85 | const std::string leader("libpdal_plugin_"); |
| 86 | auto pos = file.find(leader); |
| 87 | if (pos != 0) |
| 88 | return std::string(); |
| 89 | file = file.substr(leader.size()); |
| 90 | |
| 91 | // Strip off the type. |
| 92 | std::string type; |
| 93 | pos = file.find('_'); |
| 94 | if (pos != std::string::npos && pos < file.size() - 1) |
| 95 | type = file.substr(0, pos); |
| 96 | if (!typeValid(type)) |
| 97 | return std::string(); |
| 98 | file = file.substr(pos + 1); |
| 99 | |
| 100 | // Strip the extension off of the end. |
| 101 | pos = file.rfind('.'); |
| 102 | if (pos == std::string::npos || |
| 103 | (file.substr(pos) != Utils::dynamicLibExtension)) |
| 104 | return std::string(); |
| 105 | file = file.substr(0, pos); |
| 106 | |
| 107 | // Make sure what's left is valid. NOTE - pos is modified by parseName(). |
| 108 | pos = 0; |
| 109 | if (!Stage::parseName(file, pos) || (pos != file.size())) |
| 110 | return std::string(); |
| 111 | |
| 112 | // Coerce the filename to the stage name. |
| 113 | return type + "s." + file; |
| 114 | } |
| 115 | |
| 116 | } // unnamed namespace; |
| 117 |