Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions Core/GameEngine/Source/Common/System/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,19 @@ void DebugInit(int flags)
strlcat(theLogFileName, ".txt", ARRAY_SIZE(theLogFileNamePrev));

remove(theLogFileNamePrev);
rename(theLogFileName, theLogFileNamePrev);
if (rename(theLogFileName, theLogFileNamePrev) != 0)
{
#ifdef DEBUG_LOGGING
DebugLog("Warning: Could not rename buffer file '%s' to '%s'. Will remove instead", theLogFileName, theLogFileNamePrev);
#endif
if (remove(theLogFileName) != 0)
{
#ifdef DEBUG_LOGGING
DebugLog("Warning: Failed to remove file '%s'", theLogFileName);
#endif
}
}

theLogFile = fopen(theLogFileName, "w");
if (theLogFile != NULL)
{
Expand Down Expand Up @@ -738,7 +750,18 @@ void ReleaseCrash(const char *reason)
strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf));

remove(prevbuf);
rename(curbuf, prevbuf);
if (rename(curbuf, prevbuf) != 0)
{
#ifdef DEBUG_LOGGING
DebugLog("Warning: Could not rename buffer file '%s' to '%s'. Will remove instead", curbuf, prevbuf);
#endif
if (remove(curbuf) != 0)
{
#ifdef DEBUG_LOGGING
DebugLog("Warning: Failed to remove file '%s'", curbuf);
#endif
}
}

theReleaseCrashLogFile = fopen(curbuf, "w");
if (theReleaseCrashLogFile)
Expand Down Expand Up @@ -827,7 +850,18 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf));

remove(prevbuf);
rename(curbuf, prevbuf);
if (rename(curbuf, prevbuf) != 0)
{
#ifdef DEBUG_LOGGING
DebugLog("Warning: Could not rename buffer file '%s' to '%s'. Will remove instead", curbuf, prevbuf);
#endif
if (remove(curbuf) != 0)
{
#ifdef DEBUG_LOGGING
DebugLog("Warning: Failed to remove file '%s'", curbuf);
#endif
}
}

theReleaseCrashLogFile = fopen(curbuf, "w");
if (theReleaseCrashLogFile)
Expand Down
Loading