Re: Proposal: an addition to glib for getting the absolute path of the current binary.

On Tue, 2004-04-13 at 14:34 +0200, Sven Neumann wrote:
> The software might have been
> compiled with --datadir set to something completely unrelated. Same
> goes for configuration files.  It's common practise to call configure
> with --sysconfdir=/etc.  How is your proposal for relocatable packages
> going to deal with this?

I think that's just a matter of API design. /etc is something of a
special case, because it tends to be used no matter where the software
is installed to. How about the following?

In the case where no unusual paths are specified, DATADIR, SYSCONFDIR
and other common macros could be redefined to a special, known value
(maybe NULL). So you could call it like this:

g_get_absolute_path(DATADIR ? DATADIR : "../share/myproject", "/somefile.png");

Then the function could be defined as, if the first parameter is
absolute, just join the two arguments together, and if it's relative,
take the absolute path of the binary and merge it with the first
argument, then join the second argument.

That way, if the data directory (or any other directory) is altered
using ./configure, DATADIR is non-NULL and the result is identical to
doing open( DATADIR "/somefile.png" ); and if it's not specified, the
build system does


and the function knows to look it up using the binaries absolute path.

Does this sound workable?

thanks -mike

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