Changeset 6040 for sandbox_light/src/libraries/core/PathConfig.cc
- Timestamp:
- Nov 5, 2009, 10:15:05 PM (15 years ago)
- Location:
- sandbox_light
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sandbox_light
- Property svn:mergeinfo changed
-
sandbox_light/src/libraries/core/PathConfig.cc
r6039 r6040 75 75 : rootPath_(*(new bf::path())) 76 76 , executablePath_(*(new bf::path())) 77 , modulePath_(*(new bf::path()))78 77 , dataPath_(*(new bf::path())) 79 78 , configPath_(*(new bf::path())) … … 136 135 COUT(1) << "Running from the build tree." << std::endl; 137 136 PathConfig::bDevRun_ = true; 138 modulePath_ = specialConfig::moduleDevDirectory;139 137 } 140 138 else … … 151 149 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?"); 152 150 153 // Module path is fixed as well154 modulePath_ = rootPath_ / specialConfig::defaultModulePath;155 156 151 #else 157 152 158 153 // There is no root path, so don't set it at all 159 // Module path is fixed as well160 modulePath_ = specialConfig::moduleInstallDirectory;161 154 162 155 #endif … … 168 161 delete &rootPath_; 169 162 delete &executablePath_; 170 delete &modulePath_;171 163 delete &dataPath_; 172 164 delete &configPath_; … … 242 234 } 243 235 244 std::vector<std::string> PathConfig::getModulePaths()245 {246 std::vector<std::string> modulePaths;247 248 // We search for helper files with the following extension249 std::string moduleextension = specialConfig::moduleExtension;250 size_t moduleextensionlength = moduleextension.size();251 252 // Add that path to the PATH variable in case a module depends on another one253 std::string pathVariable = getenv("PATH");254 putenv(const_cast<char*>(("PATH=" + pathVariable + ";" + modulePath_.string()).c_str()));255 256 // Make sure the path exists, otherwise don't load modules257 if (!boost::filesystem::exists(modulePath_))258 return modulePaths;259 260 boost::filesystem::directory_iterator file(modulePath_);261 boost::filesystem::directory_iterator end;262 263 // Iterate through all files264 while (file != end)265 {266 std::string filename = file->BOOST_LEAF_FUNCTION();267 268 // Check if the file ends with the exension in question269 if (filename.size() > moduleextensionlength)270 {271 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)272 {273 // We've found a helper file274 std::string library = filename.substr(0, filename.size() - moduleextensionlength);275 modulePaths.push_back((modulePath_ / library).file_string());276 }277 }278 ++file;279 }280 281 return modulePaths;282 }283 284 236 /*static*/ std::string PathConfig::getRootPathString() 285 237 { … … 306 258 return getInstance().logPath_.string() + '/'; 307 259 } 308 309 /*static*/ std::string PathConfig::getModulePathString()310 {311 return getInstance().modulePath_.string() + '/';312 }313 260 }
Note: See TracChangeset
for help on using the changeset viewer.