@@ -406,8 +406,15 @@ void DebugInit(int flags)
406406 remove (theLogFileNamePrev);
407407 if (rename (theLogFileName, theLogFileNamePrev) != 0 )
408408 {
409- DebugLog (" Could not rename log file '%s' to '%s' and is remove instead" , theLogFileName, theLogFileNamePrev);
410- remove (theLogFileName);
409+ #ifdef DEBUG_LOGGING
410+ DebugLog (" Warning: Could not rename buffer file '%s' to '%s' and is remove instead" , theLogFileName, theLogFileNamePrev);
411+ #endif
412+ if (remove (theLogFileName) != 0 )
413+ {
414+ #ifdef DEBUG_LOGGING
415+ DebugLog (" Warning: Failed to remove file '%s'." , theLogFileName);
416+ #endif
417+ }
411418 }
412419
413420 theLogFile = fopen (theLogFileName, " w" );
@@ -745,8 +752,15 @@ void ReleaseCrash(const char *reason)
745752 remove (prevbuf);
746753 if (rename (curbuf, prevbuf) != 0 )
747754 {
748- DebugLog (" Could not rename buffer file '%s' to '%s' and is remove instead" , curbuf, prevbuf);
749- remove (curbuf);
755+ #ifdef DEBUG_LOGGING
756+ DebugLog (" Warning: Could not rename buffer file '%s' to '%s' and is remove instead" , curbuf, prevbuf);
757+ #endif
758+ if (remove (curbuf) != 0 )
759+ {
760+ #ifdef DEBUG_LOGGING
761+ DebugLog (" Warning: Failed to remove file '%s'." , curbuf);
762+ #endif
763+ }
750764 }
751765
752766 theReleaseCrashLogFile = fopen (curbuf, " w" );
@@ -838,8 +852,15 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
838852 remove (prevbuf);
839853 if (rename (curbuf, prevbuf) != 0 )
840854 {
841- DebugLog (" Could not rename buffer file '%s' to '%s' and is remove instead" , curbuf, prevbuf);
842- remove (curbuf);
855+ #ifdef DEBUG_LOGGING
856+ DebugLog (" Warning: Could not rename buffer file '%s' to '%s' and is remove instead" , curbuf, prevbuf);
857+ #endif
858+ if (remove (curbuf) != 0 )
859+ {
860+ #ifdef DEBUG_LOGGING
861+ DebugLog (" Warning: Failed to remove file '%s'." , curbuf);
862+ #endif
863+ }
843864 }
844865
845866 theReleaseCrashLogFile = fopen (curbuf, " w" );
0 commit comments