Files
UnrealEngineUWP/Engine/Source/Developer/Virtualization/Private/VirtualizationUtilities.cpp
paul chipchase 05d81ee7f3 EditorBulkData and the virtualization system now use FIoHash directly and FPayloadId is removed
#rb Per.Larsson, Devin.Doucette
#jira UE-133497
#rnx
#preflight 61f835491c5ac5523462810a

- A lot of files have been touched but most of this is changing FPayload::IsValid to !FIoHash::IsZero, the main changes are in EditorBulkData/EditorBulkDataTests
- The only difference between FPayloadId and FIoHash is that the former considered the hash of an invalid or empty buffer to be 'invalid' too where as FIoHash would return a valid hash
-- To keep behaviour the same, we only hash payloads in EditorBulkData using a utility method ::HashBuffer which will not hash empty or invalid payloads and return a default FIoHash instead.
-- Unit tests have been extended to prove that the behaviour has not changed.

#ROBOMERGE-AUTHOR: paul.chipchase
#ROBOMERGE-SOURCE: CL 18806362 in //UE5/Release-5.0/... via CL 18808527 via CL 18821790
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18822154 by paul chipchase in ue5-main branch]
2022-02-02 02:21:24 -05:00

55 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "VirtualizationUtilities.h"
#include "IO/IoHash.h"
#include "Misc/StringBuilder.h"
namespace UE::Virtualization::Utils
{
void PayloadIdToPath(const FIoHash& Id, FStringBuilderBase& OutPath)
{
OutPath.Reset();
OutPath << Id;
TStringBuilder<10> Directory;
Directory << OutPath.ToView().Left(2) << TEXT("/");
Directory << OutPath.ToView().Mid(2, 2) << TEXT("/");
Directory << OutPath.ToView().Mid(4, 2) << TEXT("/");
OutPath.ReplaceAt(0, 6, Directory);
OutPath << TEXT(".payload");
}
FString PayloadIdToPath(const FIoHash& Id)
{
TStringBuilder<52> Path;
PayloadIdToPath(Id, Path);
return FString(Path);
}
void GetFormattedSystemError(FStringBuilderBase& SystemErrorMessage)
{
SystemErrorMessage.Reset();
const uint32 SystemError = FPlatformMisc::GetLastError();
// If we have a system error we can give a more informative error message but don't output it if the error is zero as
// this can lead to very confusing error messages.
if (SystemError != 0)
{
TCHAR SystemErrorMsg[MAX_SPRINTF] = { 0 };
FPlatformMisc::GetSystemErrorMessage(SystemErrorMsg, sizeof(SystemErrorMsg), SystemError);
SystemErrorMessage.Appendf(TEXT("'%s' (%d)"), SystemErrorMsg, SystemError);
}
else
{
SystemErrorMessage << TEXT("'unknown reason' (0)");
}
}
} // namespace UE::Virtualization::Utils