Merge pull request #561 from bschramke/develop

Support for XDG Base Directory Specification
This commit is contained in:
Aleksandar Fabijanic
2015-02-09 21:04:28 -06:00
12 changed files with 399 additions and 2 deletions

View File

@@ -86,6 +86,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);
@@ -104,6 +157,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:";