diff options
author | Sam Lantinga <slouken@libsdl.org> | 2017-08-11 11:32:00 -0700 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2017-08-11 11:32:00 -0700 |
commit | 6ec1321e609234d33b3905932177974d43e3e269 (patch) | |
tree | b7983864d013111e1a76352c65379282e0fcbc0c /test | |
parent | 90603c621d06dd5986b174a588597f9e936fcb77 (diff) |
Fixed bug 3639 - SDL_GetPrefPath returns a path with two consecutive slashes on Unix if org is omitted
Fabian Greffrath
we use SDL_GetPrefPath() in Chocolate Doom to get a reasonable directory to save and restore config files and savegames:
https://github.com/chocolate-doom/chocolate-doom/blob/sdl2-branch/src/m_config.c#L2162
However, since there is no "organization" behind Chocolate Doom and there is really only one "product" called Chocolate Doom, we pass an empty string for the org parameter and the package string for app.
This leads to two consecutive slashes in the path returned by SDL_GetPrefPath() like this:
/home/user/.local/share//chocolate-doom/
While this is harmless, it sure looks bad.
I believe that it should be possible to either pass a NULL pointer for the org parameter or at least have the function detect an empty string as a means to express "there is no origanization, just a single product". The generation of the path string to be returned by the function will have to get adapted accordingly.
Diffstat (limited to 'test')
-rw-r--r-- | test/testfilesystem.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/testfilesystem.c b/test/testfilesystem.c index 6d6eab4dbb..e8a3b3c36d 100644 --- a/test/testfilesystem.c +++ b/test/testfilesystem.c @@ -46,6 +46,15 @@ main(int argc, char *argv[]) SDL_Log("pref path: '%s'\n", pref_path); SDL_free(pref_path); + pref_path = SDL_GetPrefPath(NULL, "testfilesystem"); + if(pref_path == NULL){ + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n", + SDL_GetError()); + return 1; + } + SDL_Log("pref path: '%s'\n", pref_path); + SDL_free(pref_path); + SDL_Quit(); return 0; } |