- Timestamp:
- Feb 17, 2011, 5:47:22 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/forks/sandbox_light/src/libraries/core/PathConfig.cc
r6417 r7908 76 76 : rootPath_(*(new bf::path())) 77 77 , executablePath_(*(new bf::path())) 78 , modulePath_(*(new bf::path()))79 78 , dataPath_(*(new bf::path())) 80 , externalDataPath_(*(new bf::path()))81 79 , configPath_(*(new bf::path())) 82 80 , logPath_(*(new bf::path())) … … 138 136 COUT(1) << "Running from the build tree." << std::endl; 139 137 PathConfig::bDevRun_ = true; 140 modulePath_ = specialConfig::moduleDevDirectory;141 138 } 142 139 else … … 153 150 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?"); 154 151 155 // Module path is fixed as well156 modulePath_ = rootPath_ / specialConfig::defaultModulePath;157 158 152 #else 159 153 160 154 // There is no root path, so don't set it at all 161 // Module path is fixed as well162 modulePath_ = specialConfig::moduleInstallDirectory;163 155 164 156 #endif … … 170 162 delete &rootPath_; 171 163 delete &executablePath_; 172 delete &modulePath_;173 164 delete &dataPath_; 174 delete &externalDataPath_;175 165 delete &configPath_; 176 166 delete &logPath_; … … 184 174 configPath_ = specialConfig::configDevDirectory; 185 175 logPath_ = specialConfig::logDevDirectory; 186 187 // Check for data path override by the command line188 if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())189 externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();190 else191 externalDataPath_ = specialConfig::externalDataDevDirectory;192 176 } 193 177 else … … 251 235 } 252 236 253 std::vector<std::string> PathConfig::getModulePaths()254 {255 std::vector<std::string> modulePaths;256 257 // We search for helper files with the following extension258 const std::string& moduleextension = specialConfig::moduleExtension;259 size_t moduleextensionlength = moduleextension.size();260 261 // Add that path to the PATH variable in case a module depends on another one262 std::string pathVariable(getenv("PATH"));263 putenv(const_cast<char*>(("PATH=" + pathVariable + ';' + modulePath_.string()).c_str()));264 265 // Make sure the path exists, otherwise don't load modules266 if (!boost::filesystem::exists(modulePath_))267 return modulePaths;268 269 boost::filesystem::directory_iterator file(modulePath_);270 boost::filesystem::directory_iterator end;271 272 // Iterate through all files273 while (file != end)274 {275 const std::string& filename = file->BOOST_LEAF_FUNCTION();276 277 // Check if the file ends with the exension in question278 if (filename.size() > moduleextensionlength)279 {280 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)281 {282 // We've found a helper file283 const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);284 modulePaths.push_back((modulePath_ / library).file_string());285 }286 }287 ++file;288 }289 290 return modulePaths;291 }292 293 237 /*static*/ std::string PathConfig::getRootPathString() 294 238 { … … 306 250 } 307 251 308 /*static*/ std::string PathConfig::getExternalDataPathString()309 {310 return getInstance().externalDataPath_.string() + '/';311 }312 313 252 /*static*/ std::string PathConfig::getConfigPathString() 314 253 { … … 320 259 return getInstance().logPath_.string() + '/'; 321 260 } 322 323 /*static*/ std::string PathConfig::getModulePathString()324 {325 return getInstance().modulePath_.string() + '/';326 }327 261 }
Note: See TracChangeset
for help on using the changeset viewer.