Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 30, 2015, 12:22:27 PM (9 years ago)
Author:
landauf
Message:

moved static application paths (root, executable, modules) into new class named ApplicationPaths
moved configurable data paths (data, log, config) into new class named ConfigurablePaths
removed PathConfig

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  
    2727 */
    2828
    29 #include "PathConfig.h"
     29#include "ApplicationPaths.h"
    3030
    3131#include <cassert>
     
    5353#include "util/Output.h"
    5454#include "util/Exception.h"
    55 #include "commandline/CommandLineIncludes.h"
    5655
    5756// Differentiate Boost Filesystem v2 and v3
     
    5958#  define BF_LEAF leaf
    6059#  define BF_GENERIC_STRING string
    61 #  define BF_NATIVE_STRING file_string
    6260#else
    6361#  define BF_LEAF path().filename().string
    6462#  define BF_GENERIC_STRING generic_string
    65 #  define BF_NATIVE_STRING string
    6663#endif
    6764
     
    7168
    7269    //! 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()
    7973        : rootPath_(*(new bf::path()))
    8074        , executablePath_(*(new bf::path()))
    8175        , modulePath_(*(new bf::path()))
    82         , dataPath_(*(new bf::path()))
    83         , externalDataPath_(*(new bf::path()))
    84         , configPath_(*(new bf::path()))
    85         , logPath_(*(new bf::path()))
    8676        , bBuildDirectoryRun_(false)
    8777    {
     
    138128        {
    139129            orxout(internal_info) << "Running from the build tree." << endl;
    140             PathConfig::bBuildDirectoryRun_ = true;
     130            ApplicationPaths::bBuildDirectoryRun_ = true;
    141131            modulePath_ = specialConfig::moduleDevDirectory;
    142132        }
     
    167157    }
    168158
    169     PathConfig::~PathConfig()
     159    ApplicationPaths::~ApplicationPaths()
    170160    {
    171161        delete &rootPath_;
    172162        delete &executablePath_;
    173163        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()
    255167    {
    256168        std::vector<std::string> modulePaths;
     
    288200    }
    289201
    290     /*static*/ std::string PathConfig::getRootPathString()
     202    /*static*/ std::string ApplicationPaths::getRootPathString()
    291203    {
    292204        return getInstance().rootPath_.BF_GENERIC_STRING() + '/';
    293205    }
    294206
    295     /*static*/ std::string PathConfig::getExecutablePathString()
     207    /*static*/ std::string ApplicationPaths::getExecutablePathString()
    296208    {
    297209        return getInstance().executablePath_.BF_GENERIC_STRING() + '/';
    298210    }
    299211
    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()
    321213    {
    322214        return getInstance().modulePath_.BF_GENERIC_STRING() + '/';
  • code/branches/core7/src/libraries/core/ApplicationPaths.h

    r10457 r10509  
    3232*/
    3333
    34 #ifndef _PathConfig_H__
    35 #define _PathConfig_H__
     34#ifndef _ApplicationPaths_H__
     35#define _ApplicationPaths_H__
    3636
    3737#include "CorePrereqs.h"
     
    4747    /**
    4848    @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.
    5050    @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.
    5352        It determines those by the use of platform specific functions.
    5453    @remarks
    5554        Not all paths are always available:
    5655        - root only when installed copyable
    57         - externalData only for development builds in the build tree
    5856    */
    59     class _CoreExport PathConfig //tolua_export
    60         : public Singleton<PathConfig>
     57    class _CoreExport ApplicationPaths //tolua_export
     58        : public Singleton<ApplicationPaths>
    6159    { //tolua_export
    62         friend class Singleton<PathConfig>;
    63         friend class Core;
     60        friend class Singleton<ApplicationPaths>;
    6461
    6562        public:
     
    6764            @brief
    6865                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.
     66                Also checks for "orxonox_dev_build.keep_me" in the executable directory.
    7067                If found it means that this is not an installed run, hence we
    7168                don't write the logs and config files to ~/.orxonox
     
    7370                GeneralException
    7471            */
    75             PathConfig();
    76             ~PathConfig();
     72            ApplicationPaths();
     73            ~ApplicationPaths();
    7774
    7875            //! Returns the path to the root folder as boost::filesystem::path
     
    8279            static const boost::filesystem::path& getExecutablePath()
    8380                { return getInstance().executablePath_; }
    84             //! Returns the path to the data files as boost::filesystem::path
    85             static const boost::filesystem::path& getDataPath()
    86                 { return getInstance().dataPath_; }
    87             //! Returns the path to the external data files as boost::filesystem::path
    88             static const boost::filesystem::path& getExternalDataPath()
    89                 { return getInstance().externalDataPath_; }
    90             //! Returns the path to the config files as boost::filesystem::path
    91             static const boost::filesystem::path& getConfigPath()
    92                 { return getInstance().configPath_; }
    93             //! Returns the path to the log files as boost::filesystem::path
    94             static const boost::filesystem::path& getLogPath()
    95                 { return getInstance().logPath_; }
    9681            //! Returns the path to the modules as boost::filesystem::path
    9782            static const boost::filesystem::path& getModulePath()
     
    10287            //! Returns the path to the executable folder as std::string
    10388            static std::string getExecutablePathString();
    104             //! Returns the path to the data files as std::string
    105             static std::string getDataPathString();
    106             //! Returns the path to the external data files as std::string
    107             static std::string getExternalDataPathString();
    108             //! Returns the path to the config files as std::string
    109             static std::string getConfigPathString(); //tolua_export
    110             //! Returns the path to the log files as std::string
    111             static std::string getLogPathString();
    11289            //! Returns the path to the modules as std::string
    11390            static std::string getModulePathString();
     
    11693            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
    11794
    118         private:
    119             PathConfig(const PathConfig&); //!< Don't use (undefined symbol)
    120 
    121             /**
    122             @brief
    123                 Sets config, log and media path and creates the folders if necessary.
    124             @throws
    125                 GeneralException
    126             */
    127             void setConfigurablePaths();
    12895            //! Returns a list with all modules declared by a *.module file in the module folder.
    12996            std::vector<std::string> getModulePaths();
     97
     98        private:
     99            ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol)
    130100
    131101            //! Path to the parent directory of the ones above if program was installed with relative paths
     
    133103            boost::filesystem::path& executablePath_;        //!< Path to the executable
    134104            boost::filesystem::path& modulePath_;            //!< Path to the modules
    135             boost::filesystem::path& dataPath_;              //!< Path to the data files folder
    136             boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
    137             boost::filesystem::path& configPath_;            //!< Path to the config files folder
    138             boost::filesystem::path& logPath_;               //!< Path to the log files folder
    139105
    140106            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
    141             static PathConfig* singletonPtr_s;
     107            static ApplicationPaths* singletonPtr_s;
    142108    }; //tolua_export
    143109} //tolua_export
    144110
    145 #endif /* _PathConfig_H__ */
     111#endif /* _ApplicationPaths_H__ */
  • code/branches/core7/src/libraries/core/CMakeLists.txt

    r10479 r10509  
    5555  command/ArgumentCompletionFunctions.cc
    5656  config/ConfigFile.cc
    57   PathConfig.cc
     57  ApplicationPaths.cc
     58  Configurablepaths.cc
    5859END_BUILD_UNIT
    5960
     
    8485    command/CommandExecutor.h
    8586    config/SettingsConfigFile.h
     87    ApplicationPaths.h
     88    ConfigurablePaths.h
    8689    Game.h
    8790    GameMode.h
     
    9093    Loader.h
    9194    LuaState.h
    92     PathConfig.h
    9395    input/InputManager.h
    9496    input/KeyBinder.h
  • code/branches/core7/src/libraries/core/ConfigurablePaths.cc

    r10457 r10509  
    2727 */
    2828
    29 #include "PathConfig.h"
     29#include "ConfigurablePaths.h"
    3030
    3131#include <cassert>
     
    5757// Differentiate Boost Filesystem v2 and v3
    5858#if (BOOST_FILESYSTEM_VERSION < 3)
    59 #  define BF_LEAF leaf
    6059#  define BF_GENERIC_STRING string
    61 #  define BF_NATIVE_STRING file_string
    6260#else
    63 #  define BF_LEAF path().filename().string
    6461#  define BF_GENERIC_STRING generic_string
    65 #  define BF_NATIVE_STRING string
    6662#endif
    6763
     
    7167
    7268    //! Static pointer to the singleton
    73     PathConfig* PathConfig::singletonPtr_s  = 0;
     69    ConfigurablePaths* ConfigurablePaths::singletonPtr_s  = 0;
    7470
    7571    SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
    7672    SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
    7773
    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()))
    8376        , externalDataPath_(*(new bf::path()))
    8477        , configPath_(*(new bf::path()))
    8578        , logPath_(*(new bf::path()))
    86         , bBuildDirectoryRun_(false)
    8779    {
    88         //////////////////////////
    89         // FIND EXECUTABLE PATH //
    90         //////////////////////////
    91 
    92 #ifdef ORXONOX_PLATFORM_WINDOWS
    93         // get executable module
    94         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 sure
    112                what the proper response is here.
    113                Since it really is an assert-like condition, aborting the
    114                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 #endif
    129 
    130         // Remove executable filename
    131         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         else
    144         {
    145 
    146 #ifdef INSTALL_COPYABLE // --> relative paths
    147 
    148             // Also set the root path
    149             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 well
    157             modulePath_ = rootPath_ / specialConfig::defaultModulePath;
    158 
    159 #else
    160 
    161             // There is no root path, so don't set it at all
    162             // Module path is fixed as well
    163             modulePath_ = specialConfig::moduleInstallDirectory;
    164 
    165 #endif
    166         }
    16780    }
    16881
    169     PathConfig::~PathConfig()
     82    ConfigurablePaths::~ConfigurablePaths()
    17083    {
    171         delete &rootPath_;
    172         delete &executablePath_;
    173         delete &modulePath_;
    17484        delete &dataPath_;
    17585        delete &externalDataPath_;
     
    17888    }
    17989
    180     void PathConfig::setConfigurablePaths()
     90    void ConfigurablePaths::setConfigurablePaths(const ApplicationPaths& applicationPaths)
    18191    {
    182         if (bBuildDirectoryRun_)
     92        if (applicationPaths.buildDirectoryRun())
    18393        {
    18494            dataPath_         = specialConfig::dataDevDirectory;
     
    198108
    199109            // 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;
    203113
    204114#else
     
    252162    }
    253163
    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()
    301165    {
    302166        return getInstance().dataPath_.BF_GENERIC_STRING() + '/';
    303167    }
    304168
    305     /*static*/ std::string PathConfig::getExternalDataPathString()
     169    /*static*/ std::string ConfigurablePaths::getExternalDataPathString()
    306170    {
    307171        return getInstance().externalDataPath_.BF_GENERIC_STRING() + '/';
    308172    }
    309173
    310     /*static*/ std::string PathConfig::getConfigPathString()
     174    /*static*/ std::string ConfigurablePaths::getConfigPathString()
    311175    {
    312176        return getInstance().configPath_.BF_GENERIC_STRING() + '/';
    313177    }
    314178
    315     /*static*/ std::string PathConfig::getLogPathString()
     179    /*static*/ std::string ConfigurablePaths::getLogPathString()
    316180    {
    317181        return getInstance().logPath_.BF_GENERIC_STRING() + '/';
    318182    }
    319 
    320     /*static*/ std::string PathConfig::getModulePathString()
    321     {
    322         return getInstance().modulePath_.BF_GENERIC_STRING() + '/';
    323     }
    324183}
  • code/branches/core7/src/libraries/core/ConfigurablePaths.h

    r10457 r10509  
    3232*/
    3333
    34 #ifndef _PathConfig_H__
    35 #define _PathConfig_H__
     34#ifndef _ConfigurablePaths_H__
     35#define _ConfigurablePaths_H__
    3636
    3737#include "CorePrereqs.h"
    3838
    3939#include <string>
    40 #include <vector>
    4140#include "util/Singleton.h"
    4241
     
    4746    /**
    4847    @brief
    49         The PathConfig class is a singleton used to configure different paths.
     48        The ConfigurablePaths class is a singleton used to configure different paths.
    5049    @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.
    5451    @remarks
    5552        Not all paths are always available:
    56         - root only when installed copyable
    5753        - externalData only for development builds in the build tree
    5854    */
    59     class _CoreExport PathConfig //tolua_export
    60         : public Singleton<PathConfig>
     55    class _CoreExport ConfigurablePaths //tolua_export
     56        : public Singleton<ConfigurablePaths>
    6157    { //tolua_export
    62         friend class Singleton<PathConfig>;
    63         friend class Core;
     58        friend class Singleton<ConfigurablePaths>;
    6459
    6560        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();
    7763
    78             //! Returns the path to the root folder as boost::filesystem::path
    79             static const boost::filesystem::path& getRootPath()
    80                 { return getInstance().rootPath_; }
    81             //! Returns the path to the executable folder as boost::filesystem::path
    82             static const boost::filesystem::path& getExecutablePath()
    83                 { return getInstance().executablePath_; }
    8464            //! Returns the path to the data files as boost::filesystem::path
    8565            static const boost::filesystem::path& getDataPath()
     
    9474            static const boost::filesystem::path& getLogPath()
    9575                { return getInstance().logPath_; }
    96             //! Returns the path to the modules as boost::filesystem::path
    97             static const boost::filesystem::path& getModulePath()
    98                 { return getInstance().modulePath_; }
    9976
    100             //! Returns the path to the root folder as std::string
    101             static std::string getRootPathString();
    102             //! Returns the path to the executable folder as std::string
    103             static std::string getExecutablePathString();
    10477            //! Returns the path to the data files as std::string
    10578            static std::string getDataPathString();
     
    11083            //! Returns the path to the log files as std::string
    11184            static std::string getLogPathString();
    112             //! Returns the path to the modules as std::string
    113             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)
    12085
    12186            /**
     
    12590                GeneralException
    12691            */
    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);
    13093
    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
    13597            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
    13698            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
     
    138100            boost::filesystem::path& logPath_;               //!< Path to the log files folder
    139101
    140             bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
    141             static PathConfig* singletonPtr_s;
     102            static ConfigurablePaths* singletonPtr_s;
    142103    }; //tolua_export
    143104} //tolua_export
    144105
    145 #endif /* _PathConfig_H__ */
     106#endif /* _ConfigurablePaths_H__ */
  • code/branches/core7/src/libraries/core/Core.cc

    r10484 r10509  
    5959#include "core/singleton/ScopedSingletonIncludes.h"
    6060#include "util/SignalHandler.h"
    61 #include "PathConfig.h"
     61#include "ApplicationPaths.h"
     62#include "ConfigurablePaths.h"
    6263#include "commandline/CommandLineIncludes.h"
    6364#include "config/ConfigFileManager.h"
     
    9495
    9596    Core::Core(const std::string& cmdLine)
    96         : pathConfig_(NULL)
     97        : applicationPaths_(NULL)
     98        , configurablePaths_(NULL)
    9799        , dynLibManager_(NULL)
    98100        , signalHandler_(NULL)
     
    115117
    116118        // Set the hard coded fixed paths
    117         this->pathConfig_ = new PathConfig();
     119        this->applicationPaths_ = new ApplicationPaths();
    118120
    119121        // Create a new dynamic library manager
     
    122124        // Load modules
    123125        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();
    125127        for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
    126128        {
     
    146148
    147149        // 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
    159163        // This call is placed as soon as possible, but after the directories are set
    160164        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");
    162166
    163167#ifdef ORXONOX_PLATFORM_WINDOWS
     
    186190
    187191        // 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());
    189193
    190194#if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
     
    209213
    210214        // initialise Tcl
    211         this->tclBind_ = new TclBind(PathConfig::getDataPathString());
     215        this->tclBind_ = new TclBind(ConfigurablePaths::getDataPathString());
    212216        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
    213217
     
    255259        safeObjectDelete(&signalHandler_);
    256260        safeObjectDelete(&dynLibManager_);
    257         safeObjectDelete(&pathConfig_);
     261        safeObjectDelete(&configurablePaths_);
     262        safeObjectDelete(&applicationPaths_);
    258263
    259264        orxout(internal_status) << "finished destroying Core object" << endl;
  • code/branches/core7/src/libraries/core/Core.h

    r10479 r10509  
    9191            void setThreadAffinity(int limitToCPU);
    9292
    93             PathConfig*               pathConfig_;
     93            ApplicationPaths*         applicationPaths_;
     94            ConfigurablePaths*        configurablePaths_;
    9495            DynLibManager*            dynLibManager_;
    9596            SignalHandler*            signalHandler_;
  • code/branches/core7/src/libraries/core/CoreConfig.cc

    r10480 r10509  
    3434#include "core/config/ConfigValueIncludes.h"
    3535#include "core/Language.h"
    36 #include "core/PathConfig.h"
     36#include "core/ApplicationPaths.h"
    3737
    3838namespace orxonox
     
    7272            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);
    7373
    74         SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
     74        SetConfigValue(bDevMode_, ApplicationPaths::buildDirectoryRun())
    7575            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
    7676            .callback(this, &CoreConfig::devModeChanged);
  • code/branches/core7/src/libraries/core/CorePrereqs.h

    r10479 r10509  
    132132    T orxonox_cast(U*);
    133133
     134    class ApplicationPaths;
    134135    class BaseObject;
    135136    template <class T>
     
    152153    class ConfigFileSection;
    153154    class Configurable;
     155    class ConfigurablePaths;
    154156    class ConfigValueContainer;
    155157    class Context;
     
    196198    class OrxonoxClass;
    197199    class OrxonoxInterface;
    198     class PathConfig;
    199200    struct ResourceInfo;
    200201    template <ScopeID::Value>
  • code/branches/core7/src/libraries/core/GUIManager.cc

    r10479 r10509  
    106106#include "GraphicsManager.h"
    107107#include "LuaState.h"
    108 #include "PathConfig.h"
     108#include "ConfigurablePaths.h"
    109109#include "Resource.h"
    110110#include "command/ConsoleCommandIncludes.h"
     
    331331        // Create our own logger to specify the filepath
    332332        std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
    333         ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log");
     333        ceguiLogger->setLogFilename(ConfigurablePaths::getLogPathString() + "cegui.log");
    334334        ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
    335335        this->ceguiLogger_ = ceguiLogger.release();
  • code/branches/core7/src/libraries/core/GraphicsManager.cc

    r10508 r10509  
    5959#include "GUIManager.h"
    6060#include "Loader.h"
    61 #include "PathConfig.h"
     61#include "ApplicationPaths.h"
     62#include "ConfigurablePaths.h"
    6263#include "ViewportEventListener.h"
    6364#include "WindowEventListener.h"
     
    113114
    114115        // 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");
    116117        // Load resources
    117118        resources_.reset(new XMLFile("DefaultResources.oxr"));
     
    120121
    121122        // 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");
    124125
    125126        extResources_.reset(new XMLFile("resources.oxr"));
     
    220221        }
    221222
    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_);
    224225
    225226        // create a new logManager
     
    260261        std::string pluginPath = specialConfig::ogrePluginsDirectory;
    261262#ifdef DEPENDENCY_PACKAGE_ENABLE
    262         if (!PathConfig::buildDirectoryRun())
     263        if (!ApplicationPaths::buildDirectoryRun())
    263264        {
    264265#  if defined(ORXONOX_PLATFORM_WINDOWS)
    265             pluginPath = PathConfig::getExecutablePathString();
     266            pluginPath = ApplicationPaths::getExecutablePathString();
    266267#  elif defined(ORXONOX_PLATFORM_APPLE)
    267268            // TODO: Where are the plugins being installed to?
    268             pluginPath = PathConfig::getExecutablePathString();
     269            pluginPath = ApplicationPaths::getExecutablePathString();
    269270#  endif
    270271        }
     
    559560    {
    560561        assert(this->renderWindow_);
    561         this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".png");
     562        this->renderWindow_->writeContentsToTimestampedFile(ConfigurablePaths::getLogPathString() + "screenShot_", ".png");
    562563    }
    563564}
  • code/branches/core7/src/libraries/core/Language.cc

    r10480 r10509  
    3737#include "util/Output.h"
    3838#include "util/StringUtils.h"
    39 #include "PathConfig.h"
     39#include "ConfigurablePaths.h"
    4040
    4141namespace orxonox
     
    202202        orxout(internal_info, context::language) << "Read default language file." << endl;
    203203
    204         const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
     204        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_);
    205205
    206206        // This creates the file if it's not existing
     
    252252        orxout(internal_info, context::language) << "Read translated language file (" << language << ")." << endl;
    253253
    254         const std::string& filepath = PathConfig::getConfigPathString() + getFilename(language);
     254        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(language);
    255255
    256256        // Open the file
     
    305305        orxout(verbose, context::language) << "Write default language file." << endl;
    306306
    307         const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
     307        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_);
    308308
    309309        // Open the file
  • code/branches/core7/src/libraries/core/command/Shell.cc

    r9667 r10509  
    4242#include "core/config/ConfigFileManager.h"
    4343#include "core/config/ConfigValueIncludes.h"
    44 #include "core/PathConfig.h"
     44#include "core/ApplicationPaths.h"
    4545#include "core/input/InputBuffer.h"
    4646#include "CommandExecutor.h"
     
    8484
    8585        // 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);
    8787        this->setLevelMax(defaultDebugLevel);
    8888
     
    164164    void Shell::devModeChanged(bool value)
    165165    {
    166         bool isNormal = (value == PathConfig::buildDirectoryRun());
     166        bool isNormal = (value == ApplicationPaths::buildDirectoryRun());
    167167        if (isNormal)
    168168        {
  • code/branches/core7/src/libraries/core/command/TclBind.cc

    r10347 r10509  
    3737#include "util/Exception.h"
    3838#include "util/StringUtils.h"
    39 #include "core/PathConfig.h"
     39#include "core/ApplicationPaths.h"
    4040#include "CommandExecutor.h"
    4141#include "ConsoleCommandIncludes.h"
     
    143143    {
    144144#ifdef DEPENDENCY_PACKAGE_ENABLE
    145         if (PathConfig::buildDirectoryRun())
     145        if (ApplicationPaths::buildDirectoryRun())
    146146            return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl");
    147147        else
    148             return (PathConfig::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");
     148            return (ApplicationPaths::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");
    149149#else
    150150        return "";
  • code/branches/core7/src/libraries/core/commandline/CommandLineParser.cc

    r10404 r10509  
    3737#include "util/StringUtils.h"
    3838#include "util/SubString.h"
    39 #include "core/PathConfig.h"
    4039
    4140namespace orxonox
  • code/branches/core7/src/libraries/core/config/ConfigFile.cc

    r9559 r10509  
    3838#include "util/Convert.h"
    3939#include "util/StringUtils.h"
    40 #include "core/PathConfig.h"
     40#include "core/ConfigurablePaths.h"
    4141#include "ConfigFileEntryComment.h"
    4242#include "ConfigFileEntryValue.h"
     
    8181        if (!filepath.is_complete())
    8282        {
    83             filepath = PathConfig::getConfigPath() / filepath;
     83            filepath = ConfigurablePaths::getConfigPath() / filepath;
    8484            if (this->bCopyFallbackFile_)
    8585            {
     
    8787                if (!boost::filesystem::exists(filepath))
    8888                {
    89                     boost::filesystem::path defaultFilepath(PathConfig::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);
     89                    boost::filesystem::path defaultFilepath(ConfigurablePaths::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);
    9090                    if (boost::filesystem::exists(defaultFilepath))
    9191                    {
     
    216216        boost::filesystem::path filepath(filename);
    217217        if (!filepath.is_complete())
    218             filepath = PathConfig::getConfigPath() / filename;
     218            filepath = ConfigurablePaths::getConfigPath() / filename;
    219219        std::ofstream file;
    220220        file.open(filepath.string().c_str(), std::fstream::out);
  • code/branches/core7/src/libraries/core/input/KeyBinder.cc

    r10380 r10509  
    3737#include "core/config/ConfigValueIncludes.h"
    3838#include "core/config/ConfigFile.h"
    39 #include "core/PathConfig.h"
     39#include "core/ApplicationPaths.h"
     40#include "core/ConfigurablePaths.h"
    4041#include "InputCommands.h"
    4142#include "JoyStick.h"
     
    255256        orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl;
    256257
    257         this->configFile_ = new ConfigFile(this->filename_, !PathConfig::buildDirectoryRun());
     258        this->configFile_ = new ConfigFile(this->filename_, !ApplicationPaths::buildDirectoryRun());
    258259        this->configFile_->load();
    259260
    260         if (PathConfig::buildDirectoryRun())
     261        if (ApplicationPaths::buildDirectoryRun())
    261262        {
    262263            // 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_);
    264265            std::ifstream file(defaultFilepath.c_str());
    265266            if (file.is_open())
     
    289290            addButtonToCommand(binding, it->second);
    290291            std::string str = binding;
    291             if (PathConfig::buildDirectoryRun() && binding.empty())
     292            if (ApplicationPaths::buildDirectoryRun() && binding.empty())
    292293                str = "NoBinding";
    293294            it->second->setBinding(this->configFile_, this->fallbackConfigFile_, binding, bTemporary);
  • code/branches/core7/src/libraries/tools/ResourceLocation.cc

    r9667 r10509  
    3535#include "util/Exception.h"
    3636#include "core/CoreIncludes.h"
    37 #include "core/PathConfig.h"
     37#include "core/ApplicationPaths.h"
     38#include "core/ConfigurablePaths.h"
    3839#include "core/XMLFile.h"
    3940#include "core/XMLPort.h"
     
    7475        namespace bf = boost::filesystem;
    7576        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();
    8081        else
    8182        {
Note: See TracChangeset for help on using the changeset viewer.