From 97e47c552785afcb27368e067915aa78c8eb27f8 Mon Sep 17 00:00:00 2001 From: "amusil%netscape.com" Date: Fri, 23 Apr 1999 23:43:54 +0000 Subject: [PATCH] Plugins now can properly load support dlls that are located in the plugin directory. --- modules/plugin/base/src/nsPluginsDirWin.cpp | 27 ++++++++++++++++++++- modules/plugin/nglsrc/nsPluginsDirWin.cpp | 27 ++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/modules/plugin/base/src/nsPluginsDirWin.cpp b/modules/plugin/base/src/nsPluginsDirWin.cpp index 2e433e057d71..efe3be1ab93c 100644 --- a/modules/plugin/base/src/nsPluginsDirWin.cpp +++ b/modules/plugin/base/src/nsPluginsDirWin.cpp @@ -234,9 +234,34 @@ nsPluginFile::~nsPluginFile() nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary) { // How can we convert to a full path names for using with NSPR? - //nsFilePath path(*this); const char* path = this->GetCString(); + char* index; + char* pluginFolderPath = PL_strdup(path); + + index = PL_strrchr(pluginFolderPath, '\\'); + *index = 0; + + BOOL restoreOrigDir = FALSE; + char aOrigDir[MAX_PATH + 1]; + DWORD dwCheck = ::GetCurrentDirectory(sizeof(aOrigDir), aOrigDir); + NS_ASSERTION(dwCheck <= MAX_PATH + 1, "Error in Loading plugin"); + + if (dwCheck <= MAX_PATH + 1) + { + restoreOrigDir = ::SetCurrentDirectory(pluginFolderPath); + NS_ASSERTION(restoreOrigDir, "Error in Loading plugin"); + } + outLibrary = PR_LoadLibrary(path); + + if (restoreOrigDir) + { + BOOL bCheck = ::SetCurrentDirectory(aOrigDir); + NS_ASSERTION(bCheck, "Error in Loading plugin"); + } + + PL_strfree(pluginFolderPath); + return NS_OK; } diff --git a/modules/plugin/nglsrc/nsPluginsDirWin.cpp b/modules/plugin/nglsrc/nsPluginsDirWin.cpp index 2e433e057d71..efe3be1ab93c 100644 --- a/modules/plugin/nglsrc/nsPluginsDirWin.cpp +++ b/modules/plugin/nglsrc/nsPluginsDirWin.cpp @@ -234,9 +234,34 @@ nsPluginFile::~nsPluginFile() nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary) { // How can we convert to a full path names for using with NSPR? - //nsFilePath path(*this); const char* path = this->GetCString(); + char* index; + char* pluginFolderPath = PL_strdup(path); + + index = PL_strrchr(pluginFolderPath, '\\'); + *index = 0; + + BOOL restoreOrigDir = FALSE; + char aOrigDir[MAX_PATH + 1]; + DWORD dwCheck = ::GetCurrentDirectory(sizeof(aOrigDir), aOrigDir); + NS_ASSERTION(dwCheck <= MAX_PATH + 1, "Error in Loading plugin"); + + if (dwCheck <= MAX_PATH + 1) + { + restoreOrigDir = ::SetCurrentDirectory(pluginFolderPath); + NS_ASSERTION(restoreOrigDir, "Error in Loading plugin"); + } + outLibrary = PR_LoadLibrary(path); + + if (restoreOrigDir) + { + BOOL bCheck = ::SetCurrentDirectory(aOrigDir); + NS_ASSERTION(bCheck, "Error in Loading plugin"); + } + + PL_strfree(pluginFolderPath); + return NS_OK; }