feat(core): get user "Documents" folder
Description
We can get user "data", "config", "cache" directory (respectively %APPDATA%
on windows and $XDG_USER_DATA
, $XDG_USER_CONFIG
, $XDG_USER_CACHE
on Linux), but not the current "Documents" folder (usually %USERPROFILE%/my Documents
on Windows and $HOME/Documents
on Linux
Proposal
Update libs\core\core\tools\Os.cpp to includes a getUserDocumentsDir()
, similar to other special folder getters.
Functional specifications
See proposal...
Technical specifications
On Linux, it will rely on $XDG_DOCUMENTS_DIR environment variable, on Windows, it is a bit more complicated since we must call something like:
PWSTR ppszPath; // variable to receive the path memory block pointer.
HRESULT hr = SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &ppszPath);
std::wstring myPath;
if (SUCCEEDED(hr))
{
myPath = ppszPath; // make a local copy of the path
}
CoTaskMemFree(ppszPath); // free up the path memory block
Test plan
Update unit tests