Re: [Super-tux-devel] seg fault
Brought to you by:
wkendrick
From: Ingo R. <gr...@gm...> - 2004-02-20 00:13:54
|
ri...@ae... writes: > http://rpmcruz.planetaclix.pt/repository/system/index.html#curdir > > Tobias, what do you think? Changing current directory is kind of evil, better they where you are and just open the files from whereever they are, the tricky part is always to find out where they are, since programms in linux are very often launched from PATH. Most programms use ugly evil hardcoded paths in the binary. Luckily the /proc filesystem provides the absolute location of an executable, so no need for hardcompiled stuff, code looks like: char exe_file[PATH_MAX]; if (readlink("/proc/self/exe", exe_file, PATH_MAX) < 0) { throw CL_Error(strerror(errno)); } else { return std::string(dirname(exe_file)) + "/"; } -- WWW: http://pingus.seul.org/~grumbel/ JabberID: gr...@ja... ICQ: 59461927 |