mirror of
https://github.com/pocoproject/poco.git
synced 2025-07-03 01:05:21 +02: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 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 nullImpl();
|
static std::string nullImpl();
|
||||||
static std::string systemImpl();
|
static std::string systemImpl();
|
||||||
static std::string expandImpl(const std::string& path);
|
static std::string expandImpl(const std::string& path);
|
||||||
|
@ -33,7 +33,9 @@ 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 nullImpl();
|
static std::string nullImpl();
|
||||||
static std::string systemImpl();
|
static std::string systemImpl();
|
||||||
static std::string expandImpl(const std::string& path);
|
static std::string expandImpl(const std::string& path);
|
||||||
|
@ -571,7 +571,7 @@ std::string Path::home()
|
|||||||
|
|
||||||
std::string Path::configHome()
|
std::string Path::configHome()
|
||||||
{
|
{
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
return PathImpl::configHomeImpl();
|
return PathImpl::configHomeImpl();
|
||||||
#else
|
#else
|
||||||
return PathImpl::homeImpl();
|
return PathImpl::homeImpl();
|
||||||
@ -581,7 +581,7 @@ std::string Path::configHome()
|
|||||||
|
|
||||||
std::string Path::dataHome()
|
std::string Path::dataHome()
|
||||||
{
|
{
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
return PathImpl::dataHomeImpl();
|
return PathImpl::dataHomeImpl();
|
||||||
#else
|
#else
|
||||||
return PathImpl::homeImpl();
|
return PathImpl::homeImpl();
|
||||||
@ -591,7 +591,7 @@ std::string Path::dataHome()
|
|||||||
|
|
||||||
std::string Path::tempHome()
|
std::string Path::tempHome()
|
||||||
{
|
{
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
return PathImpl::tempHomeImpl();
|
return PathImpl::tempHomeImpl();
|
||||||
#else
|
#else
|
||||||
return PathImpl::tempImpl();
|
return PathImpl::tempImpl();
|
||||||
@ -601,7 +601,7 @@ std::string Path::tempHome()
|
|||||||
|
|
||||||
std::string Path::cacheHome()
|
std::string Path::cacheHome()
|
||||||
{
|
{
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
return PathImpl::cacheHomeImpl();
|
return PathImpl::cacheHomeImpl();
|
||||||
#else
|
#else
|
||||||
return PathImpl::homeImpl();
|
return PathImpl::homeImpl();
|
||||||
@ -617,7 +617,7 @@ std::string Path::temp()
|
|||||||
|
|
||||||
std::string Path::config()
|
std::string Path::config()
|
||||||
{
|
{
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
return PathImpl::configImpl();
|
return PathImpl::configImpl();
|
||||||
#else
|
#else
|
||||||
return PathImpl::currentImpl();
|
return PathImpl::currentImpl();
|
||||||
|
@ -122,6 +122,12 @@ 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];
|
||||||
@ -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()
|
std::string PathImpl::nullImpl()
|
||||||
{
|
{
|
||||||
return "NUL:";
|
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()
|
std::string PathImpl::tempImpl()
|
||||||
{
|
{
|
||||||
Buffer<wchar_t> buffer(MAX_PATH_LEN);
|
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()
|
std::string PathImpl::nullImpl()
|
||||||
{
|
{
|
||||||
return "NUL:";
|
return "NUL:";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user