We do have *BSD users and it does work for them. Heck, we had even got a patch for binreloc to work on *BSD.
It's nice that it works for them
For your reference, the code that we use looks like this:
base = wxString(SELFPATH,wxConvUTF8);
if (base.IsEmpty())
base = _T(".");
#define SELFPATH (br_thread_local_store (br_locate ((void *) "")))
char *br_locate (void *symbol)
{
char line[5000];
FILE *f;
char *path;
br_return_val_if_fail (symbol != NULL, (char*)NULL);
f = fopen ("/proc/self/maps", "r");
if (!f)
return (char*)NULL;
while (!feof (f))
... <more code>
#define br_return_val_if_fail(expr,val) if (!(expr)) {fprintf (stderr, "..."); return val;}
I'm so happy it works nicely for BSD.
Hardcoding is out of the question.
That's unfortunate, because that's what we do now.
Why, all of the sudden, do you want to change things regarding this matter?
I don't want to change things regarding this matter at all. Heck, I could imagine more pleasant things to do.
As you asked for, I was making user plugin paths depending on the location of the config file found. The ConfigManager instances know nothing about the underlying file, that's handled by the related factory class.
Thus, the executable's path (and other paths) must be known a lot earlier now, this can no longer wait until the application eventually figures it out and sets it. Therefore, I implemented something which I thought should work.
In the end, as binreloc depends on
/proc/self too, my 6 lines of code do not change any single thing, except they are 6 lines instead of 550 lines...