Attempt to determine where we're being run from on linux as we do in windows.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4327 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2013-05-04 04:02:25 +00:00
parent 6b41038183
commit ec6a6dcd8b
1 changed files with 19 additions and 0 deletions

View File

@ -644,6 +644,7 @@ int main (int c, const char **v)
int j;
// static char cwd[1024];
static char bindir[1024];
signal(SIGFPE, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
@ -664,6 +665,24 @@ int main (int c, const char **v)
parms.membase = malloc (parms.memsize);
parms.basedir = basedir;
#ifdef __linux__
//attempt to figure out where the exe is located
if (readlink("/proc/self/exe", bindir, sizeof(bindir)) > 0)
{
*COM_SkipPath(bindir) = 0;
printf("Binary is located at \"%s\"\n", bindir);
parms.binarydir = bindir;
}
/*#elif defined(__bsd__)
//attempt to figure out where the exe is located
if (readlink("/proc/self/file", bindir, sizeof(bindir)) > 0)
{
*COM_SkipPath(bindir) = 0;
printf("Binary is located at "%s"\n", bindir);
parms.binarydir = bindir;
}
*/
#endif
isPlugin = !!COM_CheckParm("-plugin");
if (isPlugin)