Permalink
Browse files

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 <psychon@znc.in>
  • Loading branch information...
psychon committed Apr 3, 2011
1 parent ad442f4 commit 8e59f751251dda5984ea729c79e83e743ca9d57e
Showing with 36 additions and 8 deletions.
  1. +2 −1 HTTPSock.cpp
  2. +7 −0 Modules.cpp
  3. +1 −2 Modules.h
  4. +21 −0 znc.cpp
  5. +5 −5 znc.h
View
@@ -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 <sstream>
View
@@ -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);
View
@@ -11,7 +11,6 @@
#include "zncconfig.h"
#include "WebModules.h"
-#include "FileUtils.h"
#include "Utils.h"
#include <set>
#include <queue>
@@ -825,7 +824,7 @@ class CModule {
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; }
View
21 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;
View
10 znc.h
@@ -11,7 +11,6 @@
#include "zncconfig.h"
#include "Client.h"
-#include "FileUtils.h"
#include "Modules.h"
#include "Socket.h"
#include <map>
@@ -22,6 +21,7 @@ class CListener;
class CUser;
class CConnectUserTimer;
class CConfig;
+class CFile;
class CZNC {
public:
@@ -95,13 +95,13 @@ class CZNC {
size_t FilterUncommonModules(set<CModInfo>& 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; }

0 comments on commit 8e59f75

Please sign in to comment.