From 8a4a4cfd1d30fb623e33623369a7d2aa24d5a653 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 31 May 2005 23:48:57 +0000 Subject: [PATCH] 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 --- sys_shared.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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]); -- 2.39.2