From 4d726dbf62a32fa2cf1be8fb4fdbda6ed35d65a4 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 19 Dec 2010 00:11:33 -0500 Subject: [PATCH] find full path to engine in linux using /proc/self/exe --- anaglym.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/anaglym.cc b/anaglym.cc index bf9ce6a..170d031 100644 --- a/anaglym.cc +++ b/anaglym.cc @@ -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))