diff options
author | Julian Eisel <julian@blender.org> | 2020-12-11 17:36:29 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-12-11 18:20:53 +0300 |
commit | 6de85a0cc08da26f63ae0512f19fa5360556c2bd (patch) | |
tree | f3ffea47f230064a6ca36cbeaa145c5e7ee43c6c /intern/ghost/GHOST_ISystemPaths.h | |
parent | c8a3d1a1fa65f2ff21202d79c5f027119203319f (diff) |
Ghost: Support queries for special user directories (desktop, documents, etc.)
When we had to get special user directories, we'd usually do it in varying,
rather ad-hoc ways. It would be done with a bunch of `#ifdef`s for the
different operating systems. Also, some of the used Win32 functions were legacy
ones and the API docs recommend using newer ones.
Further, seems `BKE_appdir_folder_default()` used `XDG_DOCUMENTS_DIR` wrong.
It's not supposed to be an environment variable but a value inside a config
file.
This adds the platform dependent logic to Ghost, so we can abstract it away
nicely using the `GHOST_ISystemPaths` interface. Getting the desktop directory
for example can now easily be done with:
`GHOST_getUserSpecialDir(GHOST_kUserSpecialDirDesktop).`
For now I added the logic for desktop, documents, downloads, videos, images and
music directories, even though we only use the Documents one. We can extend/
change this as needed, it's easy to do now.
On Windows and macOS, it uses pretty much the same way to access the
directories as elsewhere already. On Linux, it uses the `xdg-user-dir` command
that seems to be available by default on most Linux systems.
No functional changes. The new queries are not actually used yet.
Differential Revision: https://developer.blender.org/D9800
Reviewed by: Brecht Van Lommel
Diffstat (limited to 'intern/ghost/GHOST_ISystemPaths.h')
-rw-r--r-- | intern/ghost/GHOST_ISystemPaths.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h index b47d14984d8..e7ac752d322 100644 --- a/intern/ghost/GHOST_ISystemPaths.h +++ b/intern/ghost/GHOST_ISystemPaths.h @@ -78,6 +78,12 @@ class GHOST_ISystemPaths { virtual const GHOST_TUns8 *getUserDir(int version, const char *versionstr) const = 0; /** + * Determine a special ("well known") and easy to reach user directory. + * \return Unsigned char string pointing to user dir (eg `~/Documents/`). + */ + virtual const GHOST_TUns8 *getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const = 0; + + /** * Determine the directory of the current binary * \return Unsigned char string pointing to the binary dir */ |