Changeset 10509 for code/branches/core7/src/libraries
- Timestamp:
- May 30, 2015, 12:22:27 PM (9 years ago)
- Location:
- code/branches/core7/src/libraries
- Files:
-
- 14 edited
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/ApplicationPaths.cc
r10457 r10509 27 27 */ 28 28 29 #include " PathConfig.h"29 #include "ApplicationPaths.h" 30 30 31 31 #include <cassert> … … 53 53 #include "util/Output.h" 54 54 #include "util/Exception.h" 55 #include "commandline/CommandLineIncludes.h"56 55 57 56 // Differentiate Boost Filesystem v2 and v3 … … 59 58 # define BF_LEAF leaf 60 59 # define BF_GENERIC_STRING string 61 # define BF_NATIVE_STRING file_string62 60 #else 63 61 # define BF_LEAF path().filename().string 64 62 # define BF_GENERIC_STRING generic_string 65 # define BF_NATIVE_STRING string66 63 #endif 67 64 … … 71 68 72 69 //! Static pointer to the singleton 73 PathConfig* PathConfig::singletonPtr_s = 0; 74 75 SetCommandLineArgument(externalDataPath, "").information("Path to the external data files"); 76 SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files"); 77 78 PathConfig::PathConfig() 70 ApplicationPaths* ApplicationPaths::singletonPtr_s = 0; 71 72 ApplicationPaths::ApplicationPaths() 79 73 : rootPath_(*(new bf::path())) 80 74 , executablePath_(*(new bf::path())) 81 75 , modulePath_(*(new bf::path())) 82 , dataPath_(*(new bf::path()))83 , externalDataPath_(*(new bf::path()))84 , configPath_(*(new bf::path()))85 , logPath_(*(new bf::path()))86 76 , bBuildDirectoryRun_(false) 87 77 { … … 138 128 { 139 129 orxout(internal_info) << "Running from the build tree." << endl; 140 PathConfig::bBuildDirectoryRun_ = true;130 ApplicationPaths::bBuildDirectoryRun_ = true; 141 131 modulePath_ = specialConfig::moduleDevDirectory; 142 132 } … … 167 157 } 168 158 169 PathConfig::~PathConfig()159 ApplicationPaths::~ApplicationPaths() 170 160 { 171 161 delete &rootPath_; 172 162 delete &executablePath_; 173 163 delete &modulePath_; 174 delete &dataPath_; 175 delete &externalDataPath_; 176 delete &configPath_; 177 delete &logPath_; 178 } 179 180 void PathConfig::setConfigurablePaths() 181 { 182 if (bBuildDirectoryRun_) 183 { 184 dataPath_ = specialConfig::dataDevDirectory; 185 configPath_ = specialConfig::configDevDirectory; 186 logPath_ = specialConfig::logDevDirectory; 187 188 // Check for data path override by the command line 189 if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue()) 190 externalDataPath_ = CommandLineParser::getValue("externalDataPath").get<std::string>(); 191 else 192 externalDataPath_ = specialConfig::externalDataDevDirectory; 193 } 194 else 195 { 196 197 #ifdef INSTALL_COPYABLE // --> relative paths 198 199 // Using paths relative to the install prefix, complete them 200 dataPath_ = rootPath_ / specialConfig::defaultDataPath; 201 configPath_ = rootPath_ / specialConfig::defaultConfigPath; 202 logPath_ = rootPath_ / specialConfig::defaultLogPath; 203 204 #else 205 206 dataPath_ = specialConfig::dataInstallDirectory; 207 208 // Get user directory 209 #ifdef ORXONOX_PLATFORM_UNIX 210 char* userDataPathPtr(getenv("HOME")); 211 #else 212 char* userDataPathPtr(getenv("APPDATA")); 213 #endif 214 if (userDataPathPtr == NULL) 215 ThrowException(General, "Could not retrieve user data path."); 216 bf::path userDataPath(userDataPathPtr); 217 userDataPath /= ".orxonox"; 218 219 configPath_ = userDataPath / specialConfig::defaultConfigPath; 220 logPath_ = userDataPath / specialConfig::defaultLogPath; 221 222 #endif 223 224 } 225 226 // Option to put all the config and log files in a separate folder 227 if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue()) 228 { 229 const std::string& directory(CommandLineParser::getValue("writingPathSuffix").get<std::string>()); 230 configPath_ = configPath_ / directory; 231 logPath_ = logPath_ / directory; 232 } 233 234 // Create directories to avoid problems when opening files in non existent folders. 235 std::vector<std::pair<bf::path, std::string> > directories; 236 directories.push_back(std::make_pair(bf::path(configPath_), std::string("config"))); 237 directories.push_back(std::make_pair(bf::path(logPath_), std::string("log"))); 238 239 for (std::vector<std::pair<bf::path, std::string> >::iterator it = directories.begin(); 240 it != directories.end(); ++it) 241 { 242 if (bf::exists(it->first) && !bf::is_directory(it->first)) 243 { 244 ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \ 245 Please remove " + it->first.BF_GENERIC_STRING()); 246 } 247 if (bf::create_directories(it->first)) // function may not return true at all (bug?) 248 { 249 orxout(internal_info) << "Created " << it->second << " directory" << endl; 250 } 251 } 252 } 253 254 std::vector<std::string> PathConfig::getModulePaths() 164 } 165 166 std::vector<std::string> ApplicationPaths::getModulePaths() 255 167 { 256 168 std::vector<std::string> modulePaths; … … 288 200 } 289 201 290 /*static*/ std::string PathConfig::getRootPathString()202 /*static*/ std::string ApplicationPaths::getRootPathString() 291 203 { 292 204 return getInstance().rootPath_.BF_GENERIC_STRING() + '/'; 293 205 } 294 206 295 /*static*/ std::string PathConfig::getExecutablePathString()207 /*static*/ std::string ApplicationPaths::getExecutablePathString() 296 208 { 297 209 return getInstance().executablePath_.BF_GENERIC_STRING() + '/'; 298 210 } 299 211 300 /*static*/ std::string PathConfig::getDataPathString() 301 { 302 return getInstance().dataPath_.BF_GENERIC_STRING() + '/'; 303 } 304 305 /*static*/ std::string PathConfig::getExternalDataPathString() 306 { 307 return getInstance().externalDataPath_.BF_GENERIC_STRING() + '/'; 308 } 309 310 /*static*/ std::string PathConfig::getConfigPathString() 311 { 312 return getInstance().configPath_.BF_GENERIC_STRING() + '/'; 313 } 314 315 /*static*/ std::string PathConfig::getLogPathString() 316 { 317 return getInstance().logPath_.BF_GENERIC_STRING() + '/'; 318 } 319 320 /*static*/ std::string PathConfig::getModulePathString() 212 /*static*/ std::string ApplicationPaths::getModulePathString() 321 213 { 322 214 return getInstance().modulePath_.BF_GENERIC_STRING() + '/'; -
code/branches/core7/src/libraries/core/ApplicationPaths.h
r10457 r10509 32 32 */ 33 33 34 #ifndef _ PathConfig_H__35 #define _ PathConfig_H__34 #ifndef _ApplicationPaths_H__ 35 #define _ApplicationPaths_H__ 36 36 37 37 #include "CorePrereqs.h" … … 47 47 /** 48 48 @brief 49 The PathConfig class is a singleton used to configure different paths.49 The ApplicationPaths class is a singleton which provides static paths of the application. 50 50 @details 51 The class provides information about the data, config, log, executable, 52 root and module path. 51 The class provides information about the executable, root and module path. 53 52 It determines those by the use of platform specific functions. 54 53 @remarks 55 54 Not all paths are always available: 56 55 - root only when installed copyable 57 - externalData only for development builds in the build tree58 56 */ 59 class _CoreExport PathConfig//tolua_export60 : public Singleton< PathConfig>57 class _CoreExport ApplicationPaths //tolua_export 58 : public Singleton<ApplicationPaths> 61 59 { //tolua_export 62 friend class Singleton<PathConfig>; 63 friend class Core; 60 friend class Singleton<ApplicationPaths>; 64 61 65 62 public: … … 67 64 @brief 68 65 Retrieves the executable path and sets all hard coded fixed paths (currently only the module path) 69 Also checks for "orxonox_dev_build.keep_me" in the executable dire tory.66 Also checks for "orxonox_dev_build.keep_me" in the executable directory. 70 67 If found it means that this is not an installed run, hence we 71 68 don't write the logs and config files to ~/.orxonox … … 73 70 GeneralException 74 71 */ 75 PathConfig();76 ~ PathConfig();72 ApplicationPaths(); 73 ~ApplicationPaths(); 77 74 78 75 //! Returns the path to the root folder as boost::filesystem::path … … 82 79 static const boost::filesystem::path& getExecutablePath() 83 80 { return getInstance().executablePath_; } 84 //! Returns the path to the data files as boost::filesystem::path85 static const boost::filesystem::path& getDataPath()86 { return getInstance().dataPath_; }87 //! Returns the path to the external data files as boost::filesystem::path88 static const boost::filesystem::path& getExternalDataPath()89 { return getInstance().externalDataPath_; }90 //! Returns the path to the config files as boost::filesystem::path91 static const boost::filesystem::path& getConfigPath()92 { return getInstance().configPath_; }93 //! Returns the path to the log files as boost::filesystem::path94 static const boost::filesystem::path& getLogPath()95 { return getInstance().logPath_; }96 81 //! Returns the path to the modules as boost::filesystem::path 97 82 static const boost::filesystem::path& getModulePath() … … 102 87 //! Returns the path to the executable folder as std::string 103 88 static std::string getExecutablePathString(); 104 //! Returns the path to the data files as std::string105 static std::string getDataPathString();106 //! Returns the path to the external data files as std::string107 static std::string getExternalDataPathString();108 //! Returns the path to the config files as std::string109 static std::string getConfigPathString(); //tolua_export110 //! Returns the path to the log files as std::string111 static std::string getLogPathString();112 89 //! Returns the path to the modules as std::string 113 90 static std::string getModulePathString(); … … 116 93 static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; } 117 94 118 private:119 PathConfig(const PathConfig&); //!< Don't use (undefined symbol)120 121 /**122 @brief123 Sets config, log and media path and creates the folders if necessary.124 @throws125 GeneralException126 */127 void setConfigurablePaths();128 95 //! Returns a list with all modules declared by a *.module file in the module folder. 129 96 std::vector<std::string> getModulePaths(); 97 98 private: 99 ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol) 130 100 131 101 //! Path to the parent directory of the ones above if program was installed with relative paths … … 133 103 boost::filesystem::path& executablePath_; //!< Path to the executable 134 104 boost::filesystem::path& modulePath_; //!< Path to the modules 135 boost::filesystem::path& dataPath_; //!< Path to the data files folder136 boost::filesystem::path& externalDataPath_; //!< Path to the external data files folder137 boost::filesystem::path& configPath_; //!< Path to the config files folder138 boost::filesystem::path& logPath_; //!< Path to the log files folder139 105 140 106 bool bBuildDirectoryRun_; //!< True for runs in the build directory (not installed) 141 static PathConfig* singletonPtr_s;107 static ApplicationPaths* singletonPtr_s; 142 108 }; //tolua_export 143 109 } //tolua_export 144 110 145 #endif /* _ PathConfig_H__ */111 #endif /* _ApplicationPaths_H__ */ -
code/branches/core7/src/libraries/core/CMakeLists.txt
r10479 r10509 55 55 command/ArgumentCompletionFunctions.cc 56 56 config/ConfigFile.cc 57 PathConfig.cc 57 ApplicationPaths.cc 58 Configurablepaths.cc 58 59 END_BUILD_UNIT 59 60 … … 84 85 command/CommandExecutor.h 85 86 config/SettingsConfigFile.h 87 ApplicationPaths.h 88 ConfigurablePaths.h 86 89 Game.h 87 90 GameMode.h … … 90 93 Loader.h 91 94 LuaState.h 92 PathConfig.h93 95 input/InputManager.h 94 96 input/KeyBinder.h -
code/branches/core7/src/libraries/core/ConfigurablePaths.cc
r10457 r10509 27 27 */ 28 28 29 #include " PathConfig.h"29 #include "ConfigurablePaths.h" 30 30 31 31 #include <cassert> … … 57 57 // Differentiate Boost Filesystem v2 and v3 58 58 #if (BOOST_FILESYSTEM_VERSION < 3) 59 # define BF_LEAF leaf60 59 # define BF_GENERIC_STRING string 61 # define BF_NATIVE_STRING file_string62 60 #else 63 # define BF_LEAF path().filename().string64 61 # define BF_GENERIC_STRING generic_string 65 # define BF_NATIVE_STRING string66 62 #endif 67 63 … … 71 67 72 68 //! Static pointer to the singleton 73 PathConfig* PathConfig::singletonPtr_s = 0;69 ConfigurablePaths* ConfigurablePaths::singletonPtr_s = 0; 74 70 75 71 SetCommandLineArgument(externalDataPath, "").information("Path to the external data files"); 76 72 SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files"); 77 73 78 PathConfig::PathConfig() 79 : rootPath_(*(new bf::path())) 80 , executablePath_(*(new bf::path())) 81 , modulePath_(*(new bf::path())) 82 , dataPath_(*(new bf::path())) 74 ConfigurablePaths::ConfigurablePaths() 75 : dataPath_(*(new bf::path())) 83 76 , externalDataPath_(*(new bf::path())) 84 77 , configPath_(*(new bf::path())) 85 78 , logPath_(*(new bf::path())) 86 , bBuildDirectoryRun_(false)87 79 { 88 //////////////////////////89 // FIND EXECUTABLE PATH //90 //////////////////////////91 92 #ifdef ORXONOX_PLATFORM_WINDOWS93 // get executable module94 TCHAR buffer[1024];95 if (GetModuleFileName(NULL, buffer, 1024) == 0)96 ThrowException(General, "Could not retrieve executable path.");97 98 #elif defined(ORXONOX_PLATFORM_APPLE)99 char buffer[1024];100 uint32_t path_len = 1023;101 if (_NSGetExecutablePath(buffer, &path_len))102 ThrowException(General, "Could not retrieve executable path.");103 104 #else /* Linux */105 /* written by Nicolai Haehnle <prefect_@gmx.net> */106 107 /* Get our PID and build the name of the link in /proc */108 char linkname[64]; /* /proc/<pid>/exe */109 if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)110 {111 /* This should only happen on large word systems. I'm not sure112 what the proper response is here.113 Since it really is an assert-like condition, aborting the114 program seems to be in order. */115 assert(false);116 }117 118 /* Now read the symbolic link */119 char buffer[1024];120 int ret;121 ret = readlink(linkname, buffer, 1024);122 /* In case of an error, leave the handling up to the caller */123 if (ret == -1)124 ThrowException(General, "Could not retrieve executable path.");125 126 /* Ensure proper NUL termination */127 buffer[ret] = 0;128 #endif129 130 // Remove executable filename131 executablePath_ = bf::path(buffer).branch_path();132 133 /////////////////////134 // SET MODULE PATH //135 /////////////////////136 137 if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))138 {139 orxout(internal_info) << "Running from the build tree." << endl;140 PathConfig::bBuildDirectoryRun_ = true;141 modulePath_ = specialConfig::moduleDevDirectory;142 }143 else144 {145 146 #ifdef INSTALL_COPYABLE // --> relative paths147 148 // Also set the root path149 bf::path relativeExecutablePath(specialConfig::defaultRuntimePath);150 rootPath_ = executablePath_;151 while (!bf::equivalent(rootPath_ / relativeExecutablePath, executablePath_) && !rootPath_.empty())152 rootPath_ = rootPath_.branch_path();153 if (rootPath_.empty())154 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");155 156 // Module path is fixed as well157 modulePath_ = rootPath_ / specialConfig::defaultModulePath;158 159 #else160 161 // There is no root path, so don't set it at all162 // Module path is fixed as well163 modulePath_ = specialConfig::moduleInstallDirectory;164 165 #endif166 }167 80 } 168 81 169 PathConfig::~PathConfig()82 ConfigurablePaths::~ConfigurablePaths() 170 83 { 171 delete &rootPath_;172 delete &executablePath_;173 delete &modulePath_;174 84 delete &dataPath_; 175 85 delete &externalDataPath_; … … 178 88 } 179 89 180 void PathConfig::setConfigurablePaths()90 void ConfigurablePaths::setConfigurablePaths(const ApplicationPaths& applicationPaths) 181 91 { 182 if ( bBuildDirectoryRun_)92 if (applicationPaths.buildDirectoryRun()) 183 93 { 184 94 dataPath_ = specialConfig::dataDevDirectory; … … 198 108 199 109 // Using paths relative to the install prefix, complete them 200 dataPath_ = rootPath_/ specialConfig::defaultDataPath;201 configPath_ = rootPath_/ specialConfig::defaultConfigPath;202 logPath_ = rootPath_/ specialConfig::defaultLogPath;110 dataPath_ = applicationPaths.getRootPath() / specialConfig::defaultDataPath; 111 configPath_ = applicationPaths.getRootPath() / specialConfig::defaultConfigPath; 112 logPath_ = applicationPaths.getRootPath() / specialConfig::defaultLogPath; 203 113 204 114 #else … … 252 162 } 253 163 254 std::vector<std::string> PathConfig::getModulePaths() 255 { 256 std::vector<std::string> modulePaths; 257 258 // We search for helper files with the following extension 259 const std::string& moduleextension = specialConfig::moduleExtension; 260 size_t moduleextensionlength = moduleextension.size(); 261 262 // Make sure the path exists, otherwise don't load modules 263 if (!boost::filesystem::exists(modulePath_)) 264 return modulePaths; 265 266 boost::filesystem::directory_iterator file(modulePath_); 267 boost::filesystem::directory_iterator end; 268 269 // Iterate through all files 270 while (file != end) 271 { 272 std::string filename = file->BF_LEAF(); 273 274 // Check if the file ends with the extension in question 275 if (filename.size() > moduleextensionlength) 276 { 277 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension) 278 { 279 // We've found a helper file 280 const std::string& library = filename.substr(0, filename.size() - moduleextensionlength); 281 modulePaths.push_back(getModulePathString() + library); 282 } 283 } 284 ++file; 285 } 286 287 return modulePaths; 288 } 289 290 /*static*/ std::string PathConfig::getRootPathString() 291 { 292 return getInstance().rootPath_.BF_GENERIC_STRING() + '/'; 293 } 294 295 /*static*/ std::string PathConfig::getExecutablePathString() 296 { 297 return getInstance().executablePath_.BF_GENERIC_STRING() + '/'; 298 } 299 300 /*static*/ std::string PathConfig::getDataPathString() 164 /*static*/ std::string ConfigurablePaths::getDataPathString() 301 165 { 302 166 return getInstance().dataPath_.BF_GENERIC_STRING() + '/'; 303 167 } 304 168 305 /*static*/ std::string PathConfig::getExternalDataPathString()169 /*static*/ std::string ConfigurablePaths::getExternalDataPathString() 306 170 { 307 171 return getInstance().externalDataPath_.BF_GENERIC_STRING() + '/'; 308 172 } 309 173 310 /*static*/ std::string PathConfig::getConfigPathString()174 /*static*/ std::string ConfigurablePaths::getConfigPathString() 311 175 { 312 176 return getInstance().configPath_.BF_GENERIC_STRING() + '/'; 313 177 } 314 178 315 /*static*/ std::string PathConfig::getLogPathString()179 /*static*/ std::string ConfigurablePaths::getLogPathString() 316 180 { 317 181 return getInstance().logPath_.BF_GENERIC_STRING() + '/'; 318 182 } 319 320 /*static*/ std::string PathConfig::getModulePathString()321 {322 return getInstance().modulePath_.BF_GENERIC_STRING() + '/';323 }324 183 } -
code/branches/core7/src/libraries/core/ConfigurablePaths.h
r10457 r10509 32 32 */ 33 33 34 #ifndef _ PathConfig_H__35 #define _ PathConfig_H__34 #ifndef _ConfigurablePaths_H__ 35 #define _ConfigurablePaths_H__ 36 36 37 37 #include "CorePrereqs.h" 38 38 39 39 #include <string> 40 #include <vector>41 40 #include "util/Singleton.h" 42 41 … … 47 46 /** 48 47 @brief 49 The PathConfigclass is a singleton used to configure different paths.48 The ConfigurablePaths class is a singleton used to configure different paths. 50 49 @details 51 The class provides information about the data, config, log, executable, 52 root and module path. 53 It determines those by the use of platform specific functions. 50 The class provides information about the data, config, and log path. 54 51 @remarks 55 52 Not all paths are always available: 56 - root only when installed copyable57 53 - externalData only for development builds in the build tree 58 54 */ 59 class _CoreExport PathConfig//tolua_export60 : public Singleton< PathConfig>55 class _CoreExport ConfigurablePaths //tolua_export 56 : public Singleton<ConfigurablePaths> 61 57 { //tolua_export 62 friend class Singleton<PathConfig>; 63 friend class Core; 58 friend class Singleton<ConfigurablePaths>; 64 59 65 60 public: 66 /** 67 @brief 68 Retrieves the executable path and sets all hard coded fixed paths (currently only the module path) 69 Also checks for "orxonox_dev_build.keep_me" in the executable diretory. 70 If found it means that this is not an installed run, hence we 71 don't write the logs and config files to ~/.orxonox 72 @throw 73 GeneralException 74 */ 75 PathConfig(); 76 ~PathConfig(); 61 ConfigurablePaths(); 62 ~ConfigurablePaths(); 77 63 78 //! Returns the path to the root folder as boost::filesystem::path79 static const boost::filesystem::path& getRootPath()80 { return getInstance().rootPath_; }81 //! Returns the path to the executable folder as boost::filesystem::path82 static const boost::filesystem::path& getExecutablePath()83 { return getInstance().executablePath_; }84 64 //! Returns the path to the data files as boost::filesystem::path 85 65 static const boost::filesystem::path& getDataPath() … … 94 74 static const boost::filesystem::path& getLogPath() 95 75 { return getInstance().logPath_; } 96 //! Returns the path to the modules as boost::filesystem::path97 static const boost::filesystem::path& getModulePath()98 { return getInstance().modulePath_; }99 76 100 //! Returns the path to the root folder as std::string101 static std::string getRootPathString();102 //! Returns the path to the executable folder as std::string103 static std::string getExecutablePathString();104 77 //! Returns the path to the data files as std::string 105 78 static std::string getDataPathString(); … … 110 83 //! Returns the path to the log files as std::string 111 84 static std::string getLogPathString(); 112 //! Returns the path to the modules as std::string113 static std::string getModulePathString();114 115 //! Return true for runs in the build directory (not installed)116 static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }117 118 private:119 PathConfig(const PathConfig&); //!< Don't use (undefined symbol)120 85 121 86 /** … … 125 90 GeneralException 126 91 */ 127 void setConfigurablePaths(); 128 //! Returns a list with all modules declared by a *.module file in the module folder. 129 std::vector<std::string> getModulePaths(); 92 void setConfigurablePaths(const ApplicationPaths& applicationPaths); 130 93 131 //! Path to the parent directory of the ones above if program was installed with relative paths 132 boost::filesystem::path& rootPath_; 133 boost::filesystem::path& executablePath_; //!< Path to the executable 134 boost::filesystem::path& modulePath_; //!< Path to the modules 94 private: 95 ConfigurablePaths(const ConfigurablePaths&); //!< Don't use (undefined symbol) 96 135 97 boost::filesystem::path& dataPath_; //!< Path to the data files folder 136 98 boost::filesystem::path& externalDataPath_; //!< Path to the external data files folder … … 138 100 boost::filesystem::path& logPath_; //!< Path to the log files folder 139 101 140 bool bBuildDirectoryRun_; //!< True for runs in the build directory (not installed) 141 static PathConfig* singletonPtr_s; 102 static ConfigurablePaths* singletonPtr_s; 142 103 }; //tolua_export 143 104 } //tolua_export 144 105 145 #endif /* _ PathConfig_H__ */106 #endif /* _ConfigurablePaths_H__ */ -
code/branches/core7/src/libraries/core/Core.cc
r10484 r10509 59 59 #include "core/singleton/ScopedSingletonIncludes.h" 60 60 #include "util/SignalHandler.h" 61 #include "PathConfig.h" 61 #include "ApplicationPaths.h" 62 #include "ConfigurablePaths.h" 62 63 #include "commandline/CommandLineIncludes.h" 63 64 #include "config/ConfigFileManager.h" … … 94 95 95 96 Core::Core(const std::string& cmdLine) 96 : pathConfig_(NULL) 97 : applicationPaths_(NULL) 98 , configurablePaths_(NULL) 97 99 , dynLibManager_(NULL) 98 100 , signalHandler_(NULL) … … 115 117 116 118 // Set the hard coded fixed paths 117 this-> pathConfig_ = new PathConfig();119 this->applicationPaths_ = new ApplicationPaths(); 118 120 119 121 // Create a new dynamic library manager … … 122 124 // Load modules 123 125 orxout(internal_info) << "Loading modules:" << endl; 124 const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths();126 const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths(); 125 127 for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it) 126 128 { … … 146 148 147 149 // Set configurable paths like log, config and media 148 this->pathConfig_->setConfigurablePaths(); 149 150 orxout(internal_info) << "Root path: " << PathConfig::getRootPathString() << endl; 151 orxout(internal_info) << "Executable path: " << PathConfig::getExecutablePathString() << endl; 152 orxout(internal_info) << "Data path: " << PathConfig::getDataPathString() << endl; 153 orxout(internal_info) << "Ext. data path: " << PathConfig::getExternalDataPathString() << endl; 154 orxout(internal_info) << "Config path: " << PathConfig::getConfigPathString() << endl; 155 orxout(internal_info) << "Log path: " << PathConfig::getLogPathString() << endl; 156 orxout(internal_info) << "Modules path: " << PathConfig::getModulePathString() << endl; 157 158 // create a signal handler (only active for Linux) 150 this->configurablePaths_ = new ConfigurablePaths(); 151 this->configurablePaths_->setConfigurablePaths(ApplicationPaths::getInstance()); 152 153 orxout(internal_info) << "Root path: " << ApplicationPaths::getRootPathString() << endl; 154 orxout(internal_info) << "Executable path: " << ApplicationPaths::getExecutablePathString() << endl; 155 orxout(internal_info) << "Modules path: " << ApplicationPaths::getModulePathString() << endl; 156 157 orxout(internal_info) << "Data path: " << ConfigurablePaths::getDataPathString() << endl; 158 orxout(internal_info) << "Ext. data path: " << ConfigurablePaths::getExternalDataPathString() << endl; 159 orxout(internal_info) << "Config path: " << ConfigurablePaths::getConfigPathString() << endl; 160 orxout(internal_info) << "Log path: " << ConfigurablePaths::getLogPathString() << endl; 161 162 // create a signal handler 159 163 // This call is placed as soon as possible, but after the directories are set 160 164 this->signalHandler_ = new SignalHandler(); 161 this->signalHandler_->doCatch( PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");165 this->signalHandler_->doCatch(ApplicationPaths::getExecutablePathString(), ConfigurablePaths::getLogPathString() + "orxonox_crash.log"); 162 166 163 167 #ifdef ORXONOX_PLATFORM_WINDOWS … … 186 190 187 191 // Set the correct log path and rewrite the log file with the correct log levels 188 OutputManager::getInstance().getLogWriter()->setLogDirectory( PathConfig::getLogPathString());192 OutputManager::getInstance().getLogWriter()->setLogDirectory(ConfigurablePaths::getLogPathString()); 189 193 190 194 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN) … … 209 213 210 214 // initialise Tcl 211 this->tclBind_ = new TclBind( PathConfig::getDataPathString());215 this->tclBind_ = new TclBind(ConfigurablePaths::getDataPathString()); 212 216 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 213 217 … … 255 259 safeObjectDelete(&signalHandler_); 256 260 safeObjectDelete(&dynLibManager_); 257 safeObjectDelete(&pathConfig_); 261 safeObjectDelete(&configurablePaths_); 262 safeObjectDelete(&applicationPaths_); 258 263 259 264 orxout(internal_status) << "finished destroying Core object" << endl; -
code/branches/core7/src/libraries/core/Core.h
r10479 r10509 91 91 void setThreadAffinity(int limitToCPU); 92 92 93 PathConfig* pathConfig_; 93 ApplicationPaths* applicationPaths_; 94 ConfigurablePaths* configurablePaths_; 94 95 DynLibManager* dynLibManager_; 95 96 SignalHandler* signalHandler_; -
code/branches/core7/src/libraries/core/CoreConfig.cc
r10480 r10509 34 34 #include "core/config/ConfigValueIncludes.h" 35 35 #include "core/Language.h" 36 #include "core/ PathConfig.h"36 #include "core/ApplicationPaths.h" 37 37 38 38 namespace orxonox … … 72 72 .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts); 73 73 74 SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())74 SetConfigValue(bDevMode_, ApplicationPaths::buildDirectoryRun()) 75 75 .description("Developer mode. If not set, hides some things from the user to not confuse him.") 76 76 .callback(this, &CoreConfig::devModeChanged); -
code/branches/core7/src/libraries/core/CorePrereqs.h
r10479 r10509 132 132 T orxonox_cast(U*); 133 133 134 class ApplicationPaths; 134 135 class BaseObject; 135 136 template <class T> … … 152 153 class ConfigFileSection; 153 154 class Configurable; 155 class ConfigurablePaths; 154 156 class ConfigValueContainer; 155 157 class Context; … … 196 198 class OrxonoxClass; 197 199 class OrxonoxInterface; 198 class PathConfig;199 200 struct ResourceInfo; 200 201 template <ScopeID::Value> -
code/branches/core7/src/libraries/core/GUIManager.cc
r10479 r10509 106 106 #include "GraphicsManager.h" 107 107 #include "LuaState.h" 108 #include " PathConfig.h"108 #include "ConfigurablePaths.h" 109 109 #include "Resource.h" 110 110 #include "command/ConsoleCommandIncludes.h" … … 331 331 // Create our own logger to specify the filepath 332 332 std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); 333 ceguiLogger->setLogFilename( PathConfig::getLogPathString() + "cegui.log");333 ceguiLogger->setLogFilename(ConfigurablePaths::getLogPathString() + "cegui.log"); 334 334 ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_)); 335 335 this->ceguiLogger_ = ceguiLogger.release(); -
code/branches/core7/src/libraries/core/GraphicsManager.cc
r10508 r10509 59 59 #include "GUIManager.h" 60 60 #include "Loader.h" 61 #include "PathConfig.h" 61 #include "ApplicationPaths.h" 62 #include "ConfigurablePaths.h" 62 63 #include "ViewportEventListener.h" 63 64 #include "WindowEventListener.h" … … 113 114 114 115 // At first, add the root paths of the data directories as resource locations 115 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( PathConfig::getDataPathString(), "FileSystem");116 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getDataPathString(), "FileSystem"); 116 117 // Load resources 117 118 resources_.reset(new XMLFile("DefaultResources.oxr")); … … 120 121 121 122 // Only for runs in the build directory (not installed) 122 if ( PathConfig::buildDirectoryRun())123 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( PathConfig::getExternalDataPathString(), "FileSystem");123 if (ApplicationPaths::buildDirectoryRun()) 124 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getExternalDataPathString(), "FileSystem"); 124 125 125 126 extResources_.reset(new XMLFile("resources.oxr")); … … 220 221 } 221 222 222 boost::filesystem::path ogreConfigFilepath( PathConfig::getConfigPath() / this->ogreConfigFile_);223 boost::filesystem::path ogreLogFilepath( PathConfig::getLogPath() / this->ogreLogFile_);223 boost::filesystem::path ogreConfigFilepath(ConfigurablePaths::getConfigPath() / this->ogreConfigFile_); 224 boost::filesystem::path ogreLogFilepath(ConfigurablePaths::getLogPath() / this->ogreLogFile_); 224 225 225 226 // create a new logManager … … 260 261 std::string pluginPath = specialConfig::ogrePluginsDirectory; 261 262 #ifdef DEPENDENCY_PACKAGE_ENABLE 262 if (! PathConfig::buildDirectoryRun())263 if (!ApplicationPaths::buildDirectoryRun()) 263 264 { 264 265 # if defined(ORXONOX_PLATFORM_WINDOWS) 265 pluginPath = PathConfig::getExecutablePathString();266 pluginPath = ApplicationPaths::getExecutablePathString(); 266 267 # elif defined(ORXONOX_PLATFORM_APPLE) 267 268 // TODO: Where are the plugins being installed to? 268 pluginPath = PathConfig::getExecutablePathString();269 pluginPath = ApplicationPaths::getExecutablePathString(); 269 270 # endif 270 271 } … … 559 560 { 560 561 assert(this->renderWindow_); 561 this->renderWindow_->writeContentsToTimestampedFile( PathConfig::getLogPathString() + "screenShot_", ".png");562 this->renderWindow_->writeContentsToTimestampedFile(ConfigurablePaths::getLogPathString() + "screenShot_", ".png"); 562 563 } 563 564 } -
code/branches/core7/src/libraries/core/Language.cc
r10480 r10509 37 37 #include "util/Output.h" 38 38 #include "util/StringUtils.h" 39 #include " PathConfig.h"39 #include "ConfigurablePaths.h" 40 40 41 41 namespace orxonox … … 202 202 orxout(internal_info, context::language) << "Read default language file." << endl; 203 203 204 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);204 const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_); 205 205 206 206 // This creates the file if it's not existing … … 252 252 orxout(internal_info, context::language) << "Read translated language file (" << language << ")." << endl; 253 253 254 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(language);254 const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(language); 255 255 256 256 // Open the file … … 305 305 orxout(verbose, context::language) << "Write default language file." << endl; 306 306 307 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);307 const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_); 308 308 309 309 // Open the file -
code/branches/core7/src/libraries/core/command/Shell.cc
r9667 r10509 42 42 #include "core/config/ConfigFileManager.h" 43 43 #include "core/config/ConfigValueIncludes.h" 44 #include "core/ PathConfig.h"44 #include "core/ApplicationPaths.h" 45 45 #include "core/input/InputBuffer.h" 46 46 #include "CommandExecutor.h" … … 84 84 85 85 // Choose the default level according to the path Orxonox was started (build directory or not) 86 OutputLevel defaultDebugLevel = ( PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);86 OutputLevel defaultDebugLevel = (ApplicationPaths::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User); 87 87 this->setLevelMax(defaultDebugLevel); 88 88 … … 164 164 void Shell::devModeChanged(bool value) 165 165 { 166 bool isNormal = (value == PathConfig::buildDirectoryRun());166 bool isNormal = (value == ApplicationPaths::buildDirectoryRun()); 167 167 if (isNormal) 168 168 { -
code/branches/core7/src/libraries/core/command/TclBind.cc
r10347 r10509 37 37 #include "util/Exception.h" 38 38 #include "util/StringUtils.h" 39 #include "core/ PathConfig.h"39 #include "core/ApplicationPaths.h" 40 40 #include "CommandExecutor.h" 41 41 #include "ConsoleCommandIncludes.h" … … 143 143 { 144 144 #ifdef DEPENDENCY_PACKAGE_ENABLE 145 if ( PathConfig::buildDirectoryRun())145 if (ApplicationPaths::buildDirectoryRun()) 146 146 return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl"); 147 147 else 148 return ( PathConfig::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");148 return (ApplicationPaths::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl"); 149 149 #else 150 150 return ""; -
code/branches/core7/src/libraries/core/commandline/CommandLineParser.cc
r10404 r10509 37 37 #include "util/StringUtils.h" 38 38 #include "util/SubString.h" 39 #include "core/PathConfig.h"40 39 41 40 namespace orxonox -
code/branches/core7/src/libraries/core/config/ConfigFile.cc
r9559 r10509 38 38 #include "util/Convert.h" 39 39 #include "util/StringUtils.h" 40 #include "core/ PathConfig.h"40 #include "core/ConfigurablePaths.h" 41 41 #include "ConfigFileEntryComment.h" 42 42 #include "ConfigFileEntryValue.h" … … 81 81 if (!filepath.is_complete()) 82 82 { 83 filepath = PathConfig::getConfigPath() / filepath;83 filepath = ConfigurablePaths::getConfigPath() / filepath; 84 84 if (this->bCopyFallbackFile_) 85 85 { … … 87 87 if (!boost::filesystem::exists(filepath)) 88 88 { 89 boost::filesystem::path defaultFilepath( PathConfig::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);89 boost::filesystem::path defaultFilepath(ConfigurablePaths::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_); 90 90 if (boost::filesystem::exists(defaultFilepath)) 91 91 { … … 216 216 boost::filesystem::path filepath(filename); 217 217 if (!filepath.is_complete()) 218 filepath = PathConfig::getConfigPath() / filename;218 filepath = ConfigurablePaths::getConfigPath() / filename; 219 219 std::ofstream file; 220 220 file.open(filepath.string().c_str(), std::fstream::out); -
code/branches/core7/src/libraries/core/input/KeyBinder.cc
r10380 r10509 37 37 #include "core/config/ConfigValueIncludes.h" 38 38 #include "core/config/ConfigFile.h" 39 #include "core/PathConfig.h" 39 #include "core/ApplicationPaths.h" 40 #include "core/ConfigurablePaths.h" 40 41 #include "InputCommands.h" 41 42 #include "JoyStick.h" … … 255 256 orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl; 256 257 257 this->configFile_ = new ConfigFile(this->filename_, ! PathConfig::buildDirectoryRun());258 this->configFile_ = new ConfigFile(this->filename_, !ApplicationPaths::buildDirectoryRun()); 258 259 this->configFile_->load(); 259 260 260 if ( PathConfig::buildDirectoryRun())261 if (ApplicationPaths::buildDirectoryRun()) 261 262 { 262 263 // Dev users should have combined key bindings files 263 std::string defaultFilepath( PathConfig::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_);264 std::string defaultFilepath(ConfigurablePaths::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_); 264 265 std::ifstream file(defaultFilepath.c_str()); 265 266 if (file.is_open()) … … 289 290 addButtonToCommand(binding, it->second); 290 291 std::string str = binding; 291 if ( PathConfig::buildDirectoryRun() && binding.empty())292 if (ApplicationPaths::buildDirectoryRun() && binding.empty()) 292 293 str = "NoBinding"; 293 294 it->second->setBinding(this->configFile_, this->fallbackConfigFile_, binding, bTemporary); -
code/branches/core7/src/libraries/tools/ResourceLocation.cc
r9667 r10509 35 35 #include "util/Exception.h" 36 36 #include "core/CoreIncludes.h" 37 #include "core/PathConfig.h" 37 #include "core/ApplicationPaths.h" 38 #include "core/ConfigurablePaths.h" 38 39 #include "core/XMLFile.h" 39 40 #include "core/XMLPort.h" … … 74 75 namespace bf = boost::filesystem; 75 76 bf::path path; 76 if (bf::exists( PathConfig::getDataPath() / this->getPath()))77 path = PathConfig::getDataPath() / this->getPath();78 else if ( PathConfig::buildDirectoryRun() && bf::exists(PathConfig::getExternalDataPath() / this->getPath()))79 path = PathConfig::getExternalDataPath() / this->getPath();77 if (bf::exists(ConfigurablePaths::getDataPath() / this->getPath())) 78 path = ConfigurablePaths::getDataPath() / this->getPath(); 79 else if (ApplicationPaths::buildDirectoryRun() && bf::exists(ConfigurablePaths::getExternalDataPath() / this->getPath())) 80 path = ConfigurablePaths::getExternalDataPath() / this->getPath(); 80 81 else 81 82 {
Note: See TracChangeset
for help on using the changeset viewer.