add new path values (configHome,cacheHome, etc) application config

This commit is contained in:
Björn Schramke 2014-10-09 17:48:42 +02:00 committed by Alex Fabijanic
parent b59329034f
commit b9259452a9
3 changed files with 25 additions and 1 deletions

View File

@ -369,6 +369,7 @@ private:
void getApplicationPath(Poco::Path& path) const;
void processOptions();
bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const;
bool findAppConfigFile(const Path& basePath,const std::string& appName, const std::string& extension, Poco::Path& path) const;
typedef Poco::AutoPtr<LayeredConfiguration> ConfigPtr;

View File

@ -166,6 +166,7 @@ void Application::init()
_pConfig->setString("application.dir", appPath.parent().toString());
_pConfig->setString("application.configDir", Path::configHome() + appPath.getBaseName() + Path::separator());
_pConfig->setString("application.cacheDir", Path::cacheHome() + appPath.getBaseName() + Path::separator());
_pConfig->setString("application.tempDir", Path::tempHome() + appPath.getBaseName() + Path::separator());
_pConfig->setString("application.dataDir", Path::dataHome() + appPath.getBaseName() + Path::separator());
processOptions();
}
@ -506,6 +507,29 @@ bool Application::findAppConfigFile(const std::string& appName, const std::strin
}
bool Application::findAppConfigFile(const Path& basePath, const std::string& appName, const std::string& extension, Path& path) const
{
poco_assert (!appName.empty());
Path p(basePath,appName);
p.setExtension(extension);
bool found = findFile(p);
if (!found)
{
#if defined(_DEBUG)
if (appName[appName.length() - 1] == 'd')
{
p.setBaseName(appName.substr(0, appName.length() - 1));
found = findFile(p);
}
#endif
}
if (found)
path = p;
return found;
}
void Application::defineOptions(OptionSet& options)
{
for (SubsystemVec::iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)

View File

@ -24,7 +24,6 @@
#endif
#include "Poco/Exception.h"
#include <cstdio>
#include "../../Foundation/include/Poco/Path.h"
using Poco::Environment;