add some methods to Poco::Path for make it easy to follow XDG Base Directory Specification

This commit is contained in:
Björn Schramke
2014-10-09 09:46:21 +02:00
committed by Alex Fabijanic
parent 275275baa9
commit b59329034f
7 changed files with 96 additions and 50 deletions

View File

@@ -24,6 +24,7 @@
#endif
#include "Poco/Exception.h"
#include <cstdio>
#include "../../Foundation/include/Poco/Path.h"
using Poco::Environment;
@@ -44,7 +45,9 @@ const std::string SystemConfiguration::HOMEDIR = "system.homeDir";
const std::string SystemConfiguration::CONFIGHOMEDIR = "system.configHomeDir";
const std::string SystemConfiguration::CACHEHOMEDIR = "system.cacheHomeDir";
const std::string SystemConfiguration::DATAHOMEDIR = "system.dataHomeDir";
const std::string SystemConfiguration::TEMPHOMEDIR = "system.tempHomeDir";
const std::string SystemConfiguration::TEMPDIR = "system.tempDir";
const std::string SystemConfiguration::CONFIGDIR = "system.configDir";
const std::string SystemConfiguration::DATETIME = "system.dateTime";
#if !defined(POCO_VXWORKS)
const std::string SystemConfiguration::PID = "system.pid";
@@ -121,10 +124,19 @@ bool SystemConfiguration::getRaw(const std::string& key, std::string& value) con
{
value = Path::dataHome();
}
else if (key == TEMPHOMEDIR)
{
value = Path::tempHome();
}
else if (key == TEMPDIR)
{
value = Path::temp();
}
else if (key == CONFIGDIR)
{
value = Path::config();
}
else if (key == DATETIME)
{
value = Poco::DateTimeFormatter::format(Poco::DateTime(), Poco::DateTimeFormat::ISO8601_FORMAT);
@@ -169,7 +181,9 @@ void SystemConfiguration::enumerate(const std::string& key, Keys& range) const
range.push_back("configHomeDir");
range.push_back("cacheHomeDir");
range.push_back("dataHomeDir");
range.push_back("tempHomeDir");
range.push_back("tempDir");
range.push_back("configDir");
range.push_back("dateTime");
#if !defined(POCO_VXWORKS)
range.push_back("pid");