find full path to engine in linux using /proc/self/exe

This commit is contained in:
Josh Holtrop 2010-12-19 00:11:33 -05:00
parent 9e6bb1b22d
commit 4d726dbf62

View File

@ -89,6 +89,20 @@ int main(int argc, char * argv[])
return -1;
}
/* find the full path to the program */
string engine_path = argv[0];
#ifdef PLATFORM_LINUX
/* get the full path to the process using /proc/self/exe */
char * buff = new char[10000];
ssize_t bytes_read = readlink("/proc/self/exe", buff, 9999);
if (bytes_read > 0)
{
buff[bytes_read] = '\0';
engine_path = buff;
}
delete[] buff;
#endif
dInitODE();
g_engine = new Engine(argv[0], av);
if (g_engine->load(program))