Re: [AD] [patch] new configuration variable: resource_path

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2004-08-31, Daniel Schlyder <daniel@xxxxxxxxxx> wrote:
> I need a way to specify location of keyboard.dat, as I do not wish
> to store it in the same directory as the executable. Currently,
> the only way to do this is by setting the environment variable
> ALLEGRO. I think this must be reserved for users wanting to
> specify location of their own allegro.cfg, though.
> 
> The attached patch solves this issue by introducing a new
> configuration variable [system]resource_path and modifying
> src/file.c:find_allegro_resource() to make use of this unless
> resource file is allegro.cfg (which obviously wouldn't work).
> 
> Does this seem reasonable? I know it's not a very flexible solution
> (for example, you might want to specify different locations for
> keyboard mappings and language translations).

Hardcoding the allegro.cfg string would not work if you use
set_config_file. Maybe grabbing the name from the config system, but
then you could as well be using several different .cfg files pushing
and popping. Maybe pushing and popping wouldn't affect you though.

It would be better if you added something like
set_allegro_resource_path(int num, const char *path) to Allegro. This
function would receive the path to look files for and the priority
as a number from 0 to 7 inclusive.  Setting the same number to NULL
would remove the path.

Then find_allegro_resource could loop internally over the non null
entries of that array somewhere before giving up in addition to
the ones it already does. Instead of using a static char array,
use in your implementation a static global 8 position array of
pointers to strings.  set_allegro_resource_path would then return
0 if the internal ustrdup call to store the path didn't have enough
memory. Return 1 if the string duplication is successful.

Ok. Maybe 8 custom paths aren't enough. Make that 16.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/