A couple of minor changes on how we handle the stack-trace saving on Windows (closes SpartanJ/ecode#835).

This commit is contained in:
Martín Lucas Golini
2026-03-16 01:41:31 -03:00
parent 9409a82092
commit d2dc5f9f35

View File

@@ -176,18 +176,27 @@ class WindowsSignalHandling {
}
static void handle_stacktrace( int skip_frames = 0 ) {
const auto appendCrashesPath = []( std::string& crashesPath ) {
FileSystem::dirAddSlashAtEnd( crashesPath );
crashesPath += "crashes";
FileSystem::dirAddSlashAtEnd( crashesPath );
};
std::string crashesPath( Sys::getConfigPath( "ecode" ) );
FileSystem::dirAddSlashAtEnd( crashesPath );
crashesPath += "crashes";
FileSystem::dirAddSlashAtEnd( crashesPath );
appendCrashesPath( crashesPath );
if ( !FileSystem::fileExists( crashesPath ) && !FileSystem::makeDir( crashesPath, true ) ) {
crashesPath = Sys::getProcessPath();
appendCrashesPath( crashesPath );
FileSystem::makeDir( crashesPath, true );
}
std::string dateTimeStr( Sys::getDateTimeStr() );
String::replaceAll( dateTimeStr, " ", "_" );
String::replaceAll( dateTimeStr, ":", "-" );
std::string crashFilePath(
String::format( "%sstacktrace_%s.log", crashesPath, dateTimeStr ) );
FileSystem::makeDir( crashesPath );
std::ofstream outFile( crashFilePath );
if ( !outFile.is_open() ) {
print_to_console( "Error: Failed to open " + crashFilePath +