From 804b259f69b5e4fd7b5e3eeb138517e20b66b713 Mon Sep 17 00:00:00 2001 From: psychon Date: Wed, 17 Dec 2008 15:36:47 +0000 Subject: [PATCH] Fix a bug introduced in r1289 If the config dir (/configs) didn't exist yet, ZNC didn't bother creating it and thus failed to do write a config. Thanks to m4v for testing a nightly and for reporting this bug. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1292 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 13 +++++++++++-- znc.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/znc.cpp b/znc.cpp index 74bbe427..38d25fcf 100644 --- a/znc.cpp +++ b/znc.cpp @@ -440,6 +440,15 @@ void CZNC::InitDirs(const CString& sArgvPath, const CString& sDataDir) { } } +CString CZNC::GetConfPath() const { + CString sConfPath = m_sZNCPath + "/configs/"; + if (!CFile::Exists(sConfPath)) { + CDir::MakeDir(sConfPath); + } + + return sConfPath; +} + CString CZNC::GetUserPath() const { CString sUserPath = m_sZNCPath + "/users/"; if (!CFile::Exists(sUserPath)) { @@ -464,12 +473,12 @@ CString CZNC::ExpandConfigPath(const CString& sConfigFile) { CString sRetPath; if (sConfigFile.empty()) { - sRetPath = GetZNCPath() + "/configs/znc.conf"; + sRetPath = GetConfPath() + "/znc.conf"; } else { if (sConfigFile.Left(2) == "./" || sConfigFile.Left(3) == "../") { sRetPath = GetCurPath() + "/" + sConfigFile; } else if (sConfigFile.Left(1) != "/") { - sRetPath = GetZNCPath() + "/configs/" + sConfigFile; + sRetPath = GetConfPath() + "/" + sConfigFile; } else { sRetPath = sConfigFile; } diff --git a/znc.h b/znc.h index fd4d89e6..32e14955 100644 --- a/znc.h +++ b/znc.h @@ -148,6 +148,7 @@ public: const CString& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CDir::MakeDir(m_sCurPath); } return m_sCurPath; } const CString& GetHomePath() const { if (!CFile::Exists(m_sHomePath)) { CDir::MakeDir(m_sHomePath); } return m_sHomePath; } const CString& GetZNCPath() const { if (!CFile::Exists(m_sZNCPath)) { CDir::MakeDir(m_sZNCPath); } return m_sZNCPath; } + CString GetConfPath() const; CString GetUserPath() const; CString GetModPath() const; CString GetPemLocation() const { return GetZNCPath() + "/znc.pem"; }