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
parent ce56190f9f
commit 1aaa61f3c8
3 changed files with 28 additions and 2 deletions

View File

@ -366,6 +366,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<Subsystem> SubsystemPtr;
typedef std::vector<SubsystemPtr> SubsystemVec;

View File

@ -162,7 +162,10 @@ void Application::init()
_pConfig->setString("application.name", appPath.getFileName());
_pConfig->setString("application.baseName", appPath.getBaseName());
_pConfig->setString("application.dir", appPath.parent().toString());
_pConfig->setString("application.configDir", 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();
}
@ -482,6 +485,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

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