Hello, and thank you for accepting my recent community membership request.
(Just to introduce: My name is Cor Schols, version 39 though still bugged, compiled in The Netherlands)
The purpose of this forum post is to file a feature request for SDL2. An example implementation meeting the request's purpose is included. With the release of SDL 2.0.1 a new function was introduced: SDL_GetBasePath(). The function retrieves the base directory where the application resides in. While this may possibly be considered to be a minor utility function, I really like its presence. In fact, I've filed bug reports on it before (fixed now). While a nice feature, I think there's bigger potential possible here., with just a trivial change or addition. As follows:
Like retrieving an application's base directory path, I think it would be great to also be able to retrieve the application's filename. The filename can be used for numerous purposes, for example to set a default window/dialog title or have a default log name, etc. This would be especially convenient for gamedev libraries/frameworks that use SDL in its core. As it stands, while using SDL, I find myself still having to write platform-dependant code to obtain the application's filename myself. This while SDL already had access to it while retrieving the base path. It's inefficient, duplicate, inconsistent.
 Introduce a new function "SDL_GetBasePathExt", which takes an argument indicating which part of the base path to return (i.e. full, directory-only, filename-only, filename-without-extension).
 Do not introduce above new function, but change existing SDL_GetBasePath function to include said additional argument.
 Complete overhaul of SDL_filesystem, turning it into a subsystem (like audio, timer, video). It could allow for a new function "SDL_GetPath" which would not only be able to return (parts of) the application's base directory, but also the user directory, pref path, the system's temporary directory, a temporary file name to write to, etc. It could be extended with allowing users to register their own named paths (e.g. content/asset-path). The filesystem could offer functionality to work with path symbols (e.g. %prefpath%, %basedir%). Anyway, this third option is outside the scope of this post - return to option 1 or 2, before we start incorporating Ryan's PhysFS and whatnot.
Below you find my example implementation (Win32) which shows how SDL_GetBasePath could very easily be changed to return subparts of the base path. As I see no options here to include post attachments I'll copy/paste it here, and also provide download links to the edited source code files:
Added 1 new enum typedef and 1 new function declaration.
Added 1 new function definition, changed SDL_GetBasePath to call this function.
Basically the code was copied over from SDL_GetBasePath, and then altered with a few lines of codes to enable my feature request. Simple, trivial.
Thank you for your time. Feel free to contact me if there are any questions. You can also contact me if you need additional help on working on SDL. Reasons of my (potential full-time) availability are outside the scope of this forum post.
Cor Schols, alias Coriiander
SDL mailing list
SDL_GetBasePath should retrieve the path *of* the executable (i.e.
which directory it resides in). A function that retrieves the filename
should not include "path" in it. That probably solves a lot of the
dilemma here :P
Not sure whether a variant without extension is worth the effort (just
find the last dot and replace it with a '\0' if it exists), but I'm
leaving that up to the rest to decide.
SDL mailing list
|Free forum by Nabble||Edit this page|