File: README.txt

package info (click to toggle)
clanlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 28,372 kB
  • ctags: 16,520
  • sloc: cpp: 101,145; sh: 8,752; xml: 6,410; makefile: 1,740; ansic: 463; perl: 424; php: 247
file content (19 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
         Name: ExePath
       Status: Windows(Y), Linux(Y)
        Level: Beginner
   Maintainer: Ingo Ruhnke <grumbel@gmx.de>
      Summary: How to get the executable path of the binary

This example demonstrates how to get the executable path of the
binary, this is important since programs have to locate their data
files somehow and the current directory is not sufficient for doing
at all times. GNU/Linux programs when installed are mostly started
from the PATH, thus the executable doesn't get a clue on where the
data files might be located (/usr, /usr/local, ...) since the current
working directory can be anything.

With CL_System::get_exe_path() however one can get the location of the
binary, for example if the binary is in /usr/bin/your_binary, the
function would return /usr/bin/. By appending ../share/games/your_game/
you could now find the location of your data without resorting to ugly
workarounds like hard-compiled path names in your binary or wrapper scripts.