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

Re: Path for search data files in package



Le 30/07/2013 13:28, Anton Balashov a écrit :
> Hello.
> We are creating a game and we can't find answer on question:
> How to set in code path where to search data files (for example sounds,
> images, etc). Of course we can hardcode '/usr/share/game/...' but what
> if game was installed with prefix? What is the best practice?
> 
> Thanks for help.
> 

Hi,

there is no generic answer to that question.

If your build system supports --prefix, it's not too hard to include the
prefix in the hard coded path. For a Debian package, that's all you
need: a compile-time option.

If you want your build to be relocatable (i.e. install path is not known
at compile time) you can also make the path relative to the executable
binary path.

Finally, your program can accept a command line option or an environment
variable so the user can set the path. Or even an option in a file the
user directory or in /etc.

If you implement several of those possibilities, you should make the
priority in that order: command-line, environment, user file, /etc file,
hard coded value.

Kind regards, Thibaut.


Reply to: