mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 02:06:04 +02:00
add Windows compliant implementation of XDG Base Directory Specification
This commit is contained in:
@@ -84,6 +84,59 @@ std::string PathImpl::homeImpl()
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::configHomeImpl()
|
||||
{
|
||||
std::string result;
|
||||
|
||||
// if APPDATA environment variable no exist, return home directory instead
|
||||
try
|
||||
{
|
||||
result = EnvironmentImpl::getImpl("APPDATA");
|
||||
}
|
||||
catch (NotFoundException&)
|
||||
{
|
||||
result = homeImpl();
|
||||
}
|
||||
|
||||
std::string::size_type n = result.size();
|
||||
if (n > 0 && result[n - 1] != '\\')
|
||||
result.append("\\");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::dataHomeImpl()
|
||||
{
|
||||
std::string result;
|
||||
|
||||
// if LOCALAPPDATA environment variable no exist, return config home instead
|
||||
try
|
||||
{
|
||||
result = EnvironmentImpl::getImpl("LOCALAPPDATA");
|
||||
}
|
||||
catch (NotFoundException&)
|
||||
{
|
||||
result = configHomeImpl();
|
||||
}
|
||||
|
||||
std::string::size_type n = result.size();
|
||||
if (n > 0 && result[n - 1] != '\\')
|
||||
result.append("\\");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::cacheHomeImpl()
|
||||
{
|
||||
return tempImpl();
|
||||
}
|
||||
|
||||
|
||||
std::string PathImpl::tempHomeImpl()
|
||||
{
|
||||
return tempImpl();
|
||||
}
|
||||
|
||||
std::string PathImpl::tempImpl()
|
||||
{
|
||||
Buffer<wchar_t> buffer(MAX_PATH_LEN);
|
||||
@@ -102,6 +155,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:";
|
||||
|
||||
Reference in New Issue
Block a user