]> jfr.im git - irc/rizon/znc.git/commitdiff
WriteToDisk() didn't make sure the file was empty when its map was empty
authorpsychon <redacted>
Thu, 28 Aug 2008 18:50:42 +0000 (18:50 +0000)
committerpsychon <redacted>
Thu, 28 Aug 2008 18:50:42 +0000 (18:50 +0000)
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

String.cpp

index 83b12208d6842e489044241e6313ed6f408fd6d1..e9224cd006b99f5a097636c4a23d29653c79c1df 100644 (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;
        }