diff --git a/FileUtils.cpp b/FileUtils.cpp index ebfe18d3..0dc7892a 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -7,6 +7,7 @@ */ #include "FileUtils.h" +#include "znc.h" #include "Utils.h" #include #include @@ -420,12 +421,18 @@ CString CFile::GetDir() const { return sDir; } -CString CDir::ChangeDir(const CString& sPath, const CString& sAdd, const CString& sHomeDir) { +CString CDir::ChangeDir(const CString& sPath, const CString& sAdd, const CString& sHome) { + CString sHomeDir(sHome); + + if (sHomeDir.empty()) { + sHomeDir = CZNC::Get().GetHomePath(); + } + if (sAdd == "~") { return sHomeDir; } - CString sAddDir = sAdd; + CString sAddDir(sAdd); if (sAddDir.Left(2) == "~/") { sAddDir.LeftChomp(); diff --git a/FileUtils.h b/FileUtils.h index 1c256408..321437ba 100644 --- a/FileUtils.h +++ b/FileUtils.h @@ -263,7 +263,7 @@ public: CFile::EFileAttr GetSortAttr() { return m_eSortAttr; } bool IsDescending() { return m_bDesc; } - static CString ChangeDir(const CString& sPath, const CString& sAdd, const CString& sHomeDir); + static CString ChangeDir(const CString& sPath, const CString& sAdd, const CString& sHomeDir = ""); static bool MakeDir(const CString& sPath, mode_t iMode = 0700); static CString GetCWD() {