Re: BinReloc functionality



Alexandre Moreira wrote:
Is there anything like BinReloc's
(http://autopackage.org/docs/binreloc/) functionality  in GTK+
(probably Glib would be the best place for it) available to the
programmer ?

If not, what are the odds that something like that would be implemented ?


The problem with this is to do it in a portable way. Binreloc doesn't even seem to make any attempts to be portable. I've been using the following code to get the path of the executable:

    char buf[PATH_MAX + 1];
    char* path = getenv("_");
    if (!path) {
        if (readlink("/proc/self/exe", buf, sizeof (buf)) == -1) {
            return NULL;
        }
        path = buf;
    }
    return path;

But although that should compile on any POSIX system, there's no guarantee that it would actually work. Portable programs should not rely on beeing able to reliably determine the runtime path of its executable.

--
Christer Palm



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]