- Timestamp:
- Aug 23, 2015, 11:57:53 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/ApplicationPaths.cc
r10509 r10547 74 74 , executablePath_(*(new bf::path())) 75 75 , modulePath_(*(new bf::path())) 76 , pluginPath_(*(new bf::path())) 76 77 , bBuildDirectoryRun_(false) 77 78 { … … 121 122 executablePath_ = bf::path(buffer).branch_path(); 122 123 123 ///////////////////// 124 // SET MODULE PATH//125 ///////////////////// 124 ///////////////////////////////// 125 // SET MODULE AND PLUGIN PATHS // 126 ///////////////////////////////// 126 127 127 128 if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me")) … … 130 131 ApplicationPaths::bBuildDirectoryRun_ = true; 131 132 modulePath_ = specialConfig::moduleDevDirectory; 133 pluginPath_ = specialConfig::pluginDevDirectory; 132 134 } 133 135 else … … 144 146 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?"); 145 147 146 // Module path isfixed as well148 // Module and plugin paths are fixed as well 147 149 modulePath_ = rootPath_ / specialConfig::defaultModulePath; 150 pluginPath_ = rootPath_ / specialConfig::defaultPluginPath; 148 151 149 152 #else 150 153 151 154 // There is no root path, so don't set it at all 152 // Module path isfixed as well155 // Module and plugin paths are fixed as well 153 156 modulePath_ = specialConfig::moduleInstallDirectory; 157 pluginPath_ = specialConfig::pluginInstallDirectory; 154 158 155 159 #endif … … 162 166 delete &executablePath_; 163 167 delete &modulePath_; 168 delete &pluginPath_; 164 169 } 165 170 166 171 std::vector<std::string> ApplicationPaths::getModulePaths() 167 172 { 168 std::vector<std::string> modulePaths; 173 return this->getModuleOrPluginPaths(modulePath_, specialConfig::moduleExtension); 174 } 175 176 std::vector<std::string> ApplicationPaths::getPluginPaths() 177 { 178 return this->getModuleOrPluginPaths(pluginPath_, specialConfig::pluginExtension); 179 } 180 181 std::vector<std::string> ApplicationPaths::getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension) 182 { 183 std::vector<std::string> paths; 169 184 170 185 // We search for helper files with the following extension 171 const std::string& moduleextension = specialConfig::moduleExtension; 172 size_t moduleextensionlength = moduleextension.size(); 173 174 // Make sure the path exists, otherwise don't load modules 175 if (!boost::filesystem::exists(modulePath_)) 176 return modulePaths; 177 178 boost::filesystem::directory_iterator file(modulePath_); 186 size_t extensionlength = extension.size(); 187 188 // Make sure the path exists, otherwise don't load modules/plugins 189 if (!boost::filesystem::exists(directory)) 190 return paths; 191 192 boost::filesystem::directory_iterator file(directory); 179 193 boost::filesystem::directory_iterator end; 180 194 … … 185 199 186 200 // Check if the file ends with the extension in question 187 if (filename.size() > moduleextensionlength)201 if (filename.size() > extensionlength) 188 202 { 189 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)203 if (filename.substr(filename.size() - extensionlength) == extension) 190 204 { 191 205 // We've found a helper file 192 const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);193 modulePaths.push_back(getModulePathString()+ library);206 const std::string& library = filename.substr(0, filename.size() - extensionlength); 207 paths.push_back(directory.BF_GENERIC_STRING() + '/' + library); 194 208 } 195 209 } … … 197 211 } 198 212 199 return modulePaths;213 return paths; 200 214 } 201 215 … … 214 228 return getInstance().modulePath_.BF_GENERIC_STRING() + '/'; 215 229 } 230 231 /*static*/ std::string ApplicationPaths::getPluginPathString() 232 { 233 return getInstance().pluginPath_.BF_GENERIC_STRING() + '/'; 234 } 216 235 }
Note: See TracChangeset
for help on using the changeset viewer.