From: havoc Date: Tue, 31 May 2005 23:48:57 +0000 (+0000) Subject: made Sys_LoadLibrary search in the executable path if the normal load fails (this... X-Git-Tag: xonotic-v0.1.0preview~4815 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8a4a4cfd1d30fb623e33623369a7d2aa24d5a653;p=xonotic%2Fdarkplaces.git made Sys_LoadLibrary search in the executable path if the normal load fails (this should help on Mac OSX) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5367 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/sys_shared.c b/sys_shared.c index 6cd86758..feb3164a 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -61,7 +61,35 @@ qboolean Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllf // No DLL found if (! dllhandle) - return false; + { + // see if the names can be loaded relative to the executable path + // (this is for Mac OSX which does not check next to the executable) + if (strrchr(com_argv[0], '/')) + { + char path[MAX_OSPATH]; + strlcpy(path, com_argv[0], sizeof(path)); + *(strrchr(com_argv[0], '/')) = 0; + for (i = 0; dllnames[i] != NULL; i++) + { + char temp[MAX_OSPATH]; + strlcpy(temp, path, sizeof(temp)); + strlcat(temp, dllnames[i], sizeof(temp)); +#ifdef WIN32 + dllhandle = LoadLibrary (temp); +#else + dllhandle = dlopen (temp, RTLD_LAZY); +#endif + if (dllhandle) + break; + + Con_Printf ("Can't load \"%s\".\n", temp); + } + if (! dllhandle) + return false; + } + else + return false; + } Con_Printf("\"%s\" loaded.\n", dllnames[i]);