Save crash dumps into a separate directory

This commit is contained in:
ZehMatt 2021-07-26 00:40:19 +03:00
parent dab33b3347
commit 47287e7fb1
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
4 changed files with 12 additions and 4 deletions

View File

@ -1128,6 +1128,7 @@ namespace OpenRCT2
DIRID::SEQUENCE,
DIRID::REPLAY,
DIRID::LOG_DESYNCS,
DIRID::CRASH,
});
}

View File

@ -228,6 +228,7 @@ const char * PlatformEnvironment::DirectoryNamesOpenRCT2[] =
"heightmap", // HEIGHTMAP
"replay", // REPLAY
"desyncs", // DESYNCS
"crash", // CRASH
};
const char * PlatformEnvironment::FileNames[] =

View File

@ -49,6 +49,7 @@ namespace OpenRCT2
HEIGHTMAP, // Contains heightmap data.
REPLAY, // Contains recorded replays.
LOG_DESYNCS, // Contains desync reports.
CRASH, // Contains crash dumps.
};
enum class PATHID

View File

@ -27,10 +27,12 @@
# include "../Context.h"
# include "../Game.h"
# include "../OpenRCT2.h"
# include "../PlatformEnvironment.h"
# include "../Version.h"
# include "../config/Config.h"
# include "../core/Console.hpp"
# include "../core/Guard.hpp"
# include "../core/Path.hpp"
# include "../core/String.hpp"
# include "../interface/Screenshot.h"
# include "../localisation/Language.h"
@ -54,6 +56,8 @@ const wchar_t* _wszArchitecture = WSZ(OPENRCT2_ARCHITECTURE);
# define BACKTRACE_TOKEN L"742b8d9d70c52df663e4f2449f90039cf9406f89e57ecb90b0f086ba16e33d20"
using namespace OpenRCT2;
// Note: uploading gzipped crash dumps manually requires specifying
// 'Content-Encoding: gzip' header in HTTP request, but we cannot do that,
// so just hope the file name with '.gz' suffix is enough.
@ -319,9 +323,10 @@ static bool OnCrash(
static std::wstring GetDumpDirectory()
{
char userDirectory[MAX_PATH];
platform_get_user_directory(userDirectory, nullptr, sizeof(userDirectory));
auto result = String::ToWideChar(userDirectory);
auto env = GetContext()->GetPlatformEnvironment();
auto crashPath = env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::CRASH);
auto result = String::ToWideChar(crashPath.c_str());
return result;
}
@ -337,7 +342,7 @@ CExceptionHandler crash_init()
auto exHandler = new google_breakpad::ExceptionHandler(
GetDumpDirectory(), 0, OnCrash, 0, google_breakpad::ExceptionHandler::HANDLER_ALL, MiniDumpWithDataSegs, PipeName, 0);
return reinterpret_cast<CExceptionHandler>(exHandler);
#else // USE_BREAKPAD
#else // USE_BREAKPAD
return nullptr;
#endif // USE_BREAKPAD
}