mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 19:13:30 +01:00
add Windows compliant implementation of XDG Base Directory Specification
This commit is contained in:
parent
eaaf2296f0
commit
43c44aacbb
@ -33,7 +33,9 @@ public:
|
||||
static std::string configHomeImpl();
|
||||
static std::string dataHomeImpl();
|
||||
static std::string cacheHomeImpl();
|
||||
static std::string tempHomeImpl();
|
||||
static std::string tempImpl();
|
||||
static std::string configImpl();
|
||||
static std::string nullImpl();
|
||||
static std::string systemImpl();
|
||||
static std::string expandImpl(const std::string& path);
|
||||
|
@ -33,7 +33,9 @@ public:
|
||||
static std::string configHomeImpl();
|
||||
static std::string dataHomeImpl();
|
||||
static std::string cacheHomeImpl();
|
||||
static std::string tempHomeImpl();
|
||||
static std::string tempImpl();
|
||||
static std::string configImpl();
|
||||
static std::string nullImpl();
|
||||
static std::string systemImpl();
|
||||
static std::string expandImpl(const std::string& path);
|
||||
|
@ -571,7 +571,7 @@ std::string Path::home()
|
||||
|
||||
std::string Path::configHome()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return PathImpl::configHomeImpl();
|
||||
#else
|
||||
return PathImpl::homeImpl();
|
||||
@ -581,7 +581,7 @@ std::string Path::configHome()
|
||||
|
||||
std::string Path::dataHome()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return PathImpl::dataHomeImpl();
|
||||
#else
|
||||
return PathImpl::homeImpl();
|
||||
@ -591,7 +591,7 @@ std::string Path::dataHome()
|
||||
|
||||
std::string Path::tempHome()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return PathImpl::tempHomeImpl();
|
||||
#else
|
||||
return PathImpl::tempImpl();
|
||||
@ -601,7 +601,7 @@ std::string Path::tempHome()
|
||||
|
||||
std::string Path::cacheHome()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return PathImpl::cacheHomeImpl();
|
||||
#else
|
||||
return PathImpl::homeImpl();
|
||||
@ -617,7 +617,7 @@ std::string Path::temp()
|
||||
|
||||
std::string Path::config()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return PathImpl::configImpl();
|
||||
#else
|
||||
return PathImpl::currentImpl();
|
||||
|
@ -122,6 +122,12 @@ std::string PathImpl::cacheHomeImpl()
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::tempHomeImpl()
|
||||
{
|
||||
return tempImpl();
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::tempImpl()
|
||||
{
|
||||
char buffer[MAX_PATH];
|
||||
@ -139,6 +145,26 @@ std::string PathImpl::tempImpl()
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::configImpl()
|
||||
{
|
||||
std::string result;
|
||||
|
||||
// if PROGRAMDATA environment variable not exist, return system directory instead
|
||||
try
|
||||
{
|
||||
result = EnvironmentImpl::getImpl("PROGRAMDATA");
|
||||
}
|
||||
catch (NotFoundException&)
|
||||
{
|
||||
result = systemImpl();
|
||||
}
|
||||
|
||||
std::string::size_type n = result.size();
|
||||
if (n > 0 && result[n - 1] != '\\')
|
||||
result.append("\\");
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string PathImpl::nullImpl()
|
||||
{
|
||||
return "NUL:";
|
||||
|
@ -132,6 +132,14 @@ std::string PathImpl::cacheHomeImpl()
|
||||
}
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
std::string PathImpl::tempHomeImpl()
|
||||
{
|
||||
return tempImpl();
|
||||
}
|
||||
|
||||
>>>>>>> 06e59cb... add Windows compliant implementation of XDG Base Directory Specification
|
||||
std::string PathImpl::tempImpl()
|
||||
{
|
||||
Buffer<wchar_t> buffer(MAX_PATH_LEN);
|
||||
@ -150,6 +158,26 @@ std::string PathImpl::tempImpl()
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::configImpl()
|
||||
{
|
||||
std::string result;
|
||||
|
||||
// if PROGRAMDATA environment variable not exist, return system directory instead
|
||||
try
|
||||
{
|
||||
result = EnvironmentImpl::getImpl("PROGRAMDATA");
|
||||
}
|
||||
catch (NotFoundException&)
|
||||
{
|
||||
result = systemImpl();
|
||||
}
|
||||
|
||||
std::string::size_type n = result.size();
|
||||
if (n > 0 && result[n - 1] != '\\')
|
||||
result.append("\\");
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string PathImpl::nullImpl()
|
||||
{
|
||||
return "NUL:";
|
||||
|
Loading…
x
Reference in New Issue
Block a user