Changeset 2690 for code/branches/buildsystem3/src/core/Core.cc
- Timestamp:
- Feb 23, 2009, 8:57:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem3/src/core/Core.cc
r2685 r2690 34 34 #include "Core.h" 35 35 #include <cassert> 36 #include <fstream> 37 #include <boost/filesystem.hpp> 38 39 #include "util/Exception.h" 36 40 #include "Language.h" 37 41 #include "CoreIncludes.h" … … 51 55 std::string Core::configPath_s(ORXONOX_CONFIG_INSTALL_PATH); // from OrxonoxConfig.h 52 56 std::string Core::logPath_s (ORXONOX_LOG_INSTALL_PATH); // from OrxonoxConfig.h 57 std::string Core::mediaPath_s (ORXONOX_MEDIA_INSTALL_PATH); // from OrxonoxConfig.h 53 58 54 59 Core* Core::singletonRef_s = 0; … … 119 124 defaultMediaPath = ORXONOX_MEDIA_DEV_PATH; 120 125 121 SetConfigValue(mediaPath_ , defaultMediaPath)126 SetConfigValue(mediaPath_s, defaultMediaPath) 122 127 .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged); 123 128 … … 157 162 void Core::mediaPathChanged() 158 163 { 159 if (mediaPath_ != "" && mediaPath_[mediaPath_.size() - 1] != '/')160 { 161 ModifyConfigValue(mediaPath_ , set, mediaPath_+ "/");162 } 163 164 if (mediaPath_ == "")165 { 166 ModifyConfigValue(mediaPath_ , set, "/");164 if (mediaPath_s != "" && mediaPath_s[mediaPath_s.size() - 1] != '/') 165 { 166 ModifyConfigValue(mediaPath_s, set, mediaPath_s + "/"); 167 } 168 169 if (mediaPath_s == "") 170 { 171 ModifyConfigValue(mediaPath_s, set, "/"); 167 172 COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl; 168 173 } … … 245 250 if (*path.end() != '/' && *path.end() != '\\') 246 251 { 247 ModifyConfigValue(mediaPath_ , tset, path + "/");252 ModifyConfigValue(mediaPath_s, tset, path + "/"); 248 253 } 249 254 else 250 255 { 251 ModifyConfigValue(mediaPath_ , tset, path);256 ModifyConfigValue(mediaPath_s, tset, path); 252 257 } 253 258 } … … 264 269 } 265 270 266 /*static*/ void Core::setDevBuild() 267 { 268 // Be careful never to call this function before main()! 269 270 Core::isDevBuild_s = true; 271 // Constants taken from OrxonoxConfig.h 272 Core::configPath_s = ORXONOX_CONFIG_DEV_PATH; 273 Core::logPath_s = ORXONOX_LOG_DEV_PATH; 271 /** 272 @brief 273 Checks for "orxonox_dev_build.keep_me" in the working diretory. 274 If found it means that this is not an installed run, hence we 275 don't write the logs and config files to ~/.orxonox 276 */ 277 /*static*/ void Core::checkDevBuild() 278 { 279 std::ifstream probe; 280 probe.open("orxonox_dev_build.keep_me"); 281 if (probe) 282 { 283 Core::isDevBuild_s = true; 284 // Constants are taken from OrxonoxConfig.h 285 Core::configPath_s = ORXONOX_CONFIG_DEV_PATH; 286 Core::logPath_s = ORXONOX_LOG_DEV_PATH; 287 Core::mediaPath_s = ORXONOX_MEDIA_DEV_PATH; 288 probe.close(); 289 } 290 } 291 292 /* 293 @brief 294 Checks for the log and the config directory and creates them 295 if necessary. Otherwise me might have problems opening those files. 296 */ 297 /*static*/ void Core::createDirectories() 298 { 299 std::vector<std::pair<boost::filesystem::path, std::string> > directories; 300 directories.push_back(std::pair<boost::filesystem::path, std::string> 301 (boost::filesystem::path(Core::configPath_s), "config")); 302 directories.push_back(std::pair<boost::filesystem::path, std::string> 303 (boost::filesystem::path(Core::logPath_s), "log")); 304 305 for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin(); 306 it != directories.end(); ++it) 307 { 308 if (boost::filesystem::exists(it->first) && !boost::filesystem::is_directory(it->first)) 309 { 310 ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \ 311 Please remove " + it->first.file_string()); 312 } 313 if (boost::filesystem::create_directory(it->first)) // function may not return true at all (bug?) 314 { 315 COUT(4) << "Created " << it->second << " directory" << std::endl; 316 } 317 } 274 318 } 275 319 }
Note: See TracChangeset
for help on using the changeset viewer.