Windows, Mac OS X and Linux all provide handy ways to retrieve the absolute path of the running executable. This is especially useful since argv[0] can be a relative path.
This fixes a bug on the Mac OS X build where the app cannot locate the graphics resources when when they're needed, so the application bombs out instead.
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Z5PVF4BKRAUD3CTW26IDYI2XV7H2YDKFKBWDQYWUUABCKWHF4KWAC
// A lot of OSes give ways to find the location of the running app's
// binary executable. This is useful, because argv[0] can be relative
// when we really need an absolute path in order to locate the game's
// resources.
// Faster than a memset, and counts as a null-terminated string!
tempPath[0] = 0;
#if defined ( _MSC_VER )
int retval = GetModuleFileName ( NULL, tempPath, sizeof(tempPath) );
#elif defined ( __linux__ )
int retval = readlink ( "/proc/self/exe", tempPath, sizeof(tempPath) );
#elif defined ( __MACH__ )
strncpy ( tempPath, NXArgv[0], sizeof(tempPath) );
#else
// We don't know how to find the executable's path on this OS.
#endif
return std::string(tempPath);
}