The name of the currently used Allegro configuration file.
Andrei Ellman

How do I get the name of the currently used Allegro configuration file? I suspect that when my program is ported to some platforms, it is not being read. I usually place it in the same directory as the executable and use the following code to read it.

static void
  // NOTE: This code is called after allegro_init();
  get_executable_name(szPath, sizeof(szPath));  
  replace_filename(szINIFile, szPath, CHINIFILENAME, CHIO_MAXPATHLENGTH-1);  

This succeeds on Windows and DOS, but I suspect it's failing when the app is ported to MacOs X.

In Allegro's config.c, I suspect the variable that I'm looking for is config_override, but it's declared static and is not exposed in any way. Is there any way to find out if override_config_file() succeeded in reading the INI file (it returns void so does not report back on status)?



The easy, hackish way is to create a uniquely-named string value and try to read it.

Andrei Ellman

I thought about that, but that seemed too hackish. Ideally, Allegro's configuration-file reading functions should give some indication as to whether or not they actually managed to read the file. After browsing the Allegro source, another hackish idea I had was to read the internal struct containing details of the INI filename (by referencing the variable directly and hoping that the linker will sort things out), but this would only work if I compiled a statically-linked binary.


Thread #590345. Printed from