From 8e59f751251dda5984ea729c79e83e743ca9d57e Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 3 Apr 2011 10:21:59 +0200 Subject: [PATCH] Don't include FileUtils.h in znc.h or Modules.h Both these headers only really need CFile* which can be handled with a forward declaration. To make this possible, some methods are moved from the header file into the corresponding implementation file, because they used CFile or CDir static members. Signed-off-by: Uli Schlachter --- HTTPSock.cpp | 3 ++- Modules.cpp | 7 +++++++ Modules.h | 3 +-- znc.cpp | 21 +++++++++++++++++++++ znc.h | 10 +++++----- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/HTTPSock.cpp b/HTTPSock.cpp index 16526914..6cc7d2b5 100644 --- a/HTTPSock.cpp +++ b/HTTPSock.cpp @@ -6,8 +6,9 @@ * by the Free Software Foundation. */ -#include "Modules.h" #include "HTTPSock.h" +#include "FileUtils.h" +#include "Modules.h" #include "znc.h" #include diff --git a/Modules.cpp b/Modules.cpp index 46d7bae6..dde5f204 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -145,6 +145,13 @@ CModule::~CModule() { void CModule::SetUser(CUser* pUser) { m_pUser = pUser; } void CModule::SetClient(CClient* pClient) { m_pClient = pClient; } +const CString& CModule::GetSavePath() const { + if (!CFile::Exists(m_sSavePath)) { + CDir::MakeDir(m_sSavePath); + } + return m_sSavePath; +} + bool CModule::LoadRegistry() { //CString sPrefix = (m_pUser) ? m_pUser->GetUserName() : ".global"; return (m_mssRegistry.ReadFromDisk(GetSavePath() + "/.registry") == MCString::MCS_SUCCESS); diff --git a/Modules.h b/Modules.h index a740184a..10076e17 100644 --- a/Modules.h +++ b/Modules.h @@ -11,7 +11,6 @@ #include "zncconfig.h" #include "WebModules.h" -#include "FileUtils.h" #include "Utils.h" #include #include @@ -825,7 +824,7 @@ public: void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); } bool ClearNV(bool bWriteToDisk = true); - const CString& GetSavePath() const { if (!CFile::Exists(m_sSavePath)) { CDir::MakeDir(m_sSavePath); } return m_sSavePath; } + const CString& GetSavePath() const; // Setters void SetGlobal(bool b) { m_bGlobal = b; } diff --git a/znc.cpp b/znc.cpp index ad20fa19..2e5245de 100644 --- a/znc.cpp +++ b/znc.cpp @@ -384,6 +384,27 @@ CString CZNC::GetModPath() const { return sModPath; } +const CString& CZNC::GetCurPath() const { + if (!CFile::Exists(m_sCurPath)) { + CDir::MakeDir(m_sCurPath); + } + return m_sCurPath; +} + +const CString& CZNC::GetHomePath() const { + return CFile::GetHomePath(); +} + +const CString& CZNC::GetZNCPath() const { + if (!CFile::Exists(m_sZNCPath)) { + CDir::MakeDir(m_sZNCPath); + } + return m_sZNCPath; +} + +CString CZNC::GetPemLocation() const { + return CDir::ChangeDir("", m_sSSLCertFile); +} CString CZNC::ExpandConfigPath(const CString& sConfigFile, bool bAllowMkDir) { CString sRetPath; diff --git a/znc.h b/znc.h index 1bf60f27..403f4cee 100644 --- a/znc.h +++ b/znc.h @@ -11,7 +11,6 @@ #include "zncconfig.h" #include "Client.h" -#include "FileUtils.h" #include "Modules.h" #include "Socket.h" #include @@ -22,6 +21,7 @@ class CListener; class CUser; class CConnectUserTimer; class CConfig; +class CFile; class CZNC { public: @@ -95,13 +95,13 @@ public: size_t FilterUncommonModules(set& ssModules); CString GetSkinName() const { return m_sSkinName; } const CString& GetStatusPrefix() const { return m_sStatusPrefix; } - const CString& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CDir::MakeDir(m_sCurPath); } return m_sCurPath; } - const CString& GetHomePath() const { return CFile::GetHomePath(); } - const CString& GetZNCPath() const { if (!CFile::Exists(m_sZNCPath)) { CDir::MakeDir(m_sZNCPath); } return m_sZNCPath; } + const CString& GetCurPath() const; + const CString& GetHomePath() const; + const CString& GetZNCPath() const; CString GetConfPath(bool bAllowMkDir = true) const; CString GetUserPath() const; CString GetModPath() const; - CString GetPemLocation() const { return CDir::ChangeDir("", m_sSSLCertFile); } + CString GetPemLocation() const; const CString& GetConfigFile() const { return m_sConfigFile; } bool WritePemFile(); const VCString& GetBindHosts() const { return m_vsBindHosts; }