-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathSentryFileUtils.cpp
70 lines (56 loc) · 2.14 KB
/
SentryFileUtils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2023 Sentry. All Rights Reserved.
#include "SentryFileUtils.h"
#include "SentryDefines.h"
#include "HAL/FileManager.h"
#include "GenericPlatform/GenericPlatformOutputDevices.h"
#include "Misc/Paths.h"
struct FSentrySortFileByDatePredicate
{
bool operator()(const FString& A, const FString& B) const
{
const FDateTime TimestampA = IFileManager::Get().GetTimeStamp(*A);
const FDateTime TimestampB = IFileManager::Get().GetTimeStamp(*B);
return TimestampB < TimestampA;
}
};
FString SentryFileUtils::GetGameLogName()
{
return FPaths::GetCleanFilename(FGenericPlatformOutputDevices::GetAbsoluteLogFilename());
}
FString SentryFileUtils::GetGameLogPath()
{
return IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*FGenericPlatformOutputDevices::GetAbsoluteLogFilename());
}
FString SentryFileUtils::GetGameLogBackupPath()
{
TArray<FString> GameLogBackupFiles;
IFileManager::Get().FindFiles(GameLogBackupFiles, *FString::Printf(TEXT("%s*-backup-*.*"), *FPaths::ProjectLogDir()), true, false);
if(GameLogBackupFiles.Num() == 0)
{
UE_LOG(LogSentrySdk, Log, TEXT("There are no game log backups available."));
return FString("");
}
for (int i = 0; i < GameLogBackupFiles.Num(); ++i)
{
GameLogBackupFiles[i] = FPaths::ProjectLogDir() / GameLogBackupFiles[i];
}
GameLogBackupFiles.Sort(FSentrySortFileByDatePredicate());
return IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*GameLogBackupFiles[0]);
}
FString SentryFileUtils::GetGpuDumpPath()
{
TArray<FString> GpuDumpFiles;
IFileManager::Get().FindFiles(GpuDumpFiles, *FString::Printf(TEXT("%s*.nv-gpudmp"), *FPaths::ProjectLogDir()), true, false);
if (GpuDumpFiles.Num() == 0)
{
UE_LOG(LogSentrySdk, Log, TEXT("There is no GPU dump file available."));
return FString("");
}
if (GpuDumpFiles.Num() > 1)
{
// By default, engine should handle clean up of GPU dumps from the previous runs
UE_LOG(LogSentrySdk, Log, TEXT("There are multiple GPU dump files, can't determine reliably which one to pick."));
return FString("");
}
return IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*(FPaths::ProjectLogDir() / GpuDumpFiles[0]));
}