[lokisetup] Setting the Current Path
megastep at megastep.org
Tue Jul 9 00:24:43 EDT 2002
Now that loki_utils as been released to CVS on icculus.org, you could
just use the functions in this library for this (I forgot the name,
something like loki_getinstallpath() or the like). We used to do that
all the time at Loki, so games would be able to know from where they
You could also use the setupdb API to probe the database for the install
path of your product :)
Le ven 05/07/2002 à 11:01, Ryan C. Gordon a écrit :
> > I'm using Loki Setup as the installation program for one of my games,
> > and I was wondering what the common way was to get the path the game's
> > installed in. My game is installed in, say, /usr/local/games/my_game,
> > and I need to get data out of files in /usr/local/games/my_game/data,
> > but internally, my game only has the path as "data/whatever.dat". Is
> > there a function for Linux/Win32/MacOS to get the directory the binary
> > is being run from, so I could set the current directory to that, or is
> > there a better way to do this? Should I have Loki Setup write some sort
> > of ~/.my_game/path file and grab that everytime the game starts? What is
> > normally done for this?
> PhysicsFS has code to determine this at runtime; you can either use that
> library, or (if your program is GPL/LGPL) cut-and-paste it from PhysicsFS.
> (Look at __PHYSFS_platformCalcBaseDir(). This is the internal means of
> determining it under Linux. It will need argv from your main()
> function to work).
> PhysicsFS has ways to determine this on Win32, MacOS and BeOS, too.
> Loki_setup could theoretically write out a file with path information, but
> you are in the same boat still; Unix programs can be run from current
> working directory that is not the base path of the program, so how would
> you know what file to open?
More information about the Lokisetup