| 158 | } |
| 159 | |
| 160 | std::vector<std::string> AutoLoadModules(const ModuleInfo& moduleInfo) |
| 161 | { |
| 162 | std::vector<std::string> loadedModules; |
| 163 | |
| 164 | if (moduleInfo.autoLoadDir.empty()) |
| 165 | { |
| 166 | return loadedModules; |
| 167 | } |
| 168 | |
| 169 | ModuleSettings::PathList autoLoadPaths = ModuleSettings::GetAutoLoadPaths(); |
| 170 | |
| 171 | std::size_t indexOfLastSeparator = moduleInfo.location.find_last_of(DIR_SEP); |
| 172 | std::string moduleBasePath = moduleInfo.location.substr(0, indexOfLastSeparator); |
| 173 | |
| 174 | for (ModuleSettings::PathList::iterator i = autoLoadPaths.begin(); |
| 175 | i != autoLoadPaths.end(); ++i) |
| 176 | { |
| 177 | if (*i == ModuleSettings::CURRENT_MODULE_PATH()) |
| 178 | { |
| 179 | // Load all modules from a directory located relative to this modules location |
| 180 | // and named after this modules library name. |
| 181 | *i = moduleBasePath; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | // We could have introduced a duplicate above, so remove it. |
| 186 | std::sort(autoLoadPaths.begin(), autoLoadPaths.end()); |
| 187 | autoLoadPaths.erase(std::unique(autoLoadPaths.begin(), autoLoadPaths.end()), autoLoadPaths.end()); |
| 188 | for (ModuleSettings::PathList::iterator i = autoLoadPaths.begin(); |
| 189 | i != autoLoadPaths.end(); ++i) |
| 190 | { |
| 191 | if (i->empty()) continue; |
| 192 | std::vector<std::string> paths = AutoLoadModulesFromPath(*i, moduleInfo.autoLoadDir); |
| 193 | loadedModules.insert(loadedModules.end(), paths.begin(), paths.end()); |
| 194 | } |
| 195 | return loadedModules; |
| 196 | } |
| 197 | |
| 198 | } |
| 199 | |