UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BuildPatchVerify.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5#include "Misc/EnumRange.h"
6
7namespace BuildPatchServices
8{
12 enum class EVerifyMode : uint32
13 {
14 // Fully SHA checks all files in the build.
15 ShaVerifyAllFiles = 0,
16
17 // Fully SHA checks only files touched by the install/patch process.
18 ShaVerifyTouchedFiles,
19
20 // Checks just the existence and file size of all files in the build.
21 FileSizeCheckAllFiles,
22
23 // Checks just the existence and file size of only files touched by the install/patch process.
24 FileSizeCheckTouchedFiles,
25
26 InvalidOrMax
27 };
28
32 enum class EVerifyError : uint32
33 {
34 // The file was not found.
35 FileMissing = 0,
36
37 // The file failed to open.
38 OpenFileFailed,
39
40 // The file failed its hash check.
41 HashCheckFailed,
42
43 // The file was not the expected size.
44 FileSizeFailed,
45
46 InvalidOrMax
47 };
48}
49
50ENUM_RANGE_BY_FIRST_AND_LAST(BuildPatchServices::EVerifyError, BuildPatchServices::EVerifyError::FileMissing, BuildPatchServices::EVerifyError::FileSizeFailed)
51
52static_assert((uint32)BuildPatchServices::EVerifyMode::InvalidOrMax == 4, "Please add support for the extra values to the Lex functions below.");
53
54inline const TCHAR* LexToString(BuildPatchServices::EVerifyMode VerifyMode)
55{
56#define CASE_ENUM_TO_STR(Value) case BuildPatchServices::EVerifyMode::Value: return TEXT(#Value)
57 switch (VerifyMode)
58 {
59 CASE_ENUM_TO_STR(ShaVerifyAllFiles);
60 CASE_ENUM_TO_STR(ShaVerifyTouchedFiles);
61 CASE_ENUM_TO_STR(FileSizeCheckAllFiles);
62 CASE_ENUM_TO_STR(FileSizeCheckTouchedFiles);
63 default: return TEXT("InvalidOrMax");
64 }
65#undef CASE_ENUM_TO_STR
66}
67
68inline void LexFromString(BuildPatchServices::EVerifyMode& VerifyMode, const TCHAR* Buffer)
69{
70#define RETURN_IF_EQUAL(Value) if (FCString::Stricmp(Buffer, TEXT(#Value)) == 0) { VerifyMode = BuildPatchServices::EVerifyMode::Value; return; }
71 const TCHAR* const Prefix = TEXT("EVerifyMode::");
72 const SIZE_T PrefixLen = FCString::Strlen(Prefix);
73 if (FCString::Strnicmp(Buffer, Prefix, PrefixLen) == 0)
74 {
76 }
77 RETURN_IF_EQUAL(ShaVerifyAllFiles);
78 RETURN_IF_EQUAL(ShaVerifyTouchedFiles);
79 RETURN_IF_EQUAL(FileSizeCheckAllFiles);
80 RETURN_IF_EQUAL(FileSizeCheckTouchedFiles);
81 // Did not match
82 VerifyMode = BuildPatchServices::EVerifyMode::InvalidOrMax;
83#undef RETURN_IF_EQUAL
84}
85
86static_assert((uint32)BuildPatchServices::EVerifyError::InvalidOrMax == 4, "Please add support for the extra values to the Lex functions below.");
87
88inline const TCHAR* LexToString(BuildPatchServices::EVerifyError VerifyError)
89{
90#define CASE_ENUM_TO_STR(Value) case BuildPatchServices::EVerifyError::Value: return TEXT(#Value)
91 switch (VerifyError)
92 {
93 CASE_ENUM_TO_STR(FileMissing);
94 CASE_ENUM_TO_STR(OpenFileFailed);
95 CASE_ENUM_TO_STR(HashCheckFailed);
96 CASE_ENUM_TO_STR(FileSizeFailed);
97 default: return TEXT("InvalidOrMax");
98 }
99#undef CASE_ENUM_TO_STR
100}
101
102inline void LexFromString(BuildPatchServices::EVerifyError& VerifyError, const TCHAR* Buffer)
103{
104#define RETURN_IF_EQUAL(Value) if (FCString::Stricmp(Buffer, TEXT(#Value)) == 0) { VerifyError = BuildPatchServices::EVerifyError::Value; return; }
105 const TCHAR* const Prefix = TEXT("EVerifyError::");
106 const SIZE_T PrefixLen = FCString::Strlen(Prefix);
107 if (FCString::Strnicmp(Buffer, Prefix, PrefixLen) == 0)
108 {
109 Buffer += PrefixLen;
110 }
111 RETURN_IF_EQUAL(FileMissing);
112 RETURN_IF_EQUAL(OpenFileFailed);
113 RETURN_IF_EQUAL(HashCheckFailed);
114 RETURN_IF_EQUAL(FileSizeFailed);
115 // Did not match
116 VerifyError = BuildPatchServices::EVerifyError::InvalidOrMax;
117#undef RETURN_IF_EQUAL
118}
void LexFromString(BuildPatchServices::EVerifyMode &VerifyMode, const TCHAR *Buffer)
Definition BuildPatchVerify.h:68
#define CASE_ENUM_TO_STR(Value)
#define RETURN_IF_EQUAL(Value)
const TCHAR * LexToString(BuildPatchServices::EVerifyMode VerifyMode)
Definition BuildPatchVerify.h:54
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_RANGE_BY_FIRST_AND_LAST(EnumType, First, Last)
Definition EnumRange.h:47
uint32_t uint32
Definition binka_ue_file_header.h:6
EVerifyError
Definition BuildPatchVerify.h:33
EVerifyMode
Definition BuildPatchVerify.h:13
Definition BuildPatchFileConstructor.h:28
static int32 Strlen(const CharType *String)
Definition CString.h:1047
static UE_FORCEINLINE_HINT int32 Strnicmp(const CharType *String1, const CharType *String2, SIZE_T Count)
Definition CString.h:1036