+wxString wxStandardPaths::GetDocumentsDir() const
+{
+ {
+ wxLogNull logNull;
+ wxString homeDir = wxFileName::GetHomeDir();
+ wxString configPath;
+ if (wxGetenv(wxT("XDG_CONFIG_HOME")))
+ configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
+ else
+ configPath = homeDir + wxT("/.config");
+ wxString dirsFile = configPath + wxT("/user-dirs.dirs");
+ if (wxFileExists(dirsFile))
+ {
+ wxTextFile textFile;
+ if (textFile.Open(dirsFile))
+ {
+ size_t i;
+ for (i = 0; i < textFile.GetLineCount(); i++)
+ {
+ wxString line(textFile[i]);
+ int pos = line.Find(wxT("XDG_DOCUMENTS_DIR"));
+ if (pos != wxNOT_FOUND)
+ {
+ wxString value = line.AfterFirst(wxT('='));
+ value.Replace(wxT("$HOME"), homeDir);
+ value.Trim(true);
+ value.Trim(false);
+ if (!value.IsEmpty() && wxDirExists(value))
+ return value;
+ else
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return wxStandardPathsBase::GetDocumentsDir();
+}
+