From de2f07ecc4329eba97c7b10202f71133fb6d7a7c Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 31 Mar 2009 12:25:24 +0000 Subject: [PATCH] Make znc --datadir some-dir --makeconf work Without this the restart after the config is written fails, because the file name it wants to open went through ExpandConfigPath() twice. This lead to a path like ./some-dir/configs/some-dir/configs. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1468 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 20 ++++++++++---------- znc.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/znc.cpp b/znc.cpp index aafe78be..e5707488 100644 --- a/znc.cpp +++ b/znc.cpp @@ -583,11 +583,11 @@ bool CZNC::WriteConfig() { return true; } -bool CZNC::WriteNewConfig(CString& sConfigFile) { +bool CZNC::WriteNewConfig(const CString& sConfigFile) { CString sAnswer, sUser; VCString vsLines; - sConfigFile = ExpandConfigPath((sConfigFile.empty()) ? "znc.conf" : sConfigFile); + m_sConfigFile = ExpandConfigPath((sConfigFile.empty()) ? "znc.conf" : sConfigFile); CUtils::PrintMessage("Building new config"); CUtils::PrintMessage(""); @@ -823,25 +823,25 @@ bool CZNC::WriteNewConfig(CString& sConfigFile) { CFile File; bool bFileOK, bFileOpen = false; do { - CUtils::PrintAction("Writing config [" + sConfigFile + "]"); + CUtils::PrintAction("Writing config [" + m_sConfigFile + "]"); bFileOK = true; - if (CFile::Exists(sConfigFile)) { - if (!m_LockFile.TryExLock(sConfigFile)) { + if (CFile::Exists(m_sConfigFile)) { + if (!m_LockFile.TryExLock(m_sConfigFile)) { CUtils::PrintStatus(false, "ZNC is currently running on this config."); bFileOK = false; } else { m_LockFile.Close(); CUtils::PrintStatus(false, "This config already exists."); if (CUtils::GetBoolInput("Would you like to overwrite it?", false)) - CUtils::PrintAction("Overwriting config [" + sConfigFile + "]"); + CUtils::PrintAction("Overwriting config [" + m_sConfigFile + "]"); else bFileOK = false; } } if (bFileOK) { - File.SetFileName(sConfigFile); + File.SetFileName(m_sConfigFile); if (File.Open(O_WRONLY | O_CREAT | O_TRUNC, 0600)) { bFileOpen = true; } else { @@ -850,11 +850,11 @@ bool CZNC::WriteNewConfig(CString& sConfigFile) { } } if (!bFileOK) { - CUtils::GetInput("Please specify an alternate location (or \"stdout\" for displaying the config)", sConfigFile, sConfigFile); - if (sConfigFile.Equals("stdout")) + CUtils::GetInput("Please specify an alternate location (or \"stdout\" for displaying the config)", m_sConfigFile, m_sConfigFile); + if (m_sConfigFile.Equals("stdout")) bFileOK = true; else - sConfigFile = ExpandConfigPath(sConfigFile); + m_sConfigFile = ExpandConfigPath(m_sConfigFile); } } while (!bFileOK); diff --git a/znc.h b/znc.h index e80e0cc9..cf4cd33c 100644 --- a/znc.h +++ b/znc.h @@ -104,7 +104,7 @@ public: void InitDirs(const CString& sArgvPath, const CString& sDataDir); bool OnBoot(); CString ExpandConfigPath(const CString& sConfigFile); - bool WriteNewConfig(CString& sConfigFile); + bool WriteNewConfig(const CString& sConfigFile); bool WriteConfig(); bool ParseConfig(const CString& sConfig); bool RehashConfig(CString& sError);