Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 23, 2009, 8:57:42 PM (15 years ago)
Author:
rgrieder
Message:
  • Moved def_keybindings to media repository in folder defaultConfig
  • If you have a better name for that folder, you're welcome
  • the "def_" prefix has been removed
  • ConfigFileManager now looks for a file in media/defaultConfig with the same name if the config file does not exist yet
  • No file gets written while only loading
  • Removed hacky GCC 3 warning code for each library and instead just put "Wno-sign-compare" to the GCC 3 flags (that will remove all boost::filesystem warnings)
  • ogre.cfg still remains on tardis for the development build (not install though)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/buildsystem3/src/core/Core.cc

    r2685 r2690  
    3434#include "Core.h"
    3535#include <cassert>
     36#include <fstream>
     37#include <boost/filesystem.hpp>
     38
     39#include "util/Exception.h"
    3640#include "Language.h"
    3741#include "CoreIncludes.h"
     
    5155    std::string Core::configPath_s(ORXONOX_CONFIG_INSTALL_PATH); // from OrxonoxConfig.h
    5256    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
    5358
    5459    Core* Core::singletonRef_s = 0;
     
    119124            defaultMediaPath = ORXONOX_MEDIA_DEV_PATH;
    120125
    121         SetConfigValue(mediaPath_, defaultMediaPath)
     126        SetConfigValue(mediaPath_s, defaultMediaPath)
    122127            .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged);
    123128
     
    157162    void Core::mediaPathChanged()
    158163    {
    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, "/");
    167172            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
    168173        }
     
    245250        if (*path.end() != '/' && *path.end() != '\\')
    246251        {
    247             ModifyConfigValue(mediaPath_, tset, path + "/");
     252            ModifyConfigValue(mediaPath_s, tset, path + "/");
    248253        }
    249254        else
    250255        {
    251             ModifyConfigValue(mediaPath_, tset, path);
     256            ModifyConfigValue(mediaPath_s, tset, path);
    252257        }
    253258    }
     
    264269    }
    265270
    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        }
    274318    }
    275319}
Note: See TracChangeset for help on using the changeset viewer.