Merge remote branch 'lgro/config' into config
Conflicts: components/files/path.hppactorid
commit
27caee664e
@ -1,157 +0,0 @@
|
||||
#include "configurationmanager.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace Cfg
|
||||
{
|
||||
|
||||
static const char* const openmwCfgFile = "openmw.cfg";
|
||||
static const char* const ogreCfgFile = "ogre.cfg";
|
||||
static const char* const pluginsCfgFile = "plugins.cfg";
|
||||
|
||||
|
||||
ConfigurationManager::ConfigurationManager()
|
||||
: mPath("openmw")
|
||||
{
|
||||
/**
|
||||
* According to task #168 plugins.cfg file shall be located in global
|
||||
* configuration path or in runtime configuration path.
|
||||
*/
|
||||
mPluginsCfgPath = mPath.getGlobalConfigPath() / pluginsCfgFile;
|
||||
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
||||
{
|
||||
mPluginsCfgPath = mPath.getRuntimeConfigPath() / pluginsCfgFile;
|
||||
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
||||
{
|
||||
std::cerr << "Failed to find " << pluginsCfgFile << " file!" << std::endl;
|
||||
mPluginsCfgPath.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* According to task #168 ogre.cfg file shall be located only
|
||||
* in user configuration path.
|
||||
*/
|
||||
mOgreCfgPath = mPath.getLocalConfigPath() / ogreCfgFile;
|
||||
|
||||
mLogPath = mPath.getLocalConfigPath();
|
||||
}
|
||||
|
||||
ConfigurationManager::~ConfigurationManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ConfigurationManager::readConfiguration(boost::program_options::variables_map& variables,
|
||||
boost::program_options::options_description& description)
|
||||
{
|
||||
loadConfig(mPath.getLocalConfigPath(), variables, description);
|
||||
boost::program_options::notify(variables);
|
||||
loadConfig(mPath.getRuntimeConfigPath(), variables, description);
|
||||
boost::program_options::notify(variables);
|
||||
loadConfig(mPath.getGlobalConfigPath(), variables, description);
|
||||
boost::program_options::notify(variables);
|
||||
}
|
||||
|
||||
void ConfigurationManager::loadConfig(const boost::filesystem::path& path,
|
||||
boost::program_options::variables_map& variables,
|
||||
boost::program_options::options_description& description)
|
||||
{
|
||||
boost::filesystem::path cfgFile(path);
|
||||
cfgFile /= std::string(openmwCfgFile);
|
||||
if (boost::filesystem::is_regular_file(cfgFile))
|
||||
{
|
||||
std::cout << "Loading config file: " << cfgFile.string() << "... ";
|
||||
|
||||
std::ifstream configFileStream(cfgFile.string().c_str());
|
||||
if (configFileStream.is_open())
|
||||
{
|
||||
boost::program_options::store(boost::program_options::parse_config_file(
|
||||
configFileStream, description), variables);
|
||||
|
||||
std::cout << "done." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "failed." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getGlobalConfigPath() const
|
||||
{
|
||||
return mPath.getGlobalConfigPath();
|
||||
}
|
||||
|
||||
void ConfigurationManager::setGlobalConfigPath(const boost::filesystem::path& newPath)
|
||||
{
|
||||
mPath.setGlobalConfigPath(newPath);
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getLocalConfigPath() const
|
||||
{
|
||||
return mPath.getLocalConfigPath();
|
||||
}
|
||||
|
||||
void ConfigurationManager::setLocalConfigPath(const boost::filesystem::path& newPath)
|
||||
{
|
||||
mPath.setLocalConfigPath(newPath);
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getRuntimeConfigPath() const
|
||||
{
|
||||
return mPath.getRuntimeConfigPath();
|
||||
}
|
||||
|
||||
void ConfigurationManager::setRuntimeConfigPath(const boost::filesystem::path& newPath)
|
||||
{
|
||||
mPath.setRuntimeConfigPath(newPath);
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getGlobalDataPath() const
|
||||
{
|
||||
return mPath.getGlobalDataPath();
|
||||
}
|
||||
|
||||
void ConfigurationManager::setGlobalDataPath(const boost::filesystem::path& newPath)
|
||||
{
|
||||
mPath.setGlobalDataPath(newPath);
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getLocalDataPath() const
|
||||
{
|
||||
return mPath.getLocalDataPath();
|
||||
}
|
||||
|
||||
void ConfigurationManager::setLocalDataPath(const boost::filesystem::path& newPath)
|
||||
{
|
||||
mPath.setLocalDataPath(newPath);
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getRuntimeDataPath() const
|
||||
{
|
||||
return mPath.getRuntimeDataPath();
|
||||
}
|
||||
|
||||
void ConfigurationManager::setRuntimeDataPath(const boost::filesystem::path& newPath)
|
||||
{
|
||||
mPath.setRuntimeDataPath(newPath);
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getOgreConfigPath() const
|
||||
{
|
||||
return mOgreCfgPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getPluginsConfigPath() const
|
||||
{
|
||||
return mPluginsCfgPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getLogPath() const
|
||||
{
|
||||
return mLogPath;
|
||||
}
|
||||
|
||||
} /* namespace Cfg */
|
@ -0,0 +1,194 @@
|
||||
#include "configurationmanager.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Files
|
||||
{
|
||||
|
||||
static const char* const openmwCfgFile = "openmw.cfg";
|
||||
static const char* const ogreCfgFile = "ogre.cfg";
|
||||
static const char* const pluginsCfgFile = "plugins.cfg";
|
||||
|
||||
const char* const mwToken = "?mw?";
|
||||
const char* const localToken = "?local?";
|
||||
const char* const userToken = "?user?";
|
||||
const char* const globalToken = "?global?";
|
||||
|
||||
ConfigurationManager::ConfigurationManager()
|
||||
: mFixedPath("openmw")
|
||||
{
|
||||
setupTokensMapping();
|
||||
|
||||
/**
|
||||
* According to task #168 plugins.cfg file shall be located in global
|
||||
* configuration path or in local configuration path.
|
||||
*/
|
||||
mPluginsCfgPath = mFixedPath.getGlobalPath() / pluginsCfgFile;
|
||||
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
||||
{
|
||||
mPluginsCfgPath = mFixedPath.getLocalPath() / pluginsCfgFile;
|
||||
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
||||
{
|
||||
std::cerr << "Failed to find " << pluginsCfgFile << " file!" << std::endl;
|
||||
mPluginsCfgPath.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* According to task #168 ogre.cfg file shall be located only
|
||||
* in user configuration path.
|
||||
*/
|
||||
mOgreCfgPath = mFixedPath.getUserPath() / ogreCfgFile;
|
||||
|
||||
/**
|
||||
* FIXME: Logs shoudn't be stored in the same dir where configuration is placed.
|
||||
*/
|
||||
mLogPath = mFixedPath.getUserPath();
|
||||
}
|
||||
|
||||
ConfigurationManager::~ConfigurationManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ConfigurationManager::setupTokensMapping()
|
||||
{
|
||||
mTokensMapping.insert(std::make_pair(mwToken, &FixedPath<>::getInstallPath));
|
||||
mTokensMapping.insert(std::make_pair(localToken, &FixedPath<>::getLocalDataPath));
|
||||
mTokensMapping.insert(std::make_pair(userToken, &FixedPath<>::getUserDataPath));
|
||||
mTokensMapping.insert(std::make_pair(globalToken, &FixedPath<>::getGlobalDataPath));
|
||||
}
|
||||
|
||||
void ConfigurationManager::readConfiguration(boost::program_options::variables_map& variables,
|
||||
boost::program_options::options_description& description)
|
||||
{
|
||||
loadConfig(mFixedPath.getUserPath(), variables, description);
|
||||
boost::program_options::notify(variables);
|
||||
|
||||
loadConfig(mFixedPath.getLocalPath(), variables, description);
|
||||
boost::program_options::notify(variables);
|
||||
loadConfig(mFixedPath.getGlobalPath(), variables, description);
|
||||
boost::program_options::notify(variables);
|
||||
|
||||
}
|
||||
|
||||
struct EmptyPath : public std::unary_function<const boost::filesystem::path&, bool>
|
||||
{
|
||||
bool operator()(const boost::filesystem::path& path) const
|
||||
{
|
||||
return path.empty();
|
||||
}
|
||||
};
|
||||
|
||||
void ConfigurationManager::processPaths(Files::PathContainer& dataDirs)
|
||||
{
|
||||
for (Files::PathContainer::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it)
|
||||
{
|
||||
const std::string& path = it->string();
|
||||
|
||||
// Check if path contains a token
|
||||
if (!path.empty() && *path.begin() == '?' && *path.rbegin() == '?')
|
||||
{
|
||||
TokensMappingContainer::iterator tokenIt = mTokensMapping.find(path);
|
||||
if (tokenIt != mTokensMapping.end())
|
||||
{
|
||||
boost::filesystem::path tempPath(((mFixedPath).*(tokenIt->second))());
|
||||
|
||||
if (boost::filesystem::is_directory(tempPath))
|
||||
{
|
||||
(*it) = tempPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it).clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clean invalid / unknown token, it will be removed outside the loop
|
||||
(*it).clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataDirs.erase(std::remove_if(dataDirs.begin(), dataDirs.end(), EmptyPath()), dataDirs.end());
|
||||
}
|
||||
|
||||
void ConfigurationManager::loadConfig(const boost::filesystem::path& path,
|
||||
boost::program_options::variables_map& variables,
|
||||
boost::program_options::options_description& description)
|
||||
{
|
||||
boost::filesystem::path cfgFile(path);
|
||||
cfgFile /= std::string(openmwCfgFile);
|
||||
if (boost::filesystem::is_regular_file(cfgFile))
|
||||
{
|
||||
std::cout << "Loading config file: " << cfgFile.string() << "... ";
|
||||
|
||||
std::ifstream configFileStream(cfgFile.string().c_str());
|
||||
if (configFileStream.is_open())
|
||||
{
|
||||
boost::program_options::store(boost::program_options::parse_config_file(
|
||||
configFileStream, description), variables);
|
||||
|
||||
std::cout << "done." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "failed." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getGlobalPath() const
|
||||
{
|
||||
return mFixedPath.getGlobalPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getUserPath() const
|
||||
{
|
||||
return mFixedPath.getUserPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getLocalPath() const
|
||||
{
|
||||
return mFixedPath.getLocalPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getGlobalDataPath() const
|
||||
{
|
||||
return mFixedPath.getGlobalDataPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getUserDataPath() const
|
||||
{
|
||||
return mFixedPath.getUserDataPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getLocalDataPath() const
|
||||
{
|
||||
return mFixedPath.getLocalDataPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getInstallPath() const
|
||||
{
|
||||
return mFixedPath.getInstallPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getOgreConfigPath() const
|
||||
{
|
||||
return mOgreCfgPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getPluginsConfigPath() const
|
||||
{
|
||||
return mPluginsCfgPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getLogPath() const
|
||||
{
|
||||
return mLogPath;
|
||||
}
|
||||
|
||||
} /* namespace Cfg */
|
@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
|
||||
* engine implementation.
|
||||
*
|
||||
* Copyright (C) 2011 Open Morrowind Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file components/files/fixedpath.hpp */
|
||||
|
||||
#ifndef COMPONENTS_FILES_FIXEDPATH_HPP
|
||||
#define COMPONENTS_FILES_FIXEDPATH_HPP
|
||||
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
#include <components/files/linuxpath.hpp>
|
||||
namespace Files { typedef LinuxPath TargetPathType; }
|
||||
|
||||
#elif defined(__WIN32) || defined(__WINDOWS__)
|
||||
#include <components/files/windowspath.hpp>
|
||||
namespace Files { typedef WindowsPath TargetPathType; }
|
||||
|
||||
#elif defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)
|
||||
#include <components/files/macospath.hpp>
|
||||
namespace Files { typedef MacOsPath TargetPathType; }
|
||||
|
||||
#else
|
||||
#error "Unknown platform!"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \namespace Files
|
||||
*/
|
||||
namespace Files
|
||||
{
|
||||
|
||||
/**
|
||||
* \struct Path
|
||||
*
|
||||
* \tparam P - Path strategy class type (depends on target system)
|
||||
*
|
||||
*/
|
||||
template
|
||||
<
|
||||
class P = TargetPathType
|
||||
>
|
||||
struct FixedPath
|
||||
{
|
||||
typedef P PathType;
|
||||
|
||||
/**
|
||||
* \brief Path constructor.
|
||||
*
|
||||
* \param [in] application_name - Name of the application
|
||||
*/
|
||||
FixedPath(const std::string& application_name)
|
||||
: mPath()
|
||||
, mUserPath(mPath.getUserPath())
|
||||
, mGlobalPath(mPath.getGlobalPath())
|
||||
, mLocalPath(mPath.getLocalPath())
|
||||
, mUserDataPath(mPath.getUserDataPath())
|
||||
, mGlobalDataPath(mPath.getGlobalDataPath())
|
||||
, mLocalDataPath(mPath.getLocalDataPath())
|
||||
, mInstallPath(mPath.getInstallPath())
|
||||
{
|
||||
if (!application_name.empty())
|
||||
{
|
||||
boost::filesystem::path suffix(application_name + std::string("/"));
|
||||
|
||||
mUserPath /= suffix;
|
||||
mGlobalPath /= suffix;
|
||||
|
||||
mLocalDataPath /= suffix;
|
||||
mGlobalDataPath /= suffix;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the user local configuration directory.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getUserPath() const
|
||||
{
|
||||
return mUserPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the global (system) configuration directory.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getGlobalPath() const
|
||||
{
|
||||
return mGlobalPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the directory where application was started.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getLocalPath() const
|
||||
{
|
||||
return mLocalPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& getInstallPath() const
|
||||
{
|
||||
return mInstallPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& getGlobalDataPath() const
|
||||
{
|
||||
return mGlobalDataPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& getUserDataPath() const
|
||||
{
|
||||
return mUserDataPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& getLocalDataPath() const
|
||||
{
|
||||
return mLocalDataPath;
|
||||
}
|
||||
|
||||
private:
|
||||
PathType mPath;
|
||||
|
||||
boost::filesystem::path mUserPath; /**< User path */
|
||||
boost::filesystem::path mGlobalPath; /**< Global path */
|
||||
boost::filesystem::path mLocalPath; /**< It is the same directory where application was run */
|
||||
|
||||
boost::filesystem::path mUserDataPath; /**< User data path */
|
||||
boost::filesystem::path mGlobalDataPath; /**< Global application data path */
|
||||
boost::filesystem::path mLocalDataPath; /**< Local path to the configuration files.
|
||||
By default it is a 'data' directory in same
|
||||
directory where application was run */
|
||||
boost::filesystem::path mInstallPath;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} /* namespace Files */
|
||||
|
||||
#endif /* COMPONENTS_FILES_FIXEDPATH_HPP */
|
@ -1,232 +0,0 @@
|
||||
/**
|
||||
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
|
||||
* engine implementation.
|
||||
*
|
||||
* Copyright (C) 2011 Open Morrowind Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file components/files/path.hpp */
|
||||
|
||||
#ifndef COMPONENTS_FILES_PATH_HPP
|
||||
#define COMPONENTS_FILES_PATH_HPP
|
||||
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <components/files/linuxpath.hpp>
|
||||
namespace Files { typedef LinuxPath TargetPathType; }
|
||||
|
||||
#elif defined(__WIN32) || defined(__WINDOWS__) || defined (_WINDOWS)
|
||||
#include <components/files/windowspath.hpp>
|
||||
namespace Files { typedef WindowsPath TargetPathType; }
|
||||
|
||||
#elif defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)
|
||||
#include <components/files/macospath.hpp>
|
||||
namespace Files { typedef MacOsPath TargetPathType; }
|
||||
|
||||
#else
|
||||
#error "Unknown platform!"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \namespace Files
|
||||
*/
|
||||
namespace Files
|
||||
{
|
||||
|
||||
/**
|
||||
* \struct Path
|
||||
*
|
||||
* \tparam P - Path strategy class type (depends on target system)
|
||||
*
|
||||
*/
|
||||
template
|
||||
<
|
||||
class P = TargetPathType
|
||||
>
|
||||
struct Path
|
||||
{
|
||||
typedef P PathType;
|
||||
|
||||
/**
|
||||
* \brief Path constructor.
|
||||
*
|
||||
* \param [in] application_name - Name of the application
|
||||
*/
|
||||
Path(const std::string& application_name)
|
||||
: mPath()
|
||||
, mLocalConfigPath(mPath.getLocalConfigPath())
|
||||
, mGlobalConfigPath(mPath.getGlobalConfigPath())
|
||||
, mRuntimeConfigPath(mPath.getRuntimeConfigPath())
|
||||
, mLocalDataPath(mPath.getLocalDataPath())
|
||||
, mGlobalDataPath(mPath.getGlobalDataPath())
|
||||
, mRuntimeDataPath(mPath.getRuntimeDataPath())
|
||||
{
|
||||
if (!application_name.empty())
|
||||
{
|
||||
boost::filesystem::path suffix(application_name + std::string("/"));
|
||||
|
||||
mLocalConfigPath /= suffix;
|
||||
mGlobalConfigPath /= suffix;
|
||||
|
||||
mLocalDataPath /= suffix;
|
||||
mGlobalDataPath /= suffix;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the user local configuration directory.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getLocalConfigPath() const
|
||||
{
|
||||
return mLocalConfigPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets new local configuration path.
|
||||
*
|
||||
* \param [in] path - New path
|
||||
*/
|
||||
void setLocalConfigPath(const boost::filesystem::path& path)
|
||||
{
|
||||
mLocalConfigPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the global (system) configuration directory.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getGlobalConfigPath() const
|
||||
{
|
||||
return mGlobalConfigPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets new global configuration path.
|
||||
*
|
||||
* \param [in] path - New path
|
||||
*/
|
||||
void setGlobalConfigPath(const boost::filesystem::path& path)
|
||||
{
|
||||
mGlobalConfigPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the directory where application was started.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getRuntimeConfigPath() const
|
||||
{
|
||||
return mRuntimeConfigPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets new runtime configuration path.
|
||||
*
|
||||
* \param [in] path - New path
|
||||
*/
|
||||
void setRuntimeConfigPath(const boost::filesystem::path& path)
|
||||
{
|
||||
mRuntimeConfigPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the user local data directory.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getLocalDataPath() const
|
||||
{
|
||||
return mLocalDataPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets new local data path.
|
||||
*
|
||||
* \param [in] path - New path
|
||||
*/
|
||||
void setLocalDataPath(const boost::filesystem::path& path)
|
||||
{
|
||||
mLocalDataPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the global (system) data directory.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getGlobalDataPath() const
|
||||
{
|
||||
return mGlobalDataPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets new global (system) data directory.
|
||||
*
|
||||
* \param [in] path - New path
|
||||
*/
|
||||
void setGlobalDataPath(const boost::filesystem::path& path)
|
||||
{
|
||||
mGlobalDataPath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return path pointing to the directory where application was started.
|
||||
*
|
||||
* \return boost::filesystem::path
|
||||
*/
|
||||
const boost::filesystem::path& getRuntimeDataPath() const
|
||||
{
|
||||
return mRuntimeDataPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sets new runtime data directory.
|
||||
*
|
||||
* \param [in] path - New path
|
||||
*/
|
||||
void setRuntimeDataPath(const boost::filesystem::path& path)
|
||||
{
|
||||
mRuntimeDataPath = path;
|
||||
}
|
||||
|
||||
private:
|
||||
PathType mPath;
|
||||
|
||||
boost::filesystem::path mLocalConfigPath; /**< User local path to the configuration files */
|
||||
boost::filesystem::path mGlobalConfigPath; /**< Global path to the configuration files */
|
||||
boost::filesystem::path mRuntimeConfigPath; /**< Runtime path to the configuration files.
|
||||
By default it is the same directory where
|
||||
application was run */
|
||||
|
||||
boost::filesystem::path mLocalDataPath; /**< User local application data path (user plugins / mods / etc.) */
|
||||
boost::filesystem::path mGlobalDataPath; /**< Global application data path */
|
||||
boost::filesystem::path mRuntimeDataPath; /**< Runtime path to the configuration files.
|
||||
By default it is a 'data' directory in same
|
||||
directory where application was run */
|
||||
|
||||
};
|
||||
|
||||
|
||||
} /* namespace Files */
|
||||
|
||||
#endif /* COMPONENTS_FILES_PATH_HPP */
|
Loading…
Reference in New Issue