diff --git a/Modules.cpp b/Modules.cpp index e90e2c39..9052c55d 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -961,6 +961,36 @@ void CModules::GetAvailableMods(set& ssMods, bool bGlobal) { } } +bool CModules::FindModPath(const CString& sModule, CString& sModPath, + CString& sDataPath) { + CString sMod = sModule; + CString sDir = sMod; + if (sModule.find(".") == CString::npos) + sMod += ".so"; + + sDataPath = CZNC::Get().GetCurPath() + "/modules/"; + sModPath = sDataPath + sMod; + + if (!CFile::Exists(sModPath)) { + sDataPath = CZNC::Get().GetModPath() + "/"; + sModPath = sDataPath + sMod; + + if (!CFile::Exists(sModPath)) { + sDataPath = _DATADIR_ + CString("/"); + sModPath = _MODDIR_ + CString("/") + sMod; + + if (!CFile::Exists(sModPath)) { + return false; + } + } + } + + sDataPath += sDir; + + return true; +} + + ModHandle CModules::OpenModule(const CString& sModule, CString& sModPath, CString& sDataPath, bool &bVersionMismatch, bool &bIsGlobal, CString& sDesc, CString& sRetMsg) { @@ -971,7 +1001,7 @@ ModHandle CModules::OpenModule(const CString& sModule, CString& sModPath, CStrin } } - if (!CZNC::Get().FindModPath(sModule, sModPath, sDataPath)) { + if (!FindModPath(sModule, sModPath, sDataPath)) { sRetMsg = "Unable to find module [" + sModule + "]"; return NULL; } diff --git a/Modules.h b/Modules.h index f35889aa..c375c745 100644 --- a/Modules.h +++ b/Modules.h @@ -463,6 +463,11 @@ public: bool GetModInfo(CModInfo& ModInfo, const CString& sModule, CString &sRetMsg); void GetAvailableMods(set& ssMods, bool bGlobal = false); + // This returns the path to the .so and to the data dir + // which is where static data (webadmin skins) are saved + static bool FindModPath(const CString& sModule, CString& sModPath, + CString& sDataPath); + private: ModHandle OpenModule(const CString& sModule, CString& sModPath, CString& sDataPath, bool &bVersionMismatch, bool &bIsGlobal, CString& sDesc, CString& sRetMsg); diff --git a/modules/modperl.cpp b/modules/modperl.cpp index 970e81ea..7cb262c1 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -242,7 +242,7 @@ public: { CString sModule, sTmp; - if (!CZNC::Get().FindModPath("modperl.pm", sModule, sTmp)) + if (!CModules::FindModPath("modperl.pm", sModule, sTmp)) return false; CString sBuffer, sScript; @@ -1060,7 +1060,7 @@ void CModPerl::LoadPerlMod(const CString & sModule) CString sModPath, sTmp; - if (!CZNC::Get().FindModPath(sModule, sModPath, sTmp)) + if (!CModules::FindModPath(sModule, sModPath, sTmp)) PutStatus("No such module " + sModule); else { diff --git a/znc.cpp b/znc.cpp index 3aff4ead..bab69c2a 100644 --- a/znc.cpp +++ b/znc.cpp @@ -1672,35 +1672,6 @@ void CZNC::Broadcast(const CString& sMessage, bool bAdminOnly, } } -bool CZNC::FindModPath(const CString& sModule, CString& sModPath, - CString& sDataPath) const { - CString sMod = sModule; - CString sDir = sMod; - if (sModule.find(".") == CString::npos) - sMod += ".so"; - - sDataPath = GetCurPath() + "/modules/"; - sModPath = sDataPath + sMod; - - if (!CFile::Exists(sModPath)) { - sDataPath = GetModPath() + "/"; - sModPath = sDataPath + sMod; - - if (!CFile::Exists(sModPath)) { - sDataPath = _DATADIR_ + CString("/"); - sModPath = _MODDIR_ + CString("/") + sMod; - - if (!CFile::Exists(sModPath)) { - return false; - } - } - } - - sDataPath += sDir; - - return true; -} - CUser* CZNC::FindUser(const CString& sUsername) { map::iterator it = m_msUsers.find(sUsername); diff --git a/znc.h b/znc.h index 07f2c1a0..1be31120 100644 --- a/znc.h +++ b/znc.h @@ -49,10 +49,6 @@ public: static CString GetVersion(); static CString GetTag(bool bIncludeVersion = true); CString GetUptime() const; - // This returns the path to the .so and to the data dir - // which is where static data (webadmin skins) are saved - bool FindModPath(const CString& sModule, CString& sModPath, - CString& sDataPath) const; void ClearVHosts(); bool AddVHost(const CString& sHost); bool RemVHost(const CString& sHost);