From 611e4e6d4e8e8d64a27a4627b41b7fc37ca34399 Mon Sep 17 00:00:00 2001 From: cflakes Date: Sun, 4 Apr 2010 15:58:04 +0000 Subject: [PATCH] Do not create empty directories if one does ./znc --datadir=NON_EXISTING_DIR git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1878 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 12 ++++++------ znc.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/znc.cpp b/znc.cpp index 03a0fe8e..9a1a7506 100644 --- a/znc.cpp +++ b/znc.cpp @@ -467,9 +467,9 @@ void CZNC::InitDirs(const CString& sArgvPath, const CString& sDataDir) { } } -CString CZNC::GetConfPath() const { +CString CZNC::GetConfPath(bool bAllowMkDir) const { CString sConfPath = m_sZNCPath + "/configs"; - if (!CFile::Exists(sConfPath)) { + if (bAllowMkDir && !CFile::Exists(sConfPath)) { CDir::MakeDir(sConfPath); } @@ -496,16 +496,16 @@ CString CZNC::GetModPath() const { } -CString CZNC::ExpandConfigPath(const CString& sConfigFile) { +CString CZNC::ExpandConfigPath(const CString& sConfigFile, bool bAllowMkDir) { CString sRetPath; if (sConfigFile.empty()) { - sRetPath = GetConfPath() + "/znc.conf"; + sRetPath = GetConfPath(bAllowMkDir) + "/znc.conf"; } else { if (sConfigFile.Left(2) == "./" || sConfigFile.Left(3) == "../") { sRetPath = GetCurPath() + "/" + sConfigFile; } else if (sConfigFile.Left(1) != "/") { - sRetPath = GetConfPath() + "/" + sConfigFile; + sRetPath = GetConfPath(bAllowMkDir) + "/" + sConfigFile; } else { sRetPath = sConfigFile; } @@ -985,7 +985,7 @@ bool CZNC::ParseConfig(const CString& sConfig) { CString s; - m_sConfigFile = ExpandConfigPath(sConfig); + m_sConfigFile = ExpandConfigPath(sConfig, false); return DoRehash(s); } diff --git a/znc.h b/znc.h index 10ae0287..f7dd47b9 100644 --- a/znc.h +++ b/znc.h @@ -45,7 +45,7 @@ public: bool AllowConnectionFrom(const CString& sIP) const; void InitDirs(const CString& sArgvPath, const CString& sDataDir); bool OnBoot(); - CString ExpandConfigPath(const CString& sConfigFile); + CString ExpandConfigPath(const CString& sConfigFile, bool bAllowMkDir = true); bool WriteNewConfig(const CString& sConfigFile); bool WriteConfig(); bool ParseConfig(const CString& sConfig); @@ -97,7 +97,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 GetConfPath(bool bAllowMkDir = true) const; CString GetUserPath() const; CString GetModPath() const; CString GetPemLocation() const { return GetZNCPath() + "/znc.pem"; }