Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » The name of the currently used Allegro configuration file.

This thread is locked; no one can reply to it. rss feed Print
The name of the currently used Allegro configuration file.
Andrei Ellman
Member #3,434
April 2003

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
_chSetINIFile()
{
  // NOTE: This code is called after allegro_init();
  char szPath[CHIO_MAXPATHLENGTH], szINIFile[CHIO_MAXPATHLENGTH];  
  get_executable_name(szPath, sizeof(szPath));  
  replace_filename(szINIFile, szPath, CHINIFILENAME, CHIO_MAXPATHLENGTH-1);  
  override_config_file(szINIFile);
}

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)?

AE.

--
Don't let the illegitimates turn you into carbon.

CGamesPlay
Member #2,559
July 2002
avatar

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

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Andrei Ellman
Member #3,434
April 2003

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.

AE.

--
Don't let the illegitimates turn you into carbon.

Go to: