mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-08 23:10:36 +01:00
Fix XDG Base Dir Spec implementation and remove tempHome.
This commit is contained in:
parent
25e32d38c5
commit
ed819feb83
@ -304,11 +304,6 @@ public:
|
|||||||
/// On Unix systems, this is the '~/.local/share/'. On Windows systems,
|
/// On Unix systems, this is the '~/.local/share/'. On Windows systems,
|
||||||
/// this is '%APPDATA%'.
|
/// this is '%APPDATA%'.
|
||||||
|
|
||||||
static std::string tempHome();
|
|
||||||
/// Returns the user's temp directory.
|
|
||||||
///
|
|
||||||
/// On Unix systems, this is the '~/.local/temp/'.
|
|
||||||
|
|
||||||
static std::string cacheHome();
|
static std::string cacheHome();
|
||||||
/// Returns the user's cache directory.
|
/// Returns the user's cache directory.
|
||||||
///
|
///
|
||||||
|
@ -34,7 +34,6 @@ public:
|
|||||||
static std::string homeImpl();
|
static std::string homeImpl();
|
||||||
static std::string configHomeImpl();
|
static std::string configHomeImpl();
|
||||||
static std::string dataHomeImpl();
|
static std::string dataHomeImpl();
|
||||||
static std::string tempHomeImpl();
|
|
||||||
static std::string cacheHomeImpl();
|
static std::string cacheHomeImpl();
|
||||||
static std::string tempImpl();
|
static std::string tempImpl();
|
||||||
static std::string configImpl();
|
static std::string configImpl();
|
||||||
|
@ -35,7 +35,6 @@ public:
|
|||||||
static std::string configHomeImpl();
|
static std::string configHomeImpl();
|
||||||
static std::string dataHomeImpl();
|
static std::string dataHomeImpl();
|
||||||
static std::string cacheHomeImpl();
|
static std::string cacheHomeImpl();
|
||||||
static std::string tempHomeImpl();
|
|
||||||
static std::string tempImpl();
|
static std::string tempImpl();
|
||||||
static std::string configImpl();
|
static std::string configImpl();
|
||||||
static std::string nullImpl();
|
static std::string nullImpl();
|
||||||
|
@ -35,7 +35,6 @@ public:
|
|||||||
static std::string configHomeImpl();
|
static std::string configHomeImpl();
|
||||||
static std::string dataHomeImpl();
|
static std::string dataHomeImpl();
|
||||||
static std::string cacheHomeImpl();
|
static std::string cacheHomeImpl();
|
||||||
static std::string tempHomeImpl();
|
|
||||||
static std::string tempImpl();
|
static std::string tempImpl();
|
||||||
static std::string configImpl();
|
static std::string configImpl();
|
||||||
static std::string nullImpl();
|
static std::string nullImpl();
|
||||||
|
@ -35,7 +35,6 @@ public:
|
|||||||
static std::string configHomeImpl();
|
static std::string configHomeImpl();
|
||||||
static std::string dataHomeImpl();
|
static std::string dataHomeImpl();
|
||||||
static std::string cacheHomeImpl();
|
static std::string cacheHomeImpl();
|
||||||
static std::string tempHomeImpl();
|
|
||||||
static std::string tempImpl();
|
static std::string tempImpl();
|
||||||
static std::string configImpl();
|
static std::string configImpl();
|
||||||
static std::string nullImpl();
|
static std::string nullImpl();
|
||||||
|
@ -615,16 +615,6 @@ std::string Path::dataHome()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Path::tempHome()
|
|
||||||
{
|
|
||||||
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
|
||||||
return PathImpl::tempHomeImpl();
|
|
||||||
#else
|
|
||||||
return PathImpl::tempImpl();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Path::cacheHome()
|
std::string Path::cacheHome()
|
||||||
{
|
{
|
||||||
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
|
@ -81,15 +81,23 @@ std::string PathImpl::configHomeImpl()
|
|||||||
{
|
{
|
||||||
#if defined(POCO_VXWORKS)
|
#if defined(POCO_VXWORKS)
|
||||||
return PathImpl::homeImpl();
|
return PathImpl::homeImpl();
|
||||||
#else
|
#elif POCO_OS == POCO_OS_MAC_OS_X
|
||||||
std::string path = PathImpl::homeImpl();
|
std::string path = PathImpl::homeImpl();
|
||||||
std::string::size_type n = path.size();
|
std::string::size_type n = path.size();
|
||||||
if (n > 0 && path[n - 1] == '/')
|
if (n > 0 && path[n - 1] == '/')
|
||||||
#if POCO_OS == POCO_OS_MAC_OS_X
|
path.append("Library/Preferences/");
|
||||||
path.append("Library/Preferences/");
|
return path;
|
||||||
#else
|
#else
|
||||||
path.append(".config/");
|
std::string path;
|
||||||
#endif
|
if (EnvironmentImpl::hasImpl("XDG_CONFIG_HOME"))
|
||||||
|
path = EnvironmentImpl::getImpl("XDG_CONFIG_HOME");
|
||||||
|
if (!path.empty())
|
||||||
|
return path;
|
||||||
|
|
||||||
|
path = PathImpl::homeImpl();
|
||||||
|
std::string::size_type n = path.size();
|
||||||
|
if (n > 0 && path[n - 1] == '/')
|
||||||
|
path.append(".config/");
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
#endif
|
#endif
|
||||||
@ -100,15 +108,23 @@ std::string PathImpl::dataHomeImpl()
|
|||||||
{
|
{
|
||||||
#if defined(POCO_VXWORKS)
|
#if defined(POCO_VXWORKS)
|
||||||
return PathImpl::homeImpl();
|
return PathImpl::homeImpl();
|
||||||
#else
|
#elif POCO_OS == POCO_OS_MAC_OS_X
|
||||||
std::string path = PathImpl::homeImpl();
|
std::string path = PathImpl::homeImpl();
|
||||||
std::string::size_type n = path.size();
|
std::string::size_type n = path.size();
|
||||||
if (n > 0 && path[n - 1] == '/')
|
if (n > 0 && path[n - 1] == '/')
|
||||||
#if POCO_OS == POCO_OS_MAC_OS_X
|
path.append("Library/Application Support/");
|
||||||
path.append("Library/Application Support/");
|
return path;
|
||||||
#else
|
#else
|
||||||
path.append(".local/share/");
|
std::string path;
|
||||||
#endif
|
if (EnvironmentImpl::hasImpl("XDG_DATA_HOME"))
|
||||||
|
path = EnvironmentImpl::getImpl("XDG_DATA_HOME");
|
||||||
|
if (!path.empty())
|
||||||
|
return path;
|
||||||
|
|
||||||
|
path = PathImpl::homeImpl();
|
||||||
|
std::string::size_type n = path.size();
|
||||||
|
if (n > 0 && path[n - 1] == '/')
|
||||||
|
path.append(".local/share/");
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
#endif
|
#endif
|
||||||
@ -119,34 +135,23 @@ std::string PathImpl::cacheHomeImpl()
|
|||||||
{
|
{
|
||||||
#if defined(POCO_VXWORKS)
|
#if defined(POCO_VXWORKS)
|
||||||
return PathImpl::tempImpl();
|
return PathImpl::tempImpl();
|
||||||
#else
|
#elif POCO_OS == POCO_OS_MAC_OS_X
|
||||||
std::string path = PathImpl::homeImpl();
|
std::string path = PathImpl::homeImpl();
|
||||||
std::string::size_type n = path.size();
|
std::string::size_type n = path.size();
|
||||||
if (n > 0 && path[n - 1] == '/')
|
if (n > 0 && path[n - 1] == '/')
|
||||||
#if POCO_OS == POCO_OS_MAC_OS_X
|
path.append("Library/Caches/");
|
||||||
path.append("Library/Caches/");
|
|
||||||
#else
|
|
||||||
path.append(".cache/");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string PathImpl::tempHomeImpl()
|
|
||||||
{
|
|
||||||
#if defined(POCO_VXWORKS)
|
|
||||||
return PathImpl::tempImpl();
|
|
||||||
#else
|
#else
|
||||||
std::string path = PathImpl::homeImpl();
|
std::string path;
|
||||||
|
if (EnvironmentImpl::hasImpl("XDG_CACHE_HOME"))
|
||||||
|
path = EnvironmentImpl::getImpl("XDG_CACHE_HOME");
|
||||||
|
if (!path.empty())
|
||||||
|
return path;
|
||||||
|
|
||||||
|
path = PathImpl::homeImpl();
|
||||||
std::string::size_type n = path.size();
|
std::string::size_type n = path.size();
|
||||||
if (n > 0 && path[n - 1] == '/')
|
if (n > 0 && path[n - 1] == '/')
|
||||||
#if POCO_OS == POCO_OS_MAC_OS_X
|
path.append(".cache/");
|
||||||
path.append("Library/Caches/");
|
|
||||||
#else
|
|
||||||
path.append(".local/tmp/");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
#endif
|
#endif
|
||||||
|
@ -124,12 +124,6 @@ std::string PathImpl::cacheHomeImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string PathImpl::tempHomeImpl()
|
|
||||||
{
|
|
||||||
return tempImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string PathImpl::tempImpl()
|
std::string PathImpl::tempImpl()
|
||||||
{
|
{
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
|
@ -134,12 +134,6 @@ std::string PathImpl::cacheHomeImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string PathImpl::tempHomeImpl()
|
|
||||||
{
|
|
||||||
return tempImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string PathImpl::tempImpl()
|
std::string PathImpl::tempImpl()
|
||||||
{
|
{
|
||||||
Buffer<wchar_t> buffer(MAX_PATH_LEN);
|
Buffer<wchar_t> buffer(MAX_PATH_LEN);
|
||||||
|
@ -56,12 +56,6 @@ std::string PathImpl::cacheHomeImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string PathImpl::tempHomeImpl()
|
|
||||||
{
|
|
||||||
return tempImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string PathImpl::configImpl()
|
std::string PathImpl::configImpl()
|
||||||
{
|
{
|
||||||
return("\\");
|
return("\\");
|
||||||
|
@ -44,7 +44,6 @@ class Util_API SystemConfiguration: public AbstractConfiguration
|
|||||||
/// - system.configHomeDir: the base directory relative to which user specific configuration files should be stored
|
/// - system.configHomeDir: the base directory relative to which user specific configuration files should be stored
|
||||||
/// - system.cacheHomeDir: the base directory relative to which user specific non-essential data files should be stored
|
/// - system.cacheHomeDir: the base directory relative to which user specific non-essential data files should be stored
|
||||||
/// - system.dataHomeDir: the base directory relative to which user specific data files should be stored
|
/// - system.dataHomeDir: the base directory relative to which user specific data files should be stored
|
||||||
/// - system.tempHomeDir: the base directory relative to which user-specific temporary files and other file objects should be placed
|
|
||||||
/// - system.tempDir: the system's temporary directory
|
/// - system.tempDir: the system's temporary directory
|
||||||
/// - system.configDir: the system's configuration directory
|
/// - system.configDir: the system's configuration directory
|
||||||
/// - system.dateTime: the current UTC date and time, formatted in ISO 8601 format.
|
/// - system.dateTime: the current UTC date and time, formatted in ISO 8601 format.
|
||||||
@ -84,7 +83,6 @@ private:
|
|||||||
static const std::string CONFIGHOMEDIR;
|
static const std::string CONFIGHOMEDIR;
|
||||||
static const std::string CACHEHOMEDIR;
|
static const std::string CACHEHOMEDIR;
|
||||||
static const std::string DATAHOMEDIR;
|
static const std::string DATAHOMEDIR;
|
||||||
static const std::string TEMPHOMEDIR;
|
|
||||||
static const std::string TEMPDIR;
|
static const std::string TEMPDIR;
|
||||||
static const std::string CONFIGDIR;
|
static const std::string CONFIGDIR;
|
||||||
static const std::string DATETIME;
|
static const std::string DATETIME;
|
||||||
|
@ -170,7 +170,6 @@ void Application::init()
|
|||||||
_pConfig->setString("application.dir", appPath.parent().toString());
|
_pConfig->setString("application.dir", appPath.parent().toString());
|
||||||
_pConfig->setString("application.configDir", Path::configHome() + appPath.getBaseName() + Path::separator());
|
_pConfig->setString("application.configDir", Path::configHome() + appPath.getBaseName() + Path::separator());
|
||||||
_pConfig->setString("application.cacheDir", Path::cacheHome() + 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());
|
_pConfig->setString("application.dataDir", Path::dataHome() + appPath.getBaseName() + Path::separator());
|
||||||
processOptions();
|
processOptions();
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ const std::string SystemConfiguration::HOMEDIR = "system.homeDir";
|
|||||||
const std::string SystemConfiguration::CONFIGHOMEDIR = "system.configHomeDir";
|
const std::string SystemConfiguration::CONFIGHOMEDIR = "system.configHomeDir";
|
||||||
const std::string SystemConfiguration::CACHEHOMEDIR = "system.cacheHomeDir";
|
const std::string SystemConfiguration::CACHEHOMEDIR = "system.cacheHomeDir";
|
||||||
const std::string SystemConfiguration::DATAHOMEDIR = "system.dataHomeDir";
|
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::TEMPDIR = "system.tempDir";
|
||||||
const std::string SystemConfiguration::CONFIGDIR = "system.configDir";
|
const std::string SystemConfiguration::CONFIGDIR = "system.configDir";
|
||||||
const std::string SystemConfiguration::DATETIME = "system.dateTime";
|
const std::string SystemConfiguration::DATETIME = "system.dateTime";
|
||||||
@ -125,10 +124,6 @@ bool SystemConfiguration::getRaw(const std::string& key, std::string& value) con
|
|||||||
{
|
{
|
||||||
value = Path::dataHome();
|
value = Path::dataHome();
|
||||||
}
|
}
|
||||||
else if (key == TEMPHOMEDIR)
|
|
||||||
{
|
|
||||||
value = Path::tempHome();
|
|
||||||
}
|
|
||||||
else if (key == TEMPDIR)
|
else if (key == TEMPDIR)
|
||||||
{
|
{
|
||||||
value = Path::temp();
|
value = Path::temp();
|
||||||
@ -181,7 +176,6 @@ void SystemConfiguration::enumerate(const std::string& key, Keys& range) const
|
|||||||
range.push_back("configHomeDir");
|
range.push_back("configHomeDir");
|
||||||
range.push_back("cacheHomeDir");
|
range.push_back("cacheHomeDir");
|
||||||
range.push_back("dataHomeDir");
|
range.push_back("dataHomeDir");
|
||||||
range.push_back("tempHomeDir");
|
|
||||||
range.push_back("tempDir");
|
range.push_back("tempDir");
|
||||||
range.push_back("configDir");
|
range.push_back("configDir");
|
||||||
range.push_back("dateTime");
|
range.push_back("dateTime");
|
||||||
|
@ -99,7 +99,6 @@ void SystemConfigurationTest::testKeys()
|
|||||||
assert (std::find(keys.begin(), keys.end(), "configHomeDir") != keys.end());
|
assert (std::find(keys.begin(), keys.end(), "configHomeDir") != keys.end());
|
||||||
assert (std::find(keys.begin(), keys.end(), "cacheHomeDir") != keys.end());
|
assert (std::find(keys.begin(), keys.end(), "cacheHomeDir") != keys.end());
|
||||||
assert (std::find(keys.begin(), keys.end(), "dataHomeDir") != keys.end());
|
assert (std::find(keys.begin(), keys.end(), "dataHomeDir") != keys.end());
|
||||||
assert (std::find(keys.begin(), keys.end(), "tempHomeDir") != keys.end());
|
|
||||||
assert (std::find(keys.begin(), keys.end(), "tempDir") != keys.end());
|
assert (std::find(keys.begin(), keys.end(), "tempDir") != keys.end());
|
||||||
assert (std::find(keys.begin(), keys.end(), "configDir") != keys.end());
|
assert (std::find(keys.begin(), keys.end(), "configDir") != keys.end());
|
||||||
assert (std::find(keys.begin(), keys.end(), "dateTime") != keys.end());
|
assert (std::find(keys.begin(), keys.end(), "dateTime") != keys.end());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user