Implement XDG file layout

This commit is contained in:
Martin Koegler
2016-12-10 17:56:04 +01:00
committed by Vadim Zeitlin
parent 8d5d00db9d
commit d56d127d3f
4 changed files with 55 additions and 1 deletions

View File

@@ -53,6 +53,16 @@ void wxStandardPaths::SetInstallPrefix(const wxString& prefix)
wxString wxStandardPaths::GetUserConfigDir() const
{
if (GetFileLayout() & FileLayout_XDG)
{
wxString configPath;
if (wxGetenv(wxT("XDG_CONFIG_HOME")))
configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
else
configPath = wxFileName::GetHomeDir() + wxT("/.config");
return configPath;
}
return wxFileName::GetHomeDir();
}
@@ -236,6 +246,7 @@ wxStandardPaths::GetLocalizedResourcesDir(const wxString& lang,
wxString wxStandardPaths::GetUserDir(Dir userDir) const
{
if (GetFileLayout() & FileLayout_XDG)
{
wxLogNull logNull;
wxString homeDir = wxFileName::GetHomeDir();
@@ -312,7 +323,7 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
wxString wxStandardPaths::MakeConfigFileName(const wxString& basename, int style) const
{
wxFileName fn(wxEmptyString, basename);
if (style & wxCONFIG_USE_SUBDIR)
if (style & wxCONFIG_USE_SUBDIR || GetFileLayout() & FileLayout_XDG)
fn.SetExt(wxT("conf"));
else
fn.SetName(wxT('.') + fn.GetName());