mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-27 09:39:08 +01:00
add some methods to Poco::Path for make it easy to follow XDG Base Directory Specification
This commit is contained in:
committed by
Alex Fabijanic
parent
275275baa9
commit
b59329034f
@@ -78,24 +78,10 @@ std::string PathImpl::configHomeImpl()
|
||||
{
|
||||
#if defined(POCO_VXWORKS)
|
||||
return PathImpl::homeImpl();
|
||||
#elif POCO_OS == POCO_OS_MAC_OS_X
|
||||
#else
|
||||
std::string path = PathImpl::homeImpl();
|
||||
std::string::size_type n = path.size();
|
||||
if (n > 0 && path[n - 1] == '/')
|
||||
path.append("Library/Preferences/");
|
||||
return path;
|
||||
#else
|
||||
std::string path;
|
||||
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/");
|
||||
|
||||
if (n > 0 && path[n - 1] == '/') path.append(".config/");
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
@@ -105,24 +91,10 @@ std::string PathImpl::dataHomeImpl()
|
||||
{
|
||||
#if defined(POCO_VXWORKS)
|
||||
return PathImpl::homeImpl();
|
||||
#elif POCO_OS == POCO_OS_MAC_OS_X
|
||||
#else
|
||||
std::string path = PathImpl::homeImpl();
|
||||
std::string::size_type n = path.size();
|
||||
if (n > 0 && path[n - 1] == '/')
|
||||
path.append("Library/Application Support/");
|
||||
return path;
|
||||
#else
|
||||
std::string path;
|
||||
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/");
|
||||
|
||||
if (n > 0 && path[n - 1] == '/') path.append(".local/share/");
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
@@ -132,24 +104,23 @@ std::string PathImpl::cacheHomeImpl()
|
||||
{
|
||||
#if defined(POCO_VXWORKS)
|
||||
return PathImpl::tempImpl();
|
||||
#elif POCO_OS == POCO_OS_MAC_OS_X
|
||||
#else
|
||||
std::string path = PathImpl::homeImpl();
|
||||
std::string::size_type n = path.size();
|
||||
if (n > 0 && path[n - 1] == '/')
|
||||
path.append("Library/Caches/");
|
||||
if (n > 0 && path[n - 1] == '/') path.append(".cache/");
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::tempHomeImpl()
|
||||
{
|
||||
#if defined(POCO_VXWORKS)
|
||||
return PathImpl::tempImpl();
|
||||
#else
|
||||
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 path = PathImpl::homeImpl();
|
||||
std::string::size_type n = path.size();
|
||||
if (n > 0 && path[n - 1] == '/')
|
||||
path.append(".cache/");
|
||||
|
||||
if (n > 0 && path[n - 1] == '/') path.append(".local/tmp/");
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
@@ -173,6 +144,14 @@ std::string PathImpl::tempImpl()
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::configImpl()
|
||||
{
|
||||
std::string path;
|
||||
path = "/etc/";
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::nullImpl()
|
||||
{
|
||||
#if defined(POCO_VXWORKS)
|
||||
|
||||
Reference in New Issue
Block a user