WriteToDisk() didn't make sure the file was empty when its map was empty

This bug was introduced by SilverLeo who also found and fixed it. :P


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1176 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-08-28 18:50:42 +00:00
parent 55c1232e5e
commit 5c588352d9
+8 -3
View File
@@ -1001,10 +1001,15 @@ bool CString::RightChomp(unsigned int uLen) {
//////////////// MCString ////////////////
int MCString::WriteToDisk(const CString& sPath, mode_t iMode) {
if (this->empty())
return MCS_SUCCESS;
CFile cFile(sPath);
if (this->empty()) {
if (!cFile.Exists())
return MCS_SUCCESS;
if (cFile.Delete())
return MCS_SUCCESS;
}
if (!cFile.Open(O_WRONLY|O_CREAT|O_TRUNC, iMode)) {
return MCS_EOPEN;
}