diff --git a/modules/base/HGUtility.cpp b/modules/base/HGUtility.cpp index 29aa6e32..0b7f7eb6 100644 --- a/modules/base/HGUtility.cpp +++ b/modules/base/HGUtility.cpp @@ -414,7 +414,29 @@ HGResult HGAPI HGBase_GetDocumentsPath(HGChar* documentsPath, HGUInt maxLen) strcpy(docPath, pw->pw_dir); if (docPath[strlen(docPath) - 1] != '/') strcat(docPath, "/"); - strcat(docPath, "Documents/"); + std::string docName; + FILE* file = popen("cat $HOME/.config/user-dirs.dirs | grep DOCUMENTS | tail -1 | cut -d '=' -f 2 | sed 's/\"//g'", "r"); + if (NULL != file) + { + char data[1024] = { 0 }; + if (NULL != fgets(data, 1024, file)) + { + char* start = strchr(data, '/'); + if (NULL != start && 0 != *(start + 1)) + { + char* end = strchr(start + 1, '\n'); + if (NULL != end) + *end = 0; + docName = start + 1; + } + } + + pclose(file); + } + if (docName.empty()) + docName = "Documents"; + strcat(docPath, docName.c_str()); + strcat(docPath, "/"); #endif if (maxLen < strlen(docPath) + 1)