From ec6a6dcd8b50d78480d56089466c345419004c9a Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 4 May 2013 04:02:25 +0000 Subject: [PATCH] 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 --- engine/client/sys_linux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index 4342be315..a56ec821f 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -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)